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

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 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 2

From project arquillian-container-osgi, under directory /container-embedded/src/test/java/org/jboss/test/arquillian/container/osgi/.

Source file: ARQ271BeforeClassTestCase.java

  22 
vote

@Deployment public static JavaArchive createdeployment(){
  final JavaArchive archive=ShrinkWrap.create(JavaArchive.class,"test.jar");
  archive.setManifest(new Asset(){
    public InputStream openStream(){
      OSGiManifestBuilder builder=OSGiManifestBuilder.newInstance();
      builder.addBundleSymbolicName(archive.getName());
      builder.addBundleManifestVersion(2);
      return builder.openStream();
    }
  }
);
  return archive;
}
 

Example 3

From project arquillian-container-weld, under directory /weld-se-embedded-1/src/test/java/org/jboss/arquillian/container/weld/se/embedded_1/shrinkwrap/.

Source file: ShrinkwrapBeanDeploymentArchiveTestCase.java

  22 
vote

@Test public void shouldBeAbleToFindAllClasses() throws Exception {
  JavaArchive archive=ShrinkWrap.create(JavaArchive.class).addPackage(MyBean.class.getPackage());
  ShrinkwrapBeanDeploymentArchive beanDeployment=archive.as(ShrinkwrapBeanDeploymentArchive.class);
  try {
    Collection<Class<?>> classes=beanDeployment.getBeanClasses();
    Assert.assertEquals(1,classes.size());
  }
  finally {
    beanDeployment.getClassLoader().close();
  }
}
 

Example 4

From project arquillian-core, under directory /testng/container/src/main/java/org/jboss/arquillian/testng/container/.

Source file: TestNGDeploymentAppender.java

  22 
vote

@Override protected Archive<?> buildArchive(){
  JavaArchive archive=ShrinkWrap.create(JavaArchive.class,"arquillian-testng.jar").addPackages(true,Filters.exclude("/org/testng/junit/.*|/org/testng/eclipse/.*"),"org.testng","bsh","org.jboss.arquillian.testng").addAsServiceProvider(TestRunner.class,TestNGTestRunner.class);
  optionalPackages(archive,Filters.exclude(".*/InterceptorStackCallback\\$InterceptedMethodInvocation.*"),"com.google.inject");
  optionalPackages(archive,Filters.includeAll(),"com.beust");
  return archive;
}
 

Example 5

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

Source file: DeploymentAppender.java

  22 
vote

@Override public Archive<?> createAuxiliaryArchive(){
  BytemanConfiguration config=BytemanConfiguration.from(descriptorInst.get());
  JavaArchive jar=ShrinkWrap.create(JavaArchive.class,"arquillian-byteman.jar").addClasses(Submit.class,ScriptText.class,BMRule.class,BMRules.class,BytemanRemoteExtension.class,GenerateScriptUtil.class,SubmitException.class,BytemanConfiguration.class).addPackages(false,org.jboss.arquillian.extension.byteman.impl.container.ScriptInstaller.class.getPackage(),org.jboss.arquillian.extension.byteman.impl.common.BytemanConfiguration.class.getPackage()).addAsServiceProvider(RemoteLoadableExtension.class,BytemanRemoteExtension.class);
  jar.addAsResource(new StringAsset(config.toString()),BytemanConfiguration.BYTEMAN_CONFIG);
  if (config.autoInstallAgent()) {
    JavaArchive agentJar=ShrinkWrap.create(JavaArchive.class).addPackages(true,"org.jboss.byteman").setManifest(new StringAsset("Manifest-Version: 1.0\n" + "Created-By: Arquillian\n" + "Implementation-Version: 0.0.0.Arq\n"+ "Premain-Class: org.jboss.byteman.agent.Main\n"+ "Agent-Class: org.jboss.byteman.agent.Main\n"+ "Can-Redefine-Classes: true\n"+ "Can-Retransform-Classes: true\n"));
    jar.add(new ArchiveAsset(agentJar,ZipExporter.class),BytemanConfiguration.BYTEMAN_JAR);
  }
  return jar;
}
 

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/main/java/org/jboss/arquillian/persistence/core/deployment/.

