-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#32 - increased coverage for both unit and integration testing of the…
… request forward logic
- Loading branch information
1 parent
ad826fa
commit aca74d3
Showing
7 changed files
with
108 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 36 additions & 10 deletions
46
...rom-command-line/src/test/java/org/mockserver/ClientServerMavenPluginIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,69 @@ | ||
package org.mockserver; | ||
|
||
import org.junit.After; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.mockserver.client.server.MockServerClient; | ||
import org.mockserver.integration.server.AbstractClientServerIntegrationTest; | ||
import org.mockserver.integration.testserver.TestServer; | ||
import org.mockserver.socket.PortFactory; | ||
|
||
/** | ||
* @author jamesdbloom | ||
*/ | ||
public class ClientServerMavenPluginIntegrationTest extends AbstractClientServerIntegrationTest { | ||
|
||
private final static int port = 8080; | ||
private final static int serverSecurePort = 8082; | ||
private final static int TEST_SERVER_HTTP_PORT = PortFactory.findFreePort(); | ||
private final static int TEST_SERVER_HTTPS_PORT = PortFactory.findFreePort(); | ||
private final static int SERVER_HTTP_PORT = 8080; | ||
private final static int SERVER_HTTPS_PORT = 8082; | ||
private static TestServer testServer = new TestServer(); | ||
|
||
@BeforeClass | ||
public static void createClient() throws Exception { | ||
// do nothing maven build should have started server | ||
|
||
// start test server | ||
testServer.startServer(TEST_SERVER_HTTP_PORT, TEST_SERVER_HTTPS_PORT); | ||
|
||
// start client | ||
mockServerClient = new MockServerClient("localhost", port, servletContext); | ||
mockServerClient = new MockServerClient("localhost", SERVER_HTTP_PORT, servletContext); | ||
} | ||
|
||
@Before | ||
public void clearServer() { | ||
mockServerClient.reset(); | ||
} | ||
|
||
@AfterClass | ||
public static void stopServer() throws Exception { | ||
// do nothing maven build should stop server | ||
|
||
// stop test server | ||
if (testServer != null) { | ||
testServer.stop(); | ||
} | ||
} | ||
|
||
@Override | ||
public int getPort() { | ||
return port; | ||
public int getMockServerPort() { | ||
return SERVER_HTTP_PORT; | ||
} | ||
|
||
@Override | ||
public int getSecurePort() { | ||
return serverSecurePort; | ||
public int getMockServerSecurePort() { | ||
return SERVER_HTTPS_PORT; | ||
} | ||
|
||
@After | ||
public void stopServer() throws Exception { | ||
// do nothing maven build should stop server | ||
@Override | ||
public int getTestServerPort() { | ||
return TEST_SERVER_HTTP_PORT; | ||
} | ||
|
||
@Override | ||
public int getTestServerSecurePort() { | ||
return TEST_SERVER_HTTPS_PORT; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 36 additions & 11 deletions
47
...-server-from-pom/src/test/java/org/mockserver/ClientServerMavenPluginIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,68 @@ | ||
package org.mockserver; | ||
|
||
import org.junit.After; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.mockserver.client.server.MockServerClient; | ||
import org.mockserver.integration.server.AbstractClientServerIntegrationTest; | ||
import org.mockserver.integration.testserver.TestServer; | ||
import org.mockserver.socket.PortFactory; | ||
|
||
/** | ||
* @author jamesdbloom | ||
*/ | ||
public class ClientServerMavenPluginIntegrationTest extends AbstractClientServerIntegrationTest { | ||
|
||
private final static int port = 8080; | ||
private final static int serverSecurePort = 8082; | ||
private final static int TEST_SERVER_HTTP_PORT = PortFactory.findFreePort(); | ||
private final static int TEST_SERVER_HTTPS_PORT = PortFactory.findFreePort(); | ||
private final static int SERVER_HTTP_PORT = 8080; | ||
private final static int SERVER_HTTPS_PORT = 8082; | ||
private static TestServer testServer = new TestServer(); | ||
|
||
@BeforeClass | ||
public static void createClient() throws Exception { | ||
// do nothing maven build should have started server | ||
|
||
// start test server | ||
testServer.startServer(TEST_SERVER_HTTP_PORT, TEST_SERVER_HTTPS_PORT); | ||
|
||
// start client | ||
mockServerClient = new MockServerClient("localhost", port, servletContext); | ||
mockServerClient = new MockServerClient("localhost", SERVER_HTTP_PORT, servletContext); | ||
} | ||
|
||
@Before | ||
public void clearServer() { | ||
mockServerClient.reset(); | ||
} | ||
|
||
@AfterClass | ||
public static void stopServer() throws Exception { | ||
// do nothing maven build should stop server | ||
|
||
// stop test server | ||
if (testServer != null) { | ||
testServer.stop(); | ||
} | ||
} | ||
|
||
@Override | ||
public int getPort() { | ||
return port; | ||
public int getMockServerPort() { | ||
return SERVER_HTTP_PORT; | ||
} | ||
|
||
@Override | ||
public int getSecurePort() { | ||
return serverSecurePort; | ||
public int getMockServerSecurePort() { | ||
return SERVER_HTTPS_PORT; | ||
} | ||
|
||
@After | ||
public void stopServer() throws Exception { | ||
// do nothing maven build should stop server | ||
@Override | ||
public int getTestServerPort() { | ||
return TEST_SERVER_HTTP_PORT; | ||
} | ||
|
||
@Override | ||
public int getTestServerSecurePort() { | ||
return TEST_SERVER_HTTPS_PORT; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters