You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by zo...@apache.org on 2011/02/27 21:20:30 UTC

svn commit: r1075132 [5/18] - in /aries/tags/application-0.3: ./ application-api/ application-api/src/ application-api/src/main/ application-api/src/main/java/ application-api/src/main/java/org/ application-api/src/main/java/org/apache/ application-api...

Added: aries/tags/application-0.3/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java (added)
+++ aries/tags/application-0.3/application-deployment-management/src/test/java/org/apache/aries/application/deployment/management/DeploymentGeneratorTest.java Sun Feb 27 20:20:13 2011
@@ -0,0 +1,529 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.application.deployment.management;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.Content;
+import org.apache.aries.application.InvalidAttributeException;
+import org.apache.aries.application.VersionRange;
+import org.apache.aries.application.deployment.management.impl.DeploymentManifestManagerImpl;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.ResolveConstraint;
+import org.apache.aries.application.management.ResolverException;
+import org.apache.aries.application.management.spi.repository.PlatformRepository;
+import org.apache.aries.application.management.spi.resolve.AriesApplicationResolver;
+import org.apache.aries.application.management.spi.runtime.LocalPlatform;
+import org.apache.aries.application.modelling.DeployedBundles;
+import org.apache.aries.application.modelling.ExportedPackage;
+import org.apache.aries.application.modelling.ModelledResource;
+import org.apache.aries.application.modelling.ModellingManager;
+import org.apache.aries.application.modelling.impl.ModellingManagerImpl;
+import org.apache.aries.application.modelling.utils.ModellingHelper;
+import org.apache.aries.application.modelling.utils.impl.ModellingHelperImpl;
+import org.apache.aries.application.utils.AppConstants;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
+import org.apache.aries.mocks.BundleContextMock;
+import org.apache.aries.unittest.mocks.MethodCall;
+import org.apache.aries.unittest.mocks.Skeleton;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+
+
+/**
+ * Tests to ensure we generate DEPLOYMENT.MF artifacts correctly. 
+ */
+public class DeploymentGeneratorTest
+{
+  private DeploymentManifestManagerImpl deplMFMgr;
+  private AriesApplication app;
+  private ApplicationMetadata appMetadata;
+  
+  private static class MockResolver implements AriesApplicationResolver {
+    boolean returnAppContentNextTime = true;
+    
+    @Override
+    public Collection<ModelledResource> resolve(String appName, String appVersion,
+        Collection<ModelledResource> byValueBundles, Collection<Content> inputs)
+        throws ResolverException
+    {
+      if (_nextResults != null && !_nextResults.isEmpty()) { 
+        Collection<ModelledResource> result = _nextResults.remove(0);
+        return result;
+      }
+      Collection<ModelledResource> res = new ArrayList<ModelledResource>();
+      if (returnAppContentNextTime) { 
+        res.add(CAPABILITY_A.getBundle());
+        res.add(CAPABILITY_B.getBundle());
+      } 
+      res.add(CAPABILITY_C.getBundle());
+      res.add(CAPABILITY_E.getBundle());
+      boolean addD = false;
+      for(Content ib : inputs) {
+        if(ib.getContentName().equals("aries.test.d"))
+          addD = true;
+      }
+      if(addD) {
+        try {
+          res.add(createModelledResource("aries.test.d", "1.0.0", new ArrayList<String>(), new ArrayList<String>()));
+        } catch (InvalidAttributeException e) {
+          fail("Cannot resolve import for d");
+        }
+      }
+      
+      //  deployment manifest manager calls resolve() an extra time, providing
+      // just the shared bundles. 
+      // If we added D, then the next resolve will be one trying to winnow D out: 
+      // AppContent should be returned in that one. We should not return app content
+      // next time if we did so last time, unless we just added D
+      returnAppContentNextTime = !returnAppContentNextTime || addD;
+      return res;
+    }
+    
+    List<Collection<ModelledResource>> _nextResults = null;
+    
+    //  Some tests want to override the default behaviour of the resolve() method
+    public void addResult (Collection<ModelledResource> result) { 
+      if (_nextResults == null) { 
+        _nextResults = new ArrayList<Collection<ModelledResource>>();
+      }
+      _nextResults.add(result);
+    }
+
+		public Collection<ModelledResource> resolve(String appName,
+				String appVersion, Collection<ModelledResource> byValueBundles,
+				Collection<Content> inputs,
+				PlatformRepository platformRepository) throws ResolverException 
+		{
+
+			return resolve(appName, appVersion, byValueBundles, inputs);
+		}
+
+    public BundleInfo getBundleInfo(String bundleSymbolicName, Version bundleVersion)
+    {
+      return null;
+    }
+
+    public Set<BundleInfo> resolve(AriesApplication app, ResolveConstraint... constraints)
+        throws ResolverException
+    {
+      return null;
+    }
+
+    
+  }
+  
+  static MockResolver _resolver = new MockResolver();
+
+  static class DummyLocalPlatform implements LocalPlatform {
+    public File getTemporaryDirectory() throws IOException {
+      File f = File.createTempFile("ebaTmp", null);
+      f.delete();
+      f.mkdir();
+      return f;
+    } 
+    public File getTemporaryFile () throws IOException { 
+      // Not used
+      return File.createTempFile("ebaTmp", null);
+    }
+  }
+  static LocalPlatform localPlatform = new DummyLocalPlatform();
+  static ModellingManager modellingManager = new ModellingManagerImpl();
+  static ModellingHelper modellingHelper = new ModellingHelperImpl();
+  
+  @BeforeClass
+  public static void classSetup() throws Exception
+  {
+    BundleContext bc = Skeleton.newMock(BundleContext.class);
+    bc.registerService(AriesApplicationResolver.class.getName(), _resolver, new Hashtable<String, String>());
+    bc.registerService(ModellingManager.class.getName(), modellingManager, new Hashtable<String, String>());
+    bc.registerService(ModellingHelper.class.getName(), modellingHelper, new Hashtable<String, String>());
+  }
+  
+  @AfterClass
+  public static void afterClass() throws Exception { 
+    BundleContextMock.clear();
+  }
+  
+  @Before
+  public void setup() throws Exception
+  {
+    appMetadata = Skeleton.newMock(ApplicationMetadata.class);
+    Skeleton.getSkeleton(appMetadata).setReturnValue(
+        new MethodCall(ApplicationMetadata.class, "getApplicationSymbolicName"), "aries.test");
+    Skeleton.getSkeleton(appMetadata).setReturnValue(
+        new MethodCall(ApplicationMetadata.class, "getApplicationVersion"), new Version("1.0.0"));
+    Skeleton.getSkeleton(appMetadata).setReturnValue(
+        new MethodCall(ApplicationMetadata.class, "getUseBundles"), Collections.EMPTY_LIST);    
+    
+    app = Skeleton.newMock(AriesApplication.class);
+    Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
+    
+    deplMFMgr = new DeploymentManifestManagerImpl();
+    deplMFMgr.setResolver(_resolver);
+    deplMFMgr.setLocalPlatform(localPlatform);
+    deplMFMgr.setModellingManager(modellingManager);
+    deplMFMgr.setModellingHelper(modellingHelper);
+  }
+  
+  private static ExportedPackage CAPABILITY_A;
+  private static ExportedPackage CAPABILITY_B;
+  private static ExportedPackage CAPABILITY_C;
+  private static ExportedPackage CAPABILITY_E;
+
+  
+  // use bundle
+  private static Content BUNDLE_C;
+  private static Content BUNDLE_D;
+  
+  
+
+  public static ExportedPackage createExportedPackage (String bundleName, String bundleVersion, 
+      String[] exportedPackages, String[] importedPackages ) throws InvalidAttributeException { 
+    ModelledResource mb = createModelledResource(bundleName, bundleVersion,
+        Arrays.asList(importedPackages) , Arrays.asList(exportedPackages));
+    
+    
+    return mb.getExportedPackages().iterator().next();
+  }
+  
+  static {
+    try {
+      CAPABILITY_A = createExportedPackage ("aries.test.a", "1.0.0", new String[] {"aries.test.a"}, 
+          new String[] {"aries.test.c"});
+ 
+      CAPABILITY_B = createExportedPackage("aries.test.b", "1.1.0", new String[] {"aries.test.b"}, new String[] {"aries.test.e"});
+      
+      BUNDLE_C = ManifestHeaderProcessor.parseContent("aries.test.c","[1.0.0,1.1.0)");
+      
+      CAPABILITY_C = createExportedPackage("aries.test.c", "1.0.5", new String[] {"aries.test.c"}, new String[] {});
+      
+      BUNDLE_D = ManifestHeaderProcessor.parseContent("aries.test.d","1.0.0");
+      
+     // = new ImportedBundleImpl("aries.test.e", "1.0.0");
+      
+      CAPABILITY_E = createExportedPackage("aries.test.e", "1.0.0", new String[] {"aries.test.e"}, new String[] {});
+      
+    } catch (InvalidAttributeException iae) {
+      throw new RuntimeException(iae);
+    }
+  }
+  
+  
+  @Test
+  public void testResolve() throws Exception
+  {
+    
+    Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getApplicationContents"), Arrays.asList(mockContent("aries.test.a", "1.0.0"), mockContent("aries.test.b", "[1.0.0, 2.0.0)" )));
+    Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getUseBundles"), Arrays.asList(BUNDLE_C, BUNDLE_D));
+    
+    DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles (appMetadata, 
+        new ArrayList<ModelledResource>(), Collections.<Content>emptyList()); 
+    Manifest man = deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+        appMetadata.getApplicationVersion().toString(), deployedBundles);
+    
+    Attributes attrs = man.getMainAttributes();
+    
+    assertEquals("aries.test", attrs.getValue(AppConstants.APPLICATION_SYMBOLIC_NAME));
+    assertEquals("1.0.0", attrs.getValue(AppConstants.APPLICATION_VERSION));
+    
+    String content = attrs.getValue(AppConstants.DEPLOYMENT_CONTENT);
+    String useBundle = attrs.getValue(AppConstants.DEPLOYMENT_USE_BUNDLE);
+    String provisioned =attrs.getValue(AppConstants.DEPLOYMENT_PROVISION_BUNDLE);
+    
+    assertTrue(content.contains("aries.test.a;deployed-version=1.0.0"));
+    assertTrue(content.contains("aries.test.b;deployed-version=1.1.0"));
+    
+    assertTrue(useBundle.contains("aries.test.c;deployed-version=1.0.5"));
+    assertFalse(useBundle.contains("aries.test.d"));
+    
+    assertTrue(provisioned.contains("aries.test.e;deployed-version=1.0.0"));
+  }
+  
+  @Test
+  public void checkBasicCircularDependenciesDetected() throws Exception { 
+    // Override Resolver behaviour. 
+    //ImportedBundle isolated = new ImportedBundleImpl ("test.isolated" , "1.0.0"); 
+    
+    // When we resolve isolated, we're going to get another bundle which has a dependency on isolated. 
+    Collection<ModelledResource> cmr = new ArrayList<ModelledResource>();
+    ExportedPackage testIsolatedPkg = createExportedPackage ("test.isolated", "1.0.0", 
+        new String[] {"test.shared"}, new String[] {"test.isolated.pkg"});
+    cmr.add (testIsolatedPkg.getBundle());
+    
+    ExportedPackage testSharedPkg = createExportedPackage ("test.shared", "1.0.0", 
+        new String[] {"test.isolated.pkg"}, new String[] {"test.shared"});
+    cmr.add (testSharedPkg.getBundle());
+    _resolver.addResult(cmr);
+    
+    // The second time DeploymentGenerator calls the Resolver, it will provide just 
+    // test.shared. The resolver will return test.shared _plus_ test.isolated. 
+    _resolver.addResult(cmr);
+    Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getApplicationContents"), Arrays.asList(mockContent("test.isolated" , "1.0.0")));
+    
+    
+    try { 
+      DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles (appMetadata, 
+          new ArrayList<ModelledResource>(), new ArrayList<Content>());
+      deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+          appMetadata.getApplicationVersion().toString(), deployedBundles);
+    } catch (ResolverException rx) { 
+      List<String> usr = rx.getUnsatisfiedRequirements();
+      assertEquals ("One unsatisfied requirement expected, not " + usr.size(), usr.size(), 1);
+      String chkMsg = "Shared bundle test.shared_1.0.0 has a dependency for package " +
+      		"test.shared which is exported from application bundle [test.isolated_1.0.0]";
+      assertTrue (chkMsg + " expected, not " + usr, usr.contains(chkMsg));
+      return;
+    }
+    fail ("ResolverException expected");
+  }
+  
+  /**
+   * This method checks that the a more complicated circular dependency issues the correct error message
+   * and checks that the details listed in the exception are correct. 
+   * @throws Exception
+   */
+  @Test
+  public void checkMultipleCircularDependenciesDetected() throws Exception { 
+    
+    Collection<ModelledResource> cmr = new ArrayList<ModelledResource>();
+    ExportedPackage testIsolated1 = createExportedPackage ("test.isolated1", "1.0.0", 
+        new String[] {"test.isolated1","test.isolated2"}, new String[] {"test.shared1", "test.shared2"});
+    cmr.add (testIsolated1.getBundle());
+    
+    ExportedPackage testIsolated2 = createExportedPackage ("test.isolated2", "1.0.0", 
+        new String[] {"test.isolated1","test.isolated2"}, new String[] {"test.shared1", "test.shared2"});
+    cmr.add (testIsolated2.getBundle());
+    
+    ExportedPackage testShared1 = createExportedPackage ("test.shared1", "1.0.0", 
+        new String[] {"test.shared1", "test.shared2"}, new String[] {"test.isolated1","test.isolated2"});
+    cmr.add (testShared1.getBundle());
+    
+    ExportedPackage testShared2 = createExportedPackage ("test.shared2", "1.0.0", 
+        new String[] {"test.shared1", "test.shared2"}, new String[] {"test.isolated1","test.isolated2"});
+    cmr.add (testShared2.getBundle());
+    
+    _resolver.addResult(cmr);
+    
+    // The second time DeploymentGenerator calls the Resolver, it will provide just 
+    // test.shared. The resolver will return test.shared _plus_ test.isolated. 
+    _resolver.addResult(cmr);
+    Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getApplicationContents"), Arrays.asList(mockContent("test.isolated1" , "1.0.0"), mockContent("test.isolated2" , "1.0.0")));
+    
+    app = Skeleton.newMock(AriesApplication.class);
+    Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
+    
+    try {
+      DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles (appMetadata, 
+          Arrays.asList(new ModelledResource[] {testIsolated1.getBundle(), testIsolated2.getBundle()}), 
+          new ArrayList<Content>());
+      deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+          appMetadata.getApplicationVersion().toString(), deployedBundles);
+    } catch (ResolverException rx) { 
+      // Get the unsatisfied Requirements
+      List<String> unsatisfiedReqs = rx.getUnsatisfiedRequirements();
+      // Ensure we've got 4 unsatisfied Requirements
+      assertEquals ("4 unsatisfied requirements expected, not " + unsatisfiedReqs.size(), unsatisfiedReqs.size(), 4);
+      List<String> checkMessages = new ArrayList<String>();
+      // Now load an array with the expected messages.
+      checkMessages.add("Shared bundle test.shared1_1.0.0 has a dependency for package test.isolated1 which " +
+      "is exported from application bundles [test.isolated1_1.0.0, test.isolated2_1.0.0]");
+      checkMessages.add("Shared bundle test.shared1_1.0.0 has a dependency for package test.isolated2 which " +
+      "is exported from application bundles [test.isolated1_1.0.0, test.isolated2_1.0.0]");
+      checkMessages.add("Shared bundle test.shared2_1.0.0 has a dependency for package test.isolated1 which " +
+      "is exported from application bundles [test.isolated1_1.0.0, test.isolated2_1.0.0]");
+      checkMessages.add("Shared bundle test.shared2_1.0.0 has a dependency for package test.isolated2 which " +
+      "is exported from application bundles [test.isolated1_1.0.0, test.isolated2_1.0.0]");
+      
+      // Loop through the unsatisfied Requirements and compare them to the expected msgs. We trim the strings
+      // because some unsatisfied reqs have spaces at the end of the string.
+      for (String unsatisfiedReq : unsatisfiedReqs) {
+        assertTrue(unsatisfiedReq + " is not an expected msg", checkMessages.contains(unsatisfiedReq.trim()));
+      }
+    }
+  }
+  
+  @Test
+  public void checkBundleInAppContentAndProvisionContent() throws Exception
+  {
+    List<ModelledResource> cmr = new ArrayList<ModelledResource>();
+    cmr.add(createModelledResource("test.api", "1.1.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.1.0")));
+    cmr.add(createModelledResource("test.api", "1.0.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.0.0")));
+    cmr.add(createModelledResource("test.consumer", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,2.0.0)\""), Collections.<String>emptyList()));
+    cmr.add(createModelledResource("test.provider", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,1.1.0)\""), Collections.<String>emptyList()));
+
+    // The second time DeploymentGenerator calls the Resolver, it will provide just 
+    // test.shared. The resolver will return test.shared _plus_ test.isolated. 
+    _resolver.addResult(cmr);
+    Skeleton.getSkeleton(appMetadata).setReturnValue(
+        new MethodCall(ApplicationMetadata.class, "getApplicationContents"), 
+        Arrays.asList(
+            mockContent("test.api" , "1.1.0"),
+            mockContent("test.consumer" , "1.0.0"),
+            mockContent("test.provider", "1.0.0")));
+
+    app = Skeleton.newMock(AriesApplication.class);
+    Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
+    
+    try {
+      DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles (appMetadata, 
+          Arrays.asList(new ModelledResource[] {cmr.get(0), cmr.get(2), cmr.get(3)}), 
+          new ArrayList<Content>());
+      deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+          appMetadata.getApplicationVersion().toString(), deployedBundles);
+      
+      fail("Expected exception because we can't provision an isolated bundle twice");
+    } catch (ResolverException rx) {}
+  }
+  
+  /**
+   * Similar to the checkBundleInAppContentAndProvisionContent scenario. However, this time the provisioned bundle does not provide
+   * a package or service to the isolated content, so there is no problem.
+   * @throws Exception
+   */
+  @Test
+  public void checkBundleInAppContentAndProvisionContentButNothingSharedToIsolatedContent() throws Exception
+  {
+    List<ModelledResource> cmr = new ArrayList<ModelledResource>();
+    cmr.add(createModelledResource("test.util", "1.1.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.1.0")));
+    cmr.add(createModelledResource("test.bundle", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.1.0,2.0.0)\""), Collections.<String>emptyList()));
+    cmr.add(createModelledResource("test.provisioned", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,1.1.0)\""), Collections.<String>emptyList()));
+    cmr.add(createModelledResource("test.util", "1.0.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.0.0")));
+
+    // The second time DeploymentGenerator calls the Resolver, it will provide just 
+    // test.shared. The resolver will return test.shared _plus_ test.isolated. 
+    _resolver.addResult(cmr);
+    Skeleton.getSkeleton(appMetadata).setReturnValue(
+        new MethodCall(ApplicationMetadata.class, "getApplicationContents"), 
+        Arrays.asList(
+            mockContent("test.util" , "1.1.0"),
+            mockContent("test.bundle", "1.0.0")));
+
+    app = Skeleton.newMock(AriesApplication.class);
+    Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
+    
+    DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles (appMetadata, 
+        Arrays.asList(new ModelledResource[] {cmr.get(0), cmr.get(1)}), 
+        new ArrayList<Content>());
+    Manifest mf = deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+        appMetadata.getApplicationVersion().toString(), deployedBundles);
+    
+    assertTrue(mf.getMainAttributes().getValue("Deployed-Content").contains("test.util;deployed-version=1.1.0"));
+    assertTrue(mf.getMainAttributes().getValue("Provision-Bundle").contains("test.util;deployed-version=1.0.0"));
+  }
+  
+  @Test
+  public void checkBundleInAppContentAndUseContent() throws Exception
+  {
+    List<ModelledResource> cmr = new ArrayList<ModelledResource>();
+    cmr.add(createModelledResource("test.api", "1.1.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.1.0")));
+    cmr.add(createModelledResource("test.api", "1.0.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.0.0")));
+    cmr.add(createModelledResource("test.consumer", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,2.0.0)\""), Collections.<String>emptyList()));
+    cmr.add(createModelledResource("test.provider", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,1.1.0)\""), Collections.<String>emptyList()));
+
+    // The second time DeploymentGenerator calls the Resolver, it will provide just 
+    // test.shared. The resolver will return test.shared _plus_ test.isolated. 
+    _resolver.addResult(cmr);
+    
+    Skeleton.getSkeleton(appMetadata).setReturnValue(
+        new MethodCall(ApplicationMetadata.class, "getApplicationContents"), 
+        Arrays.asList(
+            mockContent("test.api" , "1.1.0"),
+            mockContent("test.consumer" , "1.0.0"),
+            mockContent("test.provider", "1.0.0")));
+    
+    Skeleton.getSkeleton(appMetadata).setReturnValue(
+        new MethodCall(ApplicationMetadata.class, "getUseBundles"),
+        Arrays.asList(mockContent("test.api", "1.0.0")));
+
+    app = Skeleton.newMock(AriesApplication.class);
+    Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
+    
+    DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles (appMetadata, 
+        Arrays.asList(new ModelledResource[] {cmr.get(0), cmr.get(2), cmr.get(3)}), 
+        new ArrayList<Content>());
+    
+    Manifest mf = deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(),
+        appMetadata.getApplicationVersion().toString(), deployedBundles);
+    
+    mf.write(System.out);
+    assertTrue(mf.getMainAttributes().getValue("Deployed-Content").contains("test.api;deployed-version=1.1.0"));
+    assertTrue(mf.getMainAttributes().getValue("Deployed-Use-Bundle").contains("test.api;deployed-version=1.0.0"));
+  }
+  
+  public static ModelledResource createModelledResource(String bundleName, String bundleVersion, 
+      Collection<String> importedPackages, Collection<String> exportedPackages) throws InvalidAttributeException {
+    Attributes att = new Attributes();
+    att.put(new Attributes.Name(Constants.BUNDLE_SYMBOLICNAME), bundleName);
+    att.put(new Attributes.Name(Constants.BUNDLE_VERSION), bundleVersion);
+    att.put(new Attributes.Name(Constants.BUNDLE_MANIFESTVERSION), "2");
+    
+    StringBuilder builder = new StringBuilder();
+    for(String iPackage : importedPackages) {
+      builder.append(iPackage).append(",");
+    }
+    if(builder.length() > 0) {
+      builder.deleteCharAt(builder.length() - 1);
+      att.put(new Attributes.Name(Constants.IMPORT_PACKAGE), builder.toString());
+    }
+    
+    builder = new StringBuilder();
+    for(String ePackage : exportedPackages) {
+      builder.append(ePackage).append(",");
+    }
+    if(builder.length() > 0) {
+      builder.deleteCharAt(builder.length() - 1);
+      att.put(new Attributes.Name(Constants.EXPORT_PACKAGE), builder.toString());
+    }
+    return new ModellingManagerImpl().getModelledResource(null, att, null, null);
+  }
+  
+  private Content mockContent(String symbolicName, String version) {
+    Content bundle = Skeleton.newMock(Content.class);
+    VersionRange vr = Skeleton.newMock(VersionRange.class);
+    Skeleton.getSkeleton(vr).setReturnValue(new MethodCall(VersionRange.class, "toString"), version);
+    Skeleton.getSkeleton(bundle).setReturnValue(new MethodCall(Content.class, "getContentName"), symbolicName);
+    Skeleton.getSkeleton(bundle).setReturnValue(new MethodCall(Content.class, "getVersion"), vr);
+    
+       return bundle;
+  }
+}

