Java Code Examples for org.jboss.shrinkwrap.api.ShrinkWrap

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

  19 
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

  19 
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-glassfish, under directory /glassfish-managed-3.1/src/test/java/org/jboss/arquillian/container/glassfish/managed_3_1/.

Source file: GlassFishManagedDeployEarTest.java

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

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

Source file: ARQ193ExplicitTestCase.java

  19 
vote

@Deployment public static Archive<?> createDeployment(){
  final JavaArchive archive=ShrinkWrap.create(JavaArchive.class,"arq139-explicit");
  archive.addClass(ARQ193ExplicitTestCase.class);
  archive.setManifest(new Asset(){
    public InputStream openStream(){
      OSGiManifestBuilder builder=OSGiManifestBuilder.newInstance();
      builder.addBundleSymbolicName(archive.getName());
      builder.addBundleManifestVersion(2);
      builder.addExportPackages(ARQ193ExplicitTestCase.class);
      builder.addImportPackages("org.jboss.arquillian.test.api","org.jboss.arquillian.junit");
      builder.addImportPackages("org.jboss.shrinkwrap.api","org.jboss.shrinkwrap.api.asset","org.jboss.shrinkwrap.api.spec");
      builder.addImportPackages("javax.inject","org.junit","org.junit.runner","org.osgi.framework");
      return builder.openStream();
    }
  }
);
  return archive;
}
 

Example 5

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

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

From project arquillian-core, under directory /container/impl-base/src/test/java/org/jboss/arquillian/container/impl/client/container/.

Source file: ContainerDeployControllerTestCase.java

  19 
vote

@Before public void setup() throws Exception {
  when(deployableContainer1.deploy(isA(Archive.class))).thenReturn(protocolMetaData);
  when(deployableContainer1.getConfigurationClass()).thenReturn(DummyContainerConfiguration.class);
  when(deployableContainer2.deploy(isA(Archive.class))).thenReturn(protocolMetaData);
  when(deployableContainer2.getConfigurationClass()).thenReturn(DummyContainerConfiguration.class);
  when(serviceLoader.onlyOne(eq(DeployableContainer.class))).thenReturn(deployableContainer1,deployableContainer2);
  when(container1.getContainerName()).thenReturn(CONTAINER_1_NAME);
  when(container2.getContainerName()).thenReturn(CONTAINER_2_NAME);
  scenario.addDeployment(new DeploymentDescription(DEPLOYMENT_1_NAME,ShrinkWrap.create(JavaArchive.class)).setTarget(new TargetDescription(CONTAINER_1_NAME)).shouldBeTestable(false).setOrder(2));
  scenario.addDeployment(new DeploymentDescription(DEPLOYMENT_2_NAME,ShrinkWrap.create(JavaArchive.class)).setTarget(new TargetDescription(CONTAINER_2_NAME)).setOrder(1).shouldBeTestable(true).setTestableArchive(ShrinkWrap.create(JavaArchive.class)));
  scenario.addDeployment(new DeploymentDescription(DEPLOYMENT_3_NAME,ShrinkWrap.create(JavaArchive.class)).setTarget(new TargetDescription(CONTAINER_2_NAME)).setOrder(3).shouldBeTestable(false).shouldBeManaged(false));
  scenario.addDeployment(new DeploymentDescription(DEPLOYMENT_4_NAME,Descriptors.create(BeansDescriptor.class)).setTarget(new TargetDescription(CONTAINER_1_NAME)).setOrder(4).shouldBeManaged(true));
  registry=new LocalContainerRegistry(injector.get());
  bind(ApplicationScoped.class,ContainerRegistry.class,registry);
  bind(ApplicationScoped.class,DeploymentScenario.class,scenario);
}
 

Example 7

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

Source file: AgentInstaller.java

  19 
vote

public void install(@Observes(precedence=1) BeforeSuite event){
  try {
    BytemanConfiguration config=BytemanConfiguration.from(descriptorInst.get());
    if (!config.autoInstallAgent()) {
      return;
    }
    try {
      Class<?> mainClass=Thread.currentThread().getContextClassLoader().loadClass("org.jboss.byteman.agent.Main");
      if (!(Boolean)mainClass.getDeclaredField("firstTime").get(null)) {
        return;
      }
    }
 catch (    ClassNotFoundException e) {
    }
    String pid=ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
    File bytemanHome=File.createTempFile("byteman","agent");
    bytemanHome.delete();
    bytemanHome.mkdir();
    File bytemanLib=new File(bytemanHome,"lib");
    bytemanLib.mkdirs();
    InputStream bytemanInputJar=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")).as(ZipExporter.class).exportAsInputStream();
    File bytemanJar=new File(bytemanLib,BytemanConfiguration.BYTEMAN_JAR);
    GenerateScriptUtil.copy(bytemanInputJar,new FileOutputStream(bytemanJar));
    VirtualMachine vm=VirtualMachine.attach(pid);
    String agentProperties=config.agentProperties();
    vm.loadAgent(bytemanJar.getAbsolutePath(),"listener:true,port:" + config.clientAgentPort() + (agentProperties != null ? ",prop:" + agentProperties : ""));
    vm.detach();
  }
 catch (  IOException e) {
    throw new RuntimeException("Could not write byteman.jar to disk",e);
  }
catch (  Exception e) {
    throw new RuntimeException("Could not install byteman agent",e);
  }
}
 

Example 8

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

Source file: EarDeploymentTestCase.java

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

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

Source file: PersistenceExtensionConfigurationTestArchiveEnricher.java

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

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

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

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

