Java Code Examples for org.jboss.shrinkwrap.api.spec.WebArchive#addAsLibraries()
The following examples show how to use
org.jboss.shrinkwrap.api.spec.WebArchive#addAsLibraries() .
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: ArchiveProcessor.java From smallrye-metrics with Apache License 2.0 | 7 votes |
@Override public void process(TestDeployment testDeployment, Archive<?> protocolArchive) { WebArchive war = (WebArchive) protocolArchive; war.addAsWebInfResource("WEB-INF/jboss-web.xml", "jboss-web.xml"); String[] deps = { "io.smallrye:smallrye-config", "io.smallrye:smallrye-metrics", "io.smallrye:smallrye-metrics-testsuite-common", "org.eclipse.microprofile.metrics:microprofile-metrics-api", "org.jboss.weld.servlet:weld-servlet-core" }; File[] dependencies = Maven.resolver().loadPomFromFile(new File("pom.xml")).resolve(deps).withTransitivity().asFile(); war.addAsLibraries(dependencies); war.addClass(SmallRyeBeanArchiveHandler.class); war.addClass(MetricsHttpServlet.class); war.addClass(MetricsInitializer.class); war.addAsResource("io/smallrye/metrics/base-metrics.properties", "/io/smallrye/metrics/base-metrics.properties"); war.addAsServiceProvider(BeanArchiveHandler.class, SmallRyeBeanArchiveHandler.class); war.addAsServiceProvider(Extension.class, ConfigExtension.class); war.addAsServiceProvider(ConfigProviderResolver.class, SmallRyeConfigProviderResolver.class); }
Example 2
Source File: IntegrationTestUtils.java From trimou with Apache License 2.0 | 6 votes |
public static WebArchive createTestArchiveBase() { WebArchive testArchive = ShrinkWrap.create(WebArchive.class); // Suppressing implicit bean archives without beans.xml testArchive.addAsManifestResource(CDI11_JBOSSALL_WORKAROUND_ASSET, "jboss-all.xml"); // Add Weld servlet for embedded containers if (isServletContainer()) { testArchive.addAsLibraries(resolve("org.jboss.weld.servlet:weld-servlet")); testArchive.setWebXML(new StringAsset(Descriptors .create(WebAppDescriptor.class) .version(WebAppVersionType._3_0) .createListener() .listenerClass( "org.jboss.weld.environment.servlet.Listener").up() .exportAsString())); } return testArchive; }
Example 3
Source File: SmallRyeHealthArchiveProcessor.java From smallrye-health with Apache License 2.0 | 6 votes |
@Override public void process(Archive<?> applicationArchive, TestClass testClass) { if (applicationArchive instanceof WebArchive) { WebArchive testDeployment = (WebArchive) applicationArchive; // Register SmallRyeBeanArchiveHandler using the ServiceLoader mechanism testDeployment.addClass(SmallRyeBeanArchiveHandler.class); testDeployment.addAsServiceProvider(BeanArchiveHandler.class, SmallRyeBeanArchiveHandler.class); String[] deps = { "io.smallrye:smallrye-health", "io.smallrye.config:smallrye-config", "io.smallrye:smallrye-health-tck", "org.eclipse.microprofile.health:microprofile-health-tck", "org.jboss.weld.servlet:weld-servlet-core" }; File[] dependencies = Maven.resolver().loadPomFromFile(new File("pom.xml")).resolve(deps).withTransitivity() .asFile(); testDeployment.addAsLibraries(dependencies); } }
Example 4
Source File: SmallRyeHealthArchiveProcessor.java From smallrye-health with Apache License 2.0 | 6 votes |
@Override public void process(Archive<?> applicationArchive, TestClass testClass) { if (applicationArchive instanceof WebArchive) { WebArchive testDeployment = (WebArchive) applicationArchive; // Register SmallRyeBeanArchiveHandler using the ServiceLoader mechanism testDeployment.addClass(SmallRyeBeanArchiveHandler.class); testDeployment.addAsServiceProvider(BeanArchiveHandler.class, SmallRyeBeanArchiveHandler.class); String[] deps = { "io.smallrye:smallrye-health", "io.smallrye.config:smallrye-config", "io.smallrye:smallrye-health-tck", "org.eclipse.microprofile.health:microprofile-health-tck", "org.jboss.weld.servlet:weld-servlet-core" }; File[] dependencies = Maven.resolver().loadPomFromFile(new File("pom.xml")).resolve(deps).withTransitivity() .asFile(); testDeployment.addAsLibraries(dependencies); } }
Example 5
Source File: ExampleJUnitTransformer.java From appengine-tck with Apache License 2.0 | 6 votes |
public static WebArchive buildArchive(String clazz) { WebArchive war = ArquillianJUnitTransformer.createWar(); ArquillianJUnitTransformer.addClasses(war, clazz, ExampleJUnitTransformer.class.getClassLoader()); // Your test suite is most likely built separately from the TCK. You would include all the // dependencies in the pom.xml, and then declare the packages and classes here. war.addPackage("com.google.appengine.sometests"); // Include this even though you may not have an appengine-web.xml for your tests. war.addAsWebInfResource("appengine-web.xml"); final PomEquippedResolveStage resolver = getResolver("pom.xml"); // Necessary to run under App Engine. war.addAsLibraries(resolve(resolver, "com.google.appengine:appengine-api-1.0-sdk")); // GAE testing lib war.addAsLibraries(resolve(resolver, "com.google.appengine:appengine-testing")); // TCK Internals necessary for any tests to run under the TCK. war.addAsLibraries(resolve(resolver, "com.google.appengine.tck:appengine-tck-transformers")); // cleanup dep war.addAsLibraries(resolve(resolver, "com.google.appengine.tck:appengine-tck-base")); // lifecycle dep return war; }
Example 6
Source File: Deployments.java From arquillian-container-chameleon with Apache License 2.0 | 6 votes |
static void enrichTomcatWithCdi(WebArchive archive) { String contextXml = "<Context>\n" + " <Resource name=\"BeanManager\" \n" + " auth=\"Container\"\n" + " type=\"javax.enterprise.inject.spi.BeanManager\"\n" + " factory=\"org.jboss.weld.resources.ManagerObjectFactory\"/>\n" + "</Context>\n"; String webXml = "<web-app version=\"3.0\">\n" + "<listener>\n" + " <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>\n" + " </listener>" + " <resource-env-ref>\n" + " <resource-env-ref-name>BeanManager</resource-env-ref-name>\n" + " <resource-env-ref-type>\n" + " javax.enterprise.inject.spi.BeanManager\n" + " </resource-env-ref-type>\n" + " </resource-env-ref>\n" + "</web-app>"; archive.addAsLibraries(WELD_SERVLET); archive.addAsManifestResource(new StringAsset(contextXml), "context.xml"); archive.setWebXML(new StringAsset(webXml)); }
Example 7
Source File: SmallRyeGraphQLArchiveProcessor.java From smallrye-graphql with Apache License 2.0 | 5 votes |
@Override public void process(Archive<?> applicationArchive, TestClass testClass) { if (applicationArchive instanceof WebArchive) { LOG.info("\n ================================================================================" + "\n Testing [" + testClass.getName() + "]" + "\n ================================================================================" + "\n"); WebArchive testDeployment = (WebArchive) applicationArchive; final File[] dependencies = Maven.resolver() .loadPomFromFile("pom.xml") .resolve("io.smallrye:smallrye-graphql-servlet") .withTransitivity() .asFile(); // Make sure it's unique Set<File> dependenciesSet = new LinkedHashSet<>(Arrays.asList(dependencies)); testDeployment.addAsLibraries(dependenciesSet.toArray(new File[] {})); // MicroProfile properties testDeployment.addAsResource( SmallRyeGraphQLArchiveProcessor.class.getClassLoader() .getResource("META-INF/microprofile-config.properties"), "META-INF/microprofile-config.properties"); // Add our own test app testDeployment.addPackage(ProfileGraphQLApi.class.getPackage()); testDeployment.addPackage(AdditionalScalarsApi.class.getPackage()); testDeployment.addPackage(AsyncApi.class.getPackage()); testDeployment.addPackage(ErrorApi.class.getPackage()); } }
Example 8
Source File: ResteasyTomcatServerBootstrap.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override protected void addRuntimeSpecificLibraries(WebArchive wa, PomEquippedResolveStage resolver) { // inject rest easy version to differentiate between resteasy and wildfly-compatibility profile String restEasyVersion = System.getProperty("restEasyVersion"); wa.addAsLibraries(resolver.addDependencies( MavenDependencies.createDependency("org.jboss.resteasy:resteasy-jaxrs:" + restEasyVersion, ScopeType.TEST, false, MavenDependencies.createExclusion("org.apache.httpcomponents:httpclient"))).resolve() .withTransitivity().asFile()); }
Example 9
Source File: FtpIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Deployment public static WebArchive createdeployment() throws IOException { File[] libraryDependencies = Maven.configureResolverViaPlugin(). resolve("org.apache.ftpserver:ftpserver-core"). withTransitivity(). asFile(); final WebArchive archive = ShrinkWrap.create(WebArchive.class, "camel-ftp-tests.war"); archive.addAsResource(new StringAsset(System.getProperty("basedir")), FILE_BASEDIR); archive.addClasses(AvailablePortFinder.class, TestUtils.class, FileUtils.class); archive.addAsLibraries(libraryDependencies); return archive; }
Example 10
Source File: AppEngineDataNucleusTransformer.java From appengine-tck with Apache License 2.0 | 5 votes |
public static WebArchive buildArchive(String clazz) { WebArchive war = createWar(); addClasses(war, clazz, AppEngineDataNucleusTransformer.class.getClassLoader()); war.addPackage("com.google.appengine.datanucleus"); war.addClass("com.google.appengine.datanucleus.jpa.JPATestCase$EntityManagerFactoryName"); war.addClass("com.google.appengine.datanucleus.jdo.JDOTestCase$PersistenceManagerFactoryName"); war.addPackage("com.google.appengine.datanucleus.query"); war.addPackage("com.google.appengine.datanucleus.test.jdo"); war.addPackage("com.google.appengine.datanucleus.test.jpa"); war.setWebXML(new org.jboss.shrinkwrap.api.asset.StringAsset("<web/>")); war.addAsWebInfResource("appengine-web.xml"); war.addAsWebInfResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml"); war.addAsWebInfResource("META-INF/jdoconfig.xml", "classes/META-INF/jdoconfig.xml"); war.addAsResource(new StringAsset("ignore.logging=true\n"), "capedwarf-compatibility.properties"); final PomEquippedResolveStage resolver = getResolver("pom.xml"); // GAE DN libs war.addAsLibraries(resolve(resolver, "com.google.appengine.orm:datanucleus-appengine")); war.addAsLibraries(resolve(resolver, "com.google.appengine:appengine-api-1.0-sdk")); war.addAsLibraries(resolve(resolver, "com.google.appengine:appengine-testing")); war.addAsLibraries(resolve(resolver, "com.google.appengine:appengine-api-stubs")); war.addAsLibraries(resolve(resolver, "org.datanucleus:datanucleus-core")); war.addAsLibraries(resolve(resolver, "org.datanucleus:datanucleus-api-jdo")); war.addAsLibraries(resolve(resolver, "org.datanucleus:datanucleus-api-jpa")); war.addAsLibraries(resolve(resolver, "javax.jdo:jdo-api")); war.addAsLibraries(resolve(resolver, "org.apache.geronimo.specs:geronimo-jpa_2.0_spec")); war.addAsLibraries(resolve(resolver, "org.easymock:easymock")); war.addAsLibraries(resolve(resolver, "org.easymock:easymockclassextension")); // TCK Internals war.addAsLibraries(resolve(resolver, "com.google.appengine.tck:appengine-tck-transformers")); // cleanup dep war.addAsLibraries(resolve(resolver, "com.google.appengine.tck:appengine-tck-base")); // lifecycle dep return war; }
Example 11
Source File: Deployments.java From launchpad-missioncontrol with Apache License 2.0 | 5 votes |
/** * Test hooks so we can do some cleanupCreatedProject * * @return */ static WebArchive getTestDeployment() { final WebArchive archive = ShrinkWrap.create(WebArchive.class, "test.war") .addPackages( true, OpenShiftServiceSpi.class.getPackage(), OpenShiftProjectImpl.class.getPackage(), OpenShiftServiceFactory.class.getPackage(), GitHubServiceSpi.class.getPackage(), KohsukeGitHubServiceImpl.class.getPackage(), GitHubServiceFactory.class.getPackage()) .addPackage(TestSupport.class.getPackage()); final File[] depsOpenshift = Resolvers.use(MavenResolverSystem.class). loadPomFromFile("../services/openshift-service-impl/pom.xml"). importRuntimeAndTestDependencies(). resolve(). withTransitivity(). asFile(); final File[] depsGithub = Resolvers.use(MavenResolverSystem.class). loadPomFromFile("../services/github-service-impl/pom.xml"). importRuntimeAndTestDependencies(). resolve(). withTransitivity(). asFile(); final File[] ourTestDeps = Resolvers.use(MavenResolverSystem.class). loadPomFromFile("pom.xml"). importTestDependencies(). resolve(). withTransitivity(). asFile(); archive.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); archive.addAsLibraries(depsOpenshift); archive.addAsLibraries(depsGithub); archive.addAsLibraries(ourTestDeps); return archive; }
Example 12
Source File: DeploymentIndexTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test public void testIndexBuilt() { WebArchive war = ShrinkWrap.create(WebArchive.class); war.addClass(Foo.class); JavaArchive lib1 = ShrinkWrap.create(JavaArchive.class).addClass(Bar.class); war.addAsLibraries(lib1); IndexView index = new DeploymentProducer().createDeploymentIndex(war); assertContains(index, Foo.class); assertDoesNotContain(index, Baz.class); assertContains(index, Bar.class); assertDoesNotContain(index, Delta.class); }
Example 13
Source File: JaxRsMetricsActivatingProcessor.java From smallrye-metrics with Apache License 2.0 | 5 votes |
@Override public void process(TestDeployment testDeployment, Archive<?> archive) { WebArchive war = (WebArchive) archive; String[] deps = { "io.smallrye:smallrye-config", "io.smallrye:smallrye-metrics", "io.smallrye:smallrye-metrics-testsuite-common", "org.eclipse.microprofile.metrics:microprofile-metrics-api", "org.eclipse.microprofile.config:microprofile-config-api" }; File[] dependencies = Maven.resolver().loadPomFromFile(new File("pom.xml")).resolve(deps).withTransitivity().asFile(); war.addAsLibraries(dependencies); war.addClass(MetricsHttpServlet.class); war.addClass(JaxRsMetricsFilter.class); war.addClass(JaxRsMetricsServletFilter.class); // change application context root to '/' because the TCK assumes that the metrics // will be available at '/metrics', and in our case the metrics servlet is located // within the application itself, we don't use WildFly's built-in support for metrics war.addAsWebInfResource("WEB-INF/jboss-web.xml", "jboss-web.xml"); // activate the servlet filter war.setWebXML("WEB-INF/web.xml"); // activate the JAX-RS request filter war.addAsServiceProvider(Providers.class.getName(), JaxRsMetricsFilter.class.getName()); // exclude built-in Metrics and Config from WildFly war.addAsManifestResource("META-INF/jboss-deployment-structure.xml", "jboss-deployment-structure.xml"); }
Example 14
Source File: SmallRyeJWTArchiveProcessor.java From smallrye-jwt with Apache License 2.0 | 5 votes |
@Override public void process(Archive<?> applicationArchive, TestClass testClass) { if (applicationArchive instanceof WebArchive) { WebArchive war = (WebArchive) applicationArchive; war.addClass(OptionalAwareSmallRyeJWTAuthCDIExtension.class); war.addClass(SmallRyeJWTAuthJaxRsFeature.class); war.addAsServiceProvider(Extension.class, OptionalAwareSmallRyeJWTAuthCDIExtension.class); if (!war.contains("META-INF/microprofile-config.properties")) { war.addAsManifestResource("microprofile-config-local.properties", "microprofile-config.properties"); } // A few tests require the apps to be deployed in the root. Check PublicKeyAsJWKLocationURLTest and PublicKeyAsPEMLocationURLTest // Both tests set the public key location url to be in root. war.addAsWebInfResource("jboss-web.xml"); String[] deps = { "io.smallrye:smallrye-jwt", "io.smallrye.config:smallrye-config", "org.jboss.resteasy:resteasy-servlet-initializer", "org.jboss.resteasy:resteasy-jaxrs", "org.jboss.resteasy:resteasy-client", "org.jboss.resteasy:resteasy-cdi", "org.jboss.resteasy:resteasy-json-binding-provider", "org.jboss.weld.servlet:weld-servlet-core" }; File[] dependencies = Maven.resolver() .loadPomFromFile(new File("pom.xml")) .resolve(deps) .withTransitivity() .asFile(); war.addAsLibraries(dependencies); } }
Example 15
Source File: JerseyTomcatServerBootstrap.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected void addRuntimeSpecificLibraries(WebArchive wa, PomEquippedResolveStage resolver) { wa.addAsLibraries(resolver.resolve("com.sun.jersey:jersey-servlet:1.17.1").withTransitivity().asFile()); }
Example 16
Source File: TestContainer.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public static void addSpinJacksonJsonDataFormat(WebArchive webArchive) { webArchive.addAsLibraries(DeploymentHelper.getSpinJacksonJsonDataFormatForServer("tomcat")); }
Example 17
Source File: TestContainer.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public static void addJodaTimeJacksonModule(WebArchive webArchive) { webArchive.addAsLibraries(DeploymentHelper.getJodaTimeModuleForServer("jboss")); }
Example 18
Source File: CXFTomcatServerBootstrap.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected void addRuntimeSpecificLibraries(WebArchive wa, PomEquippedResolveStage resolver) { wa.addAsLibraries(resolver.resolve("org.apache.cxf:cxf-rt-frontend-jaxrs:3.0.3").withTransitivity().asFile()); }
Example 19
Source File: TestContainer.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public static void addJodaTimeJacksonModule(WebArchive webArchive) { webArchive.addAsLibraries(DeploymentHelper.getJodaTimeModuleForServer("jboss")); }
Example 20
Source File: WinkTomcatServerBootstrap.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override protected void addRuntimeSpecificLibraries(WebArchive wa, PomEquippedResolveStage resolver) { wa.addAsLibraries(resolver.resolve("org.apache.wink:wink-server:1.1.1-incubating").withTransitivity().asFile()); }