Added: aries/tags/application-0.3/application-install/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-install/pom.xml?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-install/pom.xml (added)
+++ aries/tags/application-0.3/application-install/pom.xml Sun Feb 27 20:20:13 2011
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <artifactId>application</artifactId>
+        <groupId>org.apache.aries.application</groupId>
+        <version>0.3</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.apache.aries.application.install</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Aries Application Installer</name>
+    <description>
+        A very basic application installer
+    </description>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.fileinstall</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.testsupport</groupId>
+            <artifactId>org.apache.aries.testsupport.unit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.utils</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

Added: aries/tags/application-0.3/application-install/src/main/java/org/apache/aries/application/install/EBAInstaller.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-install/src/main/java/org/apache/aries/application/install/EBAInstaller.java?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-install/src/main/java/org/apache/aries/application/install/EBAInstaller.java (added)
+++ aries/tags/application-0.3/application-install/src/main/java/org/apache/aries/application/install/EBAInstaller.java Sun Feb 27 20:20:13 2011
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.aries.application.install;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.AriesApplicationContext;
+import org.apache.aries.application.management.AriesApplicationManager;
+import org.apache.aries.application.utils.filesystem.FileSystem;
+import org.apache.felix.fileinstall.ArtifactInstaller;
+import org.osgi.framework.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EBAInstaller implements ArtifactInstaller
+{
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(EBAInstaller.class);
+
+  private Map<File, AriesApplicationContext> appContexts = new HashMap<File, AriesApplicationContext>();
+
+  private AriesApplicationManager applicationManager;
+
+  public AriesApplicationManager getApplicationManager()
+  {
+    return applicationManager;
+  }
+
+  public void setApplicationManager(AriesApplicationManager applicationManager)
+  {
+    this.applicationManager = applicationManager;
+  }
+
+  public boolean canHandle(File fileToHandlerLocation)
+  {
+    return fileToHandlerLocation.getName().toLowerCase().endsWith(".eba");
+  }
+
+  public void install(File applicationLocation) throws Exception
+  {
+    AriesApplication app = applicationManager
+        .createApplication(FileSystem.getFSRoot(applicationLocation));
+    
+    String appSymName = app.getApplicationMetadata().getApplicationSymbolicName();
+    Version appVersion = app.getApplicationMetadata().getApplicationVersion();
+
+    LOGGER.debug("created app from {} : {} {} with contents {}", new Object[] {
+        applicationLocation.getName(), appSymName, appVersion,
+        app.getApplicationMetadata().getApplicationContents() });
+
+    AriesApplicationContext context = applicationManager.install(app);
+
+    LOGGER.debug("installed app {} {} state: {}", new Object[] {
+        appSymName, appVersion,
+        context.getApplicationState() });
+    
+    context.start();
+
+    LOGGER.debug("started app {} {} state: {}", new Object[] {
+        appSymName, appVersion,
+        context.getApplicationState() });
+    
+    // Store the application context away because it is the application context we need
+    // to pass to the application manager if we're later asked to uninstall the application
+    appContexts.put(applicationLocation, context);
+  }
+
+  public void uninstall(File applicationLocation) throws Exception
+  {
+    AriesApplicationContext context = appContexts.get(applicationLocation);
+    
+    String appSymName = context.getApplication().getApplicationMetadata().getApplicationSymbolicName();
+    Version appVersion = context.getApplication().getApplicationMetadata().getApplicationVersion();
+
+    LOGGER.debug("uninstalling {} {} ", new Object[] {
+        appSymName, appVersion });
+
+    if (context != null) {
+      context.stop();
+      applicationManager.uninstall(context);
+    }
+
+    appContexts.remove(applicationLocation);
+    
+    LOGGER.debug("uninstalled {} {} state: {}", new Object[] {
+        appSymName, appVersion,
+        context.getApplicationState() });
+  }
+
+  public void update(File arg0) throws Exception
+  {
+    throw new UnsupportedOperationException("Updating .eba file is not supported");
+  }
+}

