Examples of ZipFixture


Examples of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture

  @Test
  public void testGetBundlesRecursive() throws IOException {
    File tmpDir = new File("../src/test/resources/tmpJars");
    tmpDir.mkdirs();
    for (int n =0; n< 2; n++) {
      ZipFixture bundle = ArchiveFixture.newJar().manifest()
      .attribute(Constants.BUNDLE_SYMBOLICNAME, "aa" + n)
      .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
      .attribute(Constants.IMPORT_PACKAGE, "a.b.c, p.q.r, x.y.z, javax.naming")
      .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
      FileOutputStream fout = new FileOutputStream(new File (tmpDir.getAbsoluteFile(), "aa" + n + ((n == 0)? ".jar": ".war")));
      bundle.writeOut(fout);
      fout.close();
    }
    File subDir = new File(tmpDir, "subDir");
    subDir.mkdirs();
    for (int n =0; n< 2; n++) {
      ZipFixture bundle = ArchiveFixture.newJar().manifest()
      .attribute(Constants.BUNDLE_SYMBOLICNAME, "aa" + n)
      .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
      .attribute(Constants.IMPORT_PACKAGE, "a.b.c, p.q.r, x.y.z, javax.naming")
      .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();



      FileOutputStream fout = new FileOutputStream(new File (subDir.getAbsoluteFile(), "aa" + n + ((n == 0)? ".jar": ".war")));
      bundle.writeOut(fout);
      fout.close();
    }

    for (int n =0; n< 2; n++) {
      ZipFixture bundle = ArchiveFixture.newJar().manifest()
      .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
      .attribute(Constants.IMPORT_PACKAGE, "a.b.c, p.q.r, x.y.z, javax.naming")
      .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();


      FileOutputStream fout = new FileOutputStream(new File (tmpDir, "bb" + n + ".jar"));
      bundle.writeOut(fout);
      fout.close();
    }

    IOUtils.writeOut(tmpDir, "simple.jar", new StringBufferInputStream("abc"));
    IOUtils.writeOut(tmpDir, "simple.war", new StringBufferInputStream("sss"));
View Full Code Here

Examples of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture

public class FragmentTest extends AbstractIntegrationTest
{
  @Test
  public void testFragmentProvidesBlueprintFile() throws Exception
  {
    ZipFixture hostJar = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
    .attribute(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.test.host").end();
   
    ZipFixture fragmentJar = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
      .attribute(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.test.fragment")
      .attribute(Constants.FRAGMENT_HOST, "org.apache.aries.test.host").end()
      .binary("OSGI-INF/blueprint/bp.xml", this.getClass().getResourceAsStream("/bp.xml")).end();
   
    bundleContext.installBundle("fragment", fragmentJar.getInputStream());
    bundleContext.installBundle("host", hostJar.getInputStream()).start();
   
    Runnable r = context().getService(Runnable.class);
    assertNotNull("Could not find blueprint registered service", r);
    BlueprintContainer bc = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.test.host");
View Full Code Here

Examples of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture

  }
 
  @Test
  public void testFragmentWithOverriddenHeader() throws Exception
  {
    ZipFixture hostJar = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
    .attribute(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.test.host")
    .attribute("Bundle-Blueprint", "META-INF/bp/*.xml").end();
   
    ZipFixture fragmentJar = ArchiveFixture.newJar().manifest().attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
      .attribute(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.test.fragment")
      .attribute(Constants.FRAGMENT_HOST, "org.apache.aries.test.host").end()
      .binary("META-INF/bp/bp.xml", this.getClass().getResourceAsStream("/bp.xml")).end();
   
    bundleContext.installBundle("fragment", fragmentJar.getInputStream());
    bundleContext.installBundle("host", hostJar.getInputStream()).start();
   
    Runnable r = context().getService(Runnable.class);
    assertNotNull("Could not find blueprint registered service", r);
    BlueprintContainer bc = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.test.host");
View Full Code Here

Examples of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture

   * are created in the paxweb temp directory, and not in the svn tree
   */
  @Before
  public static void createApplications() throws Exception
  {
    ZipFixture bundle = ArchiveFixture.newJar().manifest()
                            .attribute(BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_VALUE)
                            .attribute(BUNDLE_MANIFESTVERSION, "2")
                            .attribute(IMPORT_PACKAGE, "p.q.r, x.y.z, javax.naming, " + BUNDLE_IN_FRAMEWORK)
                            .attribute(BUNDLE_VERSION, "1.0.0").end();

   
    FileOutputStream fout = new FileOutputStream(CORE_BUNDLE_BY_VALUE + ".jar");
    bundle.writeOut(fout);
    fout.close();

    bundle = ArchiveFixture.newJar().manifest()
                            .attribute(BUNDLE_SYMBOLICNAME, TRANSITIVE_BUNDLE_BY_VALUE)
                            .attribute(BUNDLE_MANIFESTVERSION, "2")
                            .attribute(EXPORT_PACKAGE, "p.q.r")
                            .attribute(BUNDLE_VERSION, "1.0.0").end();

    fout = new FileOutputStream(TRANSITIVE_BUNDLE_BY_VALUE + ".jar");
    bundle.writeOut(fout);
    fout.close();

    bundle = ArchiveFixture.newJar().manifest()
                            .attribute(BUNDLE_SYMBOLICNAME, TRANSITIVE_BUNDLE_BY_REFERENCE)
                            .attribute(BUNDLE_MANIFESTVERSION, "2")
                            .attribute(EXPORT_PACKAGE, "x.y.z")
                            .attribute(BUNDLE_VERSION, "1.0.0").end();
   
    fout = new FileOutputStream(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar");
    bundle.writeOut(fout);
    fout.close();

    bundle = ArchiveFixture.newJar().manifest()
                            .attribute(BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_REFERENCE)
                            .attribute(BUNDLE_MANIFESTVERSION, "2")
                            .attribute(EXPORT_PACKAGE, "d.e.f")
                            .attribute(BUNDLE_VERSION, "1.0.0").end();
   
    fout = new FileOutputStream(CORE_BUNDLE_BY_REFERENCE + ".jar");
    bundle.writeOut(fout);
    fout.close();

    bundle = ArchiveFixture.newJar().manifest()
                            .attribute(BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_REFERENCE)
                            .attribute(BUNDLE_MANIFESTVERSION, "2")
                            .attribute(EXPORT_PACKAGE, "d.e.f").end();

    fout = new FileOutputStream(CORE_BUNDLE_BY_REFERENCE + "_0.0.0.jar");
    bundle.writeOut(fout);
    fout.close();
   
    ZipFixture testEba = ArchiveFixture.newZip()
     .binary("META-INF/APPLICATION.MF",
        OBRResolverTest.class.getClassLoader().getResourceAsStream("obr/APPLICATION.MF"))
        .end()
      .binary(CORE_BUNDLE_BY_VALUE + ".jar", new FileInputStream(CORE_BUNDLE_BY_VALUE + ".jar")).end()
      .binary(TRANSITIVE_BUNDLE_BY_VALUE + ".jar", new FileInputStream(TRANSITIVE_BUNDLE_BY_VALUE + ".jar")).end();

    fout = new FileOutputStream("blog.eba");
    testEba.writeOut(fout);
    fout.close();
  }
View Full Code Here

Examples of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture

      
    if (createdApplications) {
      return;
    }
   
    ZipFixture testEba = ArchiveFixture.newZip()
      .binary("META-INF/APPLICATION.MF",
          UpdateAppTest.class.getClassLoader().getResourceAsStream("isolated/APPLICATION.MF"))
      .jar("sample.jar")
        .manifest().symbolicName("org.apache.aries.isolated.sample")
          .attribute("Bundle-Version", "1.0.0")
          .end()
        .binary("org/apache/aries/isolated/sample/HelloWorld.class",
            UpdateAppTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class"))
        .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
            UpdateAppTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class"))
        .binary("OSGI-INF/blueprint/aries.xml",
            UpdateAppTest.class.getClassLoader().getResourceAsStream("isolated/sample-blueprint.xml"))
        .end();
     
    FileOutputStream fout = new FileOutputStream("test.eba");
    testEba.writeOut(fout);
    fout.close();
   
    ZipFixture sample2 = ArchiveFixture.newJar()
      .manifest().symbolicName("org.apache.aries.isolated.sample")
        .attribute("Bundle-Version", "2.0.0")
      .end()
      .binary("org/apache/aries/isolated/sample/HelloWorld.class",
          IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class"))
      .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
          IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class"))
      .binary("OSGI-INF/blueprint/aries.xml",
          IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample2-blueprint.xml"))
      .end();
   
    fout = new FileOutputStream("sample_2.0.0.jar");
    sample2.writeOut(fout);
    fout.close();
   
    createdApplications = true;
  }
View Full Code Here

Examples of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture

  @Before
  public static void createApplications() throws Exception {
      if (createdApplications) {
        return;
      }
      ZipFixture testBundle = ArchiveFixture.newZip()
          .manifest().symbolicName("org.apache.aries.sample.bundle")
            .attribute("Bundle-Version", "1.0.0")
            .attribute("Import-Package", "org.apache.aries.sample")
            .attribute("Export-Package", "org.apache.aries.sample.impl")
            .end()
          .binary("org/apache/aries/sample/impl/HelloWorldImpl.class",
              OBRAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/sample/impl/HelloWorldImpl.class"))
          .end();

      FileOutputStream fout = new FileOutputStream("bundle.jar");
      testBundle.writeOut(fout);
      fout.close();

      ZipFixture testEba = ArchiveFixture.newZip()
        .jar("sample.jar")
          .manifest().symbolicName("org.apache.aries.sample")
            .attribute("Bundle-Version", "1.0.0")
            .attribute("Import-Package", "org.apache.aries.sample.impl,org.apache.aries.sample")
            .end()
          .binary("OSGI-INF/blueprint/sample-blueprint.xml",
              OBRAppManagerTest.class.getClassLoader().getResourceAsStream("basic/sample-blueprint.xml"))
          .end()
           .binary("META-INF/APPLICATION.MF",
          OBRAppManagerTest.class.getClassLoader().getResourceAsStream("basic/APPLICATION.MF"))
          .end();
      fout = new FileOutputStream("test.eba");
      testEba.writeOut(fout);
      fout.close();
     
      StringBuilder repositoryXML = new StringBuilder();
     
      BufferedReader reader = new BufferedReader(new InputStreamReader(OBRAppManagerTest.class.getResourceAsStream("/obr/repository.xml")));
View Full Code Here

Examples of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture

  public static void createApplications() throws Exception {
      
    if (createdApplications) {
      return;
    }
    ZipFixture testEba = ArchiveFixture.newZip()
      .jar("sample.jar")
        .manifest().symbolicName("org.apache.aries.isolated.sample")
          .attribute("Bundle-Version", "1.0.0")
          .attribute("Import-Package", "org.osgi.service.blueprint, org.apache.aries.isolated.shared")
          // needed for testFrameworkResolvedBeforeInnerBundlesStart()
          .attribute("Bundle-ActivationPolicy", "lazy")
          .end()
        .binary("org/apache/aries/isolated/sample/HelloWorld.class",
            IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class"))
        .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
            IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class"))
        .binary("org/apache/aries/isolated/sample/SharedImpl.class",
            IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/SharedImpl.class"))
        .binary("OSGI-INF/blueprint/sample-blueprint.xml",
            IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample-blueprint.xml"))
        .end()
      .jar("shared.jar")
        .manifest().symbolicName("org.apache.aries.isolated.shared")
          .attribute("Bundle-Version", "1.0.0")
          .attribute("Export-Package", "org.apache.aries.isolated.shared")
        .end()
        .binary("org/apache/aries/isolated/shared/Shared.class",
            IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/shared/Shared.class"))
        .end();
     
    FileOutputStream fout = new FileOutputStream("test.eba");
    testEba.writeOut(fout);
    fout.close();
   
    ZipFixture testEba2 = testEba.binary("META-INF/APPLICATION.MF",
        IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/APPLICATION.MF"))
        .end();
    fout = new FileOutputStream("test2.eba");
    testEba2.writeOut(fout);
    fout.close();
   
    ZipFixture sampleJar2 = ArchiveFixture.newJar()
      .manifest().symbolicName("org.apache.aries.isolated.sample")
        .attribute("Bundle-Version", "2.0.0")
      .end()
      .binary("org/apache/aries/isolated/sample/HelloWorld.class",
          IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class"))
      .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
          IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class"))
      .binary("OSGI-INF/blueprint/aries.xml",
          IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample2-blueprint.xml"))
      .end();
 
    fout = new FileOutputStream("sample_2.0.0.jar");
    sampleJar2.writeOut(fout);
    fout.close();
   
    ZipFixture ebaWithFragment = ArchiveFixture.newZip()
      .jar("sample.jar")
        .manifest().symbolicName("org.apache.aries.isolated.sample")
          .attribute("Bundle-Version", "1.0.0")
          .end()
      .end()
      .jar("fragment.jar")
        .manifest().symbolicName("org.apache.aries.isolated.fragment")
          .attribute("Bundle-Version", "1.0.0")
          .attribute("Fragment-Host", "org.apache.aries.isolated.sample")
        .end()
        .binary("org/apache/aries/isolated/sample/HelloWorld.class",
            IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class"))
        .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
            IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class"))
        .binary("OSGI-INF/blueprint/sample-blueprint.xml",
            IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample-blueprint.xml"))
        .end();
   
    fout = new FileOutputStream("withFragment.eba");
    ebaWithFragment.writeOut(fout);
    fout.close();
   
    createdApplications = true;
  }
View Full Code Here

Examples of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture

        Assert.assertNotNull("Could not find Maven URL handler", (new RichBundleContext(context())).getService(URLStreamHandlerService.class, "url.handler.protocol=mvn", 300000));
        MavenArtifactProvisionOption configAdminProvisionOption = mavenBundleInTest(getClass().getClassLoader(), "org.apache.felix", "org.apache.felix.configadmin");
        Assert.assertNotNull("Unable to lookup config admin maven bundle", configAdminProvisionOption);
        URL configAdminUrl = new URL(configAdminProvisionOption.getURL());
       
        ZipFixture helloWorldBluePrintEba = ArchiveFixture
                .newZip()
                    .binary("META-INF/APPLICATION.MF",
                            IsolatedCfgAdminRuntimeTest.class.getClassLoader()
                                    .getResourceAsStream("isolated/config/APPLICATION-BP.MF"))
                    .binary("org.apache.felix.configadmin.jar", configAdminUrl.openStream())
                    .jar("helloworld-bundle.jar")
                        .manifest()
                            .symbolicName("org.apache.aries.isolated.helloworldbp")
                            .attribute("Bundle-Version", "1.0.0")
                            .attribute("Import-Package", "org.osgi.service.cm")
                        .end()
                        .binary("org/apache/aries/isolated/sample/HelloWorld.class",
                                IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
                                        "org/apache/aries/isolated/sample/HelloWorld.class"))
                        .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
                                IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
                                        "org/apache/aries/isolated/sample/HelloWorldImpl.class"))
                        .binary("OSGI-INF/blueprint/blueprint.xml",
                                IsolatedCfgAdminRuntimeTest.class.getClassLoader()
                                        .getResourceAsStream("isolated/config/blueprint.xml")).end();

        ZipFixture helloWorldManualEba = ArchiveFixture
                .newZip()
                    .binary("META-INF/APPLICATION.MF",
                            IsolatedCfgAdminRuntimeTest.class.getClassLoader()
                                    .getResourceAsStream("isolated/config/APPLICATION-MN.MF"))
                    .binary("org.apache.felix.configadmin.jar", configAdminUrl.openStream())
                    .jar("helloworld-bundle.jar")
                    .manifest()
                        .symbolicName("org.apache.aries.isolated.helloworldmn")
                        .attribute("Bundle-Version", "1.0.0")
                        .attribute("Bundle-Activator", "org.apache.aries.isolated.config.HelloWorldManagedServiceImpl")
                        .attribute("Import-Package", "org.osgi.framework,org.osgi.service.cm")
                    .end()
                    .binary("org/apache/aries/isolated/sample/HelloWorld.class",
                            IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
                                    "org/apache/aries/isolated/sample/HelloWorld.class"))
                    .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
                            IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
                                    "org/apache/aries/isolated/sample/HelloWorldImpl.class"))
                    .binary("org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.class",
                            IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
                                    "org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.class")).end();

        FileOutputStream fout = new FileOutputStream(APP_HWBP);
        helloWorldBluePrintEba.writeOut(fout);
        fout.close();

        fout = new FileOutputStream(APP_HWMN);
        helloWorldManualEba.writeOut(fout);
        fout.close();
    }
View Full Code Here

Examples of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture

   * are created in the paxweb temp directory, and not in the svn tree
   */
  @Before
  public static void createApplications() throws Exception
  {
    ZipFixture bundle = ArchiveFixture.newJar().manifest()
                            .attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_VALUE)
                            .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
                            .attribute(Constants.IMPORT_PACKAGE, "a.b.c, p.q.r, x.y.z, javax.naming")
                            .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();

   
    FileOutputStream fout = new FileOutputStream(CORE_BUNDLE_BY_VALUE + ".jar");
    bundle.writeOut(fout);
    fout.close();

    bundle = ArchiveFixture.newJar().manifest()
                            .attribute(Constants.BUNDLE_SYMBOLICNAME, TRANSITIVE_BUNDLE_BY_VALUE)
                            .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
                            .attribute(Constants.EXPORT_PACKAGE, "p.q.r")
                            .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();

    fout = new FileOutputStream(TRANSITIVE_BUNDLE_BY_VALUE + ".jar");
    bundle.writeOut(fout);
    fout.close();

    bundle = ArchiveFixture.newJar().manifest()
                            .attribute(Constants.BUNDLE_SYMBOLICNAME, TRANSITIVE_BUNDLE_BY_REFERENCE)
                            .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
                            .attribute(Constants.EXPORT_PACKAGE, "x.y.z")
                            .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
   
    fout = new FileOutputStream(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar");
    bundle.writeOut(fout);
    fout.close();

    bundle = ArchiveFixture.newJar().manifest()
                            .attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_REFERENCE)
                            .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
                            .attribute(Constants.EXPORT_PACKAGE, "d.e.f")
                            .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
   
    fout = new FileOutputStream(CORE_BUNDLE_BY_REFERENCE + ".jar");
    bundle.writeOut(fout);
    fout.close();

    bundle = ArchiveFixture.newJar().manifest()
    .attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_REFERENCE)
    .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
    .attribute(Constants.EXPORT_PACKAGE, "d.e.f").end();

    fout = new FileOutputStream(CORE_BUNDLE_BY_REFERENCE + "_0.0.0.jar");
    bundle.writeOut(fout);
    fout.close();

   
   
    // jar up a use bundle
    bundle = ArchiveFixture.newJar().manifest()
    .attribute(Constants.BUNDLE_SYMBOLICNAME, USE_BUNDLE_BY_REFERENCE)
    .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
    .attribute(Constants.EXPORT_PACKAGE, "a.b.c")
    .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();

    fout = new FileOutputStream(USE_BUNDLE_BY_REFERENCE + ".jar");
    bundle.writeOut(fout);
    fout.close();
    // Create the EBA application
    ZipFixture testEba = ArchiveFixture.newZip()
     .binary("META-INF/APPLICATION.MF",
        OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("obr/APPLICATION-UseBundle.MF"))
        .end()
      .binary(CORE_BUNDLE_BY_VALUE + ".jar", new FileInputStream(CORE_BUNDLE_BY_VALUE + ".jar")).end()
      .binary(TRANSITIVE_BUNDLE_BY_VALUE + ".jar", new FileInputStream(TRANSITIVE_BUNDLE_BY_VALUE + ".jar")).end();

    fout = new FileOutputStream("demo.eba");
    testEba.writeOut(fout);
    fout.close();
   

    //create the bundle
    bundle = ArchiveFixture.newJar()
    .binary("META-INF/MANIFEST.MF", OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("obr/aries.bundle1/META-INF/MANIFEST.MF")).end()
    .binary("OSGI-INF/blueprint/blueprint.xml", OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("obr/hello-world-client.xml")).end()
    .binary("OSGI-INF/blueprint/anotherBlueprint.xml", OBRResolverAdvancedTest.class.getClassLoader().getResourceAsStream("obr/aries.bundle1/OSGI-INF/blueprint/sample-blueprint.xml")).end();
    fout = new FileOutputStream(REPO_BUNDLE + ".jar");
    bundle.writeOut(fout);
    fout.close();
   

    ///////////////////////////////////////////////
    //create an eba with a helloworld client, which get all 'HelloWorld' services
    //create a helloworld client
    bundle = ArchiveFixture.newJar().manifest()
    .attribute(Constants.BUNDLE_SYMBOLICNAME, HELLO_WORLD_CLIENT_BUNDLE)
    .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
    .attribute("Import-Package", "org.apache.aries.sample")
    .attribute(Constants.BUNDLE_VERSION, "1.0.0").end()
    .binary("org/apache/aries/application/helloworld/client/HelloWorldClientImpl.class",
        BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/application/helloworld/client/HelloWorldClientImpl.class"))
    .binary("OSGI-INF/blueprint/helloClient.xml",
        BasicAppManagerTest.class.getClassLoader().getResourceAsStream("obr/hello-world-client.xml"))
    .end();

   
    fout = new FileOutputStream(HELLO_WORLD_CLIENT_BUNDLE + ".jar");
    bundle.writeOut(fout);
    fout.close();
   
 
    //create two helloworld services
    // create the 1st helloworld service
    bundle = ArchiveFixture.newJar().manifest()
    .attribute(Constants.BUNDLE_SYMBOLICNAME, HELLO_WORLD_SERVICE_BUNDLE1)
    .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
    .attribute("Import-Package", "org.apache.aries.sample")
    .attribute(Constants.BUNDLE_VERSION, "1.0.0").end()
    .binary("org/apache/aries/sample/impl/HelloWorldImpl.class",
        BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/sample/impl/HelloWorldImpl.class"))
    .binary("OSGI-INF/blueprint/sample-blueprint.xml",
        BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/sample-blueprint.xml"))
    .end();

    //create the 2nd helloworld service
    fout = new FileOutputStream(HELLO_WORLD_SERVICE_BUNDLE1 + ".jar");
    bundle.writeOut(fout);
    fout.close();
   
    bundle = ArchiveFixture.newJar().manifest()
    .attribute(Constants.BUNDLE_SYMBOLICNAME, HELLO_WORLD_SERVICE_BUNDLE2)
    .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
    .attribute("Import-Package", "org.apache.aries.sample")
    .attribute(Constants.BUNDLE_VERSION, "1.0.0").end()
    .binary("org/apache/aries/sample/impl/HelloWorldImpl.class",
        BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/sample/impl/HelloWorldImpl.class"))
    .binary("OSGI-INF/blueprint/sample-blueprint.xml",
        BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/sample-blueprint.xml"))
    .end();

    fout = new FileOutputStream(HELLO_WORLD_SERVICE_BUNDLE2 + ".jar");
    bundle.writeOut(fout);
    fout.close();
   
    //Create a helloworld eba with the client included
    ZipFixture multiServiceHelloEba = ArchiveFixture.newZip()
     .binary(HELLO_WORLD_CLIENT_BUNDLE + ".jar", new FileInputStream(HELLO_WORLD_CLIENT_BUNDLE + ".jar")).end();
    
   fout = new FileOutputStream("hello.eba");
   multiServiceHelloEba.writeOut(fout);
   fout.close();

  }
View Full Code Here

Examples of org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture

  @Before
  public static void createApplications() throws Exception {
    if (createdApplications) {
      return;
    }
    ZipFixture testEba = ArchiveFixture.newZip()
      .jar("sample.jar")
        .manifest().symbolicName("org.apache.aries.sample")
          .attribute("Bundle-Version", "1.0.0")
          .attribute("Import-Package", "org.apache.aries.sample")
          .end()
        .binary("org/apache/aries/sample/impl/HelloWorldImpl.class",
            BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/sample/impl/HelloWorldImpl.class"))
        .binary("OSGI-INF/blueprint/sample-blueprint.xml",
            BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/sample-blueprint.xml"))
        .end();
     
    FileOutputStream fout = new FileOutputStream("test.eba");
    testEba.writeOut(fout);
    fout.close();
   
    ZipFixture testEba2 = testEba.binary("META-INF/APPLICATION.MF",
        BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/APPLICATION.MF"))
        .end();
    fout = new FileOutputStream("test2.eba");
    testEba2.writeOut(fout);
    fout.close();
    createdApplications = true;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.