Package org.jboss.osgi.testing

Examples of org.jboss.osgi.testing.OSGiManifestBuilder


      // Check if the application archive already contains the test class
      String path = javaClass.getName().replace('.', '/') + ".class";
      if (appArchive.contains(path) == false)
         appArchive.addClass(javaClass);

      final OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
      Manifest manifest = getBundleManifest(appArchive);
      if (manifest != null)
      {
         Attributes attributes = manifest.getMainAttributes();
         for (Entry<Object, Object> entry : attributes.entrySet())
         {
            String key = entry.getKey().toString();
            String value = (String) entry.getValue();
            if (key.equals("Manifest-Version"))
               continue;

            if (key.equals(Constants.IMPORT_PACKAGE))
            {
               String[] imports = value.split(",");
               builder.addImportPackages(imports);
               continue;
            }

            if (key.equals(Constants.EXPORT_PACKAGE))
            {
               String[] exports = value.split(",");
               builder.addExportPackages(exports);
               continue;
            }

            builder.addManifestHeader(key, value);
         }
      }
      else
      {
         builder.addBundleManifestVersion(2);
         builder.addBundleSymbolicName(appArchive.getName());
      }

      // Export the test class package
      builder.addExportPackages(javaClass);

      // Add the imports required by the test class
      addImportsForClass(builder, javaClass);

      // Add framework imports
      // [TODO] use bnd or another tool to do this more intelligently
      builder.addImportPackages("org.jboss.arquillian.test.api", "org.jboss.arquillian.junit");
      builder.addImportPackages("org.jboss.shrinkwrap.api", "org.jboss.shrinkwrap.api.asset",
            "org.jboss.shrinkwrap.api.spec");
      builder.addImportPackages("org.junit", "org.junit.runner", "javax.inject", "org.osgi.framework");

      // SHRINKWRAP-187, to eager on not allowing overrides, delete it first
      appArchive.delete(MANIFEST_PATH);
      // Add the manifest to the archive
      appArchive.setManifest(new Asset()
      {
         public InputStream openStream()
         {
            return builder.openStream();
         }
      });
   }
View Full Code Here


        // Check if the application archive already contains the test class
        String path = javaClass.getName().replace('.', '/') + ".class";
        if (appArchive.contains(path) == false)
            appArchive.addClass(javaClass);

        final OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
        Manifest manifest = getBundleManifest(appArchive);
        if (manifest != null)
        {
            Attributes attributes = manifest.getMainAttributes();
            for (Entry<Object, Object> entry : attributes.entrySet())
            {
                String key = entry.getKey().toString();
                String value = (String)entry.getValue();
                if (key.equals("Manifest-Version"))
                    continue;

                if (key.equals(Constants.IMPORT_PACKAGE))
                {
                    String[] imports = value.split(",");
                    builder.addImportPackages(imports);
                    continue;
                }

                if (key.equals(Constants.EXPORT_PACKAGE))
                {
                    String[] exports = value.split(",");
                    builder.addExportPackages(exports);
                    continue;
                }

                builder.addManifestHeader(key, value);
            }
        }
        else
        {
            builder.addBundleManifestVersion(2);
            builder.addBundleSymbolicName(appArchive.getName());
        }

        // Export the test class package
        builder.addExportPackages(javaClass);

        // Add the imports required by the test class
        addImportsForClass(builder, javaClass);

        // Add framework imports
        // [TODO] use bnd or another tool to do this more intelligently
        builder.addImportPackages("org.jboss.arquillian.api", "org.jboss.arquillian.junit");
        builder.addImportPackages("org.jboss.shrinkwrap.api", "org.jboss.shrinkwrap.api.asset", "org.jboss.shrinkwrap.api.spec");
        builder.addImportPackages("org.junit", "org.junit.runner", "javax.inject", "org.osgi.framework");
        builder.addImportPackages("org.jboss.osgi.spi.util", "org.jboss.osgi.testing");

        // Add the manifest to the archive
        appArchive.setManifest(new Asset()
        {
            public InputStream openStream()
            {
                return builder.openStream();
            }
        });
    }
