0

I'm trying to run the following test

  import org.springframework.test.web.client.MockRestServiceServer;
    ....            

@Test
void successPost () {
MockRestServiceServer server = MockRestServiceServer.bindTo(restTemplate).build();

    server.expect(once(), requestTo("http://localhost:8080/test"))
                .andExpect(header("X-AUTH", "myToken"))
                .andRespond(withSuccess("{ \"msg\":\"hi\"}", MediaType.APPLICATION_JSON));

            WebClient<String, DummyResponse> client = new WebClient<>(restTemplate, retryTemplate, DummyResponse.class);
            DummyResponse result = client.post("http://localhost:8080","/test", "myRequest", "myToken");

            // Verify all expectations met
            server.verify();
            assertThat(result.getMsg(), is("hi"));
}

and it fails with when I have .andExpect(header("X-AUTH", "myToken")) ClassNotFoundException: org.junit.Assert

Project contains only JUnit 5 dependencies and

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>2.1.0.RELEASE</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
Omar
  • 101
  • 2

0 Answers0