org.jboss.shrinkwrap.descriptor.api.beans10.BeansDescriptor Java Examples

The following examples show how to use org.jboss.shrinkwrap.descriptor.api.beans10.BeansDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FaultToleranceInterceptorEnableByXmlTest.java    From microprofile-fault-tolerance with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive deploy() {
    BeansDescriptor beans = Descriptors.create(BeansDescriptor.class)
        .getOrCreateInterceptors()
        .clazz("org.eclipse.microprofile.fault.tolerance.tck.interceptor.xmlInterceptorEnabling.EarlyFtInterceptor").up()
        .getOrCreateInterceptors()
        .clazz("org.eclipse.microprofile.fault.tolerance.tck.interceptor.xmlInterceptorEnabling.LateFtInterceptor").up();

    JavaArchive testJar = ShrinkWrap
        .create(JavaArchive.class, "interceptorFtXml.jar")
        .addClasses(InterceptorComponent.class, EarlyFtInterceptor.class, LateFtInterceptor.class, OrderQueueProducer.class)
         .addAsManifestResource(new StringAsset(beans.exportAsString()), "beans.xml")
        .as(JavaArchive.class);

    return ShrinkWrap.create(WebArchive.class, "interceptorFtXml.war")
        .addAsLibrary(testJar);
}
 
Example #2
Source File: EnableInterceptorsTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive war()
{
    String simpleName = EnableInterceptorsTest.class.getSimpleName();
    String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

    // CDI 1.0/Weld 1.x needs EnableInterceptorsInterceptor
    BeansDescriptor beansWithEnablingInterceptor = Descriptors.create(BeansDescriptor.class);
    beansWithEnablingInterceptor.getOrCreateInterceptors().clazz(EnableInterceptorsInterceptor.class.getName());
    
    // war archive needs MyBeanInterceptor enabled
    BeansDescriptor beans = Descriptors.create(BeansDescriptor.class);
    beans.getOrCreateInterceptors().clazz(MyBeanInterceptor.class.getName());
      
    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
            .addPackage(EnableInterceptorsTest.class.getPackage())
            .addAsManifestResource(new StringAsset(beansWithEnablingInterceptor.exportAsString()), "beans.xml");

    return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndProxyArchive())
            .addAsLibraries(testJar)
            .addAsWebInfResource(new StringAsset(beans.exportAsString()), "beans.xml");
}
 
Example #3
Source File: SimpleCacheTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive war()
{
    String simpleName = SimpleCacheTest.class.getSimpleName();
    String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

    // CDI 1.0/Weld 1.x needs EnableInterceptorsInterceptor
    BeansDescriptor beansWithEnablingInterceptor = Descriptors.create(BeansDescriptor.class);
    beansWithEnablingInterceptor.getOrCreateInterceptors().clazz(EnableInterceptorsInterceptor.class.getName());
    
    // war archive needs SimpleCacheInterceptor enabled
    BeansDescriptor beans = Descriptors.create(BeansDescriptor.class);
    beans.getOrCreateInterceptors().clazz(SimpleCacheInterceptor.class.getName());
      
    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
            .addPackage(SimpleCacheTest.class.getPackage())
            .addAsManifestResource(new StringAsset(beansWithEnablingInterceptor.exportAsString()), "beans.xml");

    return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndProxyArchive())
            .addAsLibraries(testJar)
            .addAsServiceProvider(Extension.class, SimpleCacheExtension.class)
            .addAsWebInfResource(new StringAsset(beans.exportAsString()), "beans.xml");
}
 
Example #4
Source File: QuestionnairResourceTest.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
@Deployment
public static Archive<?> createTestArchive() {
    String beansDescriptor = Descriptors.create(BeansDescriptor.class).exportAsString();
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "myarchive.jar")
            .addClasses(QuestionnaireResource.class, ResourceProducer.class, GazpachoResource.class)
            .addAsResource("resources/messages.properties")
            .addAsManifestResource(new StringAsset(beansDescriptor), "beans.xml");
    return archive;
}
 
Example #5
Source File: QuestionnairResourceInServletTest.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
@Deployment
public static Archive<?> createTestArchive() {

    String beansDescriptor = Descriptors.create(BeansDescriptor.class).exportAsString();
    return ShrinkWrap
            .create(WebArchive.class, "test.war")
            .addClasses(ResourceProducer.class, GazpachoResource.class, QuestionnaireResource.class,
                    QuestionnairResourceTestServlet.class)
            .addAsWebInfResource(new StringAsset(beansDescriptor), "beans.xml");
}
 
Example #6
Source File: MessageResourceTest.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
@Deployment
public static Archive<?> createTestArchive() {
    String beansDescriptor = Descriptors.create(BeansDescriptor.class).exportAsString();

    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "myarchive.jar").addClasses(MessageBundle.class)
            .addClasses(MessageBundleImpl.class).addClasses(MessageResource.class)
            .addClasses(MessageResourceProducer.class)

            .addAsResource("resources/messages.properties")
            .addAsManifestResource(new StringAsset(beansDescriptor), "beans.xml");

    return archive;
}
 
