Search in sources :

Example 1 with ClassLoaderAsset

use of org.jboss.shrinkwrap.api.asset.ClassLoaderAsset in project camel by apache.

the class ArquillianPackager method addSpringbootPackage.

private static JavaArchive addSpringbootPackage(JavaArchive ark, String... packageNames) throws Exception {
    Iterable<ClassLoader> classLoaders = Collections.singleton(Thread.currentThread().getContextClassLoader());
    for (String packageName : packageNames) {
        for (final ClassLoader classLoader : classLoaders) {
            final URLPackageScanner.Callback callback = new URLPackageScanner.Callback() {

                @Override
                public void classFound(String className) {
                    ArchivePath classNamePath = AssetUtil.getFullPathForClassResource(className);
                    Asset asset = new ClassLoaderAsset(classNamePath.get().substring(1), classLoader);
                    ArchivePath location = new BasicPath(CLASSES_FOLDER + "/", classNamePath);
                    ark.add(asset, location);
                }
            };
            final URLPackageScanner scanner = URLPackageScanner.newInstance(true, classLoader, callback, packageName);
            scanner.scanPackage();
        }
    }
    return ark;
}
Also used : ArchivePath(org.jboss.shrinkwrap.api.ArchivePath) URLPackageScanner(org.jboss.shrinkwrap.impl.base.URLPackageScanner) Asset(org.jboss.shrinkwrap.api.asset.Asset) FileAsset(org.jboss.shrinkwrap.api.asset.FileAsset) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset) BasicPath(org.jboss.shrinkwrap.impl.base.path.BasicPath) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset)

Example 2 with ClassLoaderAsset

use of org.jboss.shrinkwrap.api.asset.ClassLoaderAsset in project tomee by apache.

the class JPAInjectionTest method getArchive.

@Deployment(testable = false)
public static WebArchive getArchive() {
    PersistenceDescriptor persistenceDescriptor = Descriptors.create(PersistenceDescriptor.class).createPersistenceUnit().name("test-pu").transactionType("JTA").clazz(PersistenceDescriptor.class.getName()).jtaDataSource("test-ds").up();
    Asset persistenceAsset = new StringAsset(persistenceDescriptor.exportAsString());
    return base("jsf-jpa-test.war").addAsWebInfResource(persistenceAsset, "persistence.xml").addClasses(DummyManagedBean.class).addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml").addAsWebResource(new ClassLoaderAsset(JPAInjectionTest.class.getPackage().getName().replace('.', '/').concat("/").concat("dummy.xhtml")), "dummy.xhtml");
}
Also used : PersistenceDescriptor(org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) EmptyAsset(org.jboss.shrinkwrap.api.asset.EmptyAsset) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) Asset(org.jboss.shrinkwrap.api.asset.Asset) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 3 with ClassLoaderAsset

use of org.jboss.shrinkwrap.api.asset.ClassLoaderAsset in project tomee by apache.

the class IvmContextTest method createDeployment.

@Deployment(testable = false)
public static WebArchive createDeployment() {
    WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class).version(WebAppVersionType._3_0).createServlet().servletName(SERVLET_NAME).servletClass(IvmContextServlet.class.getName()).up().createServletMapping().servletName(SERVLET_NAME).urlPattern("/" + TEST_NAME).up();
    WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war").addClass(IvmContextTest.class).addClass(IvmContextServlet.class).addClass(NamingBean.class).addClass(Runner.class).addAsLibraries(JarLocation.jarLocation(Test.class)).addAsWebInfResource(new ClassLoaderAsset(CONTENT_LOCATION_EJB_JAR_XML), RESOURCE_EJB_JAR_XML).setWebXML(new StringAsset(descriptor.exportAsString()));
    return archive;
}
Also used : WebAppDescriptor(org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor) Runner(org.apache.openejb.arquillian.tests.Runner) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) Test(org.junit.Test) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 4 with ClassLoaderAsset

use of org.jboss.shrinkwrap.api.asset.ClassLoaderAsset in project tomee by apache.

the class SessionSynchronizationCallbackTest method createDeployment.

@Deployment(testable = false)
public static WebArchive createDeployment() {
    WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class).version(WebAppVersionType._3_0).createServlet().servletName(SERVLET_NAME).servletClass(SessionSynchronizationCallbackServlet.class.getName()).up().createServletMapping().servletName(SERVLET_NAME).urlPattern("/" + TEST_NAME).up();
    WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war").addClass(SessionSynchronizationCallbackServlet.class).addClass(StatefulBean.class).addClass(TestEntity.class).addClass(Runner.class).addAsLibraries(JarLocation.jarLocation(Test.class)).addAsResource(new ClassLoaderAsset(PERSISTENCE_XML_SOURCE), PERSISTENCE_XML_DESTINATION).setWebXML(new StringAsset(descriptor.exportAsString()));
    return archive;
}
Also used : WebAppDescriptor(org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor) Runner(org.apache.openejb.arquillian.tests.Runner) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) Test(org.junit.Test) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 5 with ClassLoaderAsset

use of org.jboss.shrinkwrap.api.asset.ClassLoaderAsset in project tomee by apache.

the class MultiplePersistenceTest method createDeployment.

@Deployment(testable = false)
public static WebArchive createDeployment() {
    WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class).version(WebAppVersionType._3_0).createServlet().servletName("check").servletClass(MultiplePUServlet.class.getName()).up().createServletMapping().servletName("check").urlPattern("/" + TEST_NAME).up();
    WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war").addClass(MultiplePUServlet.class).addClass(Person1.class).addClass(Person2.class).addClass(Runner.class).addAsLibraries(JarLocation.jarLocation(Test.class)).addAsResource(new ClassLoaderAsset("org/apache/openejb/arquillian/tests/persistence/multiple/persistence.xml"), "META-INF/persistence.xml").setWebXML(new StringAsset(descriptor.exportAsString()));
    return archive;
}
Also used : WebAppDescriptor(org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor) Runner(org.apache.openejb.arquillian.tests.Runner) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) Test(org.junit.Test) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

ClassLoaderAsset (org.jboss.shrinkwrap.api.asset.ClassLoaderAsset)26 Deployment (org.jboss.arquillian.container.test.api.Deployment)20 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)20 File (java.io.File)15 SampleDataSourceDefinition (eu.ggnet.dwoss.mandator.tryout.SampleDataSourceDefinition)8 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)8 Test (org.junit.Test)7 Runner (org.apache.openejb.arquillian.tests.Runner)6 WebAppDescriptor (org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor)6 Coordinate (org.jboss.shrinkwrap.resolver.api.Coordinate)4 Asset (org.jboss.shrinkwrap.api.asset.Asset)3 WARArchive (org.wildfly.swarm.undertow.WARArchive)3 PersistenceIT (eu.ggnet.dwoss.customer.itest.PersistenceIT)1 CustomerTest (eu.ggnet.dwoss.customer.test.CustomerTest)1 RedTapeHelper (eu.ggnet.dwoss.redtape.itest.eao.RedTapeHelper)1 PersistenceIT (eu.ggnet.dwoss.spec.itest.PersistenceIT)1 SpecTest (eu.ggnet.dwoss.spec.test.SpecTest)1 PersistenceIT (eu.ggnet.dwoss.stock.ee.itest.PersistenceIT)1 ValidationTest (eu.ggnet.dwoss.stock.ee.test.ValidationTest)1 BufferedReader (java.io.BufferedReader)1