Added: aries/tags/application-0.3/application-install/src/main/resources/OSGI-INF/blueprint/app-install.xml
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-install/src/main/resources/OSGI-INF/blueprint/app-install.xml?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-install/src/main/resources/OSGI-INF/blueprint/app-install.xml (added)
+++ aries/tags/application-0.3/application-install/src/main/resources/OSGI-INF/blueprint/app-install.xml Sun Feb 27 20:20:13 2011
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+  
+  <reference id="app-manager" interface="org.apache.aries.application.management.AriesApplicationManager"/>
+  
+  <bean id="app-artifact-installer" class="org.apache.aries.application.install.EBAInstaller" scope="singleton" activation="lazy">
+    <property name="applicationManager" ref="app-manager"/>
+  </bean>
+
+  <service interface="org.apache.felix.fileinstall.ArtifactInstaller" ref="app-artifact-installer" />
+  
+</blueprint>

Added: aries/tags/application-0.3/application-itest-interface/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-itest-interface/pom.xml?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-itest-interface/pom.xml (added)
+++ aries/tags/application-0.3/application-itest-interface/pom.xml Sun Feb 27 20:20:13 2011
@@ -0,0 +1,40 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.application</groupId>
+        <artifactId>application</artifactId>
+        <version>0.3</version>
+    </parent>
+
+    <artifactId>org.apache.aries.application.runtime.itest.interfaces</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Aries Application itests sample application interface</name>
+    <description>
+      Interface class(es) for aplication runtime itests.
+    </description>
+
+	<properties>
+		<aries.osgi.export.pkg>
+			org.apache.aries.sample
+		</aries.osgi.export.pkg>
+	</properties>
+
+</project>

