public DeploymentImpl( final Collection<DynamicArchiveContributor> dynamicArchiveContributors, final ServiceRegistry serviceRegistry, final Collection<Metadata<Extension>> extensions, final BeansXmlModifier modifier ) { archives = dynamicArchiveContributors.stream() .map(it -> it.contribute(serviceRegistry, this::archiveSupplier)) .flatMap(Collection::stream) .collect(toMap( it -> it, it -> new WrappedBeanDeploymentArchive(it, modifier, this::mapper) )); this.serviceRegistry = serviceRegistry; this.extensions = extensions; }
public DependencyInjectionRealm init( final ServiceRegistry serviceRegistry, final Environments environment, final Collection<Metadata<Extension>> extensions, final BeansXmlModifier beansXmlModifier, final Collection<DynamicArchiveContributor> archiveContributors ) { LOG.trace("Starting dependency injection realm {}", contextId); deployment = new DeploymentImpl( archiveContributors, serviceRegistry, extensions, beansXmlModifier ); bootstrap = new WeldBootstrap() .startContainer(contextId, environment, deployment) .startInitialization() .deployBeans() .validateBeans() .endInitialization(); return this; }
@Deployment(name = "test") public static Archive<?> createDeployment() { JavaArchive archive = ShrinkWrap.create(JavaArchive.class) .addClasses( Greeter.class, Resources.class, CdiConfig.class ) .addAsServiceProvider(Extension.class, CdiConfig.class) .addAsManifestResource("META-INF/test-persistence.xml", "persistence.xml") .addAsManifestResource("META-INF/test-beans.xml", "beans.xml"); // System.out.println(archive.toString(true)); return archive; }
/** * Creates the JAR file containing the test infrastructure. * * @return The jar file. */ private static JavaArchive createTestJar() { JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, TEST_JAR_NAME); // add resources if (TEST_RESOURCES_DIRECTORY.exists()) { ResourceUtils.addResources(testJar, TEST_RESOURCES_DIRECTORY, new ResourceFilterForSuffixExclusion( DEPLOYMENT_STRUCTURE_FILE)); } // add common test class to the test.jar testJar.addClass(AbstractArquillianTest.class); testJar.addClass(AbstractServerTest.class); // add Mockito testJar.addPackages(true, Mockito.class.getPackage()); testJar.addPackages(true, ObjenesisStd.class.getPackage()); testJar.addPackage(Mock.class.getPackage()); // add CDI extension descriptors addServices(testJar, Extension.class); return testJar; }
/** * Merges the service loader descriptors for the given class and adds them * to the jar archive. * * @param jar * The jar archive. * @param serviceClass * The service class. */ private static void addServices(JavaArchive jar, Class<?> serviceClass) { try { File file = File.createTempFile(Extension.class.getName(), ""); file.deleteOnExit(); Enumeration<URL> resources = AbstractServerTest.class .getClassLoader().getResources( "META-INF/services/" + serviceClass.getName()); List<String> extensions = new ArrayList<String>(); while (resources.hasMoreElements()) { URL resource = resources.nextElement(); List<String> lines = IOUtils.readLines(resource.openStream()); extensions.addAll(lines); } try (FileWriter writer = new FileWriter(file)) { IOUtils.writeLines(extensions, null, writer); writer.close(); jar.addAsManifestResource(file, "services/" + serviceClass.getName()); } } catch (IOException e) { throw new IllegalStateException("Cannot read files", e); } }
@Deployment(order = 1, name = "test-candidate") public static WebArchive createTestArchive() { WebArchive wa = ShrinkWrap.create(WebArchive.class, "sample.war") .addPackage(SampleRepository.class.getPackage()) .addPackage(JPAQueryExecutor.class.getPackage()) .addPackage(Create.class.getPackage()) .addPackage(DefaultJPAConnection.class.getPackage()); wa.addAsWebInfResource("META-INF/beans.xml"); wa.addAsWebInfResource("ejb-jar.xml"); wa.addAsResource("META-INF/persistence.xml"); wa.addAsServiceProvider(Extension.class, RepositoryExtension.class); for (File libFile : new File("target/libs").listFiles()) { wa.addAsLibrary(libFile, libFile.getName()); } System.out.println( "------------------------------- sample.war --------------------------------"); System.out.println(wa.toString(true)); System.out.println("---------------------------------------------------------------------------"); return wa; }
@Deployment(order = 2, name = "test-candidate") public static WebArchive createTestArchive() { WebArchive wa = ShrinkWrap.create(WebArchive.class, "sample.war"); wa.addClasses(Actor.class, Movie.class, SampleRepository.class, Neo4jUplinkProducer.class, Neo4jQueryExecutor.class, SysoutLoggingBridge.class); wa.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); wa.addAsWebInfResource("ejb-jar.xml"); wa.addAsServiceProvider(Extension.class, RepositoryExtension.class); for (File libFile : new File("target/libs").listFiles()) { wa.addAsLibrary(libFile, libFile.getName()); } System.out.println( "------------------------------- sample.war --------------------------------"); System.out.println(wa.toString(true)); System.out.println( "---------------------------------------------------------------------------"); return wa; }
/** * @return the Extension from the same type but registered in a hierarchic 'parent' BeanManager */ public static synchronized <T extends Extension> T getParentExtension(Extension extension) { if (usingParentExtension()) { ClassLoader parentClassLoader = ClassUtils.getClassLoader(null).getParent(); Iterator<ExtensionStorageInfo> extIt = extensionStorage.iterator(); while (extIt.hasNext()) { ExtensionStorageInfo extensionInfo = extIt.next(); if (!extensionInfo.isAbandoned() && // weak reference case extension.getClass().equals(extensionInfo.getExtension().getClass()) && extensionInfo.getClassLoader().equals(parentClassLoader)) { return (T) extensionInfo.getExtension(); } } } return null; }
/** * X TODO creating a WebArchive is only a workaround because JavaArchive * cannot contain other archives. */ @Deployment public static WebArchive deploy() { JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "messageTest.jar") .addPackage(MessageTest.class.getPackage()) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); return ShrinkWrap .create(WebArchive.class, "messageTest.war") .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive()) .addAsLibraries(testJar) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(Extension.class, MessageBundleExtension.class); }
/** * X TODO creating a WebArchive is only a workaround because JavaArchive * cannot contain other archives. */ @Deployment public static WebArchive deploy() { JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "simpleMessageTest.jar") .addPackage(SimpleMessageTest.class.getPackage()) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); return ShrinkWrap .create(WebArchive.class, "simpleMessageTest.war") .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive()) .addAsLibraries(testJar) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(Extension.class, MessageBundleExtension.class); }
/** * X TODO creating a WebArchive is only a workaround because JavaArchive * cannot contain other archives. */ @Deployment public static WebArchive deploy() { final JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "messageContextTest.jar") .addPackage(MessageContextTest.class.getPackage()) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); return ShrinkWrap .create(WebArchive.class, "messageContextTest.war") .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive()) .addAsLibraries(testJar) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(Extension.class, MessageBundleExtension.class); }
/** * X TODO creating a WebArchive is only a workaround because JavaArchive * cannot contain other archives. */ @Deployment public static WebArchive deploy() { JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "localeMessageTest.jar") .addPackage(ConfigurableLocaleMessageTest.class.getPackage()) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); return ShrinkWrap .create(WebArchive.class, "localeMessageTest.war") .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive()) .addAsLibraries(testJar) .addAsWebInfResource(new StringAsset(BEANS_XML_CONTENT), "beans.xml") .addAsServiceProvider(Extension.class, MessageBundleExtension.class); }
/** * X TODO creating a WebArchive is only a workaround because JavaArchive * cannot contain other archives. */ @Deployment public static WebArchive deploy() { JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "minimalMessageTest.jar") .addPackages(false, Filters.exclude(MessageContextTest.class), MinimalMessagesTest.class.getPackage()) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); return ShrinkWrap .create(WebArchive.class, "minimalMessageTest.war") .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive()) .addAsLibraries(testJar) .addAsResource("customMinimalMessage_en.properties") .addAsResource("org/apache/deltaspike/test/core/api/message/MinimalMessages_en.properties") .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(Extension.class, MessageBundleExtension.class); }
/** * X TODO creating a WebArchive is only a workaround because JavaArchive * cannot contain other archives. */ @Deployment @ShouldThrowException(Exception.class) public static WebArchive deploy() { JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "invalidMessageBundleTest.jar") .addPackage(BrokenMessageBundleClass.class.getPackage()) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); return ShrinkWrap .create(WebArchive.class, "invalidMessageBundleTest.war") .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive()) .addAsLibraries(testJar) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(Extension.class, MessageBundleExtension.class); }
/** * X TODO creating a WebArchive is only a workaround because JavaArchive * cannot contain other archives. */ @Deployment public static WebArchive deploy() { Asset beansXml = new StringAsset( "<beans><alternatives>" + "<class>" + MessageFormatMessageInterpolator.class.getName() + "</class>" + "</alternatives></beans>" ); JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "messageFormattedMessageTest.jar") .addPackage(MessageFormattedMessageTest.class.getPackage()) .addAsManifestResource(beansXml, "beans.xml"); return ShrinkWrap .create(WebArchive.class, "messageFormattedMessageTest.war") .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive()) .addAsLibraries(testJar) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(Extension.class, MessageBundleExtension.class); }
/** * X TODO creating a WebArchive is only a workaround because JavaArchive cannot contain other archives. */ @Deployment public static WebArchive deploy() { String simpleName = ExcludeWarFileTest.class.getSimpleName(); String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1); System.setProperty("org.apache.deltaspike.ProjectStage", "Production"); ProjectStageProducer.setProjectStage(null); URL fileUrl = ExcludeWarFileTest.class.getClassLoader() .getResource("META-INF/apache-deltaspike.properties"); JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "excludeTest.jar") .addPackage(ExcludeWarFileTest.class.getPackage()) .addPackage(TestClassDeactivator.class.getPackage()) .addAsManifestResource(FileUtils.getFileForURL(fileUrl.toString())) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); return ShrinkWrap.create(WebArchive.class, archiveName + ".war") .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive()) .addAsLibraries(testJar) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(Extension.class, ExcludeExtension.class); }
/** * X TODO creating a WebArchive is only a workaround because JavaArchive * cannot contain other archives. */ @Deployment public static WebArchive deploy() { JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "abstractContextTest.jar") .addClass(AbstractContextTest.class) .addClass(DummyBean.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(Extension.class, DummyScopeExtension.class); return ShrinkWrap .create(WebArchive.class, "abstractContextTest.war") .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive()) .addAsLibraries(testJar) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); }
/** * Create war archive to test. * * @return the war used for testing */ public static Archive<?> createDeployment() { return ShrinkWrap.create(WebArchive.class) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(Extension.class, LauncherExtension.class) .addPackages(true, HttpEndpoints.class.getPackage(), ForgeInitializer.class.getPackage()) .addAsLibraries(Maven.resolver() .loadPomFromFile("pom.xml") .importCompileAndRuntimeDependencies() .resolve().withTransitivity().asFile()); }
private Collection<Metadata<Extension>> instanceExtensions(final Method method) { final Set<CdiExtensionFactory> factories = getInstancesOf(CdiExtensionFactory.class, releaser); return factories.stream() .map(factory -> factory.create(method)) .filter(Objects::nonNull) .map(this::testExtension) .collect(toSet()); }
private Metadata<Extension> testExtension(final Extension instance) { return new Metadata<Extension>() { @Override public Extension getValue() { return instance; } @Override public String getLocation() { return "TestEE.fi-extension:" + instance.getClass().getName(); } }; }
public static void main(String[] args) throws Exception { Swarm swarm = new Swarm(); WARArchive deployment = ShrinkWrap.create(WARArchive.class); deployment. addAllDependencies(). addClass(JaxRsActivator.class). addAsServiceProvider(Extension.class, K8SExtension.class). addPackages(true,"ch.trivadis.workshop"); deployment.staticContent(); swarm.start(); swarm.deploy(deployment); }
private void mongoSetup(DeploymentUnit deploymentUnit, ModuleLoader moduleLoader, String nosqlDriverModuleName) { Class mongoClientClass, mongoDatabaseClass; MethodHandleBuilder methodHandleBuilder = new MethodHandleBuilder(); try { mongoClientClass = moduleLoader.loadModule(ModuleIdentifier.fromString(nosqlDriverModuleName)).getClassLoader().loadClass(NoSQLConstants.MONGOCLIENTCLASS); mongoDatabaseClass = moduleLoader.loadModule(ModuleIdentifier.fromString(nosqlDriverModuleName)).getClassLoader().loadClass(NoSQLConstants.MONGODATABASECLASS); } catch (ClassNotFoundException expected) { // ignore CNFE which just means that module is not a MongoDB module return; } catch (ModuleLoadException e) { throw new RuntimeException("could not load NoSQL driver module " + nosqlDriverModuleName, e); } // only reach this point if module is a MongoDB driver try { final DeploymentUnit parent = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent(); if (WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) { WeldPortableExtensions extensions = WeldPortableExtensions.getPortableExtensions(parent); ModuleIdentifier mongoCDIExtensionModule = ModuleIdentifier.create(NoSQLConstants.MONGOCDIEXTENSIONMODULE); methodHandleBuilder.classLoader(mongoCDIExtensionModule); methodHandleBuilder.className(NoSQLConstants.MONGOCDIEXTENSIONCLASS); MethodHandle extensionCtor = methodHandleBuilder.constructor(MethodType.methodType(void.class, Class.class, Class.class)); Extension extension = (Extension) extensionCtor.invoke(mongoClientClass, mongoDatabaseClass); extensions.registerExtensionInstance(extension, parent); } } catch (Throwable throwable) { throw new RuntimeException("unexpected error constructing " + methodHandleBuilder.getTargetClass().getName(), throwable); } }
private void orientSetup(DeploymentUnit deploymentUnit, ModuleLoader moduleLoader, String nosqlDriverModuleName) { Class oPartitionedDatabasePoolClass; MethodHandleBuilder methodHandleBuilder = new MethodHandleBuilder(); try { oPartitionedDatabasePoolClass = moduleLoader.loadModule(ModuleIdentifier.fromString(nosqlDriverModuleName)).getClassLoader().loadClass(NoSQLConstants.ORIENTDBPARTIONEDDBPOOLCLASS); } catch (ClassNotFoundException expected) { // ignore CNFE which just means that module is not a OrientDB module return; } catch (ModuleLoadException e) { throw new RuntimeException("could not load NoSQL driver module " + nosqlDriverModuleName, e); } // only reach this point if module is a Orient driver try { final DeploymentUnit parent = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent(); if (WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) { WeldPortableExtensions extensions = WeldPortableExtensions.getPortableExtensions(parent); ModuleIdentifier cdiExtensionModule = ModuleIdentifier.create(NoSQLConstants.ORIENTDBCDIEXTENSIONMODULE); methodHandleBuilder.classLoader(cdiExtensionModule); methodHandleBuilder.className(NoSQLConstants.ORIENTCDIEXTENSIONCLASS); MethodHandle extensionCtor = methodHandleBuilder.constructor(MethodType.methodType(void.class, Class.class)); Extension extension = (Extension) extensionCtor.invoke(oPartitionedDatabasePoolClass); extensions.registerExtensionInstance(extension, parent); } } catch (Throwable throwable) { throw new RuntimeException("unexpected error constructing " + methodHandleBuilder.getTargetClass().getName(), throwable); } }
private void neo4jSetup(DeploymentUnit deploymentUnit, ModuleLoader moduleLoader, String nosqlDriverModuleName) { Class driverClass; MethodHandleBuilder methodHandleBuilder = new MethodHandleBuilder(); try { driverClass = moduleLoader.loadModule(ModuleIdentifier.fromString(nosqlDriverModuleName)).getClassLoader().loadClass(NoSQLConstants.NEO4JDRIVERCLASS); } catch (ClassNotFoundException expected) { // ignore CNFE which just means that module is not a Neo4j module return; } catch (ModuleLoadException e) { throw new RuntimeException("could not load NoSQL driver module " + nosqlDriverModuleName, e); } // only reach this point if module is a Neo4j driver try { final DeploymentUnit parent = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent(); if (WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) { WeldPortableExtensions extensions = WeldPortableExtensions.getPortableExtensions(parent); ModuleIdentifier cdiExtensionModule = ModuleIdentifier.create(NoSQLConstants.NEO4JCDIEXTENSIONMODULE); methodHandleBuilder.classLoader(cdiExtensionModule); methodHandleBuilder.className(NoSQLConstants.NEO4JCDIEXTENSIONCLASS); MethodHandle extensionCtor = methodHandleBuilder.constructor(MethodType.methodType(void.class, Class.class)); Extension extension = (Extension) extensionCtor.invoke(driverClass); extensions.registerExtensionInstance(extension, parent); } } catch (Throwable throwable) { throw new RuntimeException("unexpected error constructing " + methodHandleBuilder.getTargetClass().getName(), throwable); } }
private void cassandraSetup(DeploymentUnit deploymentUnit, ModuleLoader moduleLoader, String nosqlDriverModuleName) { Class clusterClass; Class sessionClass; MethodHandleBuilder methodHandleBuilder = new MethodHandleBuilder(); try { clusterClass = moduleLoader.loadModule(ModuleIdentifier.fromString(nosqlDriverModuleName)).getClassLoader().loadClass(NoSQLConstants.CASSANDRACLUSTERCLASS); sessionClass = moduleLoader.loadModule(ModuleIdentifier.fromString(nosqlDriverModuleName)).getClassLoader().loadClass(NoSQLConstants.CASSANDRASESSIONCLASS); } catch (ClassNotFoundException expected) { // ignore CNFE which just means that module is not a Cassandra module return; } catch (ModuleLoadException e) { throw new RuntimeException("could not load NoSQL driver module " + nosqlDriverModuleName, e); } // only reach this point if module is a Cassandra driver try { final DeploymentUnit parent = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent(); if (WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) { WeldPortableExtensions extensions = WeldPortableExtensions.getPortableExtensions(parent); ModuleIdentifier cdiExtensionModule = ModuleIdentifier.create(NoSQLConstants.CASSANDRACDIEXTENSIONMODULE); methodHandleBuilder.classLoader(cdiExtensionModule); methodHandleBuilder.className(NoSQLConstants.CASSANDRACDIEXTENSIONCLASS); MethodHandle extensionCtor = methodHandleBuilder.constructor(MethodType.methodType(void.class, Class.class, Class.class)); Extension extension = (Extension) extensionCtor.invoke(clusterClass, sessionClass); extensions.registerExtensionInstance(extension, parent); } } catch (Throwable throwable) { throw new RuntimeException("unexpected error constructing " + methodHandleBuilder.getTargetClass().getName(), throwable); } }
@Override public void process(Archive<?> applicationArchive, TestClass testClass) { if (applicationArchive instanceof WebArchive) { File[] coreLibs = Maven.resolver() .loadPomFromFile("pom.xml").resolve("org.apache.tamaya:tamaya-core") .withTransitivity().asFile(); File[] apiLibs = Maven.resolver() .loadPomFromFile("pom.xml").resolve("org.apache.tamaya:tamaya-api") .withTransitivity().asFile(); File[] functionsLib = Maven.resolver() .loadPomFromFile("pom.xml").resolve("org.apache.tamaya.ext:tamaya-functions") .withTransitivity().asFile(); JavaArchive configJar = ShrinkWrap .create(JavaArchive.class, "tamaya-config-impl.jar") .addPackage(JavaConfigAdapter.class.getPackage()) .addPackage(JavaConfigCDIExtension.class.getPackage()) .addPackage(BooleanAsIntegerConverterFix.class.getPackage()) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(ConfigProviderResolver.class, JavaConfigProviderResolver.class) .addAsServiceProvider(PropertyConverter.class, BooleanAsIntegerConverterFix.class) .addAsServiceProvider(PropertyConverter.class, OptionalConverter.class) .addAsServiceProvider(Extension.class, JavaConfigCDIExtension.class); ((WebArchive) applicationArchive).addAsLibraries( configJar) .addAsLibraries(apiLibs) .addAsLibraries(coreLibs) .addAsLibraries(functionsLib); } }
@Test(expected = UnsatisfiedResolutionException.class) public void bootWeldSeContainer() { Extension testExtension = ContainerLifecycleObserver.extensionBuilder() .add(afterBeanDiscovery((e) -> System.out.println("Bean discovery completed!"))) .add(processAnnotatedType().notify((e) -> { if (e.getAnnotatedType().getJavaClass().getName().startsWith("com.hantsylab")) { e.veto(); } })).build(); try (WeldContainer container = new Weld().addExtension(testExtension).initialize()) { Greeter greeter = container.select(Greeter.class).get(); //assertTrue(greeter == null); } }
@Deployment public static JavaArchive createTestArchive() { return TestArchive.createBase("ExtensionAnnotationTest.jar") .addPackage(ExtensionAnnotationTest.class.getPackage()) .addClass(FaultToleranceOperations.class) .addAsServiceProvider(Extension.class, CustomExtension.class); }
/** * Create war archive to test. * * @return the war used for testing */ public static Archive<?> createDeployment() { return ShrinkWrap.create(JAXRSArchive.class) .addAsWebInfResource("META-INF/beans.xml", "beans.xml") .addAsServiceProvider(Extension.class, LaunchpadExtension.class) .addPackages(true, ForgeInitializer.class.getPackage().getName()) .addAsLibraries(Maven.resolver() .loadPomFromFile("pom.xml") .importCompileAndRuntimeDependencies() .resolve().withTransitivity().asFile()); }
@Deployment public static Archive<?> createArchive() { return ShrinkWrap.create(JavaArchive.class) .addAsServiceProviderAndClasses(Extension.class, ArtemisExtension.class) .addClasses(ConnectionFactoryProvider.class, CDIProducers.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); }
@Deployment public static JavaArchive createDeployment() { System.setProperty("errai.marshalling.force_static_marshallers", Boolean.toString(true)); return ShrinkWrap.create(JavaArchive.class) .addPackages(true, "org.uberfire.preferences") .addPackages(true, "org.uberfire.mvp") .addPackages(true, "org.uberfire.commons") .addPackages(true, "org.uberfire.backend.java") .addPackages(true, "org.uberfire.backend.server.cdi") .addPackages(true, "org.uberfire.backend.server.cluster") .addPackages(true, "org.uberfire.backend.server.io") .addPackages(true, "org.uberfire.java.nio.fs.jgit") .addClass(JGitFileSystemProvider.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsResource("META-INF/ErraiApp.properties", "ErraiApp.properties") .addAsManifestResource("META-INF/services/org.uberfire.java.nio.file.spi.FileSystemProvider", "services/org.uberfire.java.nio.file.spi.FileSystemProvider") .addAsServiceProvider(Extension.class, WorkspaceScopedExtension.class); }
WeldContainer(Bundle toExtend) { boot = new WeldBootstrap(); String contextName = "osgi-cdi:" + toExtend.getBundleId(); // Construct our extension which does the main of the work. BundleContext context = toExtend.getBundleContext(); List<Extension> extensions = new ArrayList<>(Arrays.asList( new ScopeExtension(context), new ServiceExtension(context), new ComponentExtension())); ServiceLoader<Extension> loader = ServiceLoader.load(Extension.class, DelegatingClassLoader.from(toExtend)); loader.forEach((l) -> extensions.add(l)); BeansXml beansXml = BeansXml.EMPTY_BEANS_XML; URL url = toExtend.getEntry("/META-INF/beans.xml"); if (url != null) { beansXml = boot.parse(url); } deployment = new OurDeployment(toExtend, beansXml, extensions.stream().map((e) -> new OurMetaData<>(e.getClass().getName(), e)).collect(Collectors.toList())); // Start the container. Needs to be called now because otherwise no bean manager is returned from the bootstrap. boot.startContainer(contextName, new OurEnvironment(), deployment); // Takes care of the extension initialization. We would want to do this inside the separate // thread, but this causes some exception breakpoints because our extensions are not proxyable. boot.startInitialization(); // The remainder is done in a separate thread. Runnable runner = () -> { // Go through the bootstrap sequence. This automatically fires the // events to our extensions. boot.deployBeans(); boot.validateBeans(); boot.endInitialization(); }; new Thread(runner).start(); }
@Deployment public static Archive<?> createTestArchive() throws FileNotFoundException { WebArchive ret = ShrinkWrap .create(WebArchive.class, "test.war") .addPackage("org.jboss.javaee.mongodb") .addAsLibraries(Maven.resolver() .loadPomFromFile("pom.xml") .resolve("org.mongodb:mongo-java-driver") .withTransitivity().as(JavaArchive.class)) .addAsWebInfResource("beans.xml", "beans.xml") .addAsServiceProvider(Extension.class, MongoExtension.class); return ret; }
@Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addClasses(DataSourceDefinitionBuilder.class) .addPackage(EntityManagerFactoryProvider.class.getPackage()) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(Extension.class, DataSourceExtension.class, FlywayExtension.class); }
@Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addClasses(AnotherEmployeeService.class, ProgrammaticPUTest.class, PUConfiguration.class) .addAsServiceProviderAndClasses(Extension.class, DataSourceExtension.class, JPAExtension.class) .addPackage(EntityManagerProducer.class.getPackage()) .addAsManifestResource("META-INF/beans.xml", "beans.xml"); }
@Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addPackage(HibernateTest.class.getPackage()) .addAsServiceProviderAndClasses(Extension.class, DataSourceExtension.class, JPAExtension.class) .addPackage(EntityManagerProducer.class.getPackage()) .addAsManifestResource("META-INF/beans.xml", "beans.xml") .addAsManifestResource("META-INF/load.sql") .addAsManifestResource("META-INF/persistence.xml"); }
@Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addPackage(Employee.class.getPackage()) .addAsServiceProviderAndClasses(Extension.class, DataSourceExtension.class, JPAExtension.class) .addPackage(EntityManagerProducer.class.getPackage()) .addAsManifestResource("META-INF/beans.xml", "beans.xml") .addAsManifestResource("META-INF/load.sql") .addAsManifestResource("META-INF/persistence.xml"); }
@Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addClasses(BeanWithDataSource.class, BuilderBackedBean.class, DataSourceDefinitionBuilder.class, SimpleWrapper.class) .addPackage(DataSourceDelegateBean.class.getPackage()) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(Extension.class, DataSourceExtension.class); }
@Deployment public static Archive<?> deployment() { return ShrinkWrap.create(JavaArchive.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addClasses(LoggedIn.class, SecurityInterceptor.class) .addAsServiceProviderAndClasses(Extension.class, SecurityExtension.class); }
@Deployment public static Archive<?> deployment() { return ShrinkWrap.create(JavaArchive.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addClasses(HasAllRoles.class, SecurityInterceptor.class) .addAsServiceProviderAndClasses(Extension.class, SecurityExtension.class); }