org.mockserver.configuration.ConfigurationProperties Java Examples

The following examples show how to use org.mockserver.configuration.ConfigurationProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PGPKeysServerClientIT.java    From pgpverify-maven-plugin with Apache License 2.0 7 votes vote down vote up
@BeforeClass
public void setupMockServer() {
    mockServer = ClientAndServer.startClientAndServer(0);

    ConfigurationProperties.disableSystemOut(true);
    ConfigurationProperties.logLevel("WARNING");

    MockServerClient mockServerClient = new MockServerClient("localhost", mockServer.getLocalPort());

    mockServerClient
            .when(request().withPath("/sleep"))
            .respond(response()
                    .withStatusCode(200)
                    .withDelay(TimeUnit.SECONDS, 10));

    mockServerClient
            .when(request().withPath("/404"))
            .respond(response().withStatusCode(404));

    mockServerClient
            .when(request().withPath("/502"))
            .respond(response().withStatusCode(502));

}
 
Example #2
Source File: MetadataTestServer.java    From helidon-build-tools with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param port The port to listen on.
 * @param latest The version to return for the "/latest" request.
 * @param verbose Whether or not to do verbose logging.
 */
@SuppressWarnings("ConstantConditions")
public MetadataTestServer(int port, TestVersion latest, boolean verbose) {
    if (MockServer.class.getClassLoader() != ClassLoader.getSystemClassLoader()) {
        final String reason = "MockServer must be in system class loader";
        Log.info("$(italic,yellow Skipping: %s)", reason);
        Assumptions.assumeTrue(false, reason);
    }
    ConfigurationProperties.logLevel(verbose ? VERBOSE_LEVEL : NORMAL_LEVEL);
    this.port = port;
    this.url = URL_PREFIX + port;
    this.latest = latest;
}
 
Example #3
Source File: MockCruiseControl.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
/**
 * Sets up and returns the Cruise Control MockSever
 * @param port The port number the MockServer instance should listen on
 * @return The configured ClientAndServer instance.
 * @throws IOException If there are issues connecting to the network port.
 * @throws URISyntaxException If any of the configured end points are invalid.
 */
public static ClientAndServer getCCServer(int port) throws IOException, URISyntaxException {
    ConfigurationProperties.logLevel("WARN");
    String loggingConfiguration = "" +
            "handlers=org.mockserver.logging.StandardOutConsoleHandler\n" +
            "org.mockserver.logging.StandardOutConsoleHandler.level=WARNING\n" +
            "org.mockserver.logging.StandardOutConsoleHandler.formatter=java.util.logging.SimpleFormatter\n" +
            "java.util.logging.SimpleFormatter.format=%1$tF %1$tT  %3$s  %4$s  %5$s %6$s%n\n" +
            ".level=" + javaLoggerLogLevel() + "\n" +
            "io.netty.handler.ssl.SslHandler.level=WARNING";
    LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(loggingConfiguration.getBytes(UTF_8)));

    ClientAndServer ccServer = new ClientAndServer(port);
    return ccServer;
}
 
Example #4
Source File: BaseClientTest.java    From bdt with Apache License 2.0 5 votes vote down vote up
protected void startMockServer() throws Exception {
    ConfigurationProperties.logLevel("ERROR");
    port  = PortFactory.findFreePort();
    logger.info("Starting mock server...");
    mockServer = ClientAndServer.startClientAndServer(port);
    logger.info("Mock sever started.");
}