org.jboss.shrinkwrap.api.ArchivePaths Java Examples

The following examples show how to use org.jboss.shrinkwrap.api.ArchivePaths. 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: ServletCdiConstructorInjectionTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Deployment(testable = false)
public static WebArchive createDeployment() {

    WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
            .version("3.0")
            .createServlet().servletName("servlet").servletClass(SimpleServlet.class.getName()).up()
            .createServletMapping().servletName("servlet").urlPattern("/" + TEST_NAME).up();

    WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
            .addClass(TestRun.class)
            .addClass(SimpleServlet.class)
            .addClass(Car.class)
            .setWebXML(new StringAsset(descriptor.exportAsString()))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));



    return archive;
}
 
Example #2
Source File: ServletPersistenceInjectionTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Deployment(testable = false)
public static WebArchive createDeployment() {
    WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
            .version("3.0")
            .createServlet()
                .servletName("check").servletClass(PersistenceServlet.class.getName()).up()
            .createServletMapping()
                .servletName("check").urlPattern("/" + TEST_NAME).up();

    WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
            .addClass(PersistenceServlet.class)
            .addClass(Address.class)
            .addClass(Runner.class)
            .addAsLibraries(JarLocation.jarLocation(Test.class))
            .addAsManifestResource("persistence.xml", ArchivePaths.create("persistence.xml"))
            .setWebXML(new StringAsset(descriptor.exportAsString()));



    return archive;
}
 
Example #3
Source File: TestSetup.java    From tomee with Apache License 2.0 6 votes vote down vote up
public WebArchive createDeployment(Class...archiveClasses) {
    WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
            .version("3.0");
    decorateDescriptor(descriptor);

    WebArchive archive = ShrinkWrap.create(WebArchive.class, getTestContextName() + ".war")
            .setWebXML(new StringAsset(descriptor.exportAsString()))
            .addAsLibraries(JarLocation.jarLocation(Test.class))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
    
    if (archiveClasses != null) {
        for (Class c: archiveClasses) {
            archive.addClass(c);
        }
    }
    decorateArchive(archive);

    return archive;
}
 
Example #4
Source File: ArchiveProvider.java    From gazpachoquest with GNU General Public License v3.0 6 votes vote down vote up
static WebArchive base(String warName) {
    PomEquippedResolveStage resolver = Maven.resolver().loadPomFromFile("pom.xml");
    return ShrinkWrap
            .create(WebArchive.class, warName + ".war")
            .addClasses(FRAMEWORK_CLASSES)
            .addAsLibraries(resolver.resolve("com.vaadin:vaadin-server:7.1.6").withoutTransitivity().asSingleFile())
            .addAsLibraries(resolver.resolve("com.vaadin:vaadin-shared:7.1.6").withoutTransitivity().asSingleFile())
            .addAsWebInfResource(new ByteArrayAsset(VaadinExtension.class.getName().getBytes()),
                    ArchivePaths.create("services/javax.enterprise.inject.spi.Extension"))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));

    /*-
    MavenDependencyResolver resolver = DependencyResolvers.use(MavenDependencyResolver.class).loadMetadataFromPom(
            "pom.xml");
           
    return ShrinkWrap
            .create(WebArchive.class, warName + ".war")
            .addClasses(FRAMEWORK_CLASSES)
            .addAsLibraries(resolver.artifact("com.vaadin:vaadin-server:7.1.6").resolveAsFiles())
           .addAsLibraries(resolver.artifact("com.vaadin:vaadin-shared:7.1.6").resolveAsFiles())
            .addAsWebInfResource(new ByteArrayAsset(VaadinExtension.class.getName().getBytes()),
                    ArchivePaths.create("services/javax.enterprise.inject.spi.Extension"))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
     */

}
 
Example #5
Source File: JPAArquillianAdapterTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Deployment
public static JavaArchive archive() {
    return ShrinkWrap.create(JavaArchive.class, JPAArquillianAdapterTest.class.getSimpleName().concat(".jar"))
            .addClasses(Person.class, Persister.class)
            .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
            .addAsManifestResource(new StringAsset("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                    "<persistence version=\"2.0\"\n" +
                    "             xmlns=\"http://java.sun.com/xml/ns/persistence\"\n" +
                    "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
                    "             xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence\n" +
                    "                       http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">\n" +
                    "  <persistence-unit name=\"person\">\n" +
                    "    <jta-data-source>My DataSource</jta-data-source>\n" +
                    "    <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>\n" +
                    "    <class>" + Person.class.getName() + "</class>\n" +
                    "    <properties>\n" +
                    "      <property name=\"openjpa.jdbc.SynchronizeMappings\" value=\"buildSchema(ForeignKeys=true)\"/>\n" +
                    "    </properties>\n" +
                    "  </persistence-unit>\n" +
                    "</persistence>"), ArchivePaths.create("persistence.xml"));
}
 
