aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eji...@apache.org
Subject svn commit: r1089921 - /aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java
Date Thu, 07 Apr 2011 15:53:42 GMT
Author: ejiang
Date: Thu Apr  7 15:53:41 2011
New Revision: 1089921

URL: http://svn.apache.org/viewvc?rev=1089921&view=rev
Log:
ARIES-618: Create a command line repository generator tool

Modified:
    aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java

Modified: aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java?rev=1089921&r1=1089920&r2=1089921&view=diff
==============================================================================
--- aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java
(original)
+++ aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java
Thu Apr  7 15:53:41 2011
@@ -387,6 +387,56 @@ public class OBRResolverAdvancedTest ext
   }
   
   @Test
+  public void testRepoAgain() throws Exception {
+    // do not provision against the local runtime
+    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "true");
+    
+    RepositoryGenerator repositoryGenerator = getOsgiService(RepositoryGenerator.class);
+    
+    String fileURI = new File(REPO_BUNDLE+".jar").toURI().toString();
+    File repoXml = new File("repository.xml");
+    if (repoXml.exists()) {
+       repoXml.delete();
+    }
+    repositoryGenerator.generateRepository(new String[] {fileURI}, new FileOutputStream(repoXml));
+    
+    //print out the repository.xml
+    BufferedReader reader = new BufferedReader(new FileReader(new File("repository.xml")));
+    String line;
+    while (( line = reader.readLine()) != null) {
+        System.out.println(line);
+    }
+    // compare the generated with the expected file
+    Document real_doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new
File("repository.xml"));    
+    Document expected_doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("/obr/aries.bundle1/expectedRepository.xml"));
+    // parse two documents to make sure they have the same number of elements
+    Element element_real = real_doc.getDocumentElement();
+    Element element_expected = expected_doc.getDocumentElement();    
+    NodeList nodes_real = element_real.getElementsByTagName("capability");
+    NodeList nodes_expected = element_expected.getElementsByTagName("capability");
+    assertEquals("The number of capability is not expected. ", nodes_expected.getLength(),
nodes_real.getLength());    
+    nodes_real = element_real.getElementsByTagName("require");
+    nodes_expected = element_expected.getElementsByTagName("require");    
+    assertEquals("The number of require elements is not expected. ", nodes_expected.getLength(),
nodes_real.getLength());
+    nodes_real = element_real.getElementsByTagName("p");
+    nodes_expected = element_expected.getElementsByTagName("p");    
+    assertEquals("The number of properties is not expected. ", nodes_expected.getLength(),
nodes_real.getLength());
+    // Let's verify all p elements are shown as expected.
+    for (int index=0; index < nodes_expected.getLength(); index++) {
+      Node node = nodes_expected.item(index);
+      boolean contains = false;
+      // make sure the node exists in the real generated repository
+      for (int i=0; i<nodes_real.getLength(); i++) {
+        Node real_node = nodes_real.item(i);
+        if (node.isEqualNode(real_node)) {
+          contains = true;
+          break;
+        }
+      }
+      assertTrue("The node " + node.toString() + "should exist.", contains);
+    }
+  }
+  @Test
   public void testMutlipleServices() throws Exception{
     // provision against the local runtime
     System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");



Mime
View raw message