You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by mn...@apache.org on 2010/08/26 13:51:09 UTC

svn commit: r989612 - in /incubator/aries/trunk/application/application-itests/src/test: java/org/apache/aries/application/helloworld/ java/org/apache/aries/application/helloworld/client/ java/org/apache/aries/application/runtime/itests/ resources/basi...

Author: mnuttall
Date: Thu Aug 26 11:51:09 2010
New Revision: 989612

URL: http://svn.apache.org/viewvc?rev=989612&view=rev
Log:
ARIES-361: Provisioning changes required to support application isolation. From a patch submitted by Emily Jiang.

Added:
    incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/helloworld/
    incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/helloworld/client/
    incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/helloworld/client/HelloWorldClientImpl.java
    incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java
    incubator/aries/trunk/application/application-itests/src/test/resources/basic/fakeAppMgrServiceRepo.xml
    incubator/aries/trunk/application/application-itests/src/test/resources/obr/APPLICATION-UseBundle.MF
    incubator/aries/trunk/application/application-itests/src/test/resources/obr/aries.bundle1/
    incubator/aries/trunk/application/application-itests/src/test/resources/obr/aries.bundle1/META-INF/
    incubator/aries/trunk/application/application-itests/src/test/resources/obr/aries.bundle1/META-INF/MANIFEST.MF
    incubator/aries/trunk/application/application-itests/src/test/resources/obr/aries.bundle1/expectedRepository.xml
    incubator/aries/trunk/application/application-itests/src/test/resources/obr/hello-world-client.xml
Modified:
    incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java
    incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java
    incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java
    incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRAppManagerTest.java
    incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java

Added: incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/helloworld/client/HelloWorldClientImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/helloworld/client/HelloWorldClientImpl.java?rev=989612&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/helloworld/client/HelloWorldClientImpl.java (added)
+++ incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/helloworld/client/HelloWorldClientImpl.java Thu Aug 26 11:51:09 2010
@@ -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();
+  }
+  
+}

Modified: incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java?rev=989612&r1=989611&r2=989612&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java (original)
+++ incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java Thu Aug 26 11:51:09 2010
@@ -133,6 +133,8 @@ public class BasicAppManagerTest extends
         // 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.runtime.itest.interfaces"),
@@ -141,6 +143,7 @@ public class BasicAppManagerTest extends
         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(),

Modified: incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java?rev=989612&r1=989611&r2=989612&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java (original)
+++ incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java Thu Aug 26 11:51:09 2010
@@ -17,12 +17,12 @@
  * under the License.
  */
 package org.apache.aries.application.runtime.itests;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 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 java.lang.reflect.Method;
@@ -31,7 +31,6 @@ import org.apache.aries.application.mana
 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.isolated.sample.HelloWorld;
 import org.apache.aries.unittest.fixture.ArchiveFixture;
 import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;
@@ -47,10 +46,6 @@ import org.osgi.framework.Filter;
 import org.osgi.framework.FrameworkUtil;
 import org.osgi.service.framework.CompositeBundle;
 import org.osgi.util.tracker.ServiceTracker;
