|
1 | 1 | /**
|
2 |
| - * |
| 2 | + * |
3 | 3 | */
|
4 | 4 | package org.javaee7.websocket.binary.test;
|
5 | 5 |
|
6 |
| -import io.undertow.websockets.jsr.UndertowContainerProvider; |
7 | 6 |
|
8 | 7 | import java.io.File;
|
9 | 8 | import java.io.IOException;
|
10 | 9 | import java.net.URI;
|
11 | 10 | import java.net.URISyntaxException;
|
| 11 | +import javax.websocket.ContainerProvider; |
12 | 12 |
|
13 | 13 | import javax.websocket.DeploymentException;
|
14 | 14 | import javax.websocket.Session;
|
15 | 15 | import javax.websocket.WebSocketContainer;
|
16 | 16 |
|
17 |
| -import junit.framework.Assert; |
| 17 | +import static junit.framework.Assert.assertNull; |
18 | 18 |
|
19 | 19 | import org.javaee7.websocket.binary.MyEndpointByteArray;
|
20 | 20 | import org.javaee7.websocket.binary.MyEndpointByteBuffer;
|
|
29 | 29 | import org.junit.runner.RunWith;
|
30 | 30 |
|
31 | 31 | /**
|
32 |
| - * @author Nikos Ballas |
33 |
| - * |
| 32 | + * @author Nikos Ballas |
| 33 | + * @author Arun Gupta |
34 | 34 | */
|
35 | 35 | @RunWith(Arquillian.class)
|
36 | 36 | public class WebsocketBinaryEndpointTest {
|
37 |
| - private static final String WEBAPP_SRC = "src/main/webapp"; |
38 | 37 |
|
39 |
| - /** |
40 |
| - * Arquillian specific method for creating a file which can be deployed |
41 |
| - * while executing the test. |
42 |
| - * |
43 |
| - * @return a war file deployable in the jboss instance configuraed in arquillian.xml file. |
44 |
| - */ |
45 |
| - @Deployment(testable = false) |
46 |
| - @TargetsContainer("wildfly-arquillian") |
47 |
| - public static WebArchive createDeployment() { |
48 |
| - WebArchive war = ShrinkWrap.create(WebArchive.class) |
49 |
| - .addClass(MyEndpointByteBuffer.class) |
50 |
| - .addClass(MyEndpointByteArray.class) |
51 |
| - .addClass(MyEndpointInputStream.class) |
52 |
| - .addClass(MyEndpointClient.class) |
53 |
| - .addAsWebResource(new File(WEBAPP_SRC, "index.jsp")) |
54 |
| - .addAsWebResource(new File(WEBAPP_SRC, "websocket.js")); |
55 |
| - return war; |
56 |
| - } |
| 38 | + private static final String WEBAPP_SRC = "src/main/webapp"; |
57 | 39 |
|
58 |
| - /** |
59 |
| - * The basic test method for the class {@link MyEndpointByteBuffer} |
60 |
| - * |
61 |
| - * @throws URISyntaxException |
62 |
| - * @throws DeploymentException |
63 |
| - * @throws IOException |
64 |
| - */ |
65 |
| - @Test |
66 |
| - public void testEndpointByteBuffer() throws URISyntaxException,DeploymentException, IOException { |
67 |
| - Session session = connectToServer("bytebuffer"); |
68 |
| - Assert.assertNull(session); |
69 |
| - } |
| 40 | + /** |
| 41 | + * Arquillian specific method for creating a file which can be deployed |
| 42 | + * while executing the test. |
| 43 | + * |
| 44 | + * @return a war file deployable in the jboss instance configuraed in |
| 45 | + * arquillian.xml file. |
| 46 | + */ |
| 47 | + @Deployment(testable = false) |
| 48 | + @TargetsContainer("wildfly-arquillian") |
| 49 | + public static WebArchive createDeployment() { |
| 50 | + WebArchive war = ShrinkWrap.create(WebArchive.class) |
| 51 | + .addClass(MyEndpointByteBuffer.class) |
| 52 | + .addClass(MyEndpointByteArray.class) |
| 53 | + .addClass(MyEndpointInputStream.class) |
| 54 | + .addClass(MyEndpointClient.class) |
| 55 | + .addAsWebResource(new File(WEBAPP_SRC, "index.jsp")) |
| 56 | + .addAsWebResource(new File(WEBAPP_SRC, "websocket.js")); |
| 57 | + return war; |
| 58 | + } |
70 | 59 |
|
71 |
| - /** |
72 |
| - * The basic test method for the class {@MyEndpointByteArray |
73 |
| - * } |
74 |
| - * |
75 |
| - * @throws DeploymentException |
76 |
| - * @throws IOException |
77 |
| - * @throws URISyntaxException |
78 |
| - */ |
79 |
| - @Test |
80 |
| - public void testEndpointByteArray() throws DeploymentException,IOException, URISyntaxException { |
81 |
| - Session session = connectToServer("bytearray"); |
82 |
| - Assert.assertNull(session); |
83 |
| - } |
| 60 | + /** |
| 61 | + * The basic test method for the class {@link MyEndpointByteBuffer} |
| 62 | + * |
| 63 | + * @throws URISyntaxException |
| 64 | + * @throws DeploymentException |
| 65 | + * @throws IOException |
| 66 | + */ |
| 67 | + @Test |
| 68 | + public void testEndpointByteBuffer() throws URISyntaxException, DeploymentException, IOException { |
| 69 | + Session session = connectToServer("bytebuffer"); |
| 70 | + assertNull(session); |
| 71 | + } |
84 | 72 |
|
85 |
| - /** |
86 |
| - * The basic test method for the class {@MyEndpointInputStream |
87 |
| - * } |
88 |
| - * |
89 |
| - * @throws DeploymentException |
90 |
| - * @throws IOException |
91 |
| - * @throws URISyntaxException |
92 |
| - */ |
93 |
| - @Test |
94 |
| - public void testEndpointInputStream() throws DeploymentException,IOException, URISyntaxException { |
95 |
| - Session session = connectToServer("inputstream"); |
96 |
| - Assert.assertNull(session); |
97 |
| - } |
| 73 | + /** |
| 74 | + * The basic test method for the class { |
| 75 | + * |
| 76 | + * @MyEndpointByteArray } |
| 77 | + * |
| 78 | + * @throws DeploymentException |
| 79 | + * @throws IOException |
| 80 | + * @throws URISyntaxException |
| 81 | + */ |
| 82 | + @Test |
| 83 | + public void testEndpointByteArray() throws DeploymentException, IOException, URISyntaxException { |
| 84 | + Session session = connectToServer("bytearray"); |
| 85 | + assertNull(session); |
| 86 | + } |
98 | 87 |
|
99 |
| - /** |
100 |
| - * Method used to supply connection to the server by passing the naming of |
101 |
| - * the websocket endpoint |
102 |
| - * |
103 |
| - * @param endpoint |
104 |
| - * @return |
105 |
| - * @throws DeploymentException |
106 |
| - * @throws IOException |
107 |
| - * @throws URISyntaxException |
108 |
| - */ |
109 |
| - public Session connectToServer(String endpoint) throws DeploymentException, IOException, URISyntaxException { |
110 |
| - WebSocketContainer wSocketContainer = UndertowContainerProvider.getWebSocketContainer(); |
111 |
| - return wSocketContainer.connectToServer(MyEndpointClient.class, new URI("ws://localhost:8080/binary/" + endpoint)); |
112 |
| - } |
| 88 | + /** |
| 89 | + * The basic test method for the class { |
| 90 | + * |
| 91 | + * @MyEndpointInputStream } |
| 92 | + * |
| 93 | + * @throws DeploymentException |
| 94 | + * @throws IOException |
| 95 | + * @throws URISyntaxException |
| 96 | + */ |
| 97 | + @Test |
| 98 | + public void testEndpointInputStream() throws DeploymentException, IOException, URISyntaxException { |
| 99 | + Session session = connectToServer("inputstream"); |
| 100 | + assertNull(session); |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | + * Method used to supply connection to the server by passing the naming of |
| 105 | + * the websocket endpoint |
| 106 | + * |
| 107 | + * @param endpoint |
| 108 | + * @return |
| 109 | + * @throws DeploymentException |
| 110 | + * @throws IOException |
| 111 | + * @throws URISyntaxException |
| 112 | + */ |
| 113 | + public Session connectToServer(String endpoint) throws DeploymentException, IOException, URISyntaxException { |
| 114 | + WebSocketContainer wSocketContainer = ContainerProvider.getWebSocketContainer(); |
| 115 | + return wSocketContainer.connectToServer(MyEndpointClient.class, new URI("ws://localhost:8080/binary/" + endpoint)); |
| 116 | + } |
113 | 117 | }
|
0 commit comments