Skip to content

Commit 6a8bd7a

Browse files
committed
Adding new methods in test to cover all three test cases.I have serious
doubts though if undertow implements JSR 356 to full extend.
1 parent 3db2bb2 commit 6a8bd7a

File tree

5 files changed

+87
-46
lines changed

5 files changed

+87
-46
lines changed

pom.xml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,6 @@
6565
<version>${org.jboss.arquillian.version}</version>
6666
<scope>test</scope>
6767
</dependency>
68-
<dependency>
69-
<groupId>org.jboss.arquillian.extension</groupId>
70-
<artifactId>arquillian-drone-bom</artifactId>
71-
<version>1.2.0.Final</version>
72-
<type>pom</type>
73-
<scope>test</scope>
74-
</dependency>
75-
<dependency>
76-
<groupId>org.jboss.arquillian.graphene</groupId>
77-
<artifactId>graphene-webdriver</artifactId>
78-
<version>2.0.0.Final</version>
79-
<type>pom</type>
80-
<scope>test</scope>
81-
</dependency>
82-
<dependency>
83-
<groupId>org.jboss.arquillian.selenium</groupId>
84-
<artifactId>selenium-bom</artifactId>
85-
<version>2.35.0</version>
86-
<type>pom</type>
87-
<scope>test</scope>
88-
</dependency>
8968
</dependencies>
9069

9170
<pluginRepositories>

websocket/binary/src/main/java/org/javaee7/websocket/binary/MyEndpointClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212

