Java Code Examples for org.jboss.shrinkwrap.api.spec.WebArchive#addPackage()
The following examples show how to use
org.jboss.shrinkwrap.api.spec.WebArchive#addPackage() .
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: JAXBIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Deployment public static WebArchive deployment() { final WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxb-integration-tests.war"); archive.addPackage(Customer.class.getPackage()); archive.addClasses(XMLUtils.class); archive.addAsResource(new StringAsset("Customer"), "org/wildfly/camel/test/jaxb/model/jaxb.index"); archive.addAsResource("jaxb/customer.xml", "customer.xml"); archive.setManifest(new Asset() { @Override public InputStream openStream() { ManifestBuilder builder = new ManifestBuilder(); builder.addManifestHeader("Dependencies", "org.jdom2"); return builder.openStream(); } }); return archive; }
Example 2
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 3
Source File: ArchiveProvider.java From gazpachoquest with GNU General Public License v3.0 | 5 votes |
public static WebArchive createWebArchive(String warName, Class... classes) { WebArchive archive = base(warName); // archive.addClasses(classes); // archive.addPackage(Package.getPackage("net.sf.gazpachoquest.questionnaires.resource")); archive.addPackage(Package.getPackage("net.sf.gazpachoquest.questionnaires")); // archive.addPackage(Package.getPackage("net.sf.gazpachoquest.questionnaires.resource")); // archive.addPackage(Package.getPackage("net.sf.gazpachoquest.questionnaires.views")); System.out.println(archive.toString(true)); return archive; }
Example 4
Source File: MyTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Deployment public static WebArchive createDeployment() { final WebArchive archive = ShrinkWrap.create(WebArchive.class, "camel-tests.war"); archive.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); archive.addPackage(MyRouteBuilder.class.getPackage()); return archive; }
Example 5
Source File: AtomIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Deployment public static WebArchive createdeployment() { final WebArchive archive = ShrinkWrap.create(WebArchive.class, "atom-test.war"); archive.addAsWebInfResource(new StringAsset(""), "beans.xml"); archive.addPackage(AtomFeed.class.getPackage()); return archive; }
Example 6
Source File: Olingo2IntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Deployment(testable = false, order = 1, name = "olingo-server.war") public static WebArchive createOlingoServerDeployment() { final WebArchive archive = ShrinkWrap.create(WebArchive.class, "olingo-server.war"); archive.addPackage(Olingo2TestServlet.class.getPackage()); archive.setManifest(() -> { ManifestBuilder builder = new ManifestBuilder(); builder.addManifestHeader("Dependencies", "org.apache.cxf.ext,org.apache.olingo2"); return builder.openStream(); }); return archive; }
Example 7
Source File: ConnectorWithApplicationResourcesInWarTest.java From tomee with Apache License 2.0 | 5 votes |
@Deployment(testable = false) public static WebArchive createDeployment() { final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class); webAppDescriptor.version("3.0"); final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war"); webArchive.addPackage("org.superbiz.connector.api"); webArchive.addPackage("org.superbiz.connector.adapter"); webArchive.addPackage("org.superbiz.application"); webArchive.addAsWebInfResource(ConnectorWithApplicationResourcesInEarTest.class.getResource("/connector/resources.xml"), "resources.xml"); webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString())); System.out.println("Webapp:\n" + webArchive.toString(true)); return webArchive; }
Example 8
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 9
Source File: EndPointsTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Deployment public static WebArchive getDeployment() { TestContext context = new TestContext().setWebXmlFile("endpoints-web.xml"); WebArchive war = getDefaultDeployment(context); war.addPackage(TestEndPoint.class.getPackage()); return war; }
Example 10
Source File: TransformerTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Deployment public static WebArchive getDeployment() { TestContext context = new TestContext().setWebXmlFile("endpoints-web.xml"); WebArchive war = getDefaultDeployment(context); war.addPackage(TransformerEndPoint.class.getPackage()); return war; }
Example 11
Source File: ObjectifyBenchmarkTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Deployment public static WebArchive getDeployment() { TestContext context = new TestContext().setUseSystemProperties(true).setCompatibilityProperties(TCK_PROPERTIES); WebArchive war = getTckDeployment(context); war.addPackage(Data.class.getPackage()); LibUtils libUtils = new LibUtils(); libUtils.addLibrary(war, "com.googlecode.objectify", "objectify"); libUtils.addLibrary(war, "com.google.guava", "guava"); return war; }
Example 12
Source File: URLFetchTestBase.java From appengine-tck with Apache License 2.0 | 5 votes |
@Deployment public static Archive getDeployment() { TestContext context = new TestContext(); context.setWebXmlFile("uf-web.xml"); WebArchive war = getTckDeployment(context); war.addClasses(URLFetchTestBase.class); war.addPackage(FetchServlet.class.getPackage()); war.add(new StringAsset("<html><body>Google AppEngine TCK</body></html>"), "index.html"); return war; }
Example 13
Source File: AppIdentityTestBase.java From appengine-tck with Apache License 2.0 | 5 votes |
protected static WebArchive getDefaultDeployment() { TestContext context = new TestContext().setUseSystemProperties(true).setCompatibilityProperties(TCK_PROPERTIES); WebArchive war = getTckDeployment(context); war.addClass(AppIdentityTestBase.class); war.addPackage(EmailValidator.class.getPackage()); return war; }
Example 14
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 15
Source File: MapReduceTest.java From appengine-tck with Apache License 2.0 | 4 votes |
@Deployment public static WebArchive getDeployment() { WebArchive war = getDefaultDeployment(); war.addPackage(EntityCreator.class.getPackage()); return war; }
Example 16
Source File: EARTest.java From tomee with Apache License 2.0 | 4 votes |
@Deployment public static EnterpriseArchive createDeployment() { final JavaArchive apiJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-api.jar"); apiJar.addPackage("org.superbiz.connector.api"); System.out.println("API JAR:\n" + apiJar.toString(true)); final JavaArchive implJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-impl.jar"); implJar.addPackage("org.superbiz.connector.adapter"); System.out.println("IMPL JAR:\n" + implJar.toString(true)); final ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class,"connector-sample-ra.rar"); rar.addAsLibraries(implJar); final File raXml = Basedir.basedir("../connector-sample-rar/src/main/rar/META-INF/ra.xml"); rar.setResourceAdapterXML(raXml); System.out.println("RAR:\n" + rar.toString(true)); final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war"); webArchive.addPackage("org.superbiz.application"); final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class); webAppDescriptor.version("3.0"); final File resourcesXml = Basedir.basedir("../connector-sample-war/src/main/webapp/WEB-INF/resources.xml"); webArchive.addAsWebInfResource(resourcesXml); webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString())); webArchive.addAsWebInfResource(resourcesXml); webArchive.addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml"); System.out.println("Webapp:\n" + webArchive.toString(true)); final EnterpriseArchive enterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "connector-sample.ear"); enterpriseArchive.addAsLibraries(apiJar); enterpriseArchive.addAsModule(rar); enterpriseArchive.addAsModule(webArchive); ApplicationDescriptor applicationXml = Descriptors.create(ApplicationDescriptor.class); applicationXml.displayName("connector-sample-ear"); applicationXml.createModule() .getOrCreateWeb() .webUri("connector-sample-war.war") .contextRoot("/sample") .up().up() .createModule().connector("connector-sample-ra.rar") .up().libraryDirectory("lib"); enterpriseArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString())); System.out.println(enterpriseArchive.toString(true)); return enterpriseArchive; }
Example 17
Source File: DeployInWebAppsDirectoryTest.java From tomee with Apache License 2.0 | 4 votes |
public static EnterpriseArchive createDeployment() { final JavaArchive apiJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-api.jar"); apiJar.addPackage("org.superbiz.connector.api"); System.out.println("API JAR:\n" + apiJar.toString(true)); final JavaArchive implJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-impl.jar"); implJar.addPackage("org.superbiz.connector.adapter"); System.out.println("IMPL JAR:\n" + implJar.toString(true)); final ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class,"connector-sample-ra.rar"); rar.addAsLibraries(implJar); final File raXml = Basedir.basedir("../connector-sample-rar/src/main/rar/META-INF/ra.xml"); rar.setResourceAdapterXML(raXml); System.out.println("RAR:\n" + rar.toString(true)); final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war"); webArchive.addPackage("org.superbiz.application"); final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class); webAppDescriptor.version("3.0"); final File resourcesXml = Basedir.basedir("../connector-sample-war/src/main/webapp/WEB-INF/resources.xml"); webArchive.addAsWebInfResource(resourcesXml); webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString())); webArchive.addAsWebInfResource(resourcesXml); webArchive.addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml"); System.out.println("Webapp:\n" + webArchive.toString(true)); final EnterpriseArchive enterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "connector-sample.ear"); enterpriseArchive.addAsLibraries(apiJar); enterpriseArchive.addAsModule(rar); enterpriseArchive.addAsModule(webArchive); ApplicationDescriptor applicationXml = Descriptors.create(ApplicationDescriptor.class); applicationXml.displayName("connector-sample-ear"); applicationXml.createModule() .getOrCreateWeb() .webUri("connector-sample-war.war") .contextRoot("/sample") .up().up() .createModule().connector("connector-sample-ra.rar") .up().libraryDirectory("lib"); enterpriseArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString())); System.out.println(enterpriseArchive.toString(true)); return enterpriseArchive; }
Example 18
Source File: ConnectorWithApplicationResourcesInEarTest.java From tomee with Apache License 2.0 | 4 votes |
@Deployment public static EnterpriseArchive createDeployment() { final JavaArchive apiJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-api.jar"); apiJar.addPackage("org.superbiz.connector.api"); System.out.println("API JAR:\n" + apiJar.toString(true)); final JavaArchive implJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-impl.jar"); implJar.addPackage("org.superbiz.connector.adapter"); System.out.println("IMPL JAR:\n" + implJar.toString(true)); final ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class,"connector-sample-ra.rar"); rar.addAsLibraries(implJar); rar.setResourceAdapterXML(ConnectorWithApplicationResourcesInEarTest.class.getResource("/connector/ra.xml")); System.out.println("RAR:\n" + rar.toString(true)); final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war"); webArchive.addPackage("org.superbiz.application"); final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class); webAppDescriptor.version("3.0"); webArchive.addAsWebInfResource(ConnectorWithApplicationResourcesInEarTest.class.getResource("/connector/resources.xml"), "resources.xml"); webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString())); System.out.println("Webapp:\n" + webArchive.toString(true)); final EnterpriseArchive enterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "connector-sample.ear"); enterpriseArchive.addAsLibraries(apiJar); enterpriseArchive.addAsModule(rar); enterpriseArchive.addAsModule(webArchive); ApplicationDescriptor applicationXml = Descriptors.create(ApplicationDescriptor.class); applicationXml.displayName("connector-sample-ear"); applicationXml.createModule() .getOrCreateWeb() .webUri("connector-sample-war.war") .contextRoot("/sample") .up().up() .createModule().connector("connector-sample-ra.rar") .up().libraryDirectory("lib"); enterpriseArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString())); System.out.println(enterpriseArchive.toString(true)); return enterpriseArchive; }
Example 19
Source File: TestBase.java From appengine-tck with Apache License 2.0 | 4 votes |
protected static WebArchive getTckDeployment(TestContext context) { enhanceTestContext(context); final WebArchive war; String archiveName = context.getArchiveName(); if (archiveName != null) { if (archiveName.endsWith(".war") == false) archiveName += ".war"; war = ShrinkWrap.create(WebArchive.class, archiveName); } else { war = ShrinkWrap.create(WebArchive.class); } // this package war.addPackage(TestBase.class.getPackage()); // categories war.addPackage(IgnoreMultisuite.class.getPackage()); // events war.addPackage(TestLifecycles.class.getPackage()); // temp data war.addPackage(TempData.class.getPackage()); // mail war.addPackage(EmailAddressFormatter.class.getPackage()); // env war.addClass(Environment.class); // web.xml if (context.getWebXmlFile() != null) { war.setWebXML(context.getWebXmlFile()); } else { war.setWebXML(new StringAsset(context.getWebXmlContent())); } // context-root if (context.getContextRoot() != null) { war.addAsWebInfResource(context.getContextRoot().getDescriptor()); } // appengine-web.xml String appengineWebXmlFile = "appengine-web.xml"; if (context.getAppEngineWebXmlFile() != null) { appengineWebXmlFile = context.getAppEngineWebXmlFile(); } Asset gaeWebXml = new ClassLoaderAsset(appengineWebXmlFile); war.addAsWebInfResource(rewriteAsset(gaeWebXml), "appengine-web.xml"); if (context.hasCallbacks()) { war.addAsWebInfResource("META-INF/datastorecallbacks.xml", "classes/META-INF/datastorecallbacks.xml"); } if (context.getCompatibilityProperties() != null && (context.getProperties().isEmpty() == false || context.isUseSystemProperties())) { Properties properties = new Properties(); if (context.isUseSystemProperties()) { properties.putAll(System.getProperties()); } properties.putAll(context.getProperties()); final StringWriter writer = new StringWriter(); try { properties.store(writer, "GAE TCK testing!"); } catch (IOException e) { throw new RuntimeException("Cannot write compatibility properties.", e); } final StringAsset asset = new StringAsset(writer.toString()); war.addAsWebInfResource(asset, "classes/" + context.getCompatibilityProperties()); } if (context.isIgnoreTimestamp() == false) { war.addAsWebInfResource(new StringAsset(String.valueOf(context.getTimestamp())), "classes/" + TIMESTAMP_TXT); } return war; }
Example 20
Source File: Http4IntegrationTest.java From wildfly-camel with Apache License 2.0 | 4 votes |
@Deployment public static WebArchive createDeployment() { final WebArchive archive = ShrinkWrap.create(WebArchive.class, "simple.war"); archive.addPackage(MyServlet.class.getPackage()); return archive; }