Skip to content

Commit

Permalink
chore: re-organizing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Nov 3, 2024
1 parent b3e6159 commit 3d78d2b
Show file tree
Hide file tree
Showing 33 changed files with 64 additions and 72 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DefaultPropertiesTest {
}
```

There are more running examples in [the repo](/wiremock-spring-boot-example/src/test/java/app).
There are more running examples in [the repo](/src/test/java/usecases).

## Annotations

Expand Down
64 changes: 28 additions & 36 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,50 @@ buildscript {
}
dependencies {
classpath "se.bjurr.gradle.java-convention:se.bjurr.gradle.java-convention.gradle.plugin:0.+"
classpath "org.wiremock.tools.gradle:extension-convention-plugin:0.3.0"
}
}

plugins {
id 'org.wiremock.tools.gradle.wiremock-extension-convention' version '0.3.0'
}

apply plugin: "project-report"
apply plugin: "se.bjurr.gradle.java-convention"

group 'org.wiremock.integrations'
// Or else it will be 11 in wiremock-extension-convention
sourceCompatibility = 17
targetCompatibility = 17
apply plugin: "org.wiremock.tools.gradle.wiremock-extension-convention"

allprojects {
apply plugin: "se.bjurr.gradle.java-convention"

dependencies {
testImplementation "org.springframework.boot:spring-boot-starter-test:3.3.4"
testImplementation 'org.assertj:assertj-core:3.26.3'
testImplementation platform('org.junit:junit-bom:5.11.2')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.junit.platform:junit-platform-launcher'
testImplementation 'io.rest-assured:rest-assured:5.5.0'

constraints {
implementation('org.apache.commons:commons-compress:1.26.0') {
because 'version 1.24.0 has a vulnerability'
}
}
}
}
group 'org.wiremock.integrations'

// Because older version is set in wiremock-extension-convention
def wiremockVersion = "3.9.2"

dependencies {
api 'org.wiremock:wiremock-standalone:3.9.2'
api "org.wiremock:wiremock-standalone:${wiremockVersion}"
compileOnly "org.wiremock:wiremock:${wiremockVersion}"
shadow "org.wiremock:wiremock:${wiremockVersion}"
api "org.springframework.boot:spring-boot-test:3.3.4"
api "org.springframework:spring-test:6.1.13"
api "org.slf4j:slf4j-api:2.0.16"
api 'org.junit.jupiter:junit-jupiter-api:5.11.2'

testImplementation "org.springframework.boot:spring-boot-starter-test:3.3.4"
testImplementation 'org.assertj:assertj-core:3.26.3'
testImplementation platform('org.junit:junit-bom:5.11.2')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.junit.platform:junit-platform-launcher'
testImplementation 'io.rest-assured:rest-assured:5.5.0'

constraints {
implementation('org.apache.commons:commons-compress:1.26.0') {
because 'version 1.24.0 has a vulnerability'
}
}
}

// Not using shadowJar, but currently not possible to disable in wiremock-extension-convention
shadowJar {
mergeServiceFiles()

exclude 'META-INF/maven/**'
exclude 'META-INF/versions/17/**'
exclude 'META-INF/versions/21/**'
exclude 'module-info.class'
exclude '**/*'
}

project('wiremock-spring-boot-example', {
dependencies {
implementation "org.springframework.boot:spring-boot-starter-web:3.3.4"
implementation "org.springframework.boot:spring-boot-starter-webflux:3.3.4"

testImplementation rootProject
}
})
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
rootProject.name = 'wiremock-spring-boot'
include 'wiremock-spring-boot-example'
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private void configureWireMockForDefaultInstance(final ExtensionContext extensio

@Override
public void afterEach(final ExtensionContext context) throws Exception {
WireMock.configureFor(8080);
WireMock.configureFor(-1);
}

private static <T extends Annotation> void injectWireMockInstances(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThrows;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.wiremock.spring;
package test;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand All @@ -19,22 +19,24 @@
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.test.util.TestSocketUtils;
import org.wiremock.spring.ConfigureWireMock;
import org.wiremock.spring.EnableWireMock;
import org.wiremock.spring.InjectWireMock;
import org.wiremock.spring.WireMockConfigurationCustomizer;

@SpringBootTest(classes = WireMockConfigurationCustomizerTest.AppConfiguration.class)
@SpringBootTest(classes = LoggingTest.AppConfiguration.class)
@EnableWireMock({
@ConfigureWireMock(
name = "user-service",
baseUrlProperties = "user-service.url",
configurationCustomizers =
WireMockConfigurationCustomizerTest.SampleConfigurationCustomizer.class),
configurationCustomizers = LoggingTest.SampleConfigurationCustomizer.class),
@ConfigureWireMock(
name = "todo-service",
baseUrlProperties = "todo-service.url",
configurationCustomizers =
WireMockConfigurationCustomizerTest.SampleConfigurationCustomizer.class),
configurationCustomizers = LoggingTest.SampleConfigurationCustomizer.class),
})
@ExtendWith(OutputCaptureExtension.class)
class WireMockConfigurationCustomizerTest {
class LoggingTest {
private static final int USER_SERVICE_PORT = TestSocketUtils.findAvailableTcpPort();
private static final int TODO_SERVICE_PORT = TestSocketUtils.findAvailableTcpPort();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package test;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package app;
package usecases;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@SpringBootApplication(scanBasePackages = "usecases")
public class App {

public static void main(final String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.anyRequestedFor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.anyRequestedFor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.anyRequestedFor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package usecases;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.anyRequestedFor;
Expand Down

This file was deleted.

0 comments on commit 3d78d2b

Please sign in to comment.