View Full Code Here

        // Check if the application archive already contains the test class
        String path = javaClass.getName().replace('.', '/') + ".class";
        if (appArchive.contains(path) == false)
            appArchive.addClass(javaClass);

        final OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
        Manifest manifest = getBundleManifest(appArchive);
        if (manifest != null)
        {
            Attributes attributes = manifest.getMainAttributes();
            for (Entry<Object, Object> entry : attributes.entrySet())
            {
                String key = entry.getKey().toString();
                String value = (String)entry.getValue();
                if (key.equals("Manifest-Version"))
                    continue;

                if (key.equals(Constants.IMPORT_PACKAGE))
                {
                    String[] imports = value.split(",");
                    builder.addImportPackages(imports);
                    continue;
                }

                if (key.equals(Constants.EXPORT_PACKAGE))
                {
                    String[] exports = value.split(",");
                    builder.addExportPackages(exports);
                    continue;
                }

                builder.addManifestHeader(key, value);
            }
        }
        else
        {
            builder.addBundleManifestVersion(2);
            builder.addBundleSymbolicName(appArchive.getName());
        }

        // Export the test class package
        builder.addExportPackages(javaClass);

        // Add the imports required by the test class
        addImportsForClass(builder, javaClass);

        // Add framework imports
        // [TODO] use bnd or another tool to do this more intelligently
        builder.addImportPackages("org.jboss.arquillian.api", "org.jboss.arquillian.junit", "org.jboss.arquillian.osgi");
        builder.addImportPackages("org.jboss.shrinkwrap.api", "org.jboss.shrinkwrap.api.asset", "org.jboss.shrinkwrap.api.spec");
        builder.addImportPackages("org.junit", "org.junit.runner", "javax.inject", "org.osgi.framework");
        builder.addImportPackages("org.jboss.osgi.spi.util", "org.jboss.osgi.testing");

        // Add the manifest to the archive
        appArchive.setManifest(new Asset()
        {
            public InputStream openStream()
            {
                return builder.openStream();
            }
        });
    }
View Full Code Here

        // Check if the application archive already contains the test class
        String path = javaClass.getName().replace('.', '/') + ".class";
        if (appArchive.contains(path) == false)
            ((ClassContainer<?>)appArchive).addClass(javaClass);

        final OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
        Manifest manifest = getBundleManifest(appArchive);
        if (manifest != null)
        {
            Attributes attributes = manifest.getMainAttributes();
            for (Entry<Object, Object> entry : attributes.entrySet())
            {
                String key = entry.getKey().toString();
                String value = (String)entry.getValue();
                if (key.equals("Manifest-Version"))
                    continue;

                if (key.equals(Constants.IMPORT_PACKAGE))
                {
                    String[] imports = value.split(",");
                    builder.addImportPackages(imports);
                    continue;
                }

                if (key.equals(Constants.EXPORT_PACKAGE))
                {
                    String[] exports = value.split(",");
                    builder.addExportPackages(exports);
                    continue;
                }

                builder.addManifestHeader(key, value);
            }
        }
        else
        {
            builder.addBundleManifestVersion(2);
            builder.addBundleSymbolicName(appArchive.getName());
        }

        // Export the test class package
        builder.addExportPackages(javaClass);

        // Add the imports required by the test class
        addImportsForClass(builder, javaClass);

        // Add framework imports
        // [TODO] use bnd or another tool to do this more intelligently
        builder.addImportPackages("org.jboss.arquillian.api", "org.jboss.arquillian.junit");
        builder.addImportPackages("org.jboss.shrinkwrap.api", "org.jboss.shrinkwrap.api.asset", "org.jboss.shrinkwrap.api.spec");
        builder.addImportPackages("org.junit", "org.junit.runner", "javax.inject", "org.osgi.framework");
        builder.addImportPackages("org.jboss.osgi.spi.util", "org.jboss.osgi.testing");

        // Add the manifest to the archive
        appArchive.add(new Asset()
        {
            public InputStream openStream()
            {
                return builder.openStream();
            }
        }, JarFile.MANIFEST_NAME);
    }
View Full Code Here

TOP

Related Classes of org.jboss.osgi.testing.OSGiManifestBuilder

Copyright © 2018 www.massapicom. 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.