Added: aries/tags/application-0.3/application-itest-interface/src/main/java/org/apache/aries/sample/HelloWorld.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-itest-interface/src/main/java/org/apache/aries/sample/HelloWorld.java?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-itest-interface/src/main/java/org/apache/aries/sample/HelloWorld.java (added)
+++ aries/tags/application-0.3/application-itest-interface/src/main/java/org/apache/aries/sample/HelloWorld.java Sun Feb 27 20:20:13 2011
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.sample;
+
+public interface HelloWorld {
+
+  public String getMessage();
+}

Added: aries/tags/application-0.3/application-itest-interface/src/main/java/org/apache/aries/sample/HelloWorldManager.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-itest-interface/src/main/java/org/apache/aries/sample/HelloWorldManager.java?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-itest-interface/src/main/java/org/apache/aries/sample/HelloWorldManager.java (added)
+++ aries/tags/application-0.3/application-itest-interface/src/main/java/org/apache/aries/sample/HelloWorldManager.java Sun Feb 27 20:20:13 2011
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.sample;
+
+public interface HelloWorldManager
+{
+  int getNumOfHelloServices();
+}

Added: aries/tags/application-0.3/application-itest-twitter/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-itest-twitter/pom.xml?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-itest-twitter/pom.xml (added)
+++ aries/tags/application-0.3/application-itest-twitter/pom.xml Sun Feb 27 20:20:13 2011
@@ -0,0 +1,73 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.application</groupId>
+        <artifactId>application</artifactId>
+        <version>0.3</version>
+    </parent>
+
+    <artifactId>twitter</artifactId>
+    <groupId>org.apache.aries.application.itest.twitter</groupId>
+    <packaging>pom</packaging>
+    <name>Apache Aries Application itests Twitter sample application</name>
+    <description>
+      Application used to test pulling in dependency bundles from a remote repository rather than including them in the .eba
+    </description>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.apache.aries.application.itest.twitter</groupId>
+                <artifactId>org.apache.aries.application.itest.twitter.bundle</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.aries.application.itest.twitter</groupId>
+                <artifactId>org.apache.aries.application.itest.twitter.eba</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.servicemix.tooling</groupId>
+                <artifactId>depends-maven-plugin</artifactId>
+                <version>1.2</version>
+                <executions>
+                    <execution>
+                        <id>generate-depends-file</id>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+	<modules>
+		<module>twitter-bundle</module>
+		<module>twitter-eba</module>
+	</modules>
+
+</project>

