* @return test archive
*/
@Deployment
public static EnterpriseArchive createTestArchive() {
EnterpriseArchive enterpriseArchive = new EnterpriseArchiveBuilder()
// A - default EJB jar
.withTestClassDefinition(EnterpriseArchiveModulesTest.class)
.withClasses(Foo.class, BusinessOperationEventInspector.class)
// C - lib visible to all
.withBeanLibrary(
Descriptors.create(BeansDescriptor.class).createInterceptors()
.clazz(SecurityInterceptor.class.getName()).up(), Bar.class, AlternativeBar.class, Util.class,
Business.class, BusinessOperationEvent.class, BusinessOperationObservedEvent.class,
NonEnterprise.class, Secured.class, SecurityInterceptor.class, LoggingDecorator.class)
// D - lib visible to all
.withLibrary(LegacyService.class).noDefaultWebModule().build();
// B - not visible for ACDE
JavaArchive barArchive = ShrinkWrap.create(JavaArchive.class, "bar.jar")
.addClasses(BarInspector.class, ContainerEventsObserver.class, LegacyServiceProducer.class)
.addAsServiceProvider(Extension.class, ContainerEventsObserver.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
enterpriseArchive.addAsModule(barArchive);
// E - not visible for ABCD
WebArchive bazArchive = new WebArchiveBuilder()
.notTestArchive()
// F - with enabled decorator
.withClasses(Baz.class, EnterpriseArchiveModulesTest.class)
.withBeansXml(
Descriptors.create(BeansDescriptor.class).createDecorators().clazz(LoggingDecorator.class.getName())
.up().createAlternatives().clazz(AlternativeBar.class.getName()).up())
// G
.withBeanLibrary(Qux.class)
.build()
// Make A and B visible in a portable way
.setManifest(
new StringAsset(Descriptors.create(ManifestDescriptor.class)
.addToClassPath(EnterpriseArchiveBuilder.DEFAULT_EJB_MODULE_NAME).addToClassPath("bar.jar")
.exportAsString()));
enterpriseArchive.addAsModule(bazArchive);
return enterpriseArchive;
}