Skip to content

Commit 23a7d57

Browse files
committed
Going back to 4 space indentation and removing Undertow-specific APIs (keep the code clean and appserver-agnostic)
1 parent c8c85db commit 23a7d57

File tree

1 file changed

+80
-76
lines changed

1 file changed

+80
-76
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/**
2-
*
2+
*
33
*/
44
package org.javaee7.websocket.binary.test;
55

6-
import io.undertow.websockets.jsr.UndertowContainerProvider;
76

87
import java.io.File;
98
import java.io.IOException;
109
import java.net.URI;
1110
import java.net.URISyntaxException;
11+
import javax.websocket.ContainerProvider;
1212

1313
import javax.websocket.DeploymentException;
1414
import javax.websocket.Session;
1515
import javax.websocket.WebSocketContainer;
1616

17-
import junit.framework.Assert;
17+
import static junit.framework.Assert.assertNull;
1818

1919
import org.javaee7.websocket.binary.MyEndpointByteArray;
2020
import org.javaee7.websocket.binary.MyEndpointByteBuffer;
@@ -29,85 +29,89 @@
2929
import org.junit.runner.RunWith;
3030

3131
/**
32-
* @author Nikos Ballas
33-
*
32+
* @author Nikos Ballas
33+
* @author Arun Gupta
3434
*/
3535
@RunWith(Arquillian.class)
3636
public class WebsocketBinaryEndpointTest {
37-
private static final String WEBAPP_SRC = "src/main/webapp";
3837

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";
5739

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+
}
7059

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+
}
8472

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+
}
9887

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+
}
113117
}

0 commit comments

Comments
 (0)