Java Code Examples for org.jboss.shrinkwrap.api.spec.WebArchive

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project agorava-core, under directory /agorava-core-impl-cdi/src/test/java/org/agorava/core/cdi/.

Source file: BadOAuthServiceImplTest.java

  23 
vote

@Deployment(testable=false) public static Archive<?> createTestArchive() throws FileNotFoundException {
  WebArchive ret=ShrinkWrap.create(WebArchive.class,"test.war").addPackages(true,"org.agorava").addAsLibraries(new File("../agorava-core-api/target/agorava-core-api.jar"));
  System.out.println(System.getProperty("arquillian"));
  if (("weld-ee-embedded-1.1".equals(System.getProperty("arquillian")) || System.getProperty("arquillian") == null)) {
  }
 else {
    ret.addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class).loadMetadataFromPom("pom.xml").artifact("org.scribe:scribe").artifact("org.apache.commons:commons-lang3").artifact("org.codehaus.jackson:jackson-mapper-asl").artifact("com.google.guava:guava").resolveAsFiles());
  }
  return ret;
}
 

Example 2

From project agorava-twitter, under directory /agorava-twitter-cdi/src/test/java/org/agorava/twitter/cdi/test/.

Source file: TwitterTest.java

  22 
vote

@Deployment public static Archive<?> createTestArchive() throws FileNotFoundException {
  WebArchive ret=ShrinkWrap.create(WebArchive.class,"test.war").addPackages(true,"org.agorava").addClass(TwitterServiceProducer.class).addAsLibraries(new File("../agorava-twitter-api/target/agorava-twitter-api.jar"));
  System.out.println(System.getProperty("arquillian"));
  if (("weld-ee-embedded-1.1".equals(System.getProperty("arquillian")) || System.getProperty("arquillian") == null)) {
  }
 else {
    ret.addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class).loadMetadataFromPom("pom.xml").artifact("org.jboss.solder:solder-impl").artifact("org.scribe:scribe").artifact("org.apache.commons:commons-lang3").artifact("org.codehaus.jackson:jackson-mapper-asl").artifact("com.google.guava:guava").resolveAsFiles());
  }
  return ret;
}
 

Example 3

From project arquillian-container-gae, under directory /gae-embedded/src/main/java/org/jboss/arquillian/container/appengine/embedded/.

Source file: AppEngineSetup.java

  22 
vote

/** 
 * Prepare AppEngine libs.
 * @param archive the current archive
 */
static void prepare(Archive archive){
  File[] files=getFiles();
  WebArchive webArchive=archive.as(WebArchive.class);
  webArchive.addAsLibraries(files);
  webArchive.addClass(AppEngineHack.class);
  log.info(webArchive.toString(true));
}
 

Example 4

From project arquillian-container-glassfish, under directory /glassfish-managed-3.1/src/test/java/org/jboss/arquillian/container/glassfish/managed_3_1/.

Source file: GlassFishManagedDeployEarTest.java

  22 
vote

@Deployment(testable=false) public static Archive<?> getTestArchive(){
  final WebArchive war=ShrinkWrap.create(WebArchive.class,"test.war").addClasses(GreeterServlet.class);
  final JavaArchive ejb=ShrinkWrap.create(JavaArchive.class,"test.jar").addClasses(Greeter.class);
  final EnterpriseArchive ear=ShrinkWrap.create(EnterpriseArchive.class,"test.ear").setApplicationXML("application.xml").addAsModule(war).addAsModule(ejb);
  return ear;
}
 

Example 5

From project arquillian-core, under directory /protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/v_2_5/.

Source file: ServletProtocolDeploymentPackagerTestCase.java

  22 
vote

@Test public void shouldHandleEnterpriseArchiveWithWebArchive() throws Exception {
  WebArchive applicationWar=ShrinkWrap.create(WebArchive.class,"applicationArchive.war");
  Archive<?> archive=new ServletProtocolDeploymentPackager().generateDeployment(new TestDeployment(ShrinkWrap.create(EnterpriseArchive.class,"applicationArchive.ear").addAsModule(applicationWar),createAuxiliaryArchives()),processors());
  Assert.assertFalse("Verify that the auxiliaryArchives was not added",archive.contains(ArchivePaths.create("arquillian-protocol.war")));
  Assert.assertTrue("Verify that the auxiliaryArchives are placed in /lib",archive.contains(ArchivePaths.create("/lib/auxiliaryArchive1.jar")));
  Assert.assertTrue("Verify that the auxiliaryArchives are placed in /lib",archive.contains(ArchivePaths.create("/lib/auxiliaryArchive2.jar")));
  String webXmlContent=TestUtil.convertToString(applicationWar.get("WEB-INF/web.xml").getAsset().openStream());
  Assert.assertTrue("verify that the ServletTestRunner servlet was added to the web.xml of the existing web archive",webXmlContent.contains(ServletTestRunner.class.getName()));
  Assert.assertTrue("Verify protocol Processor SPI was called",DummyProcessor.wasCalled);
}
 

