You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by hu...@apache.org on 2010/10/22 12:24:22 UTC

svn commit: r1026277 - in /incubator/aries/trunk/application: ./ application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/ application-itest-twitter/ application-itest-twitter/twitter-bundle/ application-i...

Author: hughesj
Date: Fri Oct 22 10:24:22 2010
New Revision: 1026277

URL: http://svn.apache.org/viewvc?rev=1026277&view=rev
Log:
ARIES-461 Committed patch to DeploymentManifestManagerImpl from Emily Jiang and some small mods to make the test work

Modified:
    incubator/aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java
    incubator/aries/trunk/application/application-itest-twitter/   (props changed)
    incubator/aries/trunk/application/application-itest-twitter/twitter-bundle/   (props changed)
    incubator/aries/trunk/application/application-itest-twitter/twitter-bundle/pom.xml
    incubator/aries/trunk/application/application-itest-twitter/twitter-eba/   (props changed)
    incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java
    incubator/aries/trunk/application/pom.xml

Modified: incubator/aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java?rev=1026277&r1=1026276&r2=1026277&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java (original)
+++ incubator/aries/trunk/application/application-deployment-management/src/main/java/org/apache/aries/application/deployment/management/impl/DeploymentManifestManagerImpl.java Fri Oct 22 10:24:22 2010
@@ -246,6 +246,7 @@ public class DeploymentManifestManagerIm
     sharedBundles.addAll (deployedBundles.getDeployedProvisionBundle());
     sharedBundles.addAll (deployedBundles.getRequiredUseBundle()); 
 