-
-import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
-
 @RunWith(JUnit4TestRunner.class)
 public class IsolatedRuntimeTest extends AbstractIntegrationTest {
   
@@ -238,6 +233,10 @@ public class IsolatedRuntimeTest extends
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.isolated"),
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
+        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.framework"),
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework.management"),
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.repository"),
@@ -247,9 +246,16 @@ public class IsolatedRuntimeTest extends
         mavenBundle("org.apache.geronimo.specs","geronimo-jta_1.1_spec"),
         mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
 
-//        vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
-//        waitForFrameworkStartup(),
-
+        /* For debugging, uncommenting the following two lines and add the imports */
+        /*
+         * vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5011"),
+        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;

Modified: incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java?rev=989612&r1=989611&r2=989612&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java (original)
+++ incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java Thu Aug 26 11:51:09 2010
@@ -18,67 +18,105 @@
  */
 package org.apache.aries.application.runtime.itests;
 
-import java.io.File;
-import java.io.FileOutputStream;
-
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 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.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+
 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.unittest.fixture.ArchiveFixture;
 import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.RepositoryAdmin;
 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;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.blueprint.container.BlueprintEvent;
 import org.osgi.service.blueprint.container.BlueprintListener;
 
-
 @RunWith(JUnit4TestRunner.class)
+
 public class MinimumImportsTest 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;
+  static String fake_app_management = "application.management.fake";
   @Before
   public static void createApplications() throws Exception {
 
     if (createdApplications) { 
       return;
     }
+
+    // need to fake a application manager to export the service in order to pass the resolving for the client
+    // In the real situation, we don't allow customers' bundles to explicitly import the runtime services.
+    ZipFixture bundle = ArchiveFixture.newJar().manifest()
+    .attribute(Constants.BUNDLE_SYMBOLICNAME, fake_app_management)
+    .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+    .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
+
+    OutputStream out = new FileOutputStream(fake_app_management + ".jar");
+    bundle.writeOut(out);
+    out.close();
+
+
     ZipFixture testEba = ArchiveFixture.newZip()
-      .jar("org.apache.aries.application.itests.minimports.jar")
-        .manifest().symbolicName("org.apache.aries.application.itests.minimports")
-          .attribute("Bundle-Version", "1.0.0")
-          .attribute("Import-Package", "org.apache.aries.application.management")
-          .end()
-        .binary("org/apache/aries/application/sample/appmgrclient/AppMgrClient.class", 
-            MinimumImportsTest.class.getClassLoader().getResourceAsStream("org/apache/aries/application/sample/appmgrclient/AppMgrClient.class"))
+    .jar("org.apache.aries.application.itests.minimports.jar")
+    .manifest().symbolicName("org.apache.aries.application.itests.minimports")
+    .attribute("Bundle-Version", "1.0.0")
+    .attribute("Import-Package", "org.apache.aries.application.management")
+    .end()
+    .binary("org/apache/aries/application/sample/appmgrclient/AppMgrClient.class", 
+        MinimumImportsTest.class.getClassLoader().getResourceAsStream("org/apache/aries/application/sample/appmgrclient/AppMgrClient.class"))
         .binary("OSGI-INF/blueprint/app-mgr-client.xml", 
             MinimumImportsTest.class.getClassLoader().getResourceAsStream("app-mgr-client.xml"))
-        .end();
-      
+            .end();
+
     FileOutputStream fout = new FileOutputStream("appmgrclienttest.eba");
     testEba.writeOut(fout);
     fout.close();
-    
+
+    StringBuilder repositoryXML = new StringBuilder();
+
+    BufferedReader reader = new BufferedReader(new InputStreamReader(MinimumImportsTest.class.getResourceAsStream("/basic/fakeAppMgrServiceRepo.xml")));
+    String line;
+
+    while ((line = reader.readLine()) != null) {
+      repositoryXML.append(line);
+      repositoryXML.append("\r\n");
+    }
+
+    String repo = repositoryXML.toString().replaceAll("bundle_location", new File(fake_app_management + ".jar").toURI().toString());
+
+    System.out.println(repo);
+
+    FileWriter writer = new FileWriter("repository.xml");
+    writer.write(repo);
+    writer.close();
     createdApplications = true;
   }
-  
+
   public static class AppMgrClientBlueprintListener implements BlueprintListener {
-    
+
     Boolean success = null;
-    
+
     public void blueprintEvent(BlueprintEvent event) {
       if (event.getBundle().getSymbolicName().equals(
           "org.apache.aries.application.itests.minimports")) {
@@ -91,20 +129,29 @@ public class MinimumImportsTest extends 
       }
     }
   }
-  
+
   @Test
   public void testAppUsingAriesApplicationManager() throws Exception {
-    
+
     // Register a BlueprintListener to listen for the events from the BlueprintContainer for the bundle in the appmgrclienttest.eba
-    
+
     AppMgrClientBlueprintListener acbl = new AppMgrClientBlueprintListener();
     ServiceRegistration sr = bundleContext.registerService("org.osgi.service.blueprint.container.BlueprintListener", acbl, null);
-    
+
     AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
     AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("appmgrclienttest.eba")));
+    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
+
+    Repository[] repos = repositoryAdmin.listRepositories();
+    for (Repository repo : repos) {
+      repositoryAdmin.removeRepository(repo.getURI());
+    }
+
+    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
+
     AriesApplicationContext ctx = manager.install(app);
     ctx.start();
-    
+
     int sleepfor = 3000;
     while ((acbl.success == null || acbl.success == false) && sleepfor > 0) {
       Thread.sleep(100);
@@ -112,12 +159,12 @@ public class MinimumImportsTest extends 
     }
     assertNotNull("Timed out - didn't receive Blueprint CREATED or FAILURE event", acbl.success);
     assertTrue("Received Blueprint FAILURE event", acbl.success);
-    
+
     ctx.stop();
     manager.uninstall(ctx);
     sr.unregister();
   }