Example 6

From project arquillian-extension-jrebel, under directory /int-test/src/test/java/org/jboss/arquillian/extension/jrebel/.

Source file: EarDeploymentTestCase.java

  22 
vote

@Deployment public static EnterpriseArchive createEar(){
  final JavaArchive ejbJar=Packager.ejbJar();
  final WebArchive webArchive=Packager.warWithInjectableArtifact();
  webArchive.addClass(EarDeploymentTestCase.class);
  return ShrinkWrap.create(EnterpriseArchive.class,"jrebel-test.ear").addAsModule(ejbJar).addAsModule(webArchive);
}
 

Example 7

From project arquillian-extension-persistence, under directory /impl/src/test/java/org/jboss/arquillian/persistence/core/configuration/.

Source file: PersistenceDescriptorArchiveExtractorTest.java

  22 
vote

@Test public void should_extract_persistence_descriptor_from_war() throws Exception {
  final WebArchive war=ShrinkWrap.create(WebArchive.class,"test.war").addPackages(true,"org.fest").addAsWebInfResource(EmptyAsset.INSTANCE,"beans.xml").addAsResource("persistence-non-jta.xml","META-INF/persistence.xml");
  InputStream inputStream=persistenceDescriptorArchiveExtractor.getAsStream(war);
  String dataSourceName=persistenceDescriptorParser.obtainDataSourceName(inputStream);
  assertThat(dataSourceName).isEqualTo("java:app/datasources/postgresql_ds_non_jta");
}
 

Example 8

From project arquillian-extension-spring, under directory /arquillian-service-deployer-spring-common/src/test/java/org/jboss/arquillian/spring/deployer/client/.

Source file: SpringProtocolArchiveProcessorTestCase.java

  22 
vote

/** 
 * <p>Tests the  {@link org.jboss.arquillian.spring.deployer.client.SpringProtocolArchiveProcessor#process(TestDeployment,Archive)} method when the test deployment is a JAR archive.</p>
 * @throws Exception if any error occurs
 */
@Test public void testProcessJarAutoPackageTrue() throws Exception {
  injectConfiguration(true);
  JavaArchive deploymentArchive=ShrinkWrap.create(JavaArchive.class,"deployment.jar");
  JavaArchive auxiliaryArchive=ShrinkWrap.create(JavaArchive.class,"auxiliary.jar");
  WebArchive protocolArchive=ShrinkWrap.create(WebArchive.class,"protocol.war");
  List<Archive<?>> auxiliaryArchives=new ArrayList<Archive<?>>();
  auxiliaryArchives.add(auxiliaryArchive);
  TestDeployment testDeployment=new TestDeployment(null,deploymentArchive,auxiliaryArchives);
  instance.process(testDeployment,protocolArchive);
  assertDependencies(protocolArchive,true);
}
 

Example 9

From project arquillian-showcase, under directory /cdi/src/test/java/com/acme/cdi/payment/.

Source file: SynchronousPaymentProcessorTestCase.java

  22 
vote

@Deployment public static Archive<?> createDeployment(){
  BeansDescriptor beansXml=Descriptors.create(BeansDescriptor.class);
  beansXml.createAlternatives().clazz(MockPaymentProcessor.class.getName());
  JavaArchive jar=ShrinkWrap.create(JavaArchive.class).addAsManifestResource(new StringAsset(beansXml.exportAsString()),beansXml.getDescriptorName()).addPackage(Synchronous.class.getPackage());
  WebArchive war=ShrinkWrap.create(WebArchive.class).addAsWebInfResource(new StringAsset(beansXml.exportAsString()),beansXml.getDescriptorName()).addPackage(Synchronous.class.getPackage());
  return war;
}
 

Example 10

From project arquillian_deprecated, under directory /containers/glassfish-remote-3/src/test/java/org/jboss/arquillian/container/glassfish/remote_3/.

Source file: GlassFishJSR88RemoteContainerEARTestCase.java

  22 
vote

/** 
 * Deployment for the test
 * @return
 */
@Deployment public static Archive<?> getTestArchive(){
  final WebArchive war=ShrinkWrap.create(WebArchive.class,"test.war").addClasses(GreeterServlet.class);
  final JavaArchive ejb=ShrinkWrap.create(JavaArchive.class,"test.jar").addClass(Greeter.class);
  final EnterpriseArchive ear=ShrinkWrap.create(EnterpriseArchive.class,"test.ear").setApplicationXML("application.xml").addModule(war).addModule(ejb);
  log.info(ear.toString(true));
  return ear;
}
 

Example 11

From project beanvalidation-tck, under directory /tests/src/main/java/org/hibernate/beanvalidation/tck/util/shrinkwrap/.

Source file: WebArchiveBuilder.java

  22 
vote