Example #6
Source File: CustomVaultInModuleTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void createTestModule() throws Exception {
    File moduleXml = new File(CustomSecurityVault.class.getResource(CustomVaultInModuleTestCase.class.getSimpleName() + "-module.xml").toURI());
    testModule = new TestModule(MODULE_NAME, moduleXml);

    JavaArchive archive = testModule.addResource("test-custom-vault-in-module.jar")
            .addClass(CustomSecurityVault.class)
            .addClass(TestVaultExtension.class)
            .addClass(TestVaultParser.class)
            .addClass(TestVaultRemoveHandler.class)
            .addClass(TestVaultResolveExpressionHandler.class)
            .addClass(TestVaultSubsystemResourceDescription.class);

    ArchivePath path = ArchivePaths.create("/");
    path = ArchivePaths.create(path, "services");
    path = ArchivePaths.create(path, Extension.class.getName());
    archive.addAsManifestResource(CustomSecurityVault.class.getPackage(), Extension.class.getName(), path);
    testModule.create(true);
}
 
Example #7
Source File: ServletCdiProducerTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Deployment(testable = false)
public static WebArchive createDeployment() {

    final WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
            .version(WebAppVersionType._3_0)
            .createServlet().servletName("servlet").servletClass(SimpleServlet.class.getName()).up()
            .createServletMapping().servletName("servlet").urlPattern("/" + TEST_NAME).up();

    WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
            .addClass(TestRun.class)
            .addClass(SimpleServlet.class)
            .addClass(Car.class)
            .addClass(AssemblyLine.class)
            .setWebXML(new StringAsset(descriptor.exportAsString()))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));



    return archive;
}
 
Example #8
Source File: DuplicateExtCommandTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void createTestModule() throws Exception {
    final File moduleXml = new File(DuplicateExtCommandTestCase.class.getResource(DuplicateExtCommandTestCase.class.getSimpleName() + "-module.xml").toURI());
    testModule = new TestModule(MODULE_NAME, moduleXml);

    final JavaArchive archive = testModule.addResource("test-cli-duplicate-commands-module.jar")
            .addClass(DuplicateExtCommandHandler.class)
            .addClass(DuplicateExtCommandHandlerProvider.class)
            .addClass(DuplicateExtCommandsExtension.class)
            .addClass(CliExtCommandsParser.class)
            .addClass(DuplicateExtCommand.class)
            .addClass(DuplicateExtCommandSubsystemResourceDescription.class);

    ArchivePath services = ArchivePaths.create("/");
    services = ArchivePaths.create(services, "services");

    final ArchivePath extService = ArchivePaths.create(services, Extension.class.getName());
    archive.addAsManifestResource(getResource(DuplicateExtCommandsExtension.class), extService);

    final ArchivePath cliCmdService = ArchivePaths.create(services, CommandHandlerProvider.class.getName());
    archive.addAsManifestResource(getResource(DuplicateExtCommandHandlerProvider.class), cliCmdService);

    final ArchivePath cliAeshCmdService = ArchivePaths.create(services, Command.class.getName());
    archive.addAsManifestResource(getResource(DuplicateExtCommand.class), cliAeshCmdService);
    testModule.create(true);
}
 
Example #9
Source File: ServletCdiInjectionTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Deployment(testable = false)
public static WebArchive createDeployment() {

    WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
            .version(WebAppVersionType._3_0)
            .createServlet().servletName("servlet").servletClass(SimpleServlet.class.getName()).up()
            .createServletMapping().servletName("servlet").urlPattern("/" + TEST_NAME).up();

    WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
            .addClass(TestRun.class)
    		.addClass(SimpleServlet.class)
            .addClass(Car.class)
            .setWebXML(new StringAsset(descriptor.exportAsString()))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));



    return archive;
}
 