Source file: PersistenceExtensionConfigurationTestArchiveEnricher.java

  22 
vote

@Override public void process(Archive<?> applicationArchive,TestClass testClass){
  final PersistenceExtensionEnabler persistenceExtensionEnabler=new PersistenceExtensionEnabler(testClass);
  if (!persistenceExtensionEnabler.isPersistenceExtensionRequired()) {
    return;
  }
  obtainDataSourceFromPersistenceXml(applicationArchive);
  final JavaArchive additionalPersistenceResources=ShrinkWrap.create(JavaArchive.class,"arquillian-persistence-extension-additional-resources.jar");
  merge(additionalPersistenceResources,sqlScriptsAsResource(configurationInstance.get().getScriptsToExecuteAfterTest()),sqlScriptsAsResource(configurationInstance.get().getScriptsToExecuteBeforeTest()),persistenceConfigurationSerializedAsProperties(),dbUnitConfigurationSerializedAsProperties(),jpaCacheEvictionConfigurationSerializedAsProperties());
  addResources(applicationArchive,additionalPersistenceResources);
}
 

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-extension-warp, under directory /impl/src/main/java/org/jboss/arquillian/warp/impl/utils/.

Source file: ShrinkWrapUtils.java

  22 
vote

public static JavaArchive getJavaArchiveFromClass(Class<?> clazz){
  URL url=clazz.getResource(clazz.getSimpleName() + ".class");
  try {
    String file=url.getFile();
    file=file.substring(file.indexOf(":") + 1);
    file=file.substring(0,file.indexOf('!'));
    JavaArchive jar=ShrinkWrap.create(ZipImporter.class,file + "!").importFrom(new File(file)).as(JavaArchive.class);
    return jar;
  }
 catch (  Exception e) {
    throw new IllegalStateException("Cannot get JAR from class " + clazz.getName() + " from URL "+ url,e);
  }
}
 

Example 10

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 11

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 12

From project big-data-plugin, under directory /test-src/org/pentaho/di/job/entries/hadoopjobexecutor/.

Source file: JarUtilityTest.java

  22 
vote

/** 
 * Create a Java archive with the provided class declared as the main class in its manifest.
 * @param name Name of archive
 * @param mainClass Class to use as the main class
 * @return A Java archive with the class packaged within and manifest configured to use it as the main class.
 */
private JavaArchive createTestJarWithMainClass(String name,Class<?> mainClass){
  JavaArchive archive=ShrinkWrap.create(JavaArchive.class,"test.jar");
  StringAsset manifest=new StringAsset("Main-Class: " + getClass().getName() + "\n");
  archive.addAsManifestResource(manifest,MANIFEST_FILE_NAME);
  archive.addClass(getClass());
  return archive;
}
 

Example 13

From project ceylon-runtime, under directory /testsuite/src/test/java/org/jboss/ceylon/test/modules/defaultx/test/.

Source file: DefaultTestCase.java

  22 
vote

@Test public void testVisibility() throws Throwable {
  JavaArchive module=ShrinkWrap.create(JavaArchive.class,"biz.wiz.quiz-1.0.0.GA.car");
  module.addClasses(module_.class,run_.class);
  File defaultFile=new File(getRepo(),"default/default.car");
  Assert.assertTrue(defaultFile.exists());
  JavaArchive lib=ShrinkWrap.create(JavaArchive.class,"default.car");
  ZipImporter zipImporter=lib.as(ZipImporter.class);
  zipImporter.importFrom(defaultFile);
  testArchive(module,lib);
}
 

Example 14

From project components, under directory /tools/forge/bean/src/test/java/org/switchyard/tools/forge/bean/.