@Override protected WebArchive buildInternal(){
  WebArchive webArchive;
  if (getName() == null) {
    webArchive=ShrinkWrap.create(WebArchive.class);
  }
 else {
    webArchive=ShrinkWrap.create(WebArchive.class,getName());
  }
  processPackages(webArchive);
  processClasses(webArchive);
  processResources(webArchive);
  webArchive.setWebXML(new StringAsset(Descriptors.create(WebAppDescriptor.class).exportAsString()));
  return webArchive;
}
 

Example 12

From project capedwarf-blue, under directory /arquillian/src/main/java/org.jboss.capedwarf.arquillian/.

Source file: GaeApplicationArchiveProcessor.java

  22 
vote

public void process(Archive<?> archive,TestClass testClass){
  final String className=testClass.getName();
  if (className.contains(".testsuite.") && className.contains("JPA"))   return;
  if (archive instanceof WebArchive) {
    WebArchive war=(WebArchive)archive;
    MavenDependencyResolver resolver=DependencyResolvers.use(MavenDependencyResolver.class).loadMetadataFromPom("pom.xml");
    war.addAsLibraries(resolver.artifact("com.google.appengine:appengine-api-1.0-sdk").resolveAsFiles());
  }
}
 

Example 13

From project cdi-arq-workshop, under directory /arquillian-showcase/extension-weld-servlet/src/main/java/org/jboss/arquillian/extension/cdi/.

Source file: AbstractWeldServletArchiveProcessor.java

  22 
vote

public void process(Archive<?> archive){
  if (archive instanceof WebArchive) {
    WebArchive war=(WebArchive)archive;
    if (!war.contains("WEB-INF/jetty-env.xml")) {
      war.addAsWebInfResource(getClass().getPackage(),"jetty-env.xml","jetty-env.xml");
    }
    if (!war.contains("META-INF/context.xml")) {
      war.addAsManifestResource(getClass().getPackage(),"context.xml","context.xml");
    }
  }
}
 

Example 14

From project conversation, under directory /spi/src/test/java/org/jboss/seam/conversation/test/.

Source file: SmokeBase.java

  22 
vote

protected static WebArchive deployment(WebArchive archive,String... args){
  archive.addPackage(SetupHttpSCCFilter.class.getPackage());
  archive.addAsLibrary(ShrinkWrap.create(JavaArchive.class,"seam-conversation-spi.jar").addPackage(SeamConversationContext.class.getPackage()).addPackage(AbstractHttpSeamConversationContext.class.getPackage()).addAsManifestResource(EmptyAsset.INSTANCE,"beans.xml"));
  WebArchive webArchive=TomcatDeployments.tomcatfy(archive,args);
  webArchive.add(new StringAsset("<html/>"),"index.html");
  System.err.println(webArchive.toString(true));
  return webArchive;
}
 

Example 15

From project core_4, under directory /impl/src/test/integration/org/richfaces/integration/.

Source file: CoreDeployment.java

  22 
vote

@Override public WebArchive getFinalArchive(){
  WebArchive finalArchive=super.getFinalArchive();
  finalArchive.addManifest();
  Asset manifest=finalArchive.get("META-INF/MANIFEST.MF").getAsset();
  finalArchive.addAsResource(manifest,"META-INF/MANIFEST.MF");
  finalArchive.addAsResource(testingModules,TESTING_MODULE);
  addMavenDependencies(finalArchive);
  return finalArchive;
}
 

Example 16

From project faces_1, under directory /testsuite/src/test/java/org/jboss/seam/faces/test/server/security/config/.

Source file: SeamFaces210Test.java

  22 
vote

@Deployment(name="SeamFaces210") @ShouldThrowException(Exception.class) public static Archive<?> createTestArchive(){
  final WebArchive testArchive=BaseArchive.baseWar("seamfaces_210.war",true);
  testArchive.addAsLibraries(BaseArchive.retrieveLibs("org.jboss.solder:solder-api","org.jboss.solder:solder-impl","org.jboss.solder:solder-logging"));
  testArchive.addPackages(true,ViewConfig.class.getPackage(),ViewConfigStoreImpl.class.getPackage(),ViewConfigEnum.class.getPackage()).addClasses(SecurityBindingType.class,RestrictAtPhase.class,PhaseIdType.class).addAsServiceProvider(Extension.class,ViewConfigExtension.class);
  return testArchive;
}
 

Example 17

From project jbosgi, under directory /testsuite/example/src/test/java/org/jboss/test/osgi/example/cdi/.

Source file: ManagedBeansTestCase.java

  22 
vote

@Deployment(name=SIMPLE_EAR,testable=false) public static Archive<?> getSimpleEar(){
  WebArchive war=ShrinkWrap.create(WebArchive.class,SIMPLE_WAR);
  war.addClasses(SimpleBeanServlet.class);
  JavaArchive jar=ShrinkWrap.create(JavaArchive.class,SIMPLE_CDI_JAR);
  jar.addClasses(SimpleManagedBean.class);
  jar.addAsManifestResource(EmptyAsset.INSTANCE,"beans.xml");
  EnterpriseArchive ear=ShrinkWrap.create(EnterpriseArchive.class,SIMPLE_EAR);
  ear.addAsModule(war);
  ear.addAsModule(jar);
  return ear;
}
 