-  
+
   @org.ops4j.pax.exam.junit.Configuration
   public static Option[] configuration() {
     Option[] options = options(
@@ -140,18 +187,22 @@ public class MinimumImportsTest extends 
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime"),
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces"),
         mavenBundle("org.apache.aries", "org.apache.aries.util"),
+        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.modeller"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
         mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"), 
         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;
-        */
+
+        /* For debugging, uncomment the next two lines*/
+        /*vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5007"),
+          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);

Modified: incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRAppManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRAppManagerTest.java?rev=989612&r1=989611&r2=989612&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRAppManagerTest.java (original)
+++ incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRAppManagerTest.java Thu Aug 26 11:51:09 2010
@@ -168,6 +168,10 @@ public class OBRAppManagerTest extends A
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime").noStart(),
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
+        mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
         mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces"),
         mavenBundle("org.apache.aries", "org.apache.aries.util"),
@@ -175,15 +179,15 @@ public class OBRAppManagerTest extends A
         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=5005"),
-//        waitForFrameworkStartup(),
+        //        /* For debugging, uncomment the next two lines
+        //        vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+        //        waitForFrameworkStartup(),
 
         /* For debugging, uncomment the next two lines
         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);

Added: incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java?rev=989612&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java (added)
+++ incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java Thu Aug 26 11:51:09 2010
@@ -0,0 +1,460 @@
+/*
+ * 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 junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+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.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.aries.application.Content;
+import org.apache.aries.application.DeploymentContent;
+import org.apache.aries.application.DeploymentMetadata;
+import org.apache.aries.application.filesystem.IDirectory;
+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.management.RepositoryGenerator;
+import org.apache.aries.application.management.ResolverException;
+import org.apache.aries.application.modelling.ModelledResource;
+import org.apache.aries.application.modelling.ModelledResourceManager;
+import org.apache.aries.application.utils.filesystem.FileSystem;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor.NameValueMap;
+import org.apache.aries.sample.HelloWorld;
+import org.apache.aries.sample.HelloWorldManager;
+import org.apache.aries.unittest.fixture.ArchiveFixture;
+import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+import org.junit.After;
+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;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+@RunWith(JUnit4TestRunner.class)
+public class OBRResolverAdvancedTest extends AbstractIntegrationTest 
+{
+  public static final String CORE_BUNDLE_BY_VALUE = "core.bundle.by.value";
+  public static final String CORE_BUNDLE_BY_REFERENCE = "core.bundle.by.reference";
+  public static final String TRANSITIVE_BUNDLE_BY_VALUE = "transitive.bundle.by.value";
+  public static final String TRANSITIVE_BUNDLE_BY_REFERENCE = "transitive.bundle.by.reference";
+  public static final String USE_BUNDLE_BY_REFERENCE = "use.bundle.by.reference";
+  public static final String REPO_BUNDLE = "aries.bundle1";
+  public static final String HELLO_WORLD_CLIENT_BUNDLE="hello.world.client.bundle";
+  public static final String HELLO_WORLD_SERVICE_BUNDLE1="hello.world.service.bundle1";
+  public static final String HELLO_WORLD_SERVICE_BUNDLE2="hello.world.service.bundle2";
+  
+  /* Use @Before not @BeforeClass so as to ensure that these resources
+   * are created in the paxweb temp directory, and not in the svn tree
+   */
+  @Before
+  public static void createApplications() throws Exception 
+  {
+    ZipFixture bundle = ArchiveFixture.newJar().manifest()
+                            .attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_VALUE)
+                            .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+                            .attribute(Constants.IMPORT_PACKAGE, "a.b.c, p.q.r, x.y.z, javax.naming")
+                            .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
+
+    
+    FileOutputStream fout = new FileOutputStream(CORE_BUNDLE_BY_VALUE + ".jar");
+    bundle.writeOut(fout);
+    fout.close();
+
+    bundle = ArchiveFixture.newJar().manifest()
+                            .attribute(Constants.BUNDLE_SYMBOLICNAME, TRANSITIVE_BUNDLE_BY_VALUE)
+                            .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+                            .attribute(Constants.EXPORT_PACKAGE, "p.q.r")
+                            .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
+
+    fout = new FileOutputStream(TRANSITIVE_BUNDLE_BY_VALUE + ".jar");
+    bundle.writeOut(fout);
+    fout.close();
+
+    bundle = ArchiveFixture.newJar().manifest()
+                            .attribute(Constants.BUNDLE_SYMBOLICNAME, TRANSITIVE_BUNDLE_BY_REFERENCE)
+                            .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+                            .attribute(Constants.EXPORT_PACKAGE, "x.y.z")
+                            .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
+    
+    fout = new FileOutputStream(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar");
+    bundle.writeOut(fout);
+    fout.close();
+
+    bundle = ArchiveFixture.newJar().manifest()
+                            .attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_REFERENCE)
+                            .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+                            .attribute(Constants.EXPORT_PACKAGE, "d.e.f")
+                            .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
+    
+    fout = new FileOutputStream(CORE_BUNDLE_BY_REFERENCE + ".jar");
+    bundle.writeOut(fout);
+    fout.close();
+
+    
+    
+    // jar up a use bundle
+    bundle = ArchiveFixture.newJar().manifest()
+    .attribute(Constants.BUNDLE_SYMBOLICNAME, USE_BUNDLE_BY_REFERENCE)
+    .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+    .attribute(Constants.EXPORT_PACKAGE, "a.b.c")
+    .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
+
+    fout = new FileOutputStream(USE_BUNDLE_BY_REFERENCE + ".jar");
+    bundle.writeOut(fout);
+    fout.close();
+    // Create the EBA application
+    ZipFixture testEba = ArchiveFixture.newZip()
+     .binary("META-INF/APPLICATION.MF",
+        OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("obr/APPLICATION-UseBundle.MF"))
+        .end()
+      .binary(CORE_BUNDLE_BY_VALUE + ".jar", new FileInputStream(CORE_BUNDLE_BY_VALUE + ".jar")).end()
+      .binary(TRANSITIVE_BUNDLE_BY_VALUE + ".jar", new FileInputStream(TRANSITIVE_BUNDLE_BY_VALUE + ".jar")).end();
+
+    fout = new FileOutputStream("demo.eba");
+    testEba.writeOut(fout);
+    fout.close();
+    
+
+    //create the bundle
+    bundle = ArchiveFixture.newJar()
+    .binary("META-INF/MANIFEST.MF", OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("obr/aries.bundle1/META-INF/MANIFEST.MF")).end()
+    .binary("OSGI-INF/blueprint/blueprint.xml", OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("obr/hello-world-client.xml")).end();
+    fout = new FileOutputStream(REPO_BUNDLE + ".jar");
+    bundle.writeOut(fout);
+    fout.close();
+    
+
+    ///////////////////////////////////////////////
+    //create an eba with a helloworld client, which get all 'HelloWorld' services
+    //create a helloworld client
+    bundle = ArchiveFixture.newJar().manifest()
+    .attribute(Constants.BUNDLE_SYMBOLICNAME, HELLO_WORLD_CLIENT_BUNDLE)
+    .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+    .attribute("Import-Package", "org.apache.aries.sample")
+    .attribute(Constants.BUNDLE_VERSION, "1.0.0").end()
+    .binary("org/apache/aries/application/helloworld/client/HelloWorldClientImpl.class", 
+        BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/application/helloworld/client/HelloWorldClientImpl.class"))
+    .binary("OSGI-INF/blueprint/helloClient.xml", 
+        BasicAppManagerTest.class.getClassLoader().getResourceAsStream("obr/hello-world-client.xml"))
+    .end();
+
+    
+    fout = new FileOutputStream(HELLO_WORLD_CLIENT_BUNDLE + ".jar");
+    bundle.writeOut(fout);
+    fout.close();
+    
+  
+    //create two helloworld services
+    // create the 1st helloworld service
+    bundle = ArchiveFixture.newJar().manifest()
+    .attribute(Constants.BUNDLE_SYMBOLICNAME, HELLO_WORLD_SERVICE_BUNDLE1)
+    .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+    .attribute("Import-Package", "org.apache.aries.sample")
+    .attribute(Constants.BUNDLE_VERSION, "1.0.0").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();
+
+    //create the 2nd helloworld service
+    fout = new FileOutputStream(HELLO_WORLD_SERVICE_BUNDLE1 + ".jar");
+    bundle.writeOut(fout);
+    fout.close();
+    
+    bundle = ArchiveFixture.newJar().manifest()
+    .attribute(Constants.BUNDLE_SYMBOLICNAME, HELLO_WORLD_SERVICE_BUNDLE2)
+    .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+    .attribute("Import-Package", "org.apache.aries.sample")
+    .attribute(Constants.BUNDLE_VERSION, "1.0.0").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();
+
+    fout = new FileOutputStream(HELLO_WORLD_SERVICE_BUNDLE2 + ".jar");
+    bundle.writeOut(fout);
+    fout.close();
+    
+    //Create a helloworld eba with the client included
+    ZipFixture multiServiceHelloEba = ArchiveFixture.newZip()
+     .binary(HELLO_WORLD_CLIENT_BUNDLE + ".jar", new FileInputStream(HELLO_WORLD_CLIENT_BUNDLE + ".jar")).end();
+     
+   fout = new FileOutputStream("hello.eba");
+   multiServiceHelloEba.writeOut(fout);
+   fout.close();
+
+  }
+
+  @Test(expected=ResolverException.class)
+  public void testDemoAppResolveFail() throws ResolverException, Exception
+  {
+    startApplicationRuntimeBundle();
+
+    generateOBRRepoXML(false, TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + "_0.0.0.jar",  USE_BUNDLE_BY_REFERENCE+".jar");
+    
+    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
+    
+    Repository[] repos = repositoryAdmin.listRepositories();
+    for (Repository repo : repos) {
+      repositoryAdmin.removeRepository(repo.getURI());
+    }
+    
+    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
+
+    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
+    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("demo.eba")));
+    
+    app = manager.resolve(app);
+    
+    
+  }
+  
+  @Test
+  public void testDemoApp() throws Exception 
+  {
+    startApplicationRuntimeBundle();
+
+    generateOBRRepoXML(false, TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + ".jar", USE_BUNDLE_BY_REFERENCE+".jar");
+    
+    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
+    
+    Repository[] repos = repositoryAdmin.listRepositories();
+    for (Repository repo : repos) {
+      repositoryAdmin.removeRepository(repo.getURI());
+    }
+    
+    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
+
+    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
+    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("demo.eba")));
+    //installing requires a valid url for the bundle in repository.xml.
+    
+    app = manager.resolve(app);
+    
+    DeploymentMetadata depMeta = app.getDeploymentMetadata();
+    
+    List<DeploymentContent> provision = depMeta.getApplicationProvisionBundles();
+    Collection<DeploymentContent> useBundles = depMeta.getDeployedUseBundle();
+    Collection<Content> importPackages = depMeta.getImportPackage();
+    assertEquals(provision.toString(), 2, provision.size());
+    assertEquals(useBundles.toString(), 1, useBundles.size());
+    assertEquals(importPackages.toString(), 4, importPackages.size());
+    
+    List<String> bundleSymbolicNames = new ArrayList<String>();
+    
+    for (DeploymentContent dep : provision) {
+      bundleSymbolicNames.add(dep.getContentName());
+    }
+    
+    assertTrue("Bundle " + TRANSITIVE_BUNDLE_BY_REFERENCE + " not found.", bundleSymbolicNames.contains(TRANSITIVE_BUNDLE_BY_REFERENCE));
+    assertTrue("Bundle " + TRANSITIVE_BUNDLE_BY_VALUE + " not found.", bundleSymbolicNames.contains(TRANSITIVE_BUNDLE_BY_VALUE));
+    bundleSymbolicNames.clear();
+    for (DeploymentContent dep : useBundles) {
+      bundleSymbolicNames.add(dep.getContentName());
+    }
+    assertTrue("Bundle " + USE_BUNDLE_BY_REFERENCE + " not found.", bundleSymbolicNames.contains(USE_BUNDLE_BY_REFERENCE));
+    Collection<String> packages = new ArrayList<String>();
+    NameValueMap<String, String> maps = new NameValueMap<String, String>();
+    maps.put("version", "0.0.0");
+    maps.put("bundle-symbolic-name", "use.bundle.by.reference");
+    maps.put("bundle-version", "[1.0.0,1.0.0]");
+    Content useContent = ManifestHeaderProcessor.parseContent("a.b.c", maps);
+    assertTrue("Use Bundle not found in import packags", importPackages.contains(useContent));
+    
+    for (Content c : importPackages) {
+      packages.add(c.getContentName());
+    }
+    
+    assertTrue("package javax.naming not found", packages.contains("javax.naming"));
+    assertTrue("package p.q.r not found", packages.contains("p.q.r"));
+    assertTrue("package x.y.z not found", packages.contains("x.y.z"));
+    assertTrue("package a.b.c not found", packages.contains("a.b.c"));
+    AriesApplicationContext ctx = manager.install(app);
+    ctx.start();
+
+    Set<Bundle> bundles = ctx.getApplicationContent();
+    
+    assertEquals("Number of bundles provisioned in the app", 5, bundles.size());
+    
+    ctx.stop();
+    manager.uninstall(ctx);
+    
+  }
+
+  @Test
+  public void testRepo() throws Exception {
+    startApplicationRuntimeBundle();
+
+    generateOBRRepoXML(true, REPO_BUNDLE+".jar");
+    
+    // compare the generated with the expected file
+    BufferedReader expectedFileReader = new BufferedReader(new InputStreamReader(OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("/obr/aries.bundle1/expectedRepository.xml")));
+
+    // read out the temp file
+    BufferedReader reader = new BufferedReader(new FileReader(new File("repository.xml")));
+
+    try {
+      String tempFileline, expectedFileLine;
+      
+      while (((tempFileline = reader.readLine()) != null)
+          && ((expectedFileLine = expectedFileReader.readLine()) != null)) {
+
+        if (!(tempFileline.contains("lastmodified"))) {
+          assertEquals("The result is not expected.", expectedFileLine, tempFileline);
+        }
+
+      }
+    } finally {
+      expectedFileReader.close();
+      reader.close();
+    }
+  
+  }
+  
+  @Test
+  public void testMutlipleServices() throws Exception{
+    startApplicationRuntimeBundle();
+    generateOBRRepoXML(false, HELLO_WORLD_SERVICE_BUNDLE1 + ".jar", HELLO_WORLD_SERVICE_BUNDLE2 + ".jar");
+    
+    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
+    
+    Repository[] repos = repositoryAdmin.listRepositories();
+    for (Repository repo : repos) {
+      repositoryAdmin.removeRepository(repo.getURI());
+    }
+    
+    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
+
+    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
+    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("hello.eba")));
+    AriesApplicationContext ctx = manager.install(app);
+    ctx.start();
+    
+    HelloWorld hw = getOsgiService(HelloWorld.class);
+    String result = hw.getMessage();
+    assertEquals (result, "hello world");
+    
+    
+    // Uncomment the block below after https://issues.apache.org/jira/browse/FELIX-2546, 
+    // "Only one service is provisioned even when specifying for mulitple services"
+    // is fixed. This tracks the problem of provisioning only one service even when we 
+    // specify multiple services.
+    /* 
+     * HelloWorldManager hwm = getOsgiService(HelloWorldManager.class);
+     * int numberOfServices = hwm.getNumOfHelloServices();
+     * assertEquals(numberOfServices, 2); 
+     */
+    ctx.stop();
+    manager.uninstall(ctx);
+   
+  }
+
+  private void generateOBRRepoXML(boolean nullURI, String ... bundleFiles) throws Exception
+  {
+    Set<ModelledResource> mrs = new HashSet<ModelledResource>();
+    FileOutputStream fout = new FileOutputStream("repository.xml");
+    RepositoryGenerator repositoryGenerator = getOsgiService(RepositoryGenerator.class);
+    ModelledResourceManager modelledResourceManager = getOsgiService(ModelledResourceManager.class);
+    for (String fileName : bundleFiles) {
+      File bundleFile = new File(fileName);
+      IDirectory jarDir = FileSystem.getFSRoot(bundleFile);
+      String uri = "";
+      if (!!!nullURI) {
+        uri = bundleFile.toURI().toString();
+      }
+      mrs.add(modelledResourceManager.getModelledResource(uri, jarDir));
+    }
+    repositoryGenerator.generateRepository("Test repo description", mrs, fout);
+    fout.close();
+  }
+
+  @After
+  public void clearRepository() {
+	  RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
+	  Repository[] repos = repositoryAdmin.listRepositories();
+	  if ((repos != null) && (repos.length >0)) {
+		  for (Repository repo : repos) {
+			  repositoryAdmin.removeRepository(repo.getURI());
+		  }
+	  }
+  }
+
+  @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.management"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime").noStart(),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
+        mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
+        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("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=5010"),
+        waitForFrameworkStartup(),
+*/
+        /* For debugging, 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;
+  }
+}
\ No newline at end of file

Modified: incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java?rev=989612&r1=989611&r2=989612&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java (original)
+++ incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java Thu Aug 26 11:51:09 2010
@@ -27,29 +27,27 @@ import static org.ops4j.pax.exam.CoreOpt
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
-import java.lang.reflect.Constructor;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
 import org.apache.aries.application.DeploymentContent;
 import org.apache.aries.application.DeploymentMetadata;
+import org.apache.aries.application.filesystem.IDirectory;
 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.management.BundleInfo;
+import org.apache.aries.application.management.RepositoryGenerator;
 import org.apache.aries.application.management.ResolverException;
-import org.apache.aries.application.resolver.obr.generator.RepositoryDescriptorGenerator;
+import org.apache.aries.application.modelling.ModelledResource;
+import org.apache.aries.application.modelling.ModelledResourceManager;
 import org.apache.aries.application.utils.filesystem.FileSystem;
-import org.apache.aries.application.utils.manifest.BundleManifest;
 import org.apache.aries.unittest.fixture.ArchiveFixture;
 import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -57,10 +55,6 @@ import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
-import org.apache.felix.bundlerepository.Repository;
-import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.w3c.dom.Document;
-
 @RunWith(JUnit4TestRunner.class)
 public class OBRResolverTest extends AbstractIntegrationTest 
 {
@@ -139,6 +133,16 @@ public class OBRResolverTest extends Abs
     fout.close();
   }
 
+  @After
+  public void clearRepository() {
+	  RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
+	  Repository[] repos = repositoryAdmin.listRepositories();
+	  if ((repos != null) && (repos.length >0)) {
+		  for (Repository repo : repos) {
+			  repositoryAdmin.removeRepository(repo.getURI());
+		  }
+	  }
+  }
   @Test(expected=ResolverException.class)
   public void testBlogAppResolveFail() throws ResolverException, Exception
   {
@@ -214,32 +218,19 @@ public class OBRResolverTest extends Abs
 
   private void generateOBRRepoXML(String ... bundleFiles) throws Exception
   {
-    Set<BundleInfo> bundles = new HashSet<BundleInfo>();
-    
-    for (String file : bundleFiles) {
-      bundles.add(createBundleInfo(new File(file).toURI().toURL().toExternalForm()));
-    }
-    
-    Document doc = RepositoryDescriptorGenerator.generateRepositoryDescriptor("Test repo description", bundles);
-    
+    Set<ModelledResource> mrs = new HashSet<ModelledResource>();
     FileOutputStream fout = new FileOutputStream("repository.xml");
-    
-    TransformerFactory.newInstance().newTransformer().transform(new DOMSource(doc), new StreamResult(fout));
-    
+    RepositoryGenerator repositoryGenerator = getOsgiService(RepositoryGenerator.class);
+    ModelledResourceManager modelledResourceManager = getOsgiService(ModelledResourceManager.class);
+    for (String fileName : bundleFiles) {
+      File bundleFile = new File(fileName);
+      IDirectory jarDir = FileSystem.getFSRoot(bundleFile);
+      mrs.add(modelledResourceManager.getModelledResource(bundleFile.toURI().toString(), jarDir));
+    }
+    repositoryGenerator.generateRepository("Test repo description", mrs, fout);
     fout.close();
-    
-    TransformerFactory.newInstance().newTransformer().transform(new DOMSource(doc), new StreamResult(System.out));
-  }
+    }
 
-  private BundleInfo createBundleInfo(String urlToBundle) throws Exception
-  {
-    Bundle b = getBundle("org.apache.aries.application.management");
-    @SuppressWarnings("unchecked")
-    Class<BundleInfo> clazz = b.loadClass("org.apache.aries.application.utils.management.SimpleBundleInfo");
-    Constructor<BundleInfo> c = clazz.getConstructor(BundleManifest.class, String.class);
-    
-    return c.newInstance(BundleManifest.fromBundle(new URL(urlToBundle).openStream()), urlToBundle);
-  }
 
   @org.ops4j.pax.exam.junit.Configuration
   public static Option[] configuration() {
@@ -262,6 +253,8 @@ public class OBRResolverTest extends Abs
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime").noStart(),
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
+        mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
         mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
         mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces"),
         mavenBundle("org.apache.aries", "org.apache.aries.util"),
@@ -270,8 +263,8 @@ public class OBRResolverTest extends Abs
         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=7777"),
-//        waitForFrameworkStartup(),
+        /*vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7777"),
+        waitForFrameworkStartup(),*/
 
         /* For debugging, uncomment the next two lines
         and add these imports:

Added: incubator/aries/trunk/application/application-itests/src/test/resources/basic/fakeAppMgrServiceRepo.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/resources/basic/fakeAppMgrServiceRepo.xml?rev=989612&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/resources/basic/fakeAppMgrServiceRepo.xml (added)
+++ incubator/aries/trunk/application/application-itests/src/test/resources/basic/fakeAppMgrServiceRepo.xml Thu Aug 26 11:51:09 2010
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?><repository name="app.manager.service">
+<resource id="appManagerService/1.0.0" presentationname="application.management.fake" symbolicname="application.management.fake" uri="bundle_location" version="1.0.0">
+<capability name="bundle">
+<p n="version" t="version" v="1.0.0"/>
+<p n="symbolicname" v="application.management.fake"/>
+<p n="Bundle-ManifestVersion" v="2"/>
+<p n="mandatory" v=""/>
+</capability>
+<capability name="service">
+<p n="service" v="service"/>
+<p n="osgi.service.blueprint.compname" v="app-manager"/>
+<p n="objectClass" t="set" v="org.apache.aries.application.management.AriesApplicationManager"/>
+<p n="service.ranking" v="0"/>
+<p n="mandatory" v=""/>
+</capability>
+</resource>
+</repository>
\ No newline at end of file

Added: incubator/aries/trunk/application/application-itests/src/test/resources/obr/APPLICATION-UseBundle.MF
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/resources/obr/APPLICATION-UseBundle.MF?rev=989612&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/resources/obr/APPLICATION-UseBundle.MF (added)
+++ incubator/aries/trunk/application/application-itests/src/test/resources/obr/APPLICATION-UseBundle.MF Thu Aug 26 11:51:09 2010
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Application-ManifestVersion: 1.0
+Application-Name: test application 2
+Application-SymbolicName: org.apache.obr.resolver.test.app
+Application-Version: 1.0
+Application-Content: core.bundle.by.value; version=1.0.0,
+ core.bundle.by.reference; version=1.0.0
+Use-Bundle: use.bundle.by.reference;version="1.0.0"

Added: incubator/aries/trunk/application/application-itests/src/test/resources/obr/aries.bundle1/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/resources/obr/aries.bundle1/META-INF/MANIFEST.MF?rev=989612&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/resources/obr/aries.bundle1/META-INF/MANIFEST.MF (added)
+++ incubator/aries/trunk/application/application-itests/src/test/resources/obr/aries.bundle1/META-INF/MANIFEST.MF Thu Aug 26 11:51:09 2010
@@ -0,0 +1,25 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Test Bundle
+Bundle-SymbolicName: aries.ws.eba.bundle1;singleton:=true;fragment-attachment:=always
+Bundle-Version: 2.0.0
+Bundle-Vendor: IBM
+Import-Package: aries.ejs.ras,
+ aries.ws.app.framework.plugin;version="[1,2)",
+ aries.ws.event;version="1.0.0",
+ aries.ws.ffdc;resolution:=optional,
+ aries.ws.kernel.file;resolution:=mandatory,
+ aries.wsspi.app.container.aries;bundle-symbolic-name=B;bundle-version="[1.2.0,2.2.0)",
+ aries.wsspi.application.aries;company=yang;security:=haha,
+ org.osgi.framework;version="1.3.0"
+DynamicImport-Package: *;vendor=acmen, *,aries.ws.eba.bla,aries.ws.eba.launcher;
+ version="[1,2]"
+Export-Package: aries.ws.eba.bundle1; version=2.2.0;company=dodo;
+ security=false;mandatory:="company,security"
+Require-Bundle: com.acme.facade;visibility:=reexport,
+ com.acme.bar; visibility:=reexport;resolution:=optional,
+ com.ab.de; visibility:=private,
+ com.de.ba; resolution:=mandatory
+Import-Service: aries.ws.eba.import
+Export-Service: aries.ws.eba.export
+Fragment-Host: aries.ws.eba.framework;bundle-version="[3.0,4.0]"

Added: incubator/aries/trunk/application/application-itests/src/test/resources/obr/aries.bundle1/expectedRepository.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/resources/obr/aries.bundle1/expectedRepository.xml?rev=989612&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/resources/obr/aries.bundle1/expectedRepository.xml (added)
+++ incubator/aries/trunk/application/application-itests/src/test/resources/obr/aries.bundle1/expectedRepository.xml Thu Aug 26 11:51:09 2010
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?><repository name="Test repo description">
+<resource id="aries.ws.eba.bundle1/2.0.0" presentationname="Test Bundle" symbolicname="aries.ws.eba.bundle1" uri="" version="2.0.0">
+<capability name="bundle">
+<p n="presentationname" v="Test Bundle"/>
+<p n="Fragment-Host" v="aries.ws.eba.framework;bundle-version=&quot;[3.0,4.0]&quot;"/>
+<p n="version" t="version" v="2.0.0"/>
+<p n="symbolicname" v="aries.ws.eba.bundle1"/>
+<p n="Bundle-ManifestVersion" v="2"/>
+<p n="mandatory" v=""/>
+</capability>
+<capability name="package">
+<p n="security" v="false"/>
+<p n="mandatory" v="company,security"/>
+<p n="package" v="aries.ws.eba.bundle1"/>
+<p n="version" t="version" v="2.2.0"/>
+<p n="bundle-symbolic-name" v="aries.ws.eba.bundle1"/>
+<p n="company" v="dodo"/>
+<p n="bundle-version" t="version" v="2.0.0"/>
+</capability>
+<capability name="service">
+<p n="service" v="service"/>
+<p n="osgi.service.blueprint.compname" v="helloWorldManager"/>
+<p n="objectClass" t="set" v="org.apache.aries.sample.HelloWorldManager"/>
+<p n="service.ranking" v="0"/>
+<p n="mandatory" v=""/>
+</capability>
+<capability name="service">
+<p n="service" v="service"/>
+<p n="objectClass" t="set" v="aries.ws.eba.export"/>
+<p n="service.ranking" v="0"/>
+<p n="mandatory" v=""/>
+</capability>
+<require extend="false" filter="(&amp;(package=org.osgi.framework)(version&gt;=1.3.0))" multiple="false" name="package" optional="false">Requires package with attributes {package=org.osgi.framework, version=1.3.0}</require>
+<require extend="false" filter="(&amp;(package=aries.ws.event)(version&gt;=1.0.0))" multiple="false" name="package" optional="false">Requires package with attributes {package=aries.ws.event, version=1.0.0}</require>
+<require extend="false" filter="(&amp;(package=aries.wsspi.application.aries)(version&gt;=0.0.0)(company=yang)(mandatory:&lt;*company))" multiple="false" name="package" optional="false">Requires package with attributes {package=aries.wsspi.application.aries, version=0.0.0, company=yang}</require>
+<require extend="false" filter="(&amp;(package=aries.ws.kernel.file)(version&gt;=0.0.0))" multiple="false" name="package" optional="false">Requires package with attributes {package=aries.ws.kernel.file, version=0.0.0}</require>
+<require extend="false" filter="(&amp;(package=aries.wsspi.app.container.aries)(version&gt;=0.0.0)(bundle-symbolic-name=B)(bundle-version&gt;=1.2.0)(bundle-version&lt;=2.2.0)(!(bundle-version=2.2.0)))" multiple="false" name="package" optional="false">Requires package with attributes {package=aries.wsspi.app.container.aries, version=0.0.0, bundle-symbolic-name=B, bundle-version=[1.2.0,2.2.0)}</require>
+<require extend="false" filter="(&amp;(package=aries.ws.ffdc)(version&gt;=0.0.0))" multiple="false" name="package" optional="true">Requires package with attributes {package=aries.ws.ffdc, version=0.0.0}</require>
+<require extend="false" filter="(&amp;(package=aries.ws.app.framework.plugin)(version&gt;=1.0.0)(version&lt;=2.0.0)(!(version=2.0.0)))" multiple="false" name="package" optional="false">Requires package with attributes {package=aries.ws.app.framework.plugin, version=[1.0.0,2.0.0)}</require>
+<require extend="false" filter="(&amp;(package=aries.ejs.ras)(version&gt;=0.0.0))" multiple="false" name="package" optional="false">Requires package with attributes {package=aries.ejs.ras, version=0.0.0}</require>
+<require extend="false" filter="(&amp;(package=aries.ws.eba.bla)(version&gt;=0.0.0))" multiple="false" name="package" optional="true">Requires package with attributes {package=aries.ws.eba.bla, version=0.0.0}</require>
+<require extend="false" filter="(&amp;(package=aries.ws.eba.launcher)(version&gt;=1.0.0)(version&lt;=2.0.0))" multiple="false" name="package" optional="true">Requires package with attributes {package=aries.ws.eba.launcher, version=[1.0.0,2.0.0]}</require>
+<require extend="false" filter="(&amp;(service=service)(objectClass=org.apache.aries.sample.HelloWorld)(mandatory:&lt;*service))" multiple="true" name="service" optional="false">Requires service with attributes {service=service, objectClass=org.apache.aries.sample.HelloWorld}</require>
+<require extend="false" filter="(&amp;(service=service)(objectClass=aries.ws.eba.import)(mandatory:&lt;*service))" multiple="false" name="service" optional="false">Requires service with attributes {service=service, objectClass=aries.ws.eba.import}</require>
+<require extend="false" filter="(symbolicname=com.ab.de)" multiple="false" name="bundle" optional="false">Requires bundle with attributes {symbolicname=com.ab.de}</require>
+<require extend="false" filter="(symbolicname=com.acme.facade)" multiple="false" name="bundle" optional="false">Requires bundle with attributes {symbolicname=com.acme.facade}</require>
+<require extend="false" filter="(symbolicname=com.acme.bar)" multiple="false" name="bundle" optional="true">Requires bundle with attributes {symbolicname=com.acme.bar}</require>
+<require extend="false" filter="(symbolicname=com.de.ba)" multiple="false" name="bundle" optional="false">Requires bundle with attributes {symbolicname=com.de.ba}</require>
+<require extend="false" filter="(&amp;(version&gt;=3.0.0)(version&lt;=4.0.0)(symbolicname=aries.ws.eba.framework)(mandatory:&lt;*symbolicname))" multiple="false" name="bundle" optional="false">Requires bundle with attributes {version=[3.0.0,4.0.0], symbolicname=aries.ws.eba.framework}</require>
+</resource>
+</repository>
\ No newline at end of file

Added: incubator/aries/trunk/application/application-itests/src/test/resources/obr/hello-world-client.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/resources/obr/hello-world-client.xml?rev=989612&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/resources/obr/hello-world-client.xml (added)
+++ incubator/aries/trunk/application/application-itests/src/test/resources/obr/hello-world-client.xml Thu Aug 26 11:51:09 2010
@@ -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">
+  
+  
+  <bean id="helloWorldManager" class="org.apache.aries.application.helloworld.client.HelloWorldClientImpl" scope="singleton" activation="lazy">
+    <property name="helloWorldServices" ref="hello-world-service"/>
+  </bean>
+
+<reference-list id="hello-world-service" interface="org.apache.aries.sample.HelloWorld"/>
+  
+<service id ="helloWorldManagerService" ref="helloWorldManager" interface="org.apache.aries.sample.HelloWorldManager"/>
+</blueprint>