1313
/**
1414
* @author Nikolaos Ballas
15-
*
15+
*
1616
*/
1717
@ClientEndpoint
1818
public class MyEndpointClient {
1919
@OnOpen
20-
public void onOpen(Session session){
21-
System.out.println("[Action]->Invokint method onOpen of the class:"+this.getClass().getCanonicalName());
22-
try{
20+
public void onOpen(Session session) {
21+
System.out.println("[Action]->Invokint method onOpen of the class:"+ this.getClass().getCanonicalName());
22+
try {
2323
session.getBasicRemote().sendBinary(ByteBuffer.wrap("Hello World!".getBytes()));
24-
}catch(IOException ioe){
24+
} catch (IOException ioe) {
2525
ioe.printStackTrace();
2626
}
2727
}

websocket/binary/src/test/java/org/javaee7/websocket/binary/test/WebsocketByteBufferEndpointTest.java

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010

1111
import javax.websocket.ContainerProvider;
1212
import javax.websocket.DeploymentException;
13+
import javax.websocket.Session;
1314
import javax.websocket.WebSocketContainer;
1415

16+
import junit.framework.Assert;
17+
1518
import org.javaee7.websocket.binary.MyEndpointByteArray;
1619
import org.javaee7.websocket.binary.MyEndpointByteBuffer;
1720
import org.javaee7.websocket.binary.MyEndpointClient;
@@ -25,37 +28,84 @@
2528
import org.junit.runner.RunWith;
2629

2730
/**
28-
* @author Nikos "cirix" Ballas
29-
*
31+
* @author Nikos Ballas
32+
*
3033
*/
3134
@RunWith(Arquillian.class)
3235
public class WebsocketByteBufferEndpointTest {
3336
private static final String WEBAPP_SRC = "src/main/webapp";
34-
37+
3538
/**
36-
* Arquillian specific method for creating a file which can be deployed while executing the test.
37-
* @return a war file
39+
* Arquillian specific method for creating a file which can be deployed
40+
* while executing the test.
41+
*
42+
* @return a war file deployable in the jboss instance configuraed in arquillian.xml file.
3843
*/
39-
@Deployment(testable = false) @TargetsContainer("wildfly-arquillian")
40-
public static WebArchive createDeployment(){
41-
WebArchive war = ShrinkWrap.create(WebArchive.class).
42-
addClass(MyEndpointByteBuffer.class).
43-
addClass(MyEndpointByteArray.class).
44-
addClass(MyEndpointInputStream.class).
45-
addAsWebResource(new File(WEBAPP_SRC,"index.jsp")).
46-
addAsWebResource(new File(WEBAPP_SRC,"websocket.js"));
44+
@Deployment(testable = false)
45+
@TargetsContainer("wildfly-arquillian")
46+
public static WebArchive createDeployment() {
47+
WebArchive war = ShrinkWrap.create(WebArchive.class)
48+
.addClass(MyEndpointByteBuffer.class)
49+
.addClass(MyEndpointByteArray.class)
50+
.addClass(MyEndpointInputStream.class)
51+
.addAsWebResource(new File(WEBAPP_SRC, "index.jsp"))
52+
.addAsWebResource(new File(WEBAPP_SRC, "websocket.js"));
4753
return war;
4854
}
49-
55+
5056
/**
5157
* The basic test method for the class {@link MyEndpointByteBuffer}
58+
*
5259
* @throws URISyntaxException
5360
* @throws DeploymentException
5461
* @throws IOException
5562
*/
56-
@Test
57-
public void testEndPointByteBuffer() throws URISyntaxException, DeploymentException,IOException{
63+
@Test
64+
public void testEndpointByteBuffer() throws URISyntaxException,DeploymentException, IOException {
65+
Session session = connectToServer("bytebuffer");
66+
Assert.assertNull(session);
67+
}
68+
69+
/**
70+
* The basic test method for the class {@MyEndpointByteArray
71+
* }
72+
*
73+
* @throws DeploymentException
74+
* @throws IOException
75+
* @throws URISyntaxException
76+
*/
77+
@Test
78+
public void testEndpointByteArray() throws DeploymentException,IOException, URISyntaxException {
79+
Session session = connectToServer("bytearray");
80+
Assert.assertNull(session);
81+
}
82+
83+
/**
84+
* The basic test method for the class {@MyEndpointInputStream
85+
* }
86+
*
87+
* @throws DeploymentException
88+
* @throws IOException
89+
* @throws URISyntaxException
90+
*/
91+
@Test
92+
public void testEndpointInputStream() throws DeploymentException,IOException, URISyntaxException {
93+
Session session = connectToServer("inputstream");
94+
Assert.assertNull(session);
95+
}
96+
97+
/**
98+
* Method used to supply connection to the server by passing the naming of
99+
* the websocket endpoint
100+
*
101+
* @param endpoint
102+
* @return
103+
* @throws DeploymentException
104+
* @throws IOException
105+
* @throws URISyntaxException
106+
*/
107+
public Session connectToServer(String endpoint) throws DeploymentException, IOException, URISyntaxException {
58108
WebSocketContainer wSocketContainer = ContainerProvider.getWebSocketContainer();
59-
wSocketContainer.connectToServer(MyEndpointClient.class, new URI("ws://localhost:8080/binary/websockeet"));
109+
return wSocketContainer.connectToServer(MyEndpointClient.class, new URI("ws://localhost:8080/binary/" + endpoint));
60110
}
61111
}

websocket/binary/src/test/resources/arquillian.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
66
<defaultProtocol type="Servlet 3.0" />
77
<engine>
8-
<property name="deploymentExportPath">${serverRoot}/deployments</property>
8+
<property name="deploymentExportPath">${serverRoot}/standalone/deployments</property>
99
</engine>
1010
<extension qualifier="${browser}" />
1111
<container qualifier="wildfly-arquillian" default="true" mode="suite">

websocket/pom.xml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
<groupId>org.javaee7.websocket</groupId>
1212
<artifactId>websocket-samples</artifactId>
13-
<version>1.0-SNAPSHOT</version>
1413
<packaging>pom</packaging>
1514
<name>Java EE 7 WebSocket Samples</name>
1615

@@ -47,5 +46,18 @@
4746
<module>whiteboard</module>
4847
<module>endpoint-singleton</module>
4948
</modules>
50-
49+
<dependencies>
50+
<dependency>
51+
<groupId>io.undertow</groupId>
52+
<artifactId>undertow-core</artifactId>
53+
<version>1.0.0.Beta20</version>
54+
<scope>test</scope>
55+
</dependency>
56+
<dependency>
57+
<groupId>io.undertow</groupId>
58+
<artifactId>undertow-websockets-jsr</artifactId>
59+
<version>1.0.0.Beta20</version>
60+
<scope>test</scope>
61+
</dependency>
62+
</dependencies>
5163
</project>

0 commit comments

Comments
 (0)