Search in sources :

Example 6 with ConsoleNotifier

use of com.github.tomakehurst.wiremock.common.ConsoleNotifier in project wiremock by wiremock.

the class HandlebarsCurrentDateHelperTest method init.

@BeforeEach
public void init() {
    helper = new HandlebarsCurrentDateHelper();
    transformer = new ResponseTemplateTransformer(true);
    LocalNotifier.set(new ConsoleNotifier(true));
}
Also used : ConsoleNotifier(com.github.tomakehurst.wiremock.common.ConsoleNotifier) ResponseTemplateTransformer(com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with ConsoleNotifier

use of com.github.tomakehurst.wiremock.common.ConsoleNotifier in project wiremock by wiremock.

the class HandlebarsRandomValuesHelperTest method init.

@BeforeEach
public void init() {
    helper = new HandlebarsRandomValuesHelper();
    transformer = new ResponseTemplateTransformer(true);
    LocalNotifier.set(new ConsoleNotifier(true));
}
Also used : ConsoleNotifier(com.github.tomakehurst.wiremock.common.ConsoleNotifier) ResponseTemplateTransformer(com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with ConsoleNotifier

use of com.github.tomakehurst.wiremock.common.ConsoleNotifier in project wiremock by wiremock.

the class AltHttpServerFactory method buildHttpServer.

@Override
public HttpServer buildHttpServer(Options options, AdminRequestHandler adminRequestHandler, StubRequestHandler stubRequestHandler) {
    final Server jettyServer = new Server(0);
    ConsoleNotifier notifier = new ConsoleNotifier(false);
    ServletContextHandler adminContext = addAdminContext(jettyServer, adminRequestHandler, notifier);
    ServletContextHandler mockServiceContext = addMockServiceContext(jettyServer, stubRequestHandler, options.filesRoot(), notifier);
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] { adminContext, mockServiceContext });
    jettyServer.setHandler(handlers);
    return new HttpServer() {

        @Override
        public void start() {
            try {
                jettyServer.start();
            } catch (Exception e) {
                throwUnchecked(e);
            }
        }

        @Override
        public void stop() {
            try {
                jettyServer.stop();
            } catch (Exception e) {
                throwUnchecked(e);
            }
        }

        @Override
        public boolean isRunning() {
            return jettyServer.isRunning();
        }

        @Override
        public int port() {
            return ((ServerConnector) jettyServer.getConnectors()[0]).getLocalPort();
        }

        @Override
        public int httpsPort() {
            return 0;
        }
    };
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) ConsoleNotifier(com.github.tomakehurst.wiremock.common.ConsoleNotifier) Server(org.eclipse.jetty.server.Server) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 9 with ConsoleNotifier

use of com.github.tomakehurst.wiremock.common.ConsoleNotifier in project wiremock by wiremock.

the class PostServeActionExtensionTest method canBeSpecifiedAsAJsonObject.

@Test
public void canBeSpecifiedAsAJsonObject() {
    initWithOptions(options().dynamicPort().notifier(new ConsoleNotifier(true)).extensions(new NamedCounterAction()));
    WireMockResponse response = client.postJson("/__admin/mappings", "{\n" + "  \"request\" : {\n" + "    \"urlPath\" : \"/count-me\",\n" + "    \"method\" : \"GET\"\n" + "  },\n" + "  \"response\" : {\n" + "    \"status\" : 200\n" + "  },\n" + "  \"postServeActions\": {\n" + "    \"count-request\": {\n" + "      \"counterName\": \"things\"\n" + "    } \n" + "  }\n" + "}");
    assertThat(response.content(), response.statusCode(), is(201));
    client.get("/count-me");
    client.get("/count-me");
    await().atMost(5, SECONDS).until(getContent("/__admin/named-counter/things"), is("2"));
}
Also used : WireMockResponse(com.github.tomakehurst.wiremock.testsupport.WireMockResponse) ConsoleNotifier(com.github.tomakehurst.wiremock.common.ConsoleNotifier) Test(org.junit.jupiter.api.Test)

Example 10 with ConsoleNotifier

use of com.github.tomakehurst.wiremock.common.ConsoleNotifier in project wiremock by wiremock.

the class PostServeActionExtensionTest method multipleActionsOfTheSameNameCanBeSpecifiedViaTheDSL.

@Test
public void multipleActionsOfTheSameNameCanBeSpecifiedViaTheDSL() {
    initWithOptions(options().dynamicPort().notifier(new ConsoleNotifier(true)).extensions(new NamedCounterAction()));
    wm.stubFor(get(urlPathEqualTo("/count-me")).willReturn(ok()).withPostServeAction("count-request", counterNameParameter().withName("one")).withPostServeAction("count-request", counterNameParameter().withName("two")));
    client.get("/count-me");
    client.get("/count-me");
    client.get("/count-me");
    await().atMost(5, SECONDS).until(getContent("/__admin/named-counter/one"), is("3"));
    await().atMost(5, SECONDS).until(getContent("/__admin/named-counter/two"), is("3"));
}
Also used : ConsoleNotifier(com.github.tomakehurst.wiremock.common.ConsoleNotifier) Test(org.junit.jupiter.api.Test)

Aggregations

ConsoleNotifier (com.github.tomakehurst.wiremock.common.ConsoleNotifier)20 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)9 BeforeEach (org.junit.jupiter.api.BeforeEach)8 BeforeAll (org.junit.jupiter.api.BeforeAll)7 GsonDecoder (feign.gson.GsonDecoder)5 Slf4jLogger (feign.slf4j.Slf4jLogger)5 GsonEncoder (feign.gson.GsonEncoder)4 OkHttpClient (feign.okhttp.OkHttpClient)3 Test (org.junit.jupiter.api.Test)3 ResponseTemplateTransformer (com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer)2 WireMockResponse (com.github.tomakehurst.wiremock.testsupport.WireMockResponse)2 SystemKeyAuthoriser (com.github.tomakehurst.wiremock.extension.responsetemplating.SystemKeyAuthoriser)1 CustomErrorDecode (es.home.example.feignexample.customize.CustomErrorDecode)1 CustomTokenGeneratorInterceptor (es.home.example.feignexample.customize.CustomTokenGeneratorInterceptor)1 Request (feign.Request)1 Credentials (io.jenkins.tools.pluginmanager.config.Credentials)1 File (java.io.File)1 Server (org.eclipse.jetty.server.Server)1 ServerConnector (org.eclipse.jetty.server.ServerConnector)1 HandlerCollection (org.eclipse.jetty.server.handler.HandlerCollection)1