Java Code Examples for com.github.tomakehurst.wiremock.WireMockServer#start()
The following examples show how to use
com.github.tomakehurst.wiremock.WireMockServer#start() .
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: ApacheClientTlsAuthTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp() throws IOException { ClientTlsAuthTestBase.setUp(); // Will be used by both client and server to trust the self-signed // cert they present to each other System.setProperty("javax.net.ssl.trustStore", serverKeyStore.toAbsolutePath().toString()); System.setProperty("javax.net.ssl.trustStorePassword", STORE_PASSWORD); System.setProperty("javax.net.ssl.trustStoreType", "jks"); wireMockServer = new WireMockServer(wireMockConfig() .dynamicHttpsPort() .needClientAuth(true) .keystorePath(serverKeyStore.toAbsolutePath().toString()) .keystorePassword(STORE_PASSWORD) ); wireMockServer.start(); keyManagersProvider = FileStoreTlsKeyManagersProvider.create(clientKeyStore, CLIENT_STORE_TYPE, STORE_PASSWORD); }
Example 2
Source File: SendGridHttpTest.java From ogham with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() { when(generator.generate(anyString())).then(AdditionalAnswers.returnsArgAt(0)); server = new WireMockServer(options().dynamicPort()); server.start(); messagingService = MessagingBuilder.standard() .email() .images() .inline() .attach() .cid() .generator(generator) .and() .and() .and() .and() .sender(SendGridV4Builder.class) .url("http://localhost:"+server.port()) .apiKey("foobar") .and() .and() .build(); }
Example 3
Source File: RetryWithStateTest.java From zerocode with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpWireMock() throws Exception { mockServer = new WireMockServer(port); basePath = "http://localhost:" + port; String path = "/retry/ids/1"; fullPath = basePath + path; mockServer.start(); mockServer.stubFor(get(urlEqualTo(path)) .inScenario("Retry Scenario") .whenScenarioStateIs(STARTED) .willReturn(aResponse() .withStatus(500)) .willSetStateTo("retry") ); mockServer.stubFor(get(urlEqualTo(path)) .inScenario("Retry Scenario") .whenScenarioStateIs("retry") .willReturn(aResponse() .withStatus(200)) ); }
Example 4
Source File: AllureHttpClientTest.java From allure-java with Apache License 2.0 | 6 votes |
@BeforeEach void setUp() { server = new WireMockServer(options().dynamicPort()); server.start(); configureFor(server.port()); stubFor(get(urlEqualTo("/hello")) .willReturn(aResponse() .withBody(BODY_STRING))); stubFor(get(urlEqualTo("/empty")) .willReturn(aResponse() .withStatus(304))); stubFor(delete(urlEqualTo("/hello")) .willReturn(noContent())); }
Example 5
Source File: SendGridHttpTest.java From ogham with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() { when(generator.generate(anyString())).then(AdditionalAnswers.returnsArgAt(0)); server = new WireMockServer(options().dynamicPort()); server.start(); messagingService = MessagingBuilder.standard() .email() .images() .inline() .attach() .cid() .generator(generator) .and() .and() .and() .and() .sender(SendGridV2Builder.class) .url("http://localhost:"+server.port()) .apiKey("foobar") .and() .and() .build(); }
Example 6
Source File: SendGridFluentEmailTest.java From ogham with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() { when(generator.generate(anyString())).then(AdditionalAnswers.returnsArgAt(0)); server = new WireMockServer(options().dynamicPort()); server.start(); messagingService = MessagingBuilder.standard() .email() .images() .inline() .attach() .cid() .generator(generator) .and() .and() .and() .and() .sender(SendGridV4Builder.class) .url("http://localhost:"+server.port()) .apiKey("foobar") .and() .and() .build(); }
Example 7
Source File: LoadingInfoTest.java From otroslogviewer with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp() throws IOException { fsManager = VFS.getManager(); wireMock = new WireMockServer(wireMockConfig().port(PORT)); final byte[] gzipped = toByteArray(getSystemResourceAsStream("hierarchy/hierarchy.log.gz")); final byte[] notGzipped = toByteArray(getSystemResourceAsStream("hierarchy/hierarchy.log")); wireMock.stubFor( get(urlEqualTo("/log.txt")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/plain").withBody(notGzipped))); wireMock.stubFor( get(urlEqualTo("/log.txt.gz")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/plain").withBody(gzipped))); wireMock.start(); }
Example 8
Source File: AllureJaxRsTest.java From allure-java with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { server = new WireMockServer(options().dynamicPort()); server.start(); configureFor(server.port()); stubFor(get(urlEqualTo("/hello")) .willReturn(aResponse() .withBody(BODY_STRING))); }
Example 9
Source File: ApiStepsTest.java From akita with Apache License 2.0 | 5 votes |
@BeforeAll static void setup() { wireMockServer = new WireMockServer(); wireMockServer.start(); akitaScenario = AkitaScenario.getInstance(); api = new ApiSteps(); akitaScenario.setEnvironment(new AkitaEnvironment(new StubScenario())); }
Example 10
Source File: WnsTest.java From java-wns with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); wireMockServer = new WireMockServer(wireMockConfig().port(8089)); wireMockServer.start(); WireMock.configureFor("localhost", 8089); // Stub server response for access token stubFor(post(urlEqualTo("/accesstoken.srf")) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", MediaType.APPLICATION_JSON) .withBody("{\"access_token\":\"access_token\",\"token_type\":\"token_type\",\"expires_in\":9999}"))); }
Example 11
Source File: StashFacadeHttpsTest.java From sputnik with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { wireMockServer = new WireMockServer(wireMockConfig().port(FacadeConfigUtil.HTTP_PORT).httpsPort(FacadeConfigUtil.HTTPS_PORT)); wireMockServer.start(); httpConnectorEnv = new HttpConnectorEnv(wireMockServer); Configuration config = new ConfigurationSetup().setUp(FacadeConfigUtil.getHttpsConfig("stash"), STASH_PATCHSET_MAP); stashFacade = new StashFacadeBuilder().build(config); }
Example 12
Source File: StyxHttpClientTest.java From styx with Apache License 2.0 | 5 votes |
@BeforeEach public void setUp() { server = new WireMockServer(wireMockConfig().dynamicPort().dynamicHttpsPort()); server.start(); server.stubFor(WireMock.get(urlStartingWith("/")).willReturn(aResponse().withStatus(200))); httpRequest = get("/") .header(HOST, hostString(server.port())) .build(); secureRequest = get("/") .header(HOST, hostString(server.httpsPort())) .build(); }
Example 13
Source File: TempAndMoveTest.java From gradle-download-task with Apache License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); tempAndMoveWireMock = new WireMockServer(options() .dynamicPort() .networkTrafficListener(new TempAndMoveNetworkTrafficListener()) .jettyStopTimeout(10000L)); tempAndMoveWireMock.start(); }
Example 14
Source File: AllureOkHttp3Test.java From allure-java with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { server = new WireMockServer(options().dynamicPort()); server.start(); configureFor(server.port()); stubFor(get(urlEqualTo("/hello")) .willReturn(aResponse() .withBody(BODY_STRING))); }
Example 15
Source File: WireMockApplicationTestCase2.java From AndroidHttpMockingExamples with Apache License 2.0 | 5 votes |
@Before protected void setUp() throws Exception { this.androidTestContext = InstrumentationRegistry.getContext(); this.applicationContext = InstrumentationRegistry.getTargetContext().getApplicationContext(); wireMockServer = new WireMockServer(8080, new AndroidAssetsReadOnlyFileSource(androidTestContext.getAssets()), false); wireMockServer.start(); }
Example 16
Source File: IronTestApplication.java From irontest with Apache License 2.0 | 5 votes |
@Override public void run(IronTestConfiguration configuration, Environment environment) throws IOException { final JdbiFactory jdbiFactory = new JdbiFactory(); final Jdbi systemDBJdbi = jdbiFactory.build(environment, configuration.getSystemDatabase(), "systemDatabase"); if (!checkVersion(systemDBJdbi)) { System.out.println("Press Enter to exit."); System.in.read(); System.exit(0); } // Override Java's trusted cacerts with our own trust store if available. // Notice that setting the properties without the trust store being existing could cause unexpected result // at runtime with Java 10 (Java 1.8 does not have the issue), such as failure of SOAP test step run (caused // by 'new SSLContextBuilder().loadTrustMaterial'). if (new File(configuration.getSslTrustStorePath()).exists()) { System.setProperty("javax.net.ssl.trustStore", configuration.getSslTrustStorePath()); System.setProperty("javax.net.ssl.trustStorePassword", configuration.getSslTrustStorePassword()); } // start WireMock server (in the same JVM) WireMockServer wireMockServer = new WireMockServer(options() .extensions(new ResponseTemplateTransformer(true)) .port(Integer.parseInt(configuration.getWireMock().get("port"))) .maxRequestJournalEntries(Integer.parseInt(configuration.getWireMock().get("maxRequestJournalEntries"))) .notifier(new WireMockFileNotifier()) ); wireMockServer.start(); createSystemResources(configuration, environment, systemDBJdbi, wireMockServer); createSampleResources(configuration, environment); }
Example 17
Source File: SaasFacadeTest.java From sputnik with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { wireMockServer = new WireMockServer(wireMockConfig().port(FacadeConfigUtil.HTTP_PORT)); wireMockServer.start(); httpConnectorEnv = new HttpConnectorEnv(wireMockServer); config = new ConfigurationSetup().setUp(FacadeConfigUtil.getHttpConfig("saas"), GITHUB_PATCHSET_MAP); saasFacade = new SaasFacadeBuilder().build(config); }
Example 18
Source File: VersionUtilTest.java From otroslogviewer with Apache License 2.0 | 5 votes |
@Test public void testGetCurrentVersion() throws Exception { //given final WireMockServer wireMockServer = new WireMockServer(); wireMockServer .stubFor( get(urlMatching("/currentVersion.*")) .willReturn(aResponse() .withStatus(200) .withBody("currentVersion=1.2.3\n".getBytes())) ); wireMockServer.start(); final int port = wireMockServer.port(); final VersionUtil versionUtil = new VersionUtil("http://localhost:" + port+"/currentVersion"); final OtrosApplication otrosApplication = new OtrosApplication(); otrosApplication.setConfiguration(new DataConfiguration(new BaseConfiguration())); otrosApplication.getConfiguration().setProperty(ConfKeys.UUID,"C9457787-AF59-4B9F-B4E8-FB75334EBEF8"); //when final Optional<String> currentVersion = versionUtil.getCurrentVersion("1.2.3", Proxy.NO_PROXY, otrosApplication); wireMockServer.stop(); //then assertEquals(currentVersion,Optional.of("1.2.3")); }
Example 19
Source File: SwaggerHubUploadTest.java From swaggerhub-maven-plugin with Apache License 2.0 | 4 votes |
private void startMockServer(int port) { wireMockServer = new WireMockServer(options().port(port)); wireMockServer.start(); WireMock.configureFor("localhost", wireMockServer.port()); }
Example 20
Source File: RemoteUrlTest.java From swagger-parser with Apache License 2.0 | 4 votes |
@BeforeMethod public void setUp() throws Exception { wireMockServer = new WireMockServer(WIRE_MOCK_PORT); wireMockServer.start(); WireMock.configureFor(WIRE_MOCK_PORT); }