Example #10
Source File: TimedMethodBeanTestJava8.java    From metrics-cdi with Apache License 2.0 6 votes vote down vote up
@Deployment
public static Archive<?> createTestArchive() {
    return ShrinkWrap.create(WebArchive.class)
        // TODO: understand why this is duplicated in the Archive and fails since Weld 2.2.5.Final
        /* .addAsLibraries(
            Maven.configureResolver()
                .workOffline()
                .loadPomFromFile("pom.xml")
                .resolve("io.astefanutti.metrics.cdi:metrics-cdi", "org.jboss.weld.servlet:weld-servlet")
                .withTransitivity()
                .as(JavaArchive.class)) */
        .addClass(TimedMethodBean.class)
        .addClass(TimedMethodServlet.class)
        .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
        .setWebXML(new StringAsset(Descriptors.create(WebAppDescriptor.class)
            .version("3.1")
            .createServlet()
                .servletClass(TimedMethodServlet.class.getName())
                .servletName("TimedMethod").up()
            .createServletMapping()
                .servletName("TimedMethod")
                .urlPattern("/timedMethod").up()
            .createListener()
                .listenerClass(Listener.class.getName()).up()
            .exportAsString()));
}
 
Example #11
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 #12
Source File: VirtualResourceTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive jar() {
    return ShrinkWrap.create(WebArchive.class, SWLibTest.class.getSimpleName() + ".war")
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
            .addAsServiceProvider(Extension.class, MyExtension.class)
            .addClass(MyExtension.class);
}
 
Example #13
Source File: SWClassLoader.java    From tomee with Apache License 2.0 5 votes vote down vote up
public LinkedList<Archive<?>> findNodes(final String name) {
    final LinkedList<Archive<?>> items = new LinkedList<>();
    for (final Archive<?> a : archives) {
        final boolean isWar = WebArchive.class.isInstance(a);
        final Node node = a.get(ArchivePaths.create((isWar ? "/WEB-INF/classes/" : "") + name));
        if (node != null) {
            items.add(a);
        }
    }
    return items;
}
 
Example #14
Source File: SessionScopeTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
public static WebArchive createDeployment() {
    return ShrinkWrap.create(WebArchive.class, "test.war").addClass(PojoSessionScoped.class).addClass(PojoSessionScopedServletWrapper.class).addAsLibraries(new File("target/test-libs/commons-httpclient.jar")).addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
                .setWebXML(new StringAsset(
                    Descriptors.create(WebAppDescriptor.class).version("3.0")
                        .createServlet().servletName("servlet").servletClass(PojoSessionScopedServletWrapper.class.getName()).up()
                        .createServletMapping().servletName("servlet").urlPattern("/session").up()
                    .exportAsString()));
}
 
Example #15
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 #16
Source File: BinderExtensionTest.java    From jadira with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {
    return ShrinkWrap.create(JavaArchive.class, "test.jar")
            .addPackage(HelloWorld.class.getPackage())
            .addPackage(BinderExtension.class.getPackage())
            .addAsManifestResource(
                    "META-INF/beans.xml",
                    ArchivePaths.create("beans.xml"));
}
 
Example #17
Source File: ServletListenerPersistenceInjectionTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
public static WebArchive createDeployment() {
    WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
            .version("3.0")
            .createListener()
                .listenerClass(PersistenceServletContextListener.class.getName()).up()
            .createListener()
                .listenerClass(PersistenceServletSessionListener.class.getName()).up()
            .createServlet()
                .servletName("check").servletClass(ServletToCheckListener.class.getName()).up()
            .createServletMapping()
                .servletName("check").urlPattern("/" + TEST_NAME).up();

    WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
            .addClass(PersistenceServletContextListener.class)
            .addClass(PersistenceServletSessionListener.class)
            .addClass(ServletToCheckListener.class)
            .addClass(Address.class)
            .addClass(ContextAttributeName.class)
            .addAsManifestResource("persistence.xml", ArchivePaths.create("persistence.xml"))
            .setWebXML(new StringAsset(descriptor.exportAsString()))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));



    return archive;
}
 
Example #18
Source File: PersonsIT.java    From jaxrs-beanvalidation-javaee7 with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive createDeployment() throws IOException {
    final WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxrs-beanvalidation-javaee7.war")
            .addPackage("com.samaxes.javax.rs.validation")
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));

    LOGGER.info(war.toString(Formatters.VERBOSE));

    return war;
}
 
Example #19
Source File: PersonsIT.java    From jaxrs-beanvalidation-javaee7 with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive createDeployment() throws IOException {
    final WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxrs-beanvalidation-javaee7.war")
            .addPackage("com.samaxes.javax.rs.validation")
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));

    LOGGER.info(war.toString(Formatters.VERBOSE));

    return war;
}
 