Example 18

From project jbossportletbridge, under directory /testsuites/common/src/main/java/org/jboss/portletbridge/test/.

Source file: TestDeployment.java

  22 
vote

public static WebArchive createDeploymentWithAll(){
  WebArchive archive=createDeployment();
  addWebXml(archive);
  addFacesConfig(archive);
  addPortletXml(archive);
  return archive;
}
 

Example 19

From project jsfunit, under directory /examples-arquillian/hellojsf/src/test/java/org/jboss/jsfunit/example/hellojsf/.

Source file: Deployments.java

  22 
vote

private static WebArchive createBaseDeployment(){
  WebArchive war=ShrinkWrap.create(WebArchive.class).addPackage(Package.getPackage("org.jboss.jsfunit.example.hellojsf")).addAsWebInfResource(new File("src/main/webapp/WEB-INF/faces-config.xml"),"faces-config.xml").addAsWebInfResource(new File("src/main/webapp/WEB-INF/local-module-faces-config.xml"),"local-module-faces-config.xml").addAsWebInfResource(new File("src/main/webapp/WEB-INF/classes/users.properties"),"classes/users.properties").addAsWebInfResource(new File("src/main/webapp/WEB-INF/classes/roles.properties"),"classes/roles.properties");
  war.addAsWebInfResource(new File("src/main/webapp/WEB-INF/jboss-web.xml"),"jboss-web.xml");
  if (IS_JSF_1_2) {
    war.addAsWebResource(new File("src/main/webapp","index.jsp")).addAsWebResource(new File("src/main/webapp","finalgreeting.jsp")).addAsWebResource(new File("src/main/webapp","secured-page.jsp")).addAsWebResource(new File("src/main/webapp","NestedNamingContainers.jsp")).addAsWebResource(new File("src/main/webapp","indexWithExtraComponents.jsp")).addAsWebResource(new File("src/main/webapp","marathons.jsp")).addAsWebResource(new File("src/main/webapp","marathons_datatable.jsp"));
  }
 else {
    war.addAsWebResource(new File("src/main/webapp","index.xhtml")).addAsWebResource(new File("src/main/webapp","finalgreeting.xhtml")).addAsWebResource(new File("src/main/webapp","secured-page.xhtml")).addAsWebResource(new File("src/main/webapp","NestedNamingContainers.xhtml")).addAsWebResource(new File("src/main/webapp","indexWithExtraComponents.xhtml")).addAsWebResource(new File("src/main/webapp","marathons.xhtml")).addAsWebResource(new File("src/main/webapp","marathons_datatable.xhtml"));
  }
  appendForEmbedded(war);
  return war;
}
 

Example 20

From project juzu, under directory /core/src/test/java/juzu/impl/common/.

Source file: DevClassLoaderTestCase.java

  22 
vote

private File explode(JavaArchive classes,JavaArchive lib){
  WebArchive archive=ShrinkWrap.create(WebArchive.class);
  archive.merge(classes,"WEB-INF/classes");
  archive.addAsDirectory("WEB-INF/lib");
  File explodedDir=archive.as(ExplodedExporter.class).exportExploded(targetDir);
  File libJar=new File(explodedDir,"WEB-INF/lib/lib.jar");
  lib.as(ZipExporter.class).exportTo(libJar);
  return explodedDir;
}
 

Example 21

From project mail, under directory /testsuite/src/test/java/org/jboss/seam/mail/util/.

Source file: Deployments.java

  22 
vote

public static WebArchive baseDeployment(){
  WebArchive archive=ShrinkWrap.create(WebArchive.class,"test.war").addAsWebInfResource("beans.xml","beans.xml");
  if ("weld-ee-embedded-1.1".equals(System.getProperty("arquillian"))) {
    archive.addAsResource("seam-beans.xml","META-INF/seam-beans.xml");
    archive.addAsLibraries(MavenArtifactResolver.resolve("org.jboss.solder:solder-impl"));
  }
 else {
    archive.addAsResource("seam-beans.xml","META-INF/seam-beans.xml");
    archive.addAsLibraries(MavenArtifactResolver.resolve("org.subethamail:subethasmtp","org.jboss.solder:solder-impl","org.slf4j:slf4j-simple","com.google.guava:guava"));
  }
  return archive;
}
 

Example 22

From project persistence_1, under directory /testsuite/src/test/java/org/jboss/seam/persistence/hibernate/test/jetty/.

Source file: ManagedHibernateSessionELTest.java

  22 
vote

@Deployment public static Archive<?> createTestArchive(){
  WebArchive war=JettyTestUtils.createHibernateTestArchive();
  war.addAsWebInfResource("WEB-INF/hibernate-beans.xml","beans.xml");
  war.addAsWebInfResource("META-INF/hibernate-std.cfg.xml","classes/hibernate.cfg.xml");
  war.addClasses(getTestClasses());
  return war;
}
 

