Search in sources :

Example 91 with Manifest

use of java.util.jar.Manifest in project felix by apache.

the class PojoMetadataTest method setUp.

public void setUp() {
    File manFile = new File("src/test/resources/manipulation/MANIFEST.MF");
    Manifest manifest;
    try {
        manifest = new Manifest(new FileInputStream(manFile));
        header = manifest.getMainAttributes().getValue("iPOJO-Components");
    } catch (FileNotFoundException e) {
        fail(e.getMessage());
    } catch (IOException e) {
        fail(e.getMessage());
    }
    String comp_name = "ManipulationMetadata-FooProviderType-1";
    FooProviderType1 = getManipulationMetadataForComponent(comp_name);
    comp_name = "ManipulationMetadata-FooBarProviderType-1";
    FooBarProviderType1 = getManipulationMetadataForComponent(comp_name);
    comp_name = "ManipulationMetadata-FooProviderType-Dyn";
    FooProviderTypeDyn = getManipulationMetadataForComponent(comp_name);
    comp_name = "ManipulationMetadata-PrimitiveManipulationTester";
    PrimitiveManipulationTester = getManipulationMetadataForComponent(comp_name);
    comp_name = "ManipulationMetadata-SimpleMultipleCheckServiceProvider";
    SimpleMultipleCheckServiceProvider = getManipulationMetadataForComponent(comp_name);
}
Also used : FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Manifest(java.util.jar.Manifest) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 92 with Manifest

use of java.util.jar.Manifest in project felix by apache.

the class DirectManifestProviderTestCase method testGetManifest.

public void testGetManifest() throws Exception {
    Manifest origin = new Manifest();
    DirectManifestProvider provider = new DirectManifestProvider(origin);
    assertSame(origin, provider.getManifest());
}
Also used : Manifest(java.util.jar.Manifest)

Example 93 with Manifest

use of java.util.jar.Manifest in project felix by apache.

the class DefaultManifestBuilderTestCase method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    manifest = new Manifest();
    Attributes attributes = manifest.getMainAttributes();
    attributes.putValue("Import-Package", ORG_OSGI_FRAMEWORK_VERSION_1_5);
    attributes.putValue("Created-By", "TestCase");
    builder = new DefaultManifestBuilder();
    builder.addReferredPackage(Collections.singleton("org.osgi.service.http"));
}
Also used : Attributes(java.util.jar.Attributes) Manifest(java.util.jar.Manifest) DefaultManifestBuilder(org.apache.felix.ipojo.manipulator.store.builder.DefaultManifestBuilder)

Example 94 with Manifest

use of java.util.jar.Manifest in project felix by apache.

the class DefaultManifestBuilderTestCase method testReferredPackagesAreProperlyAdded.

public void testReferredPackagesAreProperlyAdded() throws Exception {
    List<String> p = Arrays.asList("org.apache.felix.ipojo.test", "org.apache.felix.ipojo.log");
    builder.addReferredPackage(new HashSet<String>(p));
    Manifest modified = builder.build(manifest);
    // Check that referred packages are present
    String imported = modified.getMainAttributes().getValue("Import-Package");
    Assert.assertTrue(imported.contains("org.apache.felix.ipojo.test"));
    Assert.assertTrue(imported.contains("org.apache.felix.ipojo.log"));
}
Also used : Manifest(java.util.jar.Manifest)

Example 95 with Manifest

use of java.util.jar.Manifest in project felix by apache.

the class DefaultManifestBuilderTestCase method testCreatedByHeaderDoesNotContainIPojoTwice.

public void testCreatedByHeaderDoesNotContainIPojoTwice() throws Exception {
    manifest.getMainAttributes().putValue("Created-By", "TestCase for iPOJO");
    Manifest modified = builder.build(manifest);
    // Created by header was properly not changed
    Assert.assertEquals("TestCase for iPOJO", modified.getMainAttributes().getValue("Created-By"));
}
Also used : Manifest(java.util.jar.Manifest)

Aggregations

Manifest (java.util.jar.Manifest)1226 Attributes (java.util.jar.Attributes)392 File (java.io.File)391 IOException (java.io.IOException)336 JarFile (java.util.jar.JarFile)231 InputStream (java.io.InputStream)184 URL (java.net.URL)177 JarOutputStream (java.util.jar.JarOutputStream)145 FileOutputStream (java.io.FileOutputStream)131 Test (org.junit.Test)129 FileInputStream (java.io.FileInputStream)119 Jar (aQute.bnd.osgi.Jar)105 JarInputStream (java.util.jar.JarInputStream)104 Builder (aQute.bnd.osgi.Builder)99 ZipEntry (java.util.zip.ZipEntry)99 ByteArrayOutputStream (java.io.ByteArrayOutputStream)96 JarEntry (java.util.jar.JarEntry)96 ByteArrayInputStream (java.io.ByteArrayInputStream)93 ArrayList (java.util.ArrayList)83 Map (java.util.Map)83