ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r942444 - in /incubator/ace/trunk/ace-obr-metadata: ./ src/test/java/org/apache/ace/obr/ src/test/java/org/apache/ace/obr/metadata/ src/test/java/org/apache/ace/obr/metadata/bindeximpl/
Date Sat, 08 May 2010 18:53:29 GMT
Author: marrs
Date: Sat May  8 18:53:29 2010
New Revision: 942444

URL: http://svn.apache.org/viewvc?rev=942444&view=rev
Log:
Added unit tests.

Added:
    incubator/ace/trunk/ace-obr-metadata/src/test/java/org/apache/ace/obr/
    incubator/ace/trunk/ace-obr-metadata/src/test/java/org/apache/ace/obr/metadata/
    incubator/ace/trunk/ace-obr-metadata/src/test/java/org/apache/ace/obr/metadata/bindeximpl/
    incubator/ace/trunk/ace-obr-metadata/src/test/java/org/apache/ace/obr/metadata/bindeximpl/BindexMetadataTest.java
Modified:
    incubator/ace/trunk/ace-obr-metadata/pom.xml

Modified: incubator/ace/trunk/ace-obr-metadata/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-obr-metadata/pom.xml?rev=942444&r1=942443&r2=942444&view=diff
==============================================================================
--- incubator/ace/trunk/ace-obr-metadata/pom.xml (original)
+++ incubator/ace/trunk/ace-obr-metadata/pom.xml Sat May  8 18:53:29 2010
@@ -25,7 +25,7 @@
         <groupId>org.apache.ace</groupId>
         <artifactId>ace-pom</artifactId>
         <version>0.8.0-SNAPSHOT</version>
-        <relativePath>../pom/</relativePath>                
+        <relativePath>../pom/</relativePath>
     </parent>
 
     <groupId>org.apache.ace</groupId>
@@ -50,7 +50,6 @@
     </build>
 
     <dependencies>
-
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
@@ -68,6 +67,15 @@
             <artifactId>kxml2</artifactId>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>${groupId}</groupId>
+            <artifactId>ace-util</artifactId>
+            <version>${version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${groupId}</groupId>
+            <artifactId>ace-deployment-provider-base</artifactId>
+            <version>${version}</version>
+        </dependency>
     </dependencies>
-
 </project>
\ No newline at end of file

Added: incubator/ace/trunk/ace-obr-metadata/src/test/java/org/apache/ace/obr/metadata/bindeximpl/BindexMetadataTest.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-obr-metadata/src/test/java/org/apache/ace/obr/metadata/bindeximpl/BindexMetadataTest.java?rev=942444&view=auto
==============================================================================
--- incubator/ace/trunk/ace-obr-metadata/src/test/java/org/apache/ace/obr/metadata/bindeximpl/BindexMetadataTest.java
(added)
+++ incubator/ace/trunk/ace-obr-metadata/src/test/java/org/apache/ace/obr/metadata/bindeximpl/BindexMetadataTest.java
Sat May  8 18:53:29 2010
@@ -0,0 +1,98 @@
+/*
+ * 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.ace.obr.metadata.bindeximpl;
+
+import static org.apache.ace.test.utils.TestUtils.UNIT;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
+import org.apache.ace.deployment.provider.ArtifactData;
+import org.apache.ace.deployment.provider.impl.ArtifactDataImpl;
+import org.apache.ace.obr.metadata.MetadataGenerator;
+import org.apache.ace.obr.metadata.bindex.BIndexMetadataGenerator;
+import org.apache.ace.test.utils.deployment.BundleStreamGenerator;
+import org.testng.annotations.Test;
+
+public class BindexMetadataTest {
+
+    private ArtifactData generateBundle(File file, String symbolicName, String version) throws
Exception {
+        ArtifactData bundle = new ArtifactDataImpl(file.getName(), symbolicName, version,
file.toURI().toURL(), false);
+        BundleStreamGenerator.generateBundle(bundle);
+        return bundle;
+    }
+
+    /**
+     * Generate metadata index, verify contents
+     */
+    @Test(groups = { UNIT })
+    public void generateMetaData() throws Exception {
+        File dir = File.createTempFile("meta", "");
+        dir.delete();
+        dir.mkdir();
+        generateBundle(File.createTempFile("bundle", ".jar", dir), "bundle.symbolicname.1",
"1.0.0");
+        generateBundle(File.createTempFile("bundle", ".jar", dir), "bundle.symbolicname.2",
"1.0.0");
+        generateBundle(File.createTempFile("bundle", ".jar", dir), "bundle.symbolicname.3",
"1.0.0");
+        MetadataGenerator meta = new BIndexMetadataGenerator();
+        meta.generateMetadata(dir);
+        File index = new File(dir, "repository.xml");
+        assert index.exists() : "No repository index was generated";
+        assert index.length() > 0 : "Repository index can not be size 0";
+        int count = 0;
+        String line;
+        BufferedReader in = new BufferedReader(new FileReader(index));
+        while ((line = in.readLine()) != null) {
+            if (line.contains("<resource")) {
+                count++;
+            }
+        }
+        in.close();
+        assert count == 3 : "Expected 3 resources in the repositoty index, found " + count
+ ".";
+    }
+
+    /**
+     * Generate a metadata index, remove a bundle, regenerate metadata, verify.
+     */
+    @Test(groups = { UNIT })
+    public void updateMetaData() throws Exception {
+        File dir = File.createTempFile("meta", "");
+        dir.delete();
+        dir.mkdir();
+        File bundle = File.createTempFile("bundle", ".jar", dir);
+        generateBundle(bundle, "bundle.symbolicname.1", "1.0.0");
+        MetadataGenerator meta = new BIndexMetadataGenerator();
+        meta.generateMetadata(dir);
+        bundle.delete();
+        meta.generateMetadata(dir);
+        File index = new File(dir, "repository.xml");
+        assert index.exists() : "No repository index was generated";
+        assert index.length() > 0 : "Repository index can not be size 0";
+        int count = 0;
+        String line;
+        BufferedReader in = new BufferedReader(new FileReader(index));
+        while ((line = in.readLine()) != null) {
+            if (line.contains("<resource")) {
+                count++;
+            }
+        }
+        in.close();
+        assert count == 0 : "Expected 0 resources in the repositoty index, found " + count
+ ".";
+    }
+}



Mime
View raw message