Skip to content

Commit cff6c96

Browse files
committed
Did more retries on websockets. Created PUT + GET test and deployable on
jaxrs-endpoint.
1 parent 6a8bd7a commit cff6c96

File tree

8 files changed

+113
-19
lines changed

8 files changed

+113
-19
lines changed

jaxrs/jaxrs-client/pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

11-
<groupId>org.javaee7.jaxrs</groupId>
1211
<artifactId>jaxrs-client</artifactId>
13-
<version>1.0-SNAPSHOT</version>
1412
<packaging>war</packaging>
1513
</project>

jaxrs/jaxrs-endpoint/pom.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

11-
<groupId>org.javaee7.jaxrs</groupId>
1211
<artifactId>jaxrs-endpoint</artifactId>
13-
<version>1.0-SNAPSHOT</version>
1412
<packaging>war</packaging>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.jboss.resteasy</groupId>
17+
<artifactId>resteasy-client</artifactId>
18+
<version>3.0.5.Final</version>
19+
<type>jar</type>
20+
<scope>test</scope>
21+
</dependency>
22+
</dependencies>
23+
1524
</project>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
*
3+
*/
4+
package org.javaee7.jaxrs.endpoint.test;
5+
6+
import java.net.URI;
7+
import java.net.URISyntaxException;
8+
9+
import javax.ws.rs.client.Client;
10+
import javax.ws.rs.client.ClientBuilder;
11+
import javax.ws.rs.client.Entity;
12+
import javax.ws.rs.client.WebTarget;
13+
14+
import junit.framework.Assert;
15+
16+
import org.javaee7.jaxrs.endpoint.Database;
17+
import org.javaee7.jaxrs.endpoint.MyApplication;
18+
import org.javaee7.jaxrs.endpoint.MyResource;
19+
import org.jboss.arquillian.container.test.api.Deployment;
20+
import org.jboss.arquillian.container.test.api.TargetsContainer;
21+
import org.jboss.arquillian.junit.Arquillian;
22+
import org.jboss.arquillian.junit.InSequence;
23+
import org.jboss.shrinkwrap.api.ShrinkWrap;
24+
import org.jboss.shrinkwrap.api.spec.WebArchive;
25+
import org.junit.Test;
26+
import org.junit.runner.RunWith;
27+
28+
/**
29+
* @author Nikolaos Ballas
30+
*
31+
*/
32+
@RunWith(Arquillian.class)
33+
public class JaxRSEndpointTest {
34+
35+
private Client client = null;
36+
37+
@Deployment(testable=false) @TargetsContainer("wildfly-arquillian")
38+
public static WebArchive createDeplymentI() {
39+
return ShrinkWrap.create(WebArchive.class, "jaxrs-endpoint.war").
40+
addClass(MyApplication.class).
41+
addClass(Database.class).
42+
addClass(MyResource.class);
43+
}
44+
45+
46+
@Test
47+
@InSequence(1)
48+
public void invokeEndpointPUTTest() throws URISyntaxException{
49+
WebTarget targetEndpoint= getTargetEndpoint("fruit");
50+
targetEndpoint.request().put(Entity.text("banana"));
51+
}
52+
@Test
53+
@InSequence(2)
54+
public void invokeEndpointGETTest() throws URISyntaxException {
55+
WebTarget targetEndPoint = getTargetEndpoint("fruit");
56+
String received = targetEndPoint.request().get(String.class);
57+
Assert.assertEquals("[banana]" ,received);
58+
}
59+
60+
/**
61+
* The method for obtaining a target endpoint.
62+
* @param endpointName the target endpoint name which we want to invoke
63+
* @return a WebTarget object
64+
* @throws URISyntaxException
65+
*/
66+
public WebTarget getTargetEndpoint(String endpointName) throws URISyntaxException {
67+
if(client == null) {
68+
client = ClientBuilder.newClient();
69+
}
70+
return client.target(new URI("http://localhost:8080/jaxrs-endpoint/webresources/"+endpointName));
71+
}
72+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<arquillian xmlns="http://jboss.org/schema/arquillian"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="
4+
http://jboss.org/schema/arquillian
5+
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
6+
<!-- defaultProtocol type="Servlet 3.0" /-->
7+
<engine>
8+
<property name="deploymentExportPath">${serverRoot:/opt/programs/wildfly-8.0.0.Beta1}/standalone/deployments</property>
9+
</engine>
10+
<container qualifier="wildfly-arquillian" default="true">
11+
<configuration>
12+
<property name="jbossHome">${serverRoot:/opt/programs/wildfly-8.0.0.Beta1}</property>
13+
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
14+
</configuration>
15+
</container>
16+
</arquillian>

jaxrs/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

11-
<groupId>org.javaee7.jaxrs</groupId>
1211
<artifactId>jaxrs-samples</artifactId>
13-
<version>1.0-SNAPSHOT</version>
1412
<packaging>pom</packaging>
1513
<name>Java EE 7 JAX-RS Samples</name>
1614

@@ -53,4 +51,5 @@
5351
<module>readerwriter-injection</module>
5452
</modules>
5553

54+
<groupId>org.javaee7.jaxrs</groupId>
5655
</project>

pom.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@
183183
<profiles>
184184
<profile>
185185
<id>glassfish</id>
186-
<activation>
187-
<activeByDefault>true</activeByDefault>
188-
</activation>
189186
<build>
190187
<plugins>
191188
<plugin>
@@ -285,8 +282,10 @@
285282
</profile>
286283
<profile>
287284
<id>wildfly-arquillian</id>
285+
<activation>
286+
<activeByDefault>true</activeByDefault>
287+
</activation>
288288
<properties>
289-
<browser>chromium-browser</browser>
290289
<serverProfile>standalone-full.xml</serverProfile>
291290
<serverRoot>/opt/programs/wildfly-8.0.0.Beta1</serverRoot>
292291
</properties>

websocket/binary/src/test/java/org/javaee7/websocket/binary/test/WebsocketByteBufferEndpointTest.java renamed to websocket/binary/src/test/java/org/javaee7/websocket/binary/test/WebsocketBinaryEndpointTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
*/
44
package org.javaee7.websocket.binary.test;
55

6+
import io.undertow.websockets.jsr.UndertowContainerProvider;
7+
68
import java.io.File;
79
import java.io.IOException;
810
import java.net.URI;
911
import java.net.URISyntaxException;
1012

11-
import javax.websocket.ContainerProvider;
1213
import javax.websocket.DeploymentException;
1314
import javax.websocket.Session;
1415
import javax.websocket.WebSocketContainer;
@@ -32,7 +33,7 @@
3233
*
3334
*/
3435
@RunWith(Arquillian.class)
35-
public class WebsocketByteBufferEndpointTest {
36+
public class WebsocketBinaryEndpointTest {
3637
private static final String WEBAPP_SRC = "src/main/webapp";
3738

3839
/**
@@ -48,6 +49,7 @@ public static WebArchive createDeployment() {
4849
.addClass(MyEndpointByteBuffer.class)
4950
.addClass(MyEndpointByteArray.class)
5051
.addClass(MyEndpointInputStream.class)
52+
.addClass(MyEndpointClient.class)
5153
.addAsWebResource(new File(WEBAPP_SRC, "index.jsp"))
5254
.addAsWebResource(new File(WEBAPP_SRC, "websocket.js"));
5355
return war;
@@ -105,7 +107,7 @@ public void testEndpointInputStream() throws DeploymentException,IOException, UR
105107
* @throws URISyntaxException
106108
*/
107109
public Session connectToServer(String endpoint) throws DeploymentException, IOException, URISyntaxException {
108-
WebSocketContainer wSocketContainer = ContainerProvider.getWebSocketContainer();
110+
WebSocketContainer wSocketContainer = UndertowContainerProvider.getWebSocketContainer();
109111
return wSocketContainer.connectToServer(MyEndpointClient.class, new URI("ws://localhost:8080/binary/" + endpoint));
110112
}
111113
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
xsi:schemaLocation="
44
http://jboss.org/schema/arquillian
55
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
6-
<defaultProtocol type="Servlet 3.0" />
6+
<!-- defaultProtocol type="Servlet 3.0" /-->
77
<engine>
8-
<property name="deploymentExportPath">${serverRoot}/standalone/deployments</property>
8+
<property name="deploymentExportPath">${serverRoot:/opt/programs/wildfly-8.0.0.Beta1}/standalone/deployments</property>
99
</engine>
10-
<extension qualifier="${browser}" />
11-
<container qualifier="wildfly-arquillian" default="true" mode="suite">
10+
<container qualifier="wildfly-arquillian" default="true">
1211
<configuration>
13-
<property name="jbossHome">${serverRoot}</property>
14-
<property name="serverConfig">${serverProfile}</property>
12+
<property name="jbossHome">${serverRoot:/opt/programs/wildfly-8.0.0.Beta1}</property>
13+
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
1514
</configuration>
1615
</container>
1716
</arquillian>

0 commit comments

Comments
 (0)