public static WebArchive defaultWebArchive() { return create(WebArchive.class, "test.war") .addPackages(true, "org.javaee7.jaspic") .deleteClass(ArquillianBase.class) .addAsWebInfResource(resource("web.xml")) .addAsWebInfResource(resource("jboss-web.xml")) .addAsWebInfResource(resource("glassfish-web.xml")); }
public static Archive<?> tryWrapEAR(WebArchive webArchive) { if (getBoolean("useEarForJaspic")) { return // EAR archive create(EnterpriseArchive.class, "test.ear") // Liberty needs to have the binding file in an ear. // TODO: this is no longer the case and this code can be removed (-bnd.xml // needs to be moved to correct place) .addAsManifestResource(resource("ibm-application-bnd.xml")) // Web module // This is needed to prevent Arquillian generating an illegal application.xml .addAsModule( webArchive ); } else { return webArchive; } }
/** * @throws IOException ShrinkWrap errors */ @Override protected void setupPathManager() throws IOException { final JavaArchive homeArchive = ShrinkWrap.create(JavaArchive.class); final FileSystem vfs = ShrinkWrapFileSystems.newFileSystem(homeArchive); PathManager.getInstance().useOverrideHomePath(vfs.getPath("")); }
@Deployment public static WebArchive createDeployment() { return ShrinkWrap.create( WebArchive.class ) .addClass( Kryptonite.class ) .addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" ) .addAsResource( new StringAsset( persistenceXml().exportAsString() ), "META-INF/persistence.xml" ); }
@Deployment public static WebArchive deploy() throws Exception { final WebArchive war = ShrinkWrap.create( WebArchive.class, ARCHIVE_NAME + ".war" ) .setManifest( "org/hibernate/test/wf/ddl/manifest.mf" ) .addClasses( WildFlyDdlEntity.class ) .addAsResource( new StringAsset( hibernate_cfg ), "hibernate.cfg.xml" ) .addClasses( BmtSfStatefulBean.class ) .addClasses( DdlInWildFlyUsingBmtAndSfTest.class ); return war; }
@Deployment public static WebArchive buildDeployment() { WebArchive war = ShrinkWrap.create( WebArchive.class ) .setManifest( "org/hibernate/test/wf/ddl/manifest.mf" ) .addClass( WildFlyDdlEntity.class ) // .addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml") .addAsResource( new StringAsset( persistenceXml().exportAsString() ), PERSISTENCE_XML_RESOURCE_NAME ) .addAsResource( "org/hibernate/test/wf/ddl/log4j.properties", "log4j.properties" ); System.out.println( war.toString(true) ); return war; }
public static File generateJar( Class<?>[] classes, String[] resources, String prefix, String archiveName) throws IOException { File jarFile = File.createTempFile(prefix, ".jar"); JavaArchive archive = ShrinkWrap.create(JavaArchive.class, archiveName).addClasses(classes); for (String resource : resources) { archive = archive.addAsResource(resource); } archive.as(ZipExporter.class).exportTo(jarFile, true); return jarFile; }
protected File buildLargeJar() throws Exception { final String fileName = "large.jar"; final JavaArchive archive = ShrinkWrap.create( JavaArchive.class, fileName ); // Build a large jar by adding a lorem ipsum file repeatedly. final Path loremipsumTxtFile = Paths.get( ScannerTests.class.getResource( "/org/hibernate/jpa/test/packaging/loremipsum.txt" ).toURI() ); for ( int i = 0; i < 100; i++ ) { ArchivePath path = ArchivePaths.create( "META-INF/file" + i ); archive.addAsResource( loremipsumTxtFile.toFile(), path ); } File testPackage = new File( shrinkwrapArchiveDirectory, fileName ); archive.as( ZipExporter.class ).exportTo( testPackage, true ); return testPackage; }
Map<ArchivePath, Node> archiveContents = archive.getContent(); for (Map.Entry<ArchivePath, Node> entry : archiveContents.entrySet()) { ArchivePath path = entry.getKey(); Node n = entry.getValue(); Path f = subpath(deployDir, path.get()); if (n.getAsset() == null) { Files.copy(n.getAsset().openStream(), f, StandardCopyOption.REPLACE_EXISTING); String p = n.getPath().get(); if (callback != null) { callback.accept(p);
@Deployment(testable = false) public static WebArchive createDeployment() { File file = findPomFile(); return ShrinkWrap.create(MavenImporter.class) .loadPomFromFile(file) .importBuildOutput() .as(WebArchive.class); }
@Test public void shouldGenerateDependencies() throws Exception { Archive<?> archive = new JUnitDeploymentAppender().createAuxiliaryArchive(); Assert.assertTrue( "Should have added Extension", archive.contains( ArchivePaths.create("/META-INF/services/org.jboss.arquillian.container.test.spi.TestRunner"))); Assert.assertTrue( "Should have added TestRunner Impl", archive.contains(ArchivePaths.create("/org/jboss/arquillian/junit/container/JUnitTestRunner.class"))); } }
@Deployment public static WebArchive createDeployment() { return ShrinkWrap.create( WebArchive.class ) .addClass( AuditedEntity.class ) .addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" ) .addAsResource( new StringAsset( persistenceXml().exportAsString() ), "META-INF/persistence.xml" ); }
@Deployment public static WebArchive deploy() throws Exception { final WebArchive war = ShrinkWrap.create( WebArchive.class, ARCHIVE_NAME + ".war" ) .setManifest( "org/hibernate/test/wf/ddl/manifest.mf" ) .addClasses( WildFlyDdlEntity.class ) .addAsResource( new StringAsset( hibernate_cfg ), "hibernate.cfg.xml" ) .addClasses( CmtSfStatefulBean.class ) .addClasses( DdlInWildFlyUsingCmtAndSfTest.class ); return war; }
@BeforeClass public static void setupEnvironment() throws Exception { final JavaArchive homeArchive = ShrinkWrap.create(JavaArchive.class); final FileSystem vfs = ShrinkWrapFileSystems.newFileSystem(homeArchive); PathManager.getInstance().useOverrideHomePath(vfs.getPath("")); /* * Create at least for each class a new headless environemnt as it is fast and prevents side effects * (Reusing a headless environment after other tests have modified the core registry isn't really clean) */ env = new HeadlessEnvironment(new Name("engine")); context = env.getContext(); moduleManager = context.get(ModuleManager.class); }
contexts.put(archive.getId(), context);
@Deployment public static WebArchive createDeployment() { return ShrinkWrap.create( WebArchive.class ) .addClass( Kryptonite.class ) .addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" ) .addAsResource( new StringAsset( persistenceXml().exportAsString() ), "META-INF/persistence.xml" ); }
@Before public void setup() throws Exception { super.setup(); JavaArchive homeArchive = ShrinkWrap.create(JavaArchive.class); FileSystem vfs = ShrinkWrapFileSystems.newFileSystem(homeArchive); PathManager.getInstance().useOverrideHomePath(temporaryFolder.getRoot().toPath()); savePath = PathManager.getInstance().getSavePath("testSave");