Example 23

From project picketlink-integration-tests, under directory /unit-tests/saml/src/test/java/org/picketlink/test/integration/saml2/.

Source file: SAML2EncryptionUnitTestCase.java

  22 
vote

@Deployment(name="idp-enc",testable=false) @TargetsContainer("jboss") public static WebArchive createIDPSigDeployment() throws GeneralSecurityException, IOException {
  WebArchive idp=MavenArtifactUtil.getQuickstartsMavenArchive("idp-enc");
  addTrustedDomain(idp,getServerAddress());
  addValidatingAlias(idp,getServerAddress(),getServerAddress());
  addKeyStoreAlias(idp,getServerAddress());
  return idp;
}
 

Example 24

From project quickstart, under directory /ArjunaJTA/jee_transactional_app/src/test/java/.

Source file: TestManagedBeanCustomerManager.java

  22 
vote

@Deployment public static WebArchive createDeployment(){
  WebArchive archive=ShrinkWrap.create(WebArchive.class,"test.war").addClasses(CustomerManagerEJB.class,CustomerManagerEJBImpl.class,Customer.class).addClasses(CustomerCreationCounter.class).addClasses(CustomerManager.class,CustomerManagerManagedBean.class).addAsResource("META-INF/persistence.xml","META-INF/persistence.xml").addAsWebInfResource(EmptyAsset.INSTANCE,"beans.xml");
  archive.delete(ArchivePaths.create("META-INF/MANIFEST.MF"));
  final String ManifestMF="Manifest-Version: 1.0\n" + "Dependencies: org.jboss.modules,deployment.arquillian-service,org.jboss.msc,org.jboss.jts\n";
  archive.setManifest(new StringAsset(ManifestMF));
  return archive;
}
 

Example 25

From project resolver, under directory /impl-maven-integration-tests/war-sample/src/test/java/test/.

Source file: WarTestCase.java

  22 
vote

@Test public void testWar(){
  WebArchive archive=ShrinkWrap.create(MavenImporter.class,"test.war").loadEffectivePom("pom.xml").importBuildOutput().as(WebArchive.class);
  Assert.assertNotNull("Archive is not null",archive);
  Assert.assertTrue("Archive contains war class",archive.contains("WEB-INF/classes/test/WarClass.class"));
  Assert.assertTrue("Archive contains main.properties",archive.contains("WEB-INF/classes/main.properties"));
  Assert.assertTrue("Archive contains web.xml",archive.contains("WEB-INF/web.xml"));
}
 

Example 26

From project security, under directory /testsuite/src/test/java/org/jboss/seam/security/externaltest/integration/client/.

Source file: ArchiveBuilder.java

  22 
vote

static WebArchive getArchive(String entity){
  WebArchive webArchive=webArchives.get(entity);
  if (webArchive == null) {
    webArchive=createTestArchive(entity);
    webArchives.put(entity,webArchive);
  }
  return webArchive;
}
 

Example 27

From project social_1, under directory /services/twitter/src/test/java/org/jboss/seam/social/twitter/test/.

Source file: TwitterTest.java

  22 
vote

@Deployment public static Archive<?> createTestArchive() throws FileNotFoundException {
  WebArchive ret=ShrinkWrap.create(WebArchive.class,"test.war").addAsLibraries(ShrinkWrap.create(ZipImporter.class,"seam-social-api.jar").importFrom(new File("../../api/target/seam-social-api.jar")).as(JavaArchive.class),ShrinkWrap.create(ZipImporter.class,"seam-social.jar").importFrom(new File("../../impl/target/seam-social.jar")).as(JavaArchive.class),ShrinkWrap.create(ZipImporter.class,"seam-social-twitter.jar").importFrom(new File("target/seam-social-twitter.jar")).as(JavaArchive.class)).addAsWebInfResource(EmptyAsset.INSTANCE,"beans.xml").addClass(TwitterServiceProducer.class);
  if ("weld-ee-embedded-1.1".equals(System.getProperty("arquillian"))) {
    ret.addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class).configureFrom("../../settings.xml").loadMetadataFromPom("../../impl/pom.xml").artifact("org.jboss.solder:solder-impl").resolveAs(GenericArchive.class));
  }
 else {
    ret.addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class).configureFrom("../../settings.xml").loadMetadataFromPom("../../impl/pom.xml").artifact("org.jboss.solder:solder-impl").artifact("org.scribe:scribe").artifact("org.apache.commons:commons-lang3").artifact("org.codehaus.jackson:jackson-mapper-asl").artifact("com.google.guava:guava").resolveAs(GenericArchive.class));
  }
  return ret;
}
 

Example 28

From project solder, under directory /testsuite/src/test/java/org/jboss/solder/test/util/.

Source file: Deployments.java

  22 
vote