Added: aries/tags/application-0.3/application-itest-twitter/twitter-bundle/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-itest-twitter/twitter-bundle/pom.xml?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-itest-twitter/twitter-bundle/pom.xml (added)
+++ aries/tags/application-0.3/application-itest-twitter/twitter-bundle/pom.xml Sun Feb 27 20:20:13 2011
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+	<modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.application.itest.twitter</groupId>
+        <artifactId>twitter</artifactId>
+        <version>0.3</version>
+    </parent>
+
+	<artifactId>org.apache.aries.application.itest.twitter.bundle</artifactId>
+	<name>Apache Aries Twitter itest bundle</name>
+	<packaging>bundle</packaging>
+
+    <properties>
+        <aries.osgi.import.pkg>
+            twitter4j;version="[2.0.8,2.1.0)",
+            *
+        </aries.osgi.import.pkg>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>net.homeip.yusuke</groupId>
+            <artifactId>twitter4j</artifactId>
+            <version>2.0.8</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<configuration>
+					<instructions>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Activator>org.apache.aries.application.itest.twitter.TwitterQuery</Bundle-Activator>
+                        <Private-Package>org.apache.aries.application.itest.twitter</Private-Package>
+					</instructions>
+				</configuration> 
+			</plugin>
+		</plugins>
+	</build>
+</project>
+	

