|
6 | 6 |
|
7 | 7 | package org.javaee7.jaxrs.mapping.exceptions; |
8 | 8 |
|
| 9 | +import static org.junit.Assert.assertEquals; |
| 10 | +import static org.junit.Assert.fail; |
| 11 | + |
| 12 | +import java.net.MalformedURLException; |
| 13 | +import java.net.URL; |
| 14 | + |
9 | 15 | import javax.ws.rs.ClientErrorException; |
10 | 16 | import javax.ws.rs.client.Client; |
11 | 17 | import javax.ws.rs.client.ClientBuilder; |
12 | 18 | import javax.ws.rs.client.WebTarget; |
| 19 | + |
| 20 | +import org.jboss.arquillian.container.test.api.Deployment; |
| 21 | +import org.jboss.arquillian.junit.Arquillian; |
| 22 | +import org.jboss.arquillian.test.api.ArquillianResource; |
| 23 | +import org.jboss.shrinkwrap.api.ShrinkWrap; |
| 24 | +import org.jboss.shrinkwrap.api.spec.WebArchive; |
13 | 25 | import org.junit.Before; |
14 | 26 | import org.junit.Test; |
15 | | -import static org.junit.Assert.*; |
| 27 | +import org.junit.runner.RunWith; |
16 | 28 |
|
17 | 29 | /** |
18 | 30 | * |
19 | 31 | * @author argupta |
20 | 32 | */ |
| 33 | +@RunWith(Arquillian.class) |
21 | 34 | public class MyResourceTest { |
22 | | - WebTarget target; |
| 35 | + |
| 36 | + @Deployment(testable = false) |
| 37 | + public static WebArchive createDeployment() { |
| 38 | + return ShrinkWrap.create(WebArchive.class) |
| 39 | + .addClasses( |
| 40 | + MyApplication.class, MyResource.class, |
| 41 | + OrderNotFoundException.class, OrderNotFoundExceptionMapper.class); |
| 42 | + } |
| 43 | + @ArquillianResource |
| 44 | + private URL base; |
| 45 | + |
| 46 | + private WebTarget target; |
23 | 47 |
|
24 | 48 | @Before |
25 | | - public void setUp() { |
| 49 | + public void setUp() throws MalformedURLException { |
26 | 50 | Client client = ClientBuilder.newClient(); |
27 | 51 | target = client |
28 | | - .target("http://localhost:8080/mapping-exceptions/webresources/order"); |
| 52 | + .target(new URL(base, "webresources/order").toExternalForm()); |
29 | 53 | } |
30 | 54 |
|
31 | 55 | /** |
|
0 commit comments