public static WebArchive baseDeployment(boolean includeEmptyBeansXml){
  WebArchive archive;
  archive=ShrinkWrap.create(WebArchive.class,"test.war").addAsLibraries(ShrinkWrap.create(ZipImporter.class,"solder-api.jar").importFrom(new File(SOLDER_API_JAR)).as(JavaArchive.class),ShrinkWrap.create(ZipImporter.class,"solder-impl.jar").importFrom(new File(SOLDER_IMPL_JAR)).as(JavaArchive.class),ShrinkWrap.create(ZipImporter.class,"solder-logging.jar").importFrom(new File(SOLDER_LOGGING_JAR)).as(JavaArchive.class));
  if (includeEmptyBeansXml) {
    archive.addAsWebInfResource(EmptyAsset.INSTANCE,"beans.xml");
  }
  return archive;
}
 

Example 29

From project transaction, under directory /testsuite/src/test/java/org/jboss/seam/transaction/test/jboss/.

Source file: TransactionAttributeInterceptorTest.java

  22 
vote

@Deployment public static Archive<?> createTestArchive(){
  WebArchive war=JBossASTestUtils.createTestArchive(false);
  war.addClasses(getTestClasses());
  war.addAsWebInfResource("META-INF/persistence.xml","classes/META-INF/persistence.xml");
  war.addAsWebInfResource(new ByteArrayAsset(("<beans><interceptors><class>" + TransactionInterceptor.class.getName() + "</class></interceptors></beans>").getBytes()),"beans.xml");
  return war;
}
 

Example 30

From project arquillian-extension-seam2, under directory /src/main/java/org/jboss/arquillian/seam2/client/.

Source file: Seam2ArchiveProcessor.java

  21 
vote

private void appendSeamLibraries(Archive<?> applicationArchive){
  final File[] seamDependencies=resolveSeamDependencies();
  if (applicationArchive instanceof EnterpriseArchive) {
    final File[] jbossElDependencies=resolveArtifact(Seam2Configuration.JBOSS_EL_ARTIFACT,configurationInstance.get().getJbossElVersion());
    final EnterpriseArchive ear=(EnterpriseArchive)applicationArchive;
    ear.addAsModules(seamDependencies).addAsLibraries(jbossElDependencies);
  }
 else   if (applicationArchive instanceof WebArchive) {
    final WebArchive war=(WebArchive)applicationArchive;
    war.addAsLibraries(seamDependencies);
  }
 else {
    throw new RuntimeException("Unsupported archive format[" + applicationArchive.getClass().getSimpleName() + ", "+ applicationArchive.getName()+ "] for Seam 2 application. Please use WAR or EAR.");
  }
}
 

Example 31

From project arquillian-extension-warp, under directory /impl/src/main/java/org/jboss/arquillian/warp/.

Source file: DeploymentEnricher.java

  21 
vote

@Override public void process(Archive<?> applicationArchive,TestClass testClass){
  if (testClass.isAnnotationPresent(WarpTest.class)) {
    if (applicationArchive instanceof WebArchive) {
      WebArchive webArchive=(WebArchive)applicationArchive;
      Collection<WarpLifecycleExtension> lifecycleExtensions=serviceLoader.get().all(WarpLifecycleExtension.class);
      for (      WarpLifecycleExtension extension : lifecycleExtensions) {
        JavaArchive library=extension.getEnrichmentLibrary();
        if (library != null) {
          webArchive.addAsLibrary(library);
        }
        extension.enrichWebArchive(webArchive);
      }
    }
  }
}
 

Example 32

From project jms, under directory /testsuite/src/test/java/org/jboss/seam/jms/test/.

Source file: DeploymentFactory.java

  21 
vote

private static WebArchive createBasicDeployment(Class<?>... classes){
  JavaArchive ejbModule=ShrinkWrap.create(JavaArchive.class,"test.jar");
  ejbModule.addPackage(DeploymentFactory.class.getPackage());
  ejbModule.addPackage(Seam3JmsExtension.class.getPackage());
  ejbModule.addPackage(JmsSession.class.getPackage());
  ejbModule.addPackage(SessionProducer.class.getPackage());
  ejbModule.addPackage(JmsConnectionProducer.class.getPackage());
  ejbModule.addPackage(Route.class.getPackage());
  ejbModule.addAsManifestResource(EmptyAsset.INSTANCE,"beans.xml");
  ejbModule.addAsServiceProvider(Extension.class,Seam3JmsExtension.class);
  for (  Class<?> c : classes) {
    ejbModule.addPackage(c.getPackage());
  }
  WebArchive war=ShrinkWrap.create(WebArchive.class,"test.war");
  war.addAsLibraries(ejbModule);
  war.addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class).loadMetadataFromPom("pom.xml").artifact("org.jboss.solder:solder-impl").resolveAs(JavaArchive.class));
  return war;
}
 

Example 33

From project rewrite, under directory /test-harness/src/main/java/org/ocpsoft/rewrite/test/.

Source file: RewriteTest.java

  21 
vote