Source file: ForgeBeanTest.java

  22 
vote

/** 
 * The deployment method is where references to classes, packages, and configuration files are added via  Arquillian.
 * @return the Traditional JAR (Java Archive) structure
 */
@Deployment public static JavaArchive getDeployment(){
  JavaArchive archive=AbstractShellTest.getDeployment();
  archive.addPackages(true,SwitchYardFacet.class.getPackage());
  archive.addPackages(true,BeanFacet.class.getPackage());
  return archive;
}
 

Example 15

From project core_1, under directory /test/src/main/java/org/switchyard/test/mixins/jca/.

Source file: JCAMixIn.java

  22 
vote

private void deployMockResourceAdapter(String raName,Map<String,String> connDefs){
  ResourceAdapterArchive raa=ShrinkWrap.create(ResourceAdapterArchive.class,stripDotRarSuffix(raName == null ? "mock-ra.rar" : raName) + ".rar");
  JavaArchive ja=ShrinkWrap.create(JavaArchive.class,UUID.randomUUID().toString() + ".jar");
  ja.addClasses(MessageListener.class,MockActivationSpec.class,MockConnection.class,MockConnectionFactory.class,MockConnectionManager.class,MockManagedConnection.class,MockManagedConnectionFactory.class,MockResourceAdapter.class,TransactionManagerLocator.class);
  raa.addAsLibrary(ja);
  URL url=Thread.currentThread().getContextClassLoader().getResource(MOCK_RESOURCE_ADAPTER_XML);
  raa.setResourceAdapterXML(url);
  if (connDefs.size() == 0) {
    connDefs.put(JNDI_PREFIX + "/" + stripDotRarSuffix(raName),MOCK_DEFAULT_MCF_CLASS);
  }
  deployResourceAdapterArchive(raa,connDefs);
}
 

Example 16

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

Source file: CoreDeployment.java

  22 
vote

/** 
 * Adds Push and all its dependencies
 */
public CoreDeployment withPush(){
  if (addFeature(CoreFeature.PUSH)) {
    return this;
  }
  withService(PushContextFactory.class,PushContextFactoryImpl.class);
  StringAsset pushServletInitializer=new StringAsset(PushServletContainerInitializer.class.getName());
  JavaArchive servletInitializer=ShrinkWrap.create(JavaArchive.class,"push-classes.jar").addAsResource(pushServletInitializer,"META-INF/services/" + ServletContainerInitializer.class.getName()).addClasses(PushServlet.class,PushFilter.class,PushHandlerFilter.class,ServletConfigDefaultsWrapper.class).addClasses(PushServletContainerInitializer.class,GenericServletContainerInitializer.class).addClasses(TopicsContext.class,TopicsContextImpl.class).addClasses(SessionManager.class,SessionManagerImpl.class,SessionQueue.class).addClasses(SessionFactory.class,SessionFactoryImpl.class).addClasses(Session.class,SessionImpl.class).addClasses(Topic.class,TopicImpl.class,AbstractTopic.class,TopicKey.class,TopicEvent.class,TopicListener.class).addClasses(MessageDataSerializer.class,DefaultMessageDataSerializer.class,MessageDataScriptString.class).addClasses(Request.class,RequestImpl.class).addClasses(PushContext.class,PushContextImpl.class).addClasses(PushContextFactory.class,PushContextFactoryImpl.class).addClasses(SessionSubscriptionEvent.class,SessionUnsubscriptionEvent.class).addClasses(MessageException.class).addClasses(JMSTopicsContextImpl.class);
  archive().addAsLibrary(servletInitializer);
  addMavenDependency("org.atmosphere:atmosphere-runtime:1.0.0.beta5","org.atmosphere:atmosphere-compat-jbossweb:1.0.0.beta5","org.atmosphere:atmosphere-compat-tomcat:1.0.0.beta5","org.atmosphere:atmosphere-compat-tomcat7:1.0.0.beta5");
  return this;
}
 

