Skip to content

Commit c0ac3a4

Browse files
committed
Adding the extra Endpoint Client and necessary configuration at the
test.
1 parent 7a3db86 commit c0ac3a4

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
*
3+
*/
4+
package org.javaee7.websocket.binary;
5+
6+
import java.io.IOException;
7+
import java.nio.ByteBuffer;
8+
9+
import javax.websocket.ClientEndpoint;
10+
import javax.websocket.OnOpen;
11+
import javax.websocket.Session;
12+
13+
/**
14+
* @author Nikolaos Ballas
15+
*
16+
*/
17+
@ClientEndpoint
18+
public class MyEndpointClient {
19+
@OnOpen
20+
public void onOpen(Session session){
21+
System.out.println("[Action]->Invokint method onOpen of the class:"+this.getClass().getCanonicalName());
22+
try{
23+
session.getBasicRemote().sendBinary(ByteBuffer.wrap("Hello World!".getBytes()));
24+
}catch(IOException ioe){
25+
ioe.printStackTrace();
26+
}
27+
}
28+
}

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
import java.io.IOException;
88
import java.net.URI;
99
import java.net.URISyntaxException;
10-
import java.nio.ByteBuffer;
1110

1211
import javax.websocket.ContainerProvider;
1312
import javax.websocket.DeploymentException;
14-
import javax.websocket.Session;
1513
import javax.websocket.WebSocketContainer;
1614

1715
import org.javaee7.websocket.binary.MyEndpoint;
16+
import org.javaee7.websocket.binary.MyEndpointClient;
1817
import org.jboss.arquillian.container.test.api.Deployment;
1918
import org.jboss.arquillian.container.test.api.TargetsContainer;
2019
import org.jboss.arquillian.junit.Arquillian;
@@ -53,7 +52,6 @@ public static WebArchive createDeployment(){
5352
@Test
5453
public void testEndPointBinary() throws URISyntaxException, DeploymentException,IOException{
5554
WebSocketContainer socketContainer = ContainerProvider.getWebSocketContainer();
56-
Session session = socketContainer.connectToServer(MyEndpoint.class, new URI("ws://localhost:8080/binary/websockeet"));
57-
session.getBasicRemote().sendBinary(ByteBuffer.wrap("Hello World".getBytes()));
55+
socketContainer.connectToServer(MyEndpointClient.class, new URI("ws://localhost:8080/binary/websockeet"));
5856
}
5957
}

0 commit comments

Comments
 (0)