Skip to content

Commit

Permalink
Merge pull request #311 from alexsm82/master
Browse files Browse the repository at this point in the history
Clean up websocket hard coded ports and servlet URLs
  • Loading branch information
arun-gupta committed Jun 24, 2015
2 parents 6d194bc + 4ec30e2 commit a63598d
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 10 deletions.
26 changes: 25 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,32 @@
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-wlp-managed-8.5</artifactId>
<version>1.0.0.Beta2</version>
</dependency>
<dependency>
<groupId>org.glassfish.tyrus</groupId>
<artifactId>tyrus-client</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.tyrus</groupId>
<artifactId>tyrus-container-grizzly-client</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.4</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public void setup() {

@Test
public void testGet() throws IOException, SAXException {
TextPage page = webClient.getPage(base + "/TestServlet");
TextPage page = webClient.getPage(base + "TestServlet");
assertEquals("my GET", page.getContent());
}

@Test
public void testPost() throws IOException, SAXException {
WebRequest request = new WebRequest(new URL(base + "/TestServlet"), HttpMethod.POST);
WebRequest request = new WebRequest(new URL(base + "TestServlet"), HttpMethod.POST);
TextPage page = webClient.getPage(request);
assertEquals("my POST", page.getContent());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public void setup() {

@Test
public void testGet() throws IOException, SAXException {
TextPage page = webClient.getPage(base + "/SimpleServlet");
TextPage page = webClient.getPage(base + "SimpleServlet");
assertEquals("my GET", page.getContent());
}

@Test
public void testPost() throws IOException, SAXException {
WebRequest request = new WebRequest(new URL(base + "/SimpleServlet"), HttpMethod.POST);
WebRequest request = new WebRequest(new URL(base + "SimpleServlet"), HttpMethod.POST);
TextPage page = webClient.getPage(request);
assertEquals("my POST", page.getContent());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");

WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://localhost:8080" + request.getContextPath() + "/websocket";
String uri = "ws://localhost:" + request.getLocalPort() + request.getContextPath() + "/websocket";
out.println("Connecting to " + uri);
container.connectToServer(MyClient.class, URI.create(uri));
out.println("<br><br>Look in server.log for log messages from message exchange between client/server.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");

WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://localhost:8080" + request.getContextPath() + "/websocket";
String uri = "ws://localhost:" + request.getLocalPort() + request.getContextPath() + "/websocket";
out.println("Connecting to " + uri);
container.connectToServer(MyClient.class,
ClientEndpointConfig.Builder.create().configurator(new MyConfigurator()).build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
decoders.add(MyMessageDecoder.class);

WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://localhost:8080" + request.getContextPath() + "/websocket";
String uri = "ws://localhost:" + request.getLocalPort() + request.getContextPath() + "/websocket";
out.println("Connecting to " + uri);
container.connectToServer(MyClient.class,
ClientEndpointConfig.Builder.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");

WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://localhost:8080" + request.getContextPath() + "/websocket";
String uri = "ws://localhost:" + request.getLocalPort() + request.getContextPath() + "/websocket";
out.println("Connecting to " + uri);
container.connectToServer(MyClient.class,
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");

WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://localhost:8080" + request.getContextPath() + "/websocket";
String uri = "ws://localhost:" + request.getLocalPort() + request.getContextPath() + "/websocket";
out.println("Connecting to " + uri);
container.connectToServer(MyClient.class, URI.create(uri));
out.println("<br><br>Look in server.log for log messages from message exchange between client/server.");
Expand Down

0 comments on commit a63598d

Please sign in to comment.