Example 17

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

Source file: ExcludeTest.java

  22 
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 18

From project javaee-tutorial, under directory /jaxrs/client/src/test/java/org/jboss/ee/tutorial/jaxrs/client/.

Source file: JaxrsClientTestCase.java

  22 
vote

@Deployment(testable=false) public static Archive<?> deploy(){
  File serverTargetDir=new File("../server/target");
  String[] list=serverTargetDir.list(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".war");
    }
  }
);
  File warFile=new File(serverTargetDir + "/" + list[0]);
  JavaArchive archive=ShrinkWrap.createFromZipFile(JavaArchive.class,warFile);
  return archive;
}
 

Example 19

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

Source file: ManagedBeansTestCase.java

  22 
vote

@Deployment public static Archive<?> deployment(){
  final JavaArchive jar=ShrinkWrap.create(JavaArchive.class,"osgi-cdi-test");
  jar.addClasses(HttpRequest.class);
  jar.setManifest(new Asset(){
    @Override public InputStream openStream(){
      OSGiManifestBuilder builder=OSGiManifestBuilder.newInstance();
      builder.addBundleSymbolicName(jar.getName());
      builder.addBundleManifestVersion(2);
      return builder.openStream();
    }
  }
);
  return jar;
}
 

Example 20

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

Source file: WeldServletDeploymentAppender.java

  21 
vote

@Override public Archive<?> createAuxiliaryArchive(){
  File settingsXml=null;
  InputStream in=null;
  BufferedOutputStream out=null;
  try {
    settingsXml=File.createTempFile("arquillian-","-settings.xml");
    settingsXml.deleteOnExit();
    in=WeldServletDeploymentAppender.class.getResourceAsStream("jboss-repository-settings.xml");
    out=new BufferedOutputStream(new FileOutputStream(settingsXml));
    byte[] buffer=new byte[1024];
    int len;
    while ((len=in.read(buffer)) != -1) {
      out.write(buffer,0,len);
    }
  }
 catch (  IOException ioe) {
    throw new IllegalStateException("Could not read settings.xml from classpath");
  }
 finally {
    if (in != null) {
      try {
        in.close();
      }
 catch (      IOException ioe) {
      }
    }
    if (out != null) {
      try {
        out.close();
      }
 catch (      IOException ioe) {
      }
    }
  }
  MavenDependencyResolver resolver=DependencyResolvers.use(MavenDependencyResolver.class).configureFrom(settingsXml.getAbsolutePath());
  JavaArchive weldServlet=resolver.artifact("org.jboss.weld.servlet:weld-servlet:1.1.0.Final").resolveAs(JavaArchive.class).iterator().next();
  WebAppDescriptor webFragmentXml=Descriptors.create(WebAppDescriptor.class);
  return weldServlet.addAsManifestResource(new StringAsset(webFragmentXml.listener("org.jboss.weld.environment.servlet.Listener").exportAsString().replaceAll("web-app","web-fragment").replace("<listener>","<name>WeldServlet</name><listener>")),"web-fragment.xml");
}
 

Example 21

From project crash, under directory /shell/core/src/test/java/org/crsh/vfs/.

Source file: FSTestCase.java

  21 
vote