public static WebArchive getDeploymentNoWebXml(String name){
  if (isJetty() && "ROOT.war".equals(name))   name=".war";
  WebArchive archive=ShrinkWrap.create(WebArchive.class,name).addPackages(true,MockBinding.class.getPackage()).addAsLibraries(resolveDependencies("org.ocpsoft.logging:logging-api")).addAsLibraries(getRewriteArchive()).addAsLibraries(getRewriteAnnotationsArchive()).addAsLibraries(getContainerArchive()).addAsLibraries(getCurrentArchive());
  if (isJetty()) {
    archive.add(new StringAsset("com.sun.el.ExpressionFactoryImpl"),"/WEB-INF/classes/META-INF/services/javax.el.ExpressionFactory");
    archive.addAsWebInfResource("jetty-env.xml","jetty-env.xml");
    archive.addAsWebInfResource("jetty-log4j.xml","log4j.xml");
  }
  if (isTomcat()) {
    if (isWeld()) {
      archive.addAsLibraries(resolveDependencies("org.jboss.weld:weld-core:1.1.9.Final"));
      archive.addAsLibraries(resolveDependencies("org.jboss.weld.servlet:weld-servlet-core:1.1.9.Final"));
      archive.addAsWebResource("tomcat-weld-context.xml","META-INF/context.xml");
    }
    if (isOWB()) {
      archive.addAsLibraries(resolveDependencies("javax.enterprise:cdi-api:1.0-SP4"));
      archive.addAsLibraries(resolveDependencies("org.apache.openwebbeans:openwebbeans-impl:1.1.5"));
      archive.addAsLibraries(resolveDependencies("org.apache.openwebbeans:openwebbeans-web:1.1.5"));
      archive.addAsLibraries(resolveDependencies("org.apache.openwebbeans:openwebbeans-spi:1.1.5"));
      archive.addAsLibraries(resolveDependencies("org.apache.openwebbeans:openwebbeans-resource:1.1.5"));
      archive.addAsWebResource("tomcat-owb-context.xml","META-INF/context.xml");
    }
    archive.addAsLibraries(resolveDependencies("org.glassfish:javax.faces:2.1.13"));
    archive.addAsLibraries(resolveDependencies("javax.servlet:jstl:1.2"));
  }
  return archive;
}
 

Example 34

From project arquillian-container-openshift, under directory /openshift-express/src/main/java/org/jboss/arquillian/container/openshift/express/archive/.

Source file: ArchiveUtil.java

  19 
vote

private static final <T>void getDefinedClasses(Collection<String> classNames,Collection<Class<T>> needleImpls,Archive<?> archive,Class<T> needle){
  if (isEarArchive(archive)) {
    for (    JavaArchive jar : getScannableNestedArchives(archive,JavaArchive.class,AssetUtil.JAR_FILTER)) {
      getDefinedClasses(classNames,needleImpls,jar,needle);
    }
    for (    WebArchive war : getScannableNestedArchives(archive,WebArchive.class,AssetUtil.WAR_FILTER)) {
      getDefinedClasses(classNames,needleImpls,war,needle);
    }
  }
 else   if (isWarArchive(archive)) {
    ByteAssetClassLoader cl=new ByteAssetClassLoader(archive,ArchiveType.WAR);
    for (    Entry<ArchivePath,Node> node : archive.getContent(AssetUtil.CLASS_FILTER).entrySet()) {
      getDefinedClasses(classNames,needleImpls,ArchiveType.WAR,node.getKey(),node.getValue(),needle,cl);
    }
    for (    JavaArchive jar : getScannableNestedArchives(archive,JavaArchive.class,AssetUtil.JAR_FILTER)) {
      getDefinedClasses(classNames,needleImpls,jar,needle);
    }
  }
 else   if (isJarArchive(archive)) {
    ByteAssetClassLoader cl=new ByteAssetClassLoader(archive,ArchiveType.JAR);
    for (    Entry<ArchivePath,Node> node : archive.getContent(AssetUtil.CLASS_FILTER).entrySet()) {
      getDefinedClasses(classNames,needleImpls,ArchiveType.JAR,node.getKey(),node.getValue(),needle,cl);
    }
  }
}
 

Example 35

From project arquillian-container-openwebbeans, under directory /openwebbeans-embedded-1/src/main/java/org/jboss/arquillian/container/openwebbeans/embedded_1/.

Source file: ShrinkWrapMetaDataDiscovery.java

  19 
vote

/** 
 * Scan the given Archive. The following types are supported: <ul> <li> {@link JavaArchive}</li> <li> {@link WebArchive}</li> </ul> We do not support EARs yet!
 * @param archive to scan
 */