Example #20
Source File: ServletListenerEjbLocalInjectionTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
public static WebArchive createDeployment() {
    final WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
            .version("3.0")
            .createListener()
                .listenerClass(PojoServletContextListener.class.getName()).up()
            .createListener()
                .listenerClass(PojoServletSessionListener.class.getName()).up()
            .createServlet()
                .servletName("check").servletClass(ServletToCheckListener.class.getName()).up()
            .createServletMapping()
                .servletName("check").urlPattern("/" + TEST_NAME).up();

    addEnvEntry(descriptor, "returnEmail", "java.lang.String", "[email protected]");
    addEnvEntry(descriptor, "connectionPool", "java.lang.Integer", "20");
    addEnvEntry(descriptor, "startCount", "java.lang.Long", "200000");
    addEnvEntry(descriptor, "initSize", "java.lang.Short", "5");
    addEnvEntry(descriptor, "enableEmail", "java.lang.Boolean", "true");
    addEnvEntry(descriptor, "totalQuantity", "java.lang.Byte", "5");
    addEnvEntry(descriptor, "optionDefault", "java.lang.Character", "X");
    addEnvEntry(descriptor, "auditWriter", "java.lang.Class", "java.lang.String");
    //addEnvEntry(descriptor, "defaultCode", "java.lang.Enum", "org.apache.openejb.arquillian.ServletListenerPojoInjectionTest$Code.OK");

    final WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
            .addClass(PojoServletContextListener.class)
            .addClass(PojoServletSessionListener.class)
            .addClass(ServletToCheckListener.class)
            .addClass(Car.class)
            .addClass(CompanyLocal.class)
            .addClass(Company.class)
            .addClass(DefaultCompany.class)
            .addClass(SuperMarket.class)
            .addClass(Code.class)
            .addClass(ContextAttributeName.class)
            .setWebXML(new StringAsset(descriptor.exportAsString()))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));


    return archive;
}
 
Example #21
Source File: ServletListenerEjbRemoteTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
public static WebArchive createDeployment() {
    WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
            .version("3.0")
            .createListener()
                .listenerClass(RemoteServletContextListener.class.getName()).up()
            .createListener()
                .listenerClass(RemoteServletSessionListener.class.getName()).up()
            .createServlet()
                .servletName("check").servletClass(ServletToCheckListener.class.getName()).up()
            .createServletMapping()
                .servletName("check").urlPattern("/" + TEST_NAME).up();

    WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
            .addClass(RemoteServletContextListener.class)
            .addClass(RemoteServletSessionListener.class)
            .addClass(ServletToCheckListener.class)
            .addClass(CompanyRemote.class)
            .addClass(DefaultCompany.class)
            .addClass(ContextAttributeName.class)
            .setWebXML(new StringAsset(descriptor.exportAsString()))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));



    return archive;
}
 
Example #22
Source File: TestApplication.java    From smallrye-jwt with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive createDeployment() {
    return ShrinkWrap
            .create(WebArchive.class)
            .addClass(TestServlet.class)
            .addClass(RestApplication.class)
            .addClass(TestEndpoint.class)
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
}
 
Example #23
Source File: HibernateTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive war() {
    File[] hibernate;
    try { // try offline first since it is generally faster
        hibernate = Maven.configureResolver()
                .workOffline()
                .loadPomFromFile("src/test/resources/hibernate-pom.xml")
                .importCompileAndRuntimeDependencies().resolve().withTransitivity()
                .asFile();
    } catch (ResolutionException re) { // try on central
        hibernate = Maven.resolver()
                .loadPomFromFile("src/test/resources/hibernate-pom.xml")
                .importCompileAndRuntimeDependencies().resolve().withTransitivity()
                .asFile();
    }

    return ShrinkWrap.create(WebArchive.class, "hibernate-app.war")
            .addAsWebInfResource(new StringAsset("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                    "<persistence version=\"2.0\"\n" +
                    "    xmlns=\"http://java.sun.com/xml/ns/persistence\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
                    "    xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence" +
                    "                         http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">\n" +
                    "  <persistence-unit name=\"hibernate\">\n" +
                    "    <provider>org.hibernate.jpa.HibernatePersistence</provider>\n" +
                    "    <exclude-unlisted-classes>true</exclude-unlisted-classes>\n" +
                    "    <properties>\n" +
                    "      <property name=\"hibernate.hbm2ddl.auto\" value=\"create-drop\" />\n" +
                    "    </properties>\n" +
                    "  </persistence-unit>\n" +
                    "</persistence>"), ArchivePaths.create("persistence.xml"))
            .addAsLibraries(hibernate)
            .addAsLibraries(JarLocation.jarLocation(ResolutionException.class))
            .addAsLibraries(JarLocation.jarLocation(org.jboss.shrinkwrap.resolver.api.maven.filter.MavenResolutionFilter.class));
}
 
Example #24
Source File: ServletFilterEnvEntryInjectionTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
    public static WebArchive createDeployment() {
        WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
                .version(WebAppVersionType._3_0)
                .createFilter()
                    .filterName("filter").filterClass(PojoServletFilter.class.getName()).up()
                .createFilterMapping()
                    .filterName("filter").urlPattern("/" + TEST_NAME).up();

        addEnvEntry(descriptor, "returnEmail", "java.lang.String", "[email protected]");
        addEnvEntry(descriptor, "connectionPool", "java.lang.Integer", "20");
        addEnvEntry(descriptor, "startCount", "java.lang.Long", "200000");
        addEnvEntry(descriptor, "initSize", "java.lang.Short", "5");
        addEnvEntry(descriptor, "enableEmail", "java.lang.Boolean", "true");
        addEnvEntry(descriptor, "totalQuantity", "java.lang.Byte", "5");
        addEnvEntry(descriptor, "optionDefault", "java.lang.Character", "X");
        addEnvEntry(descriptor, "auditWriter", "java.lang.Class", "java.lang.String");
//        addEnvEntry(descriptor, "defaultCode", "java.lang.Enum", "Code.OK");

        WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
        		.addClass(Code.class)
        		.addClass(PojoServletFilter.class)
                .addClass(Car.class)
                .addClass(CompanyLocal.class)
                .addClass(Company.class)
                .addClass(DefaultCompany.class)
                .addClass(SuperMarket.class)
                .setWebXML(new StringAsset(descriptor.exportAsString()))
                .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));



        return archive;
    }
 
Example #25
Source File: WebAppClassLoaderTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive war() {
    return ShrinkWrap.create(WebArchive.class, "WebAppClassLoaderTest.war")
            .addClasses(HashCdiExtension.class, HashServlet.class)
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
            .addAsServiceProvider(Extension.class, HashCdiExtension.class);
}
 
Example #26
Source File: ServletDisposeRequestScopeTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
public static WebArchive createDeployment() {
    return new WebModule(ServletDisposeRequestScopeTest.class, ServletDisposeRequestScopeTest.class)
            .getArchive()
            .setWebXML(new StringAsset(Descriptors.create(WebAppDescriptor.class).version(WebAppVersionType._3_0).exportAsString()))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
}
 
Example #27
Source File: WebAppClassLoaderSkipClassesTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive war() {
    final File[] libs = Maven
            .configureResolver()
            .workOffline()
            .resolve("commons-logging:commons-logging:1.2")
            .withTransitivity()
            .asFile();


    return ShrinkWrap.create(WebArchive.class, "WebAppClassLoaderTest.war")
            .addClasses(TestService.class)
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
            .addAsLibraries(libs);
}
 
Example #28
Source File: MyFacesExtCdiDeploymentTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive getArchive() {
    final WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class).version(WebAppVersionType._3_0);
    // web.xml params is not supported by default
    // descriptor.contextParam(ProjectStage.PROJECT_STAGE_PARAM_NAME, ProjectStage.SystemTest.name());

    return ShrinkWrap.create(WebArchive.class, "MyFacesExtCdiDeploymentTest.war")
            .addAsLibraries(JarLocation.jarLocation(JsfProjectStageProducer.class)) // codi
            .setWebXML(new StringAsset(descriptor.exportAsString()))
            .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
}
 
Example #29
Source File: SessionScopeTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
public static WebArchive createDeployment() {
    return ShrinkWrap.create(WebArchive.class, "SessionScopeTest.war")
        .addClass(PojoSessionScoped.class).addClass(PojoSessionScopedServletWrapper.class)
        .addAsLibraries(new File("target/test-libs/commons-httpclient.jar"))
        .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
        .setWebXML(new StringAsset(Descriptors.create(WebAppDescriptor.class)
            .version("3.0")
                .createServlet().servletName("servlet").servletClass(PojoSessionScopedServletWrapper.class.getName()).up()
                .createServletMapping().servletName("servlet").urlPattern("/session").up()
            .exportAsString()));
}
 
Example #30
Source File: OrmXmlBasedRepositoryTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive<?> deployment()
{
    return initDeployment()
            .addClasses(MappedOneRepository.class)
            .addAsLibraries(
                    ShrinkWrap.create(JavaArchive.class, "domain.jar")
                            .addPackage(MappedOne.class.getPackage())
                            .addAsResource("test-custom-orm.xml", ArchivePaths.create("META-INF/custom-orm.xml"))
            )
            .addAsWebInfResource("test-mapped-persistence.xml",
                    ArchivePaths.create("classes/META-INF/persistence.xml"))
            .addAsWebInfResource("test-default-orm.xml", ArchivePaths.create("classes/META-INF/orm.xml"));
}