public void testJar() throws Exception {
  java.io.File file=java.io.File.createTempFile("test",".jar");
  file.deleteOnExit();
  JavaArchive archive=ShrinkWrap.create(JavaArchive.class);
  archive.addClass(FSTestCase.class);
  ZipExporter exporter=archive.as(ZipExporter.class);
  exporter.exportTo(file,true);
  URLClassLoader cl=new URLClassLoader(new URL[]{file.toURI().toURL()});
  URL classURL=cl.findResource(FSTestCase.class.getName().replace('.','/') + ".class");
  JarURLConnection conn=(JarURLConnection)classURL.openConnection();
  JarURLDriver driver=new JarURLDriver(cl,conn);
  org.crsh.vfs.spi.jarurl.Handle root=driver.root();
  assertEquals("",driver.name(root));
  assertTrue(driver.isDir(root));
  Iterator<org.crsh.vfs.spi.jarurl.Handle> rootChildren=driver.children(root).iterator();
  org.crsh.vfs.spi.jarurl.Handle org=rootChildren.next();
  assertFalse(rootChildren.hasNext());
  assertEquals("org",driver.name(org));
  assertTrue(driver.isDir(org));
  Iterator<org.crsh.vfs.spi.jarurl.Handle> orgChildren=driver.children(org).iterator();
  org.crsh.vfs.spi.jarurl.Handle crsh=orgChildren.next();
  assertFalse(orgChildren.hasNext());
  assertEquals("crsh",driver.name(crsh));
  assertTrue(driver.isDir(crsh));
  Iterator<org.crsh.vfs.spi.jarurl.Handle> vfsChildren=driver.children(crsh).iterator();
  org.crsh.vfs.spi.jarurl.Handle vfs=vfsChildren.next();
  assertFalse(vfsChildren.hasNext());
  assertEquals("vfs",driver.name(vfs));
  assertTrue(driver.isDir(vfs));
  Iterator<org.crsh.vfs.spi.jarurl.Handle> clazzChildren=driver.children(vfs).iterator();
  org.crsh.vfs.spi.jarurl.Handle clazz=clazzChildren.next();
  assertFalse(clazzChildren.hasNext());
  assertEquals(FSTestCase.class.getSimpleName() + ".class",driver.name(clazz));
  assertFalse(driver.isDir(clazz));
  InputStream in=driver.open(clazz);
  in.close();
}
 

Example 22

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 23

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 24

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

Source file: SmokeBase.java

  19 
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 25

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 26

From project hibernate-ogm, under directory /hibernate-ogm-core/src/test/java/org/hibernate/ogm/test/utils/.

Source file: PackagingRule.java

  19 
vote

public PackagingRule(String persistenceConfResource,Class<?>... entities){
  archive=ShrinkWrap.create(JavaArchive.class,"jtastandalone.jar");
  archive.addClasses(entities);
  archive.addAsManifestResource(persistenceConfResource,persistencePath);
  try {
    testPackage=newFile();
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
  archive.as(ZipExporter.class).exportTo(testPackage,true);
}
 

Example 27

From project hibernate-validator, under directory /integration/src/test/java/org/hibernate/validator/integration/util/.

Source file: IntegrationTestUtil.java

  19 
vote

public static Collection<JavaArchive> bundleHibernateValidatorWithDependencies(boolean removeServiceFile){
  Collection<JavaArchive> hibernateValidatorWithDependencies=DependencyResolvers.use(MavenDependencyResolver.class).goOffline().artifact("org.hibernate:hibernate-validator:" + VALIDATOR_VERSION).resolveAs(JavaArchive.class);
  if (removeServiceFile) {
    for (    JavaArchive archive : hibernateValidatorWithDependencies) {
      if (archive.contains(VALIDATION_PROVIDER_SERVICE_FILE_PATH)) {
        archive.delete(VALIDATION_PROVIDER_SERVICE_FILE_PATH);
      }
    }
  }
  hibernateValidatorWithDependencies.addAll(bundleLoggingDependencies());
  return hibernateValidatorWithDependencies;
}
 

Example 28

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

Source file: Libraries.java

  19 
vote

public static Collection<JavaArchive> seamIntlLibraryWithTransitives(){
  Collection<JavaArchive> libs=new LinkedList<JavaArchive>();
  libs.addAll(seamIntlLibrary());
  libs.addAll(solderLibraryWithTransitives());
  libs.addAll(jodaLibraryWithTransitives());
  return libs;
}