From f4fdd766e5393220fd0e7b54a57de9d4dde02cca Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Mon, 8 Dec 2014 22:25:14 +0100 Subject: [PATCH 1/3] starting to add Arquillian deps --- solution/movieplex7/pom.xml | 81 +++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/solution/movieplex7/pom.xml b/solution/movieplex7/pom.xml index ba0863e..a081f5f 100644 --- a/solution/movieplex7/pom.xml +++ b/solution/movieplex7/pom.xml @@ -8,7 +8,24 @@ war Java EE 7 Hands-on Lab Solution + + + 1.1.1.Final + 8.2.0.Final + + + + + org.jboss.arquillian + arquillian-bom + ${org.jboss.arquillian.version} + import + pom + + + + javax @@ -16,6 +33,20 @@ 7.0 provided + + + junit + junit + 4.10 + test + + + + org.jboss.arquillian.junit + arquillian-junit-container + test + 1.1.5.Final + @@ -44,6 +75,56 @@ + + + + wildfly-remote-arquillian + + + io.undertow + undertow-websockets-jsr + 1.0.0.Beta33 + test + + + org.jboss.resteasy + resteasy-client + 3.0.10.Final + test + + + org.jboss.resteasy + resteasy-jaxb-provider + 3.0.10.Final + test + + + org.jboss.resteasy + resteasy-json-p-provider + 3.0.10.Final + test + + + org.wildfly + wildfly-arquillian-container-remote + ${org.wildfly} + test + + + + + + src/test/resources + true + + + src/test/resources-wildfly-remote + true + + + + + From 250079fc5273a3b90a1122e5f18a07b0cf37ddf7 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Mon, 8 Dec 2014 22:28:04 +0100 Subject: [PATCH 2/3] adding first test - not working yet --- .../movieplex7/rest/MovieFacadeRESTTest.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 solution/movieplex7/src/test/java/org/javaee7/movieplex7/rest/MovieFacadeRESTTest.java diff --git a/solution/movieplex7/src/test/java/org/javaee7/movieplex7/rest/MovieFacadeRESTTest.java b/solution/movieplex7/src/test/java/org/javaee7/movieplex7/rest/MovieFacadeRESTTest.java new file mode 100644 index 0000000..9e3b4bb --- /dev/null +++ b/solution/movieplex7/src/test/java/org/javaee7/movieplex7/rest/MovieFacadeRESTTest.java @@ -0,0 +1,50 @@ +package org.javaee7.movieplex7.rest; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.WebTarget; +import org.javaee7.movieplex7.entities.Movie; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; +import org.junit.runner.RunWith; + +/** + * @author arungupta + */ +@RunWith(Arquillian.class) +public class MovieFacadeRESTTest { + + private WebTarget target; + + @Deployment(testable = false) + public static WebArchive createDeployment() { + return ShrinkWrap.create(WebArchive.class) + .addPackages(true, "org.javaee7.movieplex7"); + } + + @ArquillianResource + private URL base; + + @Before + public void setUp() throws MalformedURLException { + Client client = ClientBuilder.newClient(); + target = client.target(URI.create(new URL(base, "webresources/movie").toExternalForm())); + target.register(Movie.class); + } + + @Test + public void testGetAll() throws Exception { + Movie[] list = target.request().get(Movie[].class); + assertEquals(20, list.length); + } + +} From 5c8e041f3fe26b168baed401fd37367a66f2d22b Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Mon, 8 Dec 2014 23:06:03 +0100 Subject: [PATCH 3/3] simple test is now working --- .../movieplex7/rest/MovieFacadeRESTTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/solution/movieplex7/src/test/java/org/javaee7/movieplex7/rest/MovieFacadeRESTTest.java b/solution/movieplex7/src/test/java/org/javaee7/movieplex7/rest/MovieFacadeRESTTest.java index 9e3b4bb..a0898f4 100644 --- a/solution/movieplex7/src/test/java/org/javaee7/movieplex7/rest/MovieFacadeRESTTest.java +++ b/solution/movieplex7/src/test/java/org/javaee7/movieplex7/rest/MovieFacadeRESTTest.java @@ -1,5 +1,6 @@ package org.javaee7.movieplex7.rest; +import java.io.File; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; @@ -24,11 +25,24 @@ public class MovieFacadeRESTTest { private WebTarget target; + private static final String WEBAPP_SRC = "src/main/webapp"; + private static final String RESOURCE_SRC = "src/main/resources"; @Deployment(testable = false) public static WebArchive createDeployment() { - return ShrinkWrap.create(WebArchive.class) + WebArchive war = ShrinkWrap.create(WebArchive.class) .addPackages(true, "org.javaee7.movieplex7"); + + for (File file : new File(WEBAPP_SRC + "/WEB-INF").listFiles()) { + war.addAsWebInfResource(file); + } + + for (File file : new File(RESOURCE_SRC).listFiles()) { + war.addAsResource(file); + } + + System.out.println(war.toString(true)); + return war; } @ArquillianResource