Added: aries/tags/application-0.3/application-itest-twitter/twitter-bundle/src/main/java/org/apache/aries/application/itest/twitter/TwitterQuery.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-itest-twitter/twitter-bundle/src/main/java/org/apache/aries/application/itest/twitter/TwitterQuery.java?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-itest-twitter/twitter-bundle/src/main/java/org/apache/aries/application/itest/twitter/TwitterQuery.java (added)
+++ aries/tags/application-0.3/application-itest-twitter/twitter-bundle/src/main/java/org/apache/aries/application/itest/twitter/TwitterQuery.java Sun Feb 27 20:20:13 2011
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.application.itest.twitter;
+import java.util.List;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+import twitter4j.Query;
+import twitter4j.QueryResult;
+import twitter4j.Tweet;
+import twitter4j.Twitter;
+import org.apache.commons.lang.StringEscapeUtils;
+
+public class TwitterQuery implements BundleActivator {
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		Twitter twitter = new Twitter();
+		Query query = new Query("from:theasf");
+		
+		try {
+			QueryResult result = twitter.search(query);
+		    List<Tweet> tweets = result.getTweets(); 
+		    System.out.println("hits:" + tweets.size());
+		    for (Tweet tweet : result.getTweets()) {
+		        System.out.println(tweet.getFromUser() + ":" + StringEscapeUtils.unescapeXml(tweet.getText()));
+		    }
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+	}
+
+}

Propchange: aries/tags/application-0.3/application-itest-twitter/twitter-bundle/src/main/java/org/apache/aries/application/itest/twitter/TwitterQuery.java
------------------------------------------------------------------------------
    svn:executable = *

Added: aries/tags/application-0.3/application-itest-twitter/twitter-eba/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-itest-twitter/twitter-eba/pom.xml?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-itest-twitter/twitter-eba/pom.xml (added)
+++ aries/tags/application-0.3/application-itest-twitter/twitter-eba/pom.xml Sun Feb 27 20:20:13 2011
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.aries.application.itest.twitter</groupId>
+        <artifactId>twitter</artifactId>
+        <version>0.3</version>
+    </parent>
+
+    <artifactId>org.apache.aries.application.itest.twitter.eba</artifactId>
+    <name>Apache Aries Twitter itest EBA</name>
+    <description>This is the module that constructs the Twitter itest application from the Twitter itest bundle</description>
+    <packaging>eba</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.application.itest.twitter</groupId>
+            <artifactId>org.apache.aries.application.itest.twitter.bundle</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.aries</groupId>
+                <artifactId>eba-maven-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <generateManifest>true</generateManifest>
+                    <instructions>
+                        <Application-SymbolicName>${pom.artifactId}</Application-SymbolicName>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Added: aries/tags/application-0.3/application-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-itests/pom.xml?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-itests/pom.xml (added)
+++ aries/tags/application-0.3/application-itests/pom.xml Sun Feb 27 20:20:13 2011
@@ -0,0 +1,283 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <artifactId>application</artifactId>
+        <groupId>org.apache.aries.application</groupId>
+        <version>0.3</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.apache.aries.application.runtime.isolated.itests</artifactId>
+    <packaging>jar</packaging>
+    <name>Apache Aries Application integration tests</name>
+    <description>
+        Integration tests for the Application runtime
+    </description>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.configadmin</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.aries</groupId>
+			<artifactId>org.apache.aries.util</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.aries.blueprint</groupId>
+			<artifactId>org.apache.aries.blueprint</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.aries.proxy</groupId>
+			<artifactId>org.apache.aries.proxy</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>asm</groupId>
+			<artifactId>asm-all</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.ops4j.pax.logging</groupId>
+			<artifactId>pax-logging-api</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.ops4j.pax.logging</groupId>
+			<artifactId>pax-logging-service</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.ops4j.pax.exam</groupId>
+			<artifactId>pax-exam</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.ops4j.pax.exam</groupId>
+			<artifactId>pax-exam-junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.ops4j.pax.exam</groupId>
+			<artifactId>pax-exam-container-default</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.ops4j.pax.url</groupId>
+			<artifactId>pax-url-mvn</artifactId>
+            <scope>test</scope>
+		</dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.bundlerepository</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>test</scope>
+        </dependency>       
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.utils</artifactId>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.aries.testsupport</groupId>
+            <artifactId>org.apache.aries.testsupport.unit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.runtime.itest.interfaces</artifactId>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.aries.application.itest.twitter</groupId>
+            <artifactId>org.apache.aries.application.itest.twitter.eba</artifactId>
+            <version>${project.version}</version>
+            <type>eba</type>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>twitter4j</artifactId>
+            <version>0.3</version>
+            
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.management</artifactId>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+        	<groupId>org.apache.aries.application</groupId>
+        	<artifactId>org.apache.aries.application.runtime.framework</artifactId>
+        	<scope>test</scope>
+        </dependency>
+        
+        <dependency>
+        	<groupId>org.apache.aries.application</groupId>
+        	<artifactId>org.apache.aries.application.runtime.framework.management</artifactId>
+        	<scope>test</scope>
+        </dependency>
+        
+        <dependency>
+        	<groupId>org.apache.aries.application</groupId>
+        	<artifactId>org.apache.aries.application.runtime.repository</artifactId>
+        	<scope>test</scope>
+        </dependency>
+        
+        <dependency>
+        	<groupId>org.apache.aries.application</groupId>
+        	<artifactId>org.apache.aries.application.runtime.isolated</artifactId>
+        	<scope>test</scope>
+        </dependency>
+        
+        <dependency>
+        	<groupId>org.apache.aries.application</groupId>
+        	<artifactId>org.apache.aries.application.runtime</artifactId>
+        	<scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.resolver.obr</artifactId>
+            <scope>test</scope>
+        </dependency>
+       
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.resolver.noop</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.noop.platform.repo</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.noop.postresolve.process</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+             <groupId>org.apache.aries.application</groupId>
+             <artifactId>org.apache.aries.application.default.local.platform</artifactId>
+             <scope>test</scope>
+        </dependency>
+        <dependency>
+        	<groupId>org.apache.aries.transaction</groupId>
+        	<artifactId>org.apache.aries.transaction.blueprint</artifactId>
+        	<scope>test</scope>
+        </dependency>
+        <dependency>
+        	<groupId>org.apache.geronimo.specs</groupId>
+        	<artifactId>geronimo-jta_1.1_spec</artifactId>
+        	<version>1.1.1</version>
+        	<scope>test</scope>
+        </dependency>
+        <dependency>
+        	<groupId>org.eclipse</groupId>
+        	<artifactId>osgi</artifactId>
+        	<version>3.5.0.v20090520</version>
+        	<type>jar</type>
+        	<scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.servicemix.tooling</groupId>
+                <artifactId>depends-maven-plugin</artifactId>
+                <version>1.2</version>
+                <executions>
+                    <execution>
+                        <id>generate-depends-file</id>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                        <configuration>
+                            <outputFile>${project.build.directory}/test-classes/META-INF/maven/dependencies.properties</outputFile>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <forkMode>pertest</forkMode>
+                    <excludes>
+                        <exclude>**/*$*</exclude>
+                        <exclude>**/Abstract*.java</exclude>
+                    </excludes>
+                    <includes>
+                        <include>**/Test*.java</include>
+                        <include>**/*Test.java</include>
+                    </includes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>ci-build-profile</id>
+            <activation>
+                <property>
+                    <name>maven.repo.local</name>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <!--
+                                when the local repo location has been specified, we need to pass
+                                on this information to PAX mvn url
+                            -->
+                            <argLine>-Dorg.ops4j.pax.url.mvn.localRepository=${maven.repo.local}</argLine>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+</project>

Added: aries/tags/application-0.3/application-itests/src/test/java/org/apache/aries/application/helloworld/client/HelloWorldClientImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-itests/src/test/java/org/apache/aries/application/helloworld/client/HelloWorldClientImpl.java?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-itests/src/test/java/org/apache/aries/application/helloworld/client/HelloWorldClientImpl.java (added)
+++ aries/tags/application-0.3/application-itests/src/test/java/org/apache/aries/application/helloworld/client/HelloWorldClientImpl.java Sun Feb 27 20:20:13 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.application.helloworld.client;
+import java.util.List;
+
+import org.apache.aries.sample.HelloWorld;
+import org.apache.aries.sample.HelloWorldManager;
+public class HelloWorldClientImpl implements HelloWorldManager
+{
+
+  List<HelloWorld> helloWorldServices;
+
+  public List<HelloWorld> getHelloWorldServices()
+  {
+    return helloWorldServices;
+  }
+
+  public void setHelloWorldServices(List<HelloWorld> helloWorldServices)
+  {
+    this.helloWorldServices = helloWorldServices;
+  }
+  public int getNumOfHelloServices() {
+    return helloWorldServices.size();
+  }
+  
+}

Added: aries/tags/application-0.3/application-itests/src/test/java/org/apache/aries/application/runtime/itests/AbstractIntegrationTest.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-itests/src/test/java/org/apache/aries/application/runtime/itests/AbstractIntegrationTest.java?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-itests/src/test/java/org/apache/aries/application/runtime/itests/AbstractIntegrationTest.java (added)
+++ aries/tags/application-0.3/application-itests/src/test/java/org/apache/aries/application/runtime/itests/AbstractIntegrationTest.java Sun Feb 27 20:20:13 2011
@@ -0,0 +1,223 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.application.runtime.itests;
+
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
+import static org.ops4j.pax.exam.OptionUtils.combine;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.ops4j.pax.url.mvn.Handler;
+import org.ops4j.pax.url.mvn.ServiceConstants;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.Version;
+import org.osgi.util.tracker.ServiceTracker;
+
+@RunWith(JUnit4TestRunner.class)
+public class AbstractIntegrationTest {
+
+  public static final long DEFAULT_TIMEOUT = 60000;
+
+  @Inject
+  protected BundleContext bundleContext;
+  
+  private List<ServiceTracker> srs;
+
+  @Before
+  public void setUp() {
+      srs = new ArrayList<ServiceTracker>();
+  }
+  
+  @After
+  public void tearDown() throws Exception{
+      for (ServiceTracker st : srs) {
+          if (st != null) {
+              st.close();
+          }  
+      }
+  }
+  
+  protected Bundle getBundle(String symbolicName) {
+    return getBundle(symbolicName, null);
+  }
+	
+  protected Bundle getBundle(String bundleSymbolicName, String version) {
+    Bundle result = null;
+    for (Bundle b : bundleContext.getBundles()) {
+      if (b.getSymbolicName().equals(bundleSymbolicName)) {
+        if (version == null
+            || b.getVersion().equals(Version.parseVersion(version))) {
+          result = b;
+          break;
+        }
+      }
+    }
+    return result;
+  }
+
+  public static MavenArtifactProvisionOption mavenBundle(String groupId,
+          String artifactId) {
+    return CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId)
+        .versionAsInProject();
+  }
+
+  
+  protected static Option[] updateOptions(Option[] options) {
+    // We need to add pax-exam-junit here when running with the ibm
+    // jdk to avoid the following exception during the test run:
+    // ClassNotFoundException: org.ops4j.pax.exam.junit.Configuration
+    if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
+      Option[] ibmOptions = options(wrappedBundle(mavenBundle(
+          "org.ops4j.pax.exam", "pax-exam-junit")));
+      options = combine(ibmOptions, options);
+    }
+
+    return options;
+  }
+
+  protected <T> T getOsgiService(Class<T> type, long timeout) {
+    return getOsgiService(type, null, timeout);
+  }
+
+  protected <T> T getOsgiService(Class<T> type) {
+    return getOsgiService(type, null, DEFAULT_TIMEOUT);
+  }
+  
+  protected <T> T getOsgiService(Class<T> type, String filter, long timeout) {
+    return getOsgiService(null, type, filter, timeout);
+  }
+
+  protected <T> T getOsgiService(BundleContext bc, Class<T> type,
+      String filter, long timeout) {
+    ServiceTracker tracker = null;
+    try {
+      String flt;
+      if (filter != null) {
+        if (filter.startsWith("(")) {
+          flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")"
+              + filter + ")";
+        } else {
+          flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")("
+              + filter + "))";
+        }
+      } else {
+        flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
+      }
+      Filter osgiFilter = FrameworkUtil.createFilter(flt);
+      tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter,
+          null);
+      tracker.open();
+     
+      // add tracker to the list of trackers we close at tear down
+      srs.add(tracker);
+
+      Object x = tracker.waitForService(timeout);
+      Object svc = type.cast(x);
+      if (svc == null) {
+        throw new RuntimeException("Gave up waiting for service " + flt);
+      }
+      return type.cast(svc);
+    } catch (InvalidSyntaxException e) {
+      throw new IllegalArgumentException("Invalid filter", e);
+    } catch (InterruptedException e) {
+      throw new RuntimeException(e);
+    }
+  }
+ 
+  public static URL getUrlToEba(String groupId, String artifactId) throws MalformedURLException {
+    String artifactVersion = getArtifactVersion(groupId, artifactId);
+
+    // Need to use handler from org.ops4j.pax.url.mvn
+    URL urlToEba = new URL(null,
+        ServiceConstants.PROTOCOL + ":" + groupId + "/" +artifactId + "/"
+            + artifactVersion + "/eba", new Handler());
+    return urlToEba;
+  }
+  
+  public static URL getUrlToBundle(String groupId, String artifactId) throws MalformedURLException {
+	    String artifactVersion = getArtifactVersion(groupId, artifactId);
+
+	    // Need to use handler from org.ops4j.pax.url.mvn
+	    URL urlToEba = new URL(null,
+	        ServiceConstants.PROTOCOL + ":" + groupId + "/" +artifactId + "/"
+	            + artifactVersion, new Handler());
+	    return urlToEba;
+	  }
+
+  public static String getArtifactVersion(final String groupId, final String artifactId)
+  {
+    final Properties dependencies = new Properties();
+    try {
+      InputStream in = getFileFromClasspath("META-INF/maven/dependencies.properties");
+      try {
+        dependencies.load(in);
+      } finally {
+        in.close();
+      }
+      final String version = dependencies.getProperty(groupId + "/" + artifactId + "/version");
+      if (version == null) {
+        throw new RuntimeException("Could not resolve version. Do you have a dependency for "
+            + groupId + "/" + artifactId + " in your maven project?");
+      }
+      return version;
+    } catch (IOException e) {
+      // TODO throw a better exception
+      throw new RuntimeException(
+          "Could not resolve version. Did you configure the depends-maven-plugin in your maven project? "
+              + " Or maybe you did not run the maven build and you are using an IDE?");
+    }
+  }  
+
+  private static InputStream getFileFromClasspath( final String filePath )
+    throws FileNotFoundException
+  {
+    try
+    {
+        URL fileURL = AbstractIntegrationTest.class.getClassLoader().getResource( filePath );
+        if( fileURL == null )
+        {
+            throw new FileNotFoundException( "File [" + filePath + "] could not be found in classpath" );
+        }
+        return fileURL.openStream();
+    }
+    catch (IOException e)
+    {
+        throw new FileNotFoundException( "File [" + filePath + "] could not be found: " + e.getMessage() );
+    }
+  }
+}
\ No newline at end of file

Added: aries/tags/application-0.3/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java
URL: http://svn.apache.org/viewvc/aries/tags/application-0.3/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java?rev=1075132&view=auto
==============================================================================
--- aries/tags/application-0.3/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java (added)
+++ aries/tags/application-0.3/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java Sun Feb 27 20:20:13 2011
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.application.runtime.itests;
+
+import static org.junit.Assert.assertEquals;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.AriesApplicationContext;
+import org.apache.aries.application.management.AriesApplicationManager;
+import org.apache.aries.application.utils.filesystem.FileSystem;
+import org.apache.aries.sample.HelloWorld;
+import org.apache.aries.unittest.fixture.ArchiveFixture;
+import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+@RunWith(JUnit4TestRunner.class)
+public class BasicAppManagerTest extends AbstractIntegrationTest {
+  
+  /* Use @Before not @BeforeClass so as to ensure that these resources
+   * are created in the paxweb temp directory, and not in the svn tree 
+   */
+  static boolean createdApplications = false;
+  @Before
+  public static void createApplications() throws Exception {
+    if (createdApplications) { 
+      return;
+    }
+    ZipFixture testEba = ArchiveFixture.newZip()
+      .jar("sample.jar")
+        .manifest().symbolicName("org.apache.aries.sample")
+          .attribute("Bundle-Version", "1.0.0")
+          .attribute("Import-Package", "org.apache.aries.sample")
+          .end()
+        .binary("org/apache/aries/sample/impl/HelloWorldImpl.class", 
+            BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/sample/impl/HelloWorldImpl.class"))
+        .binary("OSGI-INF/blueprint/sample-blueprint.xml", 
+            BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/sample-blueprint.xml"))
+        .end();
+      
+    FileOutputStream fout = new FileOutputStream("test.eba");
+    testEba.writeOut(fout);
+    fout.close();
+    
+    ZipFixture testEba2 = testEba.binary("META-INF/APPLICATION.MF", 
+        BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/APPLICATION.MF"))
+        .end();
+    fout = new FileOutputStream("test2.eba");
+    testEba2.writeOut(fout);
+    fout.close();
+    createdApplications = true;
+  }
+  
+  @Test
+  public void testAppWithoutApplicationManifest() throws Exception {
+    
+    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
+    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
+    
+    // application name should be equal to eba name since application.mf is not provided
+    assertEquals("test.eba", app.getApplicationMetadata().getApplicationName());
+    AriesApplicationContext ctx = manager.install(app);
+    ctx.start();
+    
+    HelloWorld hw = getOsgiService(HelloWorld.class);
+    String result = hw.getMessage();
+    assertEquals (result, "hello world");
+    
+    ctx.stop();
+    manager.uninstall(ctx);
+  }
+
+  @Test
+  public void testAppWithApplicationManifest() throws Exception {
+    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
+    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
+    
+    // application name should equal to whatever Application name provided in the application.mf
+    assertEquals("test application 2", app.getApplicationMetadata().getApplicationName());
+    
+    AriesApplicationContext ctx = manager.install(app);
+    ctx.start();
+    
+    HelloWorld hw = getOsgiService(HelloWorld.class);
+    String result = hw.getMessage();
+    assertEquals (result, "hello world");
+    
+    ctx.stop();
+    manager.uninstall(ctx);
+  }
+
+  
+  @org.ops4j.pax.exam.junit.Configuration
+  public static Option[] configuration() {
+    Option[] options = options(
+        // Log
+        mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+        mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+        // Felix Config Admin
+        mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+        // Felix mvn url handler
+        mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+        // this is how you set the default log level when using pax
+        // logging (logProfile)
+        systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+        // Bundles
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.noop.platform.repo"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.noop.postresolve.process"),
+        mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces"),
+        mavenBundle("org.apache.aries", "org.apache.aries.util"),
+        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"), 
+        mavenBundle("asm", "asm-all"),
+        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+        mavenBundle("org.osgi", "org.osgi.compendium"),
+        mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
+        
+        
+        /* For debugging, uncomment the next two lines
+        vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
+        waitForFrameworkStartup(),
+        
+        and add these imports:
+        import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
+        import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+        */
+
+        equinox().version("3.5.0"));
+    options = updateOptions(options);
+    return options;
+  }
+}