+    Collection<ModelledResource> appContentBundles = deployedBundles.getDeployedContent();
     Collection<Content> requiredSharedBundles = new ArrayList<Content>();
     for (ModelledResource mr : sharedBundles) { 
       String version = mr.getExportedBundle().getVersion();
@@ -260,10 +261,13 @@ public class DeploymentManifestManagerIm
     Collection<ModelledResource> resolvedSharedBundles = resolver.resolve(appSymbolicName, appVersion
         , byValueBundles, requiredSharedBundles);
 
-    List<String> differences = findDifferences (resolvedSharedBundles, sharedBundles);
+    // we need to find out whether any shared bundles depend on the isolated bundles
+    List<String> suspects = findSuspects (resolvedSharedBundles, sharedBundles, appContentBundles);
     // If we have differences, it means that we have shared bundles trying to import packages
     // from isolated bundles. We need to build up the error message and throw a ResolverException
-    if (!differences.isEmpty()) { 
+    if (!suspects.isEmpty()) { 
+    	
+    	
       StringBuilder msgs = new StringBuilder();
       List<String> unsatisfiedRequirements = new ArrayList<String>();
 
@@ -271,7 +275,7 @@ public class DeploymentManifestManagerIm
       // Find the isolated bundles and store all the packages that they export in a map.
       for (ModelledResource mr : resolvedSharedBundles) {
         String mrName = mr.getSymbolicName() + "_" + mr.getExportedBundle().getVersion();
-        if (differences.contains(mrName)) {
+        if (suspects.contains(mrName)) {
           List<String> exportedPackages = new ArrayList<String>();
           isolatedBundles.put(mrName, exportedPackages);
           for (ExportedPackage ep : mr.getExportedPackages()) {
@@ -283,8 +287,8 @@ public class DeploymentManifestManagerIm
       // are exported from the isolated bundles.
       for (ModelledResource mr : resolvedSharedBundles) {
         String mrName = mr.getSymbolicName() + "_" + mr.getExportedBundle().getVersion();
-        // if current reource isn't an isolated bundle check it's requirements
-        if (!!! differences.contains(mrName)) {
+        // if current resource isn't an isolated bundle check it's requirements
+        if (!!! suspects.contains(mrName)) {
           // Iterate through the imported packages of the current shared bundle.
           for (ImportedPackage ip : mr.getImportedPackages()) {
             String packageName = ip.getPackageName();
@@ -488,31 +492,37 @@ public class DeploymentManifestManagerIm
 
   /**
    * We've done a sanity check resolve on our sharedBundles and received back 
-   * resolvedSharedBundles. These two collections should be equal in size and 
-   * contain the same elements. If this is not true, we've found a circular dependency. 
+   * resolvedSharedBundles. The resolvedSharedBundles should not contain any bundles listed in the isolated bundle list.
+   * If this is not true, we've found a case of shared bundles depending on isolated bundles. 
    * This method extracts the name_versions of those bundles in resolvedSharedBundles
    * that do not appear in sharedBundles. 
    * @param resolvedSharedBundles What we got back from the resolver
    * @param sharedBundles         What we expected to get back from the resolver
-   * @return                      The difference
+   * @param appContentBundles     The isolated bundles
+   * @return                      The isolated bundles depended by the shared bundles
    */
-  private List<String> findDifferences (Collection<ModelledResource> resolvedSharedBundles, 
-      Collection<ModelledResource> sharedBundles){
-    _logger.debug(LOG_ENTRY, "findDifferences", new Object[]{resolvedSharedBundles,sharedBundles });
+  private List<String> findSuspects (Collection<ModelledResource> resolvedSharedBundles, 
+      Collection<ModelledResource> sharedBundles, Collection<ModelledResource> appContentBundles){
+    _logger.debug(LOG_ENTRY, "findSuspects", new Object[]{resolvedSharedBundles,sharedBundles, appContentBundles });
     Set<String> expectedBundles = new HashSet<String>();
+    Set<String> isolatedBundles = new HashSet<String>();
     for (ModelledResource sb : sharedBundles) { 
       expectedBundles.add(sb.getExportedBundle().getSymbolicName() + "_" + 
           sb.getExportedBundle().getVersion());
     }
+    for (ModelledResource sb : appContentBundles) { 
+    	isolatedBundles.add(sb.getExportedBundle().getSymbolicName() + "_" + 
+            sb.getExportedBundle().getVersion());
+    }
     List<String> suspects = new ArrayList<String>();
     for (ModelledResource mr : resolvedSharedBundles) {
       String thisBundle = mr.getExportedBundle().getSymbolicName() + "_" + 
       mr.getExportedBundle().getVersion();
-      if (!expectedBundles.contains(thisBundle)) { 
+      if (!expectedBundles.contains(thisBundle) && (isolatedBundles.contains(thisBundle))) { 
         suspects.add(thisBundle);   
       }
     }
-    _logger.debug(LOG_EXIT, "pruneFakeBundleFromResults", new Object[]{suspects});
+    _logger.debug(LOG_EXIT, "findSuspects", new Object[]{suspects});
 
     return suspects;
   }

Propchange: incubator/aries/trunk/application/application-itest-twitter/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Oct 22 10:24:22 2010
@@ -0,0 +1,4 @@
+target
+.classpath
+.project
+.settings

Propchange: incubator/aries/trunk/application/application-itest-twitter/twitter-bundle/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Oct 22 10:24:22 2010
@@ -0,0 +1,4 @@
+target
+.classpath
+.project
+.settings

Modified: incubator/aries/trunk/application/application-itest-twitter/twitter-bundle/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itest-twitter/twitter-bundle/pom.xml?rev=1026277&r1=1026276&r2=1026277&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-itest-twitter/twitter-bundle/pom.xml (original)
+++ incubator/aries/trunk/application/application-itest-twitter/twitter-bundle/pom.xml Fri Oct 22 10:24:22 2010
@@ -30,9 +30,9 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.twitter4j</groupId>
-            <artifactId>twitter4j-core</artifactId>
-            <version>2.1.6</version>
+            <groupId>net.homeip.yusuke</groupId>
+            <artifactId>twitter4j</artifactId>
+            <version>2.0.8</version>
         </dependency>
         <dependency>
             <groupId>commons-lang</groupId>

Propchange: incubator/aries/trunk/application/application-itest-twitter/twitter-eba/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Oct 22 10:24:22 2010
@@ -0,0 +1,4 @@
+target
+.classpath
+.project
+.settings

Modified: 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=1026277&r1=1026276&r2=1026277&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java (original)
+++ incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java Fri Oct 22 10:24:22 2010
@@ -408,38 +408,38 @@ public class OBRResolverAdvancedTest ext
 
 
   //Test for JIRA-461 which currently fails.
-//  @Test
-//  public void testTwitter() throws Exception
-//  {
-//    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
-//    Repository[] repos = repositoryAdmin.listRepositories();
-//    for (Repository repo : repos) {
-//      repositoryAdmin.removeRepository(repo.getURI());
-//    }
-//
-//    // Use the superclasses' getUrlToEba() method instead of the pax-exam mavenBundle() method because pax-exam is running in a
-//    // diffference bundle which doesn't have visibility to the META-INF/maven/dependencies.properties file used to figure out the
-//    // version of the maven artifact.
-//    URL twitterEbaUrl = getUrlToEba("org.apache.aries.application.itest.twitter",
-//        "org.apache.aries.application.itest.twitter.eba");
-//
-//    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
-//    repositoryAdmin.addRepository("http://sigil.codecauldron.org/spring-external.obr");
-//    AriesApplication app = manager.createApplication(twitterEbaUrl);
-//    //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<DeploymentContent> appContent = depMeta.getApplicationDeploymentContents();
-//    assertEquals(provision.toString(), 2, provision.size());
-//    assertEquals(useBundles.toString(), 0, useBundles.size());
-//    assertEquals(appContent.toString(), 1, appContent.size());
-//    AriesApplicationContext ctx = manager.install(app);
-//    ctx.start();
-//  }
+  @Test
+  public void testTwitter() throws Exception
+  {
+    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
+    Repository[] repos = repositoryAdmin.listRepositories();
+    for (Repository repo : repos) {
+      repositoryAdmin.removeRepository(repo.getURI());
+    }
+
+    // Use the superclasses' getUrlToEba() method instead of the pax-exam mavenBundle() method because pax-exam is running in a
+    // diffference bundle which doesn't have visibility to the META-INF/maven/dependencies.properties file used to figure out the
+    // version of the maven artifact.
+    URL twitterEbaUrl = getUrlToEba("org.apache.aries.application.itest.twitter",
+        "org.apache.aries.application.itest.twitter.eba");
+
+    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
+    repositoryAdmin.addRepository("http://sigil.codecauldron.org/spring-external.obr");
+    AriesApplication app = manager.createApplication(twitterEbaUrl);
+    //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<DeploymentContent> appContent = depMeta.getApplicationDeploymentContents();
+    assertEquals(provision.toString(), 2, provision.size());
+    assertEquals(useBundles.toString(), 0, useBundles.size());
+    assertEquals(appContent.toString(), 1, appContent.size());
+    AriesApplicationContext ctx = manager.install(app);
+    ctx.start();
+  }
   
   private void generateOBRRepoXML(boolean nullURI, String ... bundleFiles) throws Exception
   {

Modified: incubator/aries/trunk/application/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/pom.xml?rev=1026277&r1=1026276&r2=1026277&view=diff
==============================================================================
--- incubator/aries/trunk/application/pom.xml (original)
+++ incubator/aries/trunk/application/pom.xml Fri Oct 22 10:24:22 2010
@@ -226,6 +226,7 @@
         <module>application-noop-platform-repository</module>
 	   <module>application-noop-postresolve-process</module>
 	   <module>application-default-local-platform</module>
+        <module>application-itest-twitter</module>
 
     </modules>