Example #7
Source File: ExceptionInjectionTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
@ShouldThrowException(javax.enterprise.inject.spi.DeploymentException.class)
public static WebArchive war() {
    return ShrinkWrap.create(WebArchive.class)
            .addAsWebInfResource(new StringAsset(Descriptors.create(BeansDescriptor.class)
                    .getOrCreateInterceptors()
                        .clazz("i.dont.exist.so.i.ll.make.the.deployment.fail")
                    .up()
                    .exportAsString()), ArchivePaths.create("beans.xml"));
}
 
Example #8
Source File: DeploymentExceptionErrorTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
@ShouldThrowException(OpenEJBRuntimeException.class)
public static WebArchive war() {
    return ShrinkWrap.create(WebArchive.class, "DeploymentExceptionErrorTest.war")
                .addAsWebInfResource(new StringAsset(Descriptors.create(BeansDescriptor.class)
                        .getOrCreateInterceptors()
                            .clazz("i.dont.exist.so.i.ll.make.the.deployment.fail")
                        .up()
                        .exportAsString()), ArchivePaths.create("beans.xml"));
}
 
Example #9
Source File: FutureableTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive deploy()
{
    // create beans.xml with added interceptor
    BeansDescriptor beans = Descriptors.create(BeansDescriptor.class);
    beans.getOrCreateInterceptors().clazz(FutureableInterceptor.class.getName());
    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "FutureableTest.jar")
            .addPackage(Service.class.getPackage().getName())
            .addAsManifestResource(new StringAsset(beans.exportAsString()), "beans.xml");

    return ShrinkWrap.create(WebArchive.class, "FutureableTest.war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
            .addAsLibraries(testJar)
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #10
Source File: LockedTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive deploy()
{
    // create beans.xml with added interceptor
    BeansDescriptor beans = Descriptors.create(BeansDescriptor.class);
    beans.getOrCreateInterceptors().clazz(LockedInterceptor.class.getName());
    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "LockedTest.jar")
            .addPackage(Service.class.getPackage().getName())
            .addAsManifestResource(new StringAsset(beans.exportAsString()), "beans.xml");

    return ShrinkWrap.create(WebArchive.class, "LockedTest.war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
            .addAsLibraries(testJar)
            .addAsWebInfResource(new StringAsset(beans.exportAsString()), "beans.xml");
}
 
Example #11
Source File: BuildCoordinatorDeployments.java    From pnc with Apache License 2.0 4 votes vote down vote up
private static JavaArchive defaultLibs() {
    Filter<ArchivePath> filter = path -> {
        String packageStylePath = path.get().replaceAll("/", ".").replaceAll("\\.class$", "").substring(1);
        log.debug("Checking path: {}.", packageStylePath);
        if (packageStylePath.equals(DefaultBuildExecutor.class.getName())) {
            return false;
        }
        return true;
    };

    JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
            .addClass(Configuration.class)
            .addClass(BuildSetStatusChangedEvent.class)
            .addClass(DefaultBuildSetStatusChangedEvent.class)
            .addClass(BuildEnvironment.Builder.class)
            .addClass(TestEntitiesFactory.class)
            .addClass(BuildCoordinatorFactory.class)
            .addClass(BuildConfigurationAuditedRepositoryMock.class)
            .addPackages(false, filter, BuildResultMapper.class.getPackage())
            .addPackages(
                    true,
                    filter,
                    BuildCoordinator.class.getPackage(),
                    DefaultBuildCoordinator.class.getPackage(),
                    BuildSetStatusNotifications.class.getPackage(),
                    TestProjectConfigurationBuilder.class.getPackage(),
                    ContentIdentityManager.class.getPackage(),
                    BuildConfigSetRecordRepository.class.getPackage(),
                    TestCDIBuildStatusChangedReceiver.class.getPackage(),
                    BuildSetCallBack.class.getPackage(),
                    BuildCallBack.class.getPackage(),
                    BuildCoordinationStatus.class.getPackage(),
                    DefaultBuildStatusChangedEvent.class.getPackage(),
                    BuildExecutorMock.class.getPackage(),
                    DefaultBuildExecutionSession.class.getPackage(),
                    MessageSender.class.getPackage(),
                    SystemConfig.class.getPackage(),
                    ModuleConfigFactory.class.getPackage(),
                    AbstractArtifactMapper.class.getPackage())
            // TODO remove, no need to use default beans.xml
            .addAsManifestResource(
                    new StringAsset(Descriptors.create(BeansDescriptor.class).exportAsString()),
                    "beans.xml")
            .addAsResource("logback-test.xml", "logback.xml");

    log.info("Deployment content: {}", jar.toString(true));
    return jar;
}
 
Example #12
Source File: IntegrationTestsBase.java    From BootsFaces-OSP with Apache License 2.0 4 votes vote down vote up
public static WebArchive createBaseDeployment() {

        WebArchive deployment = ShrinkWrap.create(WebArchive.class, "test.war");
        
        BeansDescriptor beans = Descriptors.importAs(BeansDescriptor.class)
                .fromFile(WEBAPP_SRC+"/WEB-INF/beans.xml");
        
        WebAppDescriptor webDescriptor = Descriptors.importAs(WebAppDescriptor.class)
                .fromFile(WEBAPP_SRC+"/WEB-INF/web.xml");
        

        deployment.addAsWebInfResource(new StringAsset(beans.exportAsString()), "beans.xml")
                    .addAsWebInfResource(new StringAsset(webDescriptor.exportAsString()), "web.xml")
                    .addAsLibraries(new File("target/bootsfaces-test.jar"));
        
        return deployment;
    }