Search in sources :

Example 16 with ConsoleNotifier

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

the class PostServeActionExtensionTest method multipleActionsOfTheSameNameCanBeSpecifiedAsAJsonArray.

@Test
public void multipleActionsOfTheSameNameCanBeSpecifiedAsAJsonArray() {
    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" + "    {\n" + "      \"name\": \"count-request\",\n" + "      \"parameters\": {\n" + "        \"counterName\": \"one\"  \n" + "      }\n" + "    },\n" + "    {\n" + "      \"name\": \"count-request\",\n" + "      \"parameters\": {\n" + "        \"counterName\": \"two\"\n" + "      }\n" + "    }\n" + "  ]\n" + "}");
    assertThat(response.content(), response.statusCode(), is(201));
    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 : WireMockResponse(com.github.tomakehurst.wiremock.testsupport.WireMockResponse) ConsoleNotifier(com.github.tomakehurst.wiremock.common.ConsoleNotifier) Test(org.junit.jupiter.api.Test)

Example 17 with ConsoleNotifier

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

the class AbstractTest method startWiremockServer.

@BeforeAll
static void startWiremockServer() {
    wireMockServer = new WireMockServer(options().port(8080).notifier(new ConsoleNotifier(false)));
    wireMockServer.start();
}
Also used : ConsoleNotifier(com.github.tomakehurst.wiremock.common.ConsoleNotifier) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 18 with ConsoleNotifier

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

the class FeignInterceptor method setup.

@BeforeAll
public static void setup() {
    bookClient = Feign.builder().client(new OkHttpClient()).encoder(new GsonEncoder()).decoder(new GsonDecoder()).logger(new Slf4jLogger(BookClient.class)).logLevel(Logger.Level.FULL).requestInterceptor(new CustomTokenGeneratorInterceptor("123456", "654321")).target(BookClient.class, "http://localhost:57010/api/books");
    wireMockServer = new WireMockServer(WireMockConfiguration.wireMockConfig().withRootDirectory(FOLDER).port(57010).notifier(new ConsoleNotifier(true)));
    wireMockServer.start();
}
Also used : CustomTokenGeneratorInterceptor(es.home.example.feignexample.customize.CustomTokenGeneratorInterceptor) ConsoleNotifier(com.github.tomakehurst.wiremock.common.ConsoleNotifier) OkHttpClient(feign.okhttp.OkHttpClient) GsonEncoder(feign.gson.GsonEncoder) Slf4jLogger(feign.slf4j.Slf4jLogger) GsonDecoder(feign.gson.GsonDecoder) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 19 with ConsoleNotifier

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

the class WiremockTest method setup.

@BeforeEach
public void setup() {
    wireMockServer = new WireMockServer(WireMockConfiguration.wireMockConfig().withRootDirectory(FOLDER).port(57002).httpsPort(57005).keystorePath(FOLDER + "/identity.jks").notifier(new ConsoleNotifier(true)));
    wireMockServer.start();
}
Also used : ConsoleNotifier(com.github.tomakehurst.wiremock.common.ConsoleNotifier) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 20 with ConsoleNotifier

use of com.github.tomakehurst.wiremock.common.ConsoleNotifier in project plugin-installation-manager-tool by jenkinsci.

the class PluginManagerWiremockTest method proxyToWireMock.

@Before
public void proxyToWireMock() {
    archives = new WireMockServer(WireMockConfiguration.options().dynamicPort().notifier(new ConsoleNotifier(true)));
    archives.start();
    protectedArchives = new WireMockServer(WireMockConfiguration.options().dynamicPort().notifier(new ConsoleNotifier(true)));
    protectedArchives.start();
    cfg = Config.builder().withJenkinsWar(Settings.DEFAULT_WAR).withPluginDir(new File(folder.getRoot(), "plugins")).withCredentials(Collections.singletonList(new Credentials("myuser", "mypassword", "localhost", protectedArchives.port()))).build();
    pm = new PluginManager(cfg);
    if (record) {
        archives.stubFor(proxyAllTo("http://archives.jenkins-ci.org").atPriority(1));
    }
// the mappings from src/test/resources/mappings are used otherwise
}
Also used : ConsoleNotifier(com.github.tomakehurst.wiremock.common.ConsoleNotifier) File(java.io.File) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) Credentials(io.jenkins.tools.pluginmanager.config.Credentials) Before(org.junit.Before)

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