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 2009/12/24 13:04:52 UTC

svn commit: r893735 - in /incubator/aries/trunk/application/application-utils: ./ src/test/java/org/apache/aries/application/utils/manifest/ src/test/java/org/apache/aries/application/utils/manifest/test/ src/test/resources/bundles/ src/test/resources/...

Author: mnuttall
Date: Thu Dec 24 12:04:51 2009
New Revision: 893735

URL: http://svn.apache.org/viewvc?rev=893735&view=rev
Log:
ARIES-89: Implement application support: BundleManifest unit test

Added:
    incubator/aries/trunk/application/application-utils/src/test/java/org/apache/aries/application/utils/manifest/
    incubator/aries/trunk/application/application-utils/src/test/java/org/apache/aries/application/utils/manifest/test/
    incubator/aries/trunk/application/application-utils/src/test/java/org/apache/aries/application/utils/manifest/test/BundleManifestTest.java
    incubator/aries/trunk/application/application-utils/src/test/resources/bundles/
    incubator/aries/trunk/application/application-utils/src/test/resources/bundles/exploded.jar/
    incubator/aries/trunk/application/application-utils/src/test/resources/bundles/exploded.jar/META-INF/
    incubator/aries/trunk/application/application-utils/src/test/resources/bundles/exploded.jar/META-INF/MANIFEST.MF
    incubator/aries/trunk/application/application-utils/src/test/resources/bundles/exploded.jar/META-INF/beforeManifest.file
Modified:
    incubator/aries/trunk/application/application-utils/pom.xml

Modified: incubator/aries/trunk/application/application-utils/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/pom.xml?rev=893735&r1=893734&r2=893735&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/pom.xml (original)
+++ incubator/aries/trunk/application/application-utils/pom.xml Thu Dec 24 12:04:51 2009
@@ -57,6 +57,12 @@
             <artifactId>slf4j-api</artifactId>
             <version>1.4.3</version>
       </dependency>
+      <dependency>
+      	<groupId>org.slf4j</groupId>
+      	<artifactId>slf4j-simple</artifactId>
+      	<version>1.4.3</version>
+      	<scope>test</scope>
+      </dependency>
   </dependencies>
 
     <build>

Added: incubator/aries/trunk/application/application-utils/src/test/java/org/apache/aries/application/utils/manifest/test/BundleManifestTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/test/java/org/apache/aries/application/utils/manifest/test/BundleManifestTest.java?rev=893735&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/test/java/org/apache/aries/application/utils/manifest/test/BundleManifestTest.java (added)
+++ incubator/aries/trunk/application/application-utils/src/test/java/org/apache/aries/application/utils/manifest/test/BundleManifestTest.java Thu Dec 24 12:04:51 2009
@@ -0,0 +1,89 @@
+/*
+ * 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.utils.manifest.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.jar.JarInputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.aries.application.utils.filesystem.IOUtils;
+import org.apache.aries.application.utils.manifest.BundleManifest;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class BundleManifestTest
+{
+  @BeforeClass
+  public static void setup() throws Exception
+  {
+    ZipOutputStream out = new ZipOutputStream(new FileOutputStream("../src/test/resources/bundles/nonExploded.jar"));
+    ZipEntry ze = new ZipEntry("META-INF/");
+    out.putNextEntry(ze);
+    
+    File f = new File("../src/test/resources/bundles/exploded.jar/META-INF/beforeManifest.file");
+    ze = new ZipEntry("META-INF/beforeManifest.file");
+    ze.setSize(f.length());
+    out.putNextEntry(ze);
+    IOUtils.copy(new FileInputStream(f), out);
+    
+    f = new File("../src/test/resources/bundles/exploded.jar/META-INF/MANIFEST.MF");
+    ze = new ZipEntry("META-INF/MANIFEST.MF");
+    ze.setSize(f.length());
+    out.putNextEntry(ze);
+    IOUtils.copy(new FileInputStream(f), out);    
+    
+    out.close();
+  }
+  
+  @AfterClass
+  public static void cleanup()
+  {
+    new File("../src/test/resources/bundles/nonExploded.jar").delete();
+  }
+  
+  @Test
+  public void testExploded()
+  {
+    BundleManifest sut = BundleManifest.fromBundle(new File("../src/test/resources/bundles/exploded.jar"));
+    assertEquals("com.ibm.test", sut.getSymbolicName());
+    assertEquals("1.0.0", sut.getVersion().toString());
+  }
+  
+  @Test
+  public void testZip() throws Exception
+  {
+    // make sure that the manifest is not the first file in the jar archive
+    JarInputStream jarIs = new JarInputStream(new FileInputStream("../src/test/resources/bundles/nonExploded.jar"));
+    assertNull(jarIs.getManifest());
+    jarIs.close();
+    
+    BundleManifest sut = BundleManifest.fromBundle(new File("../src/test/resources/bundles/nonExploded.jar"));
+    assertEquals("com.ibm.test", sut.getSymbolicName());
+    assertEquals("1.0.0", sut.getVersion().toString());
+  }
+}
+

Added: incubator/aries/trunk/application/application-utils/src/test/resources/bundles/exploded.jar/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/test/resources/bundles/exploded.jar/META-INF/MANIFEST.MF?rev=893735&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/test/resources/bundles/exploded.jar/META-INF/MANIFEST.MF (added)
+++ incubator/aries/trunk/application/application-utils/src/test/resources/bundles/exploded.jar/META-INF/MANIFEST.MF Thu Dec 24 12:04:51 2009
@@ -0,0 +1,2 @@
+Bundle-SymbolicName: com.ibm.test;singleton:=true
+Bundle-Version: 1.0.0

Added: incubator/aries/trunk/application/application-utils/src/test/resources/bundles/exploded.jar/META-INF/beforeManifest.file
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/test/resources/bundles/exploded.jar/META-INF/beforeManifest.file?rev=893735&view=auto
==============================================================================
    (empty)