66
77package org .javaee7 .jaxrs .endpoint ;
88
9+ import static org .junit .Assert .assertEquals ;
10+
11+ import java .net .MalformedURLException ;
12+ import java .net .URL ;
13+
914import javax .ws .rs .client .Client ;
1015import javax .ws .rs .client .ClientBuilder ;
1116import javax .ws .rs .client .Entity ;
1217import javax .ws .rs .client .WebTarget ;
18+
1319import org .jboss .arquillian .container .test .api .Deployment ;
14- import org .jboss .arquillian .container .test .api .TargetsContainer ;
1520import org .jboss .arquillian .junit .Arquillian ;
21+ import org .jboss .arquillian .test .api .ArquillianResource ;
1622import org .jboss .shrinkwrap .api .ShrinkWrap ;
1723import org .jboss .shrinkwrap .api .spec .WebArchive ;
18- import org .junit .Test ;
19- import static org .junit .Assert .*;
20- import org .junit .BeforeClass ;
24+ import org .junit .Before ;
2125import org .junit .FixMethodOrder ;
26+ import org .junit .Test ;
2227import org .junit .runner .RunWith ;
2328import org .junit .runners .MethodSorters ;
2429
2530/**
2631 * @author Arun Gupta
2732 */
28- // @RunWith(Arquillian.class)
33+ @ RunWith (Arquillian .class )
2934@ FixMethodOrder (MethodSorters .NAME_ASCENDING )
3035public class MyResourceTest {
3136
@@ -37,8 +42,7 @@ public class MyResourceTest {
3742 *
3843 * @return a war file
3944 */
40- @ Deployment
41- // @TargetsContainer("wildfly-arquillian")
45+ @ Deployment (testable = false )
4246 public static WebArchive createDeployment () {
4347 WebArchive war = ShrinkWrap .create (WebArchive .class ).
4448 addClass (MyApplication .class ).
@@ -49,10 +53,13 @@ public static WebArchive createDeployment() {
4953 return war ;
5054 }
5155
52- @ BeforeClass
53- public static void setupClass () {
56+ @ ArquillianResource
57+ private URL base ;
58+
59+ @ Before
60+ public void setupClass () throws MalformedURLException {
5461 Client client = ClientBuilder .newClient ();
55- target = client .target ("http://localhost:8080/jaxrs-endpoint/ webresources/fruit" );
62+ target = client .target (new URL ( base , " webresources/fruit"). toExternalForm () );
5663 }
5764
5865 /**
0 commit comments