tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From afryer <>
Subject Re: tomee-embedded test case best practice?
Date Wed, 30 Nov 2011 07:58:33 GMT
After much head banging I managed to work out how to create an almost
identical war file to deploy using arquillian.  I'm posting the code here
because I found it pretty difficult to work out how to do this...

	public static WebArchive createTestArchive() {
		WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war");
		// adds every dependency from the pom.xml with a scope of compile
					.resolveAs(JavaArchive.class, new ScopeFilter("compile"))
		// add any other jars in the src folder.  Could make this generic.
		// adds everything in target/classes to the war file WEB-INF/classes
		war.addAsResource(new File("target/classes"), "");
		// add everything in /src/main/webapp but filter out .svn directory
		JavaArchive webappFolder = ShrinkWrap.create(JavaArchive.class,
		war.merge(webappFolder, "", new Filter<ArchivePath>() {
			public boolean include(ArchivePath ap) {
				String path = ap.get();
				return (!path.contains(".svn") && !path.contains("context.xml"));

		// uncomment this if you want to examine the war file
		// File("test.war"));
		return war;

View this message in context:
Sent from the OpenEJB User mailing list archive at

View raw message