Source file: DeploymentEnricher.java

  19 
vote

@Override public Archive<?> createAuxiliaryArchive(){
  TestClass testClass=this.testClass.get();
  if (testClass.isAnnotationPresent(WarpTest.class)) {
    JavaArchive archive=ShrinkWrap.create(JavaArchive.class,"extension-warp.jar");
    archive.addClass(ServerAssertion.class);
    archive.addPackage("org.jboss.arquillian.warp.spi");
    archive.addPackage("org.jboss.arquillian.warp.impl.server.assertion");
    archive.addPackage("org.jboss.arquillian.warp.impl.server.enrichment");
    archive.addPackage("org.jboss.arquillian.warp.impl.server.event");
    archive.addPackage("org.jboss.arquillian.warp.impl.server.execution");
    archive.addPackage("org.jboss.arquillian.warp.impl.server.lifecycle");
    archive.addPackage("org.jboss.arquillian.warp.impl.server.provider");
    archive.addPackage("org.jboss.arquillian.warp.impl.server.request");
    archive.addPackage("org.jboss.arquillian.warp.impl.server.test");
    archive.addPackage("org.jboss.arquillian.warp.impl.shared");
    archive.addPackage("org.jboss.arquillian.warp.impl.utils");
    archive.addPackage("org.jboss.arquillian.warp.extension.servlet");
    archive.addClass(WarpRemoteExtension.class);
    archive.addAsServiceProvider(RemoteLoadableExtension.class,WarpRemoteExtension.class);
    return archive;
  }
 else {
    return null;
  }
}
 

Example 12

From project arquillian-maven, under directory /plugin/src/main/java/org/jboss/arquillian/maven/.

Source file: BaseCommand.java

  19 
vote

Archive<?> createDeployment(){
  getLog().info(goal() + " file: " + file().getAbsoluteFile());
  File deploymentFile=file();
  Archive<?> deployment=ShrinkWrap.create(ZipImporter.class,deploymentFile.getName()).importFrom(deploymentFile).as(GenericArchive.class);
  return deployment;
}
 

Example 13

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

Source file: SynchronousPaymentProcessorTestCase.java

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

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

Source file: GlassFishJSR88RemoteContainerEARTestCase.java

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

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

Source file: WebArchiveBuilder.java

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

From project big-data-plugin, under directory /shims/api/test-src/org/pentaho/hadoop/shim/.

Source file: HadoopConfigurationLocatorTest.java

  19 
vote

@BeforeClass public static void setup() throws Exception {
  FileObject ramRoot=VFS.getManager().resolveFile(HADOOP_CONFIGURATIONS_PATH);
  FileObject aConfigFolder=ramRoot.resolveFile("a");
  if (aConfigFolder.exists()) {
    aConfigFolder.delete(new AllFileSelector());
  }
  aConfigFolder.createFolder();
  assertEquals(FileType.FOLDER,aConfigFolder.getType());
  FileObject configFile=aConfigFolder.resolveFile("config.properties");
  Properties p=new Properties();
  p.setProperty("name","Test Configuration A");
  p.setProperty("classpath","");
  p.setProperty("library.path","");
  p.store(configFile.getContent().getOutputStream(),"Test Configuration A");
  FileObject implJar=aConfigFolder.resolveFile("a-config.jar");
  implJar.createFile();
  JavaArchive archive=ShrinkWrap.create(JavaArchive.class,"a-configuration.jar").addAsServiceProvider(HadoopShim.class,MockHadoopShim.class).addClass(MockHadoopShim.class);
  archive.as(ZipExporter.class).exportTo(implJar.getContent().getOutputStream());
}
 

Example 17

From project capedwarf-blue, under directory /quota/src/test/java/org/jboss/test/capedwarf/quota/test/.

Source file: SimpleQuotaTestCase.java

  19 
vote

@Deployment public static WebArchive getDeployment(){
  final WebArchive war=ShrinkWrap.create(WebArchive.class);
  war.setWebXML(new StringAsset("<web/>"));
  war.addAsWebInfResource("appengine-web.xml");
  return war;
}
 

Example 18

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

Source file: DefaultTestCase.java

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

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 20

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

Source file: JCAMixIn.java

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

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 22

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

Source file: CoreDeployment.java

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

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

Source file: FSTestCase.java

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

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 25

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 26

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

Source file: JaxrsClientTestCase.java

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

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

Source file: BlueprintTestCase.java

  19 
vote

@Deployment(name=BLUEPRINT_PROVIDER) public static JavaArchive blueprintProvider(){
  final JavaArchive archive=ShrinkWrap.create(JavaArchive.class,BLUEPRINT_PROVIDER);
  archive.addClasses(JMXSupport.class,BlueprintSupport.class,AriesSupport.class,RepositorySupport.class);
  archive.addClasses(BeanA.class,ServiceA.class,BeanB.class,ServiceB.class);
  archive.addAsManifestResource(RepositorySupport.BUNDLE_VERSIONS_FILE);
  archive.setManifest(new Asset(){
    public InputStream openStream(){
      OSGiManifestBuilder builder=OSGiManifestBuilder.newInstance();
      builder.addBundleSymbolicName(archive.getName());
      builder.addBundleManifestVersion(2);
      builder.addImportPackages(XRequirementBuilder.class,XRequirement.class,Repository.class,Resource.class);
      builder.addImportPackages(PackageAdmin.class,MBeanServer.class,ServiceTracker.class);
      builder.addExportPackages(ServiceA.class);
      return builder.openStream();
    }
  }
);
  return archive;
}