[mule-scm] [mule][25301] branches/mule-3.x/modules/jersey/src/test/java/org/mule/ module/jersey: Replacing fixed port with a dynamic one in order to remove test flakiness

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[mule-scm] [mule][25301] branches/mule-3.x/modules/jersey/src/test/java/org/mule/ module/jersey: Replacing fixed port with a dynamic one in order to remove test flakiness

pablo.kraan
[mule][25301] branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey: Replacing fixed port with a dynamic one in order to remove test flakiness

Diff

Modified: branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey/AbstractServletTestCase.java (25300 => 25301)


--- branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey/AbstractServletTestCase.java	2013-02-22 15:06:26 UTC (rev 25300)
+++ branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey/AbstractServletTestCase.java	2013-02-22 15:22:19 UTC (rev 25301)
@@ -11,28 +11,30 @@
 package org.mule.module.jersey;
 
 import static org.junit.Assert.assertEquals;
+import org.mule.api.MuleMessage;
+import org.mule.api.config.MuleProperties;
+import org.mule.module.client.MuleClient;
+import org.mule.tck.AbstractServiceAndFlowTestCase;
+import org.mule.tck.junit4.rule.DynamicPort;
+import org.mule.transport.http.HttpConnector;
+import org.mule.transport.http.HttpConstants;
+import org.mule.transport.servlet.MuleReceiverServlet;
 
 import java.util.HashMap;
 import java.util.Map;
 
 import javax.servlet.ServletContext;
 
+import org.junit.Rule;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.servlet.Context;
 import org.mortbay.jetty.servlet.ServletHolder;
-import org.mule.api.MuleMessage;
-import org.mule.api.config.MuleProperties;
-import org.mule.module.client.MuleClient;
-import org.mule.tck.AbstractServiceAndFlowTestCase;
-import org.mule.transport.http.HttpConnector;
-import org.mule.transport.http.HttpConstants;
-import org.mule.transport.servlet.MuleReceiverServlet;
 
 public abstract class AbstractServletTestCase extends AbstractServiceAndFlowTestCase
 {
 
-    //TODO(pablo.kraan): replace with a dynamic endpoint
-    public static final int HTTP_PORT = 63088;
+    @Rule
+    public DynamicPort httpPort = new DynamicPort("httpPort");
 
     private Server httpServer;
     private String context;
@@ -48,7 +50,7 @@
     {
         super.doSetUp();
 
-        httpServer = new Server(HTTP_PORT);
+        httpServer = new Server(httpPort.getNumber());
 
         Context root = new Context(httpServer,"/",Context.SESSIONS);
         ServletHolder holder = new ServletHolder(MuleReceiverServlet.class);

Modified: branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey/NonRootServletTestCase.java (25300 => 25301)


--- branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey/NonRootServletTestCase.java	2013-02-22 15:06:26 UTC (rev 25300)
+++ branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey/NonRootServletTestCase.java	2013-02-22 15:22:19 UTC (rev 25301)
@@ -35,6 +35,6 @@
     @Test
     public void testBasic() throws Exception
     {
-        doTestBasic("http://localhost:63088/context/base");
+        doTestBasic("http://localhost:" + httpPort.getNumber() + "/context/base");
     }
 }

Modified: branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey/RootServletTestCase.java (25300 => 25301)


--- branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey/RootServletTestCase.java	2013-02-22 15:06:26 UTC (rev 25300)
+++ branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey/RootServletTestCase.java	2013-02-22 15:22:19 UTC (rev 25301)
@@ -36,6 +36,6 @@
     @Test
     public void testBasic() throws Exception
     {
-        doTestBasic("http://localhost:63088/base");
+        doTestBasic("http://localhost:" + httpPort.getNumber() + "/base");
     }
 }

Modified: branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey/SimpleServiceRootServletTestCase.java (25300 => 25301)


--- branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey/SimpleServiceRootServletTestCase.java	2013-02-22 15:06:26 UTC (rev 25300)
+++ branches/mule-3.x/modules/jersey/src/test/java/org/mule/module/jersey/SimpleServiceRootServletTestCase.java	2013-02-22 15:22:19 UTC (rev 25301)
@@ -35,6 +35,6 @@
     @Test
     public void testBasic() throws Exception
     {
-        doTestBasic("http://localhost:63088/base");
+        doTestBasic("http://localhost:" + httpPort.getNumber() + "/base");
     }
 }

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Loading...