private void scanArchive(Archive<?> archive){
  boolean beansXmlPresent=false;
  if (archive instanceof WebArchive) {
    Map<ArchivePath,Node> beansXmls;
    beansXmls=archive.getContent(Filters.include("/WEB-INF/beans.xml"));
    beansXmlPresent|=parseBeansXmls(archive.getName(),beansXmls);
    beansXmls=archive.getContent(Filters.include("/WEB-INF/classes/META-INF/beans.xml"));
    beansXmlPresent|=parseBeansXmls(archive.getName(),beansXmls);
    if (beansXmlPresent) {
      scanArchiveClasses(archive);
    }
    Map<ArchivePath,Node> jarFiles=archive.getContent(Filters.include("/WEB-INF/lib/.*\\.jar"));
    for (    Map.Entry<ArchivePath,Node> jarEntry : jarFiles.entrySet()) {
      ArchiveAsset archiveAsset=(ArchiveAsset)jarEntry.getValue().getAsset();
      Archive jarArchive=(JavaArchive)archiveAsset.getArchive();
      scanArchive(jarArchive);
    }
  }
 else   if (archive instanceof JavaArchive) {
    Map<ArchivePath,Node> beansXmls;
    beansXmls=archive.getContent(Filters.include("/META-INF/beans.xml"));
    beansXmlPresent=parseBeansXmls(archive.getName(),beansXmls);
    if (beansXmlPresent) {
      scanArchiveClasses(archive);
    }
  }
}
 

Example 36

From project Core_2, under directory /test-harness-web/src/main/java/org/jboss/forge/test/web/.

Source file: WebTestImpl.java

  19 
vote

@Override public Method<JavaClass> buildDefaultDeploymentMethod(final Project project,final JavaClass clazz,final Collection<String> deploymentItems){
  try {
    JavaSourceFacet java=project.getFacet(JavaSourceFacet.class);
    JavaResource root=java.getTestJavaResource(java.getBasePackage() + ".Root");
    if (!root.exists()) {
      java.saveTestJavaSource(JavaParser.create(JavaInterface.class).setName("Root").setPackage(java.getBasePackage()));
    }
    clazz.addImport(root.getJavaSource());
    clazz.addImport(WebArchive.class);
    clazz.addImport(Deployment.class);
    clazz.addImport(ShrinkWrap.class);
    Method<JavaClass> method=clazz.getMethod("getDeployment");
    if (method == null)     method=clazz.addMethod("public static WebArchive getDeployment() {}");
    if (!method.hasAnnotation(Deployment.class))     method.addAnnotation(Deployment.class);
    clazz.addImport(ExplodedImporter.class);
    clazz.addImport(JavaArchive.class);
    clazz.addImport(Filters.class);
    String body="return ShrinkWrap.create(WebArchive.class)" + ".addPackages(true, " + "Root.class.getPackage()"+ ")";
    for (    String item : deploymentItems) {
      body=body + item;
    }
    body=body + ".merge(ShrinkWrap.create(ExplodedImporter.class, \"temp.jar\")" + ".importDirectory(\"src/main/webapp\") "+ ".as(JavaArchive.class),\"/\", Filters.includeAll());";
    method.setBody(body);
    return method;
  }
 catch (  FileNotFoundException e) {
    throw new RuntimeException(e);
  }
}
 

Example 37

From project incubator-deltaspike, under directory /deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/exclude/.

Source file: ExcludeTest.java

  19 
vote

/** 
 * X TODO creating a WebArchive is only a workaround because JavaArchive cannot contain other archives.
 */
@Deployment public static WebArchive deploy(){
  System.setProperty("org.apache.deltaspike.ProjectStage","Production");
  ProjectStageProducer.setProjectStage(null);
  URL fileUrl=ExcludeTest.class.getClassLoader().getResource("META-INF/apache-deltaspike.properties");
  JavaArchive testJar=ShrinkWrap.create(JavaArchive.class,"excludeTest.jar").addPackage(ExcludeTest.class.getPackage()).addPackage(TestClassDeactivator.class.getPackage()).addAsManifestResource(FileUtils.getFileForURL(fileUrl.toString())).addAsManifestResource(EmptyAsset.INSTANCE,"beans.xml");
  return ShrinkWrap.create(WebArchive.class,"exclude.war").addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive()).addAsLibraries(testJar).addAsWebInfResource(EmptyAsset.INSTANCE,"beans.xml").addAsServiceProvider(Extension.class,ExcludeExtension.class);
}
 

Example 38

From project shrinkwrap, under directory /impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/.

Source file: DynamicWebContainerTestBase.java

  19 
vote

/** 
 * Override to handle web archive special case (service providers in WEB-INF/classes/META-INF/services)
 * @throws Exception if an exception occurs
 */
@Test @Override public void testAddServiceProvider() throws Exception {
  ServiceProviderPathExposingWebArchive webArchive=new ServiceProviderPathExposingWebArchive(ShrinkWrap.create(WebArchive.class));
  webArchive.addAsServiceProvider(DummyInterfaceForTest.class,DummyClassForTest.class);
  ArchivePath testPath=webArchive.getServiceProvidersPath();
  Assert.assertTrue("Archive should contain " + testPath,webArchive.contains(testPath));
  testPath=new BasicPath(webArchive.getServiceProvidersPath(),DummyInterfaceForTest.class.getName());
  Assert.assertTrue("Archive should contain " + testPath,webArchive.contains(testPath));
}