Skip to content

Instantly share code, notes, and snippets.

@agritsik
Last active April 24, 2016 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agritsik/2c3b23c1995dd34ba79b87520c524a94 to your computer and use it in GitHub Desktop.
Save agritsik/2c3b23c1995dd34ba79b87520c524a94 to your computer and use it in GitHub Desktop.
JEE integration testing with Arquillian and Glassfish
import junit.framework.TestCase;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
public class ServiceTest extends TestCase {
// EJB injection is available here
// @EJB MyService myService;
@Deployment
public static Archive<?> createDeployment() {
return ShrinkWrap.create(WebArchive.class, "test.war")
.addPackages(true, "${package}")
.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Test
public void testCRUD() throws Exception {
// Write tests here ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment