|
18 | 18 | import org.javaee7.websocket.binary.MyEndpointClient; |
19 | 19 | import org.javaee7.websocket.binary.MyEndpointInputStream; |
20 | 20 | import org.jboss.arquillian.container.test.api.Deployment; |
21 | | -import org.jboss.arquillian.container.test.api.TargetsContainer; |
22 | 21 | import org.jboss.arquillian.junit.Arquillian; |
| 22 | +import org.jboss.arquillian.test.api.ArquillianResource; |
23 | 23 | import org.jboss.shrinkwrap.api.ShrinkWrap; |
24 | 24 | import org.jboss.shrinkwrap.api.spec.WebArchive; |
25 | 25 | import static org.junit.Assert.*; |
|
30 | 30 | * @author Nikos Ballas |
31 | 31 | * @author Arun Gupta |
32 | 32 | */ |
33 | | -//@RunWith(Arquillian.class) |
| 33 | +@RunWith(Arquillian.class) |
34 | 34 | public class WebsocketBinaryEndpointTest { |
35 | 35 |
|
36 | | - private static final String WEBAPP_SRC = "src/main/webapp"; |
37 | 36 | private static final String RESPONSE = "Hello World!"; |
38 | 37 |
|
| 38 | + @ArquillianResource |
| 39 | + URI base; |
| 40 | + |
39 | 41 | /** |
40 | 42 | * Arquillian specific method for creating a file which can be deployed |
41 | 43 | * while executing the test. |
42 | | - * |
43 | | - * @return a war file deployable in the jboss instance configuraed in |
44 | | - * arquillian.xml file. |
45 | 44 | */ |
46 | | - @Deployment(testable = false) |
47 | | -// @TargetsContainer("wildfly-arquillian") |
| 45 | + @Deployment(testable=false) |
48 | 46 | public static WebArchive createDeployment() { |
49 | 47 | WebArchive war = ShrinkWrap.create(WebArchive.class) |
50 | | - .addClass(MyEndpointByteBuffer.class) |
51 | | - .addClass(MyEndpointByteArray.class) |
52 | | - .addClass(MyEndpointInputStream.class) |
53 | | - .addClass(MyEndpointClient.class) |
54 | | - .addAsWebResource(new File(WEBAPP_SRC, "websocket.js")); |
| 48 | + .addClasses(MyEndpointByteBuffer.class, |
| 49 | + MyEndpointByteArray.class, |
| 50 | + MyEndpointInputStream.class, |
| 51 | + MyEndpointClient.class); |
| 52 | + System.out.println(war.toString(true)); |
55 | 53 | return war; |
56 | 54 | } |
57 | 55 |
|
@@ -122,6 +120,18 @@ public void testEndpointInputStream() throws DeploymentException, IOException, U |
122 | 120 | */ |
123 | 121 | public Session connectToServer(String endpoint) throws DeploymentException, IOException, URISyntaxException { |
124 | 122 | WebSocketContainer container = ContainerProvider.getWebSocketContainer(); |
125 | | - return container.connectToServer(MyEndpointClient.class, new URI("ws://localhost:8080/binary/" + endpoint)); |
| 123 | + URI uri = new URI("ws://" |
| 124 | + + base.getHost() |
| 125 | + + ":" |
| 126 | + + base.getPort() |
| 127 | + + "/" |
| 128 | + + base.getPath() |
| 129 | + + "/" |
| 130 | + |
| 131 | +// "localhost:8080/binary/"" |
| 132 | + + endpoint); |
| 133 | + System.out.println("Connecting to: " + uri); |
| 134 | + return container.connectToServer(MyEndpointClient.class, uri); |
| 135 | + |
126 | 136 | } |
127 | 137 | } |
0 commit comments