Skip to content

Commit ba48a72

Browse files
committed
Inject ApplicationContext not WebApplicationContext with WebTestClient
Closes gh-582
1 parent 303656c commit ba48a72

9 files changed

+28
-28
lines changed

docs/src/test/java/com/example/webtestclient/CustomDefaultOperationPreprocessors.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,9 +19,9 @@
1919
import org.junit.Before;
2020
import org.junit.Rule;
2121

22+
import org.springframework.context.ApplicationContext;
2223
import org.springframework.restdocs.JUnitRestDocumentation;
2324
import org.springframework.test.web.reactive.server.WebTestClient;
24-
import org.springframework.web.context.WebApplicationContext;
2525

2626
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
2727
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
@@ -34,7 +34,7 @@ public class CustomDefaultOperationPreprocessors {
3434
@Rule
3535
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
3636

37-
private WebApplicationContext context;
37+
private ApplicationContext context;
3838

3939
@SuppressWarnings("unused")
4040
private WebTestClient webTestClient;

docs/src/test/java/com/example/webtestclient/CustomDefaultSnippets.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@
2020
import org.junit.Rule;
2121

2222
import org.springframework.beans.factory.annotation.Autowired;
23+
import org.springframework.context.ApplicationContext;
2324
import org.springframework.restdocs.JUnitRestDocumentation;
2425
import org.springframework.test.web.reactive.server.WebTestClient;
25-
import org.springframework.web.context.WebApplicationContext;
2626

2727
import static org.springframework.restdocs.cli.CliDocumentation.curlRequest;
2828
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.documentationConfiguration;
@@ -35,7 +35,7 @@ public class CustomDefaultSnippets {
3535
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
3636

3737
@Autowired
38-
private WebApplicationContext context;
38+
private ApplicationContext context;
3939

4040
@SuppressWarnings("unused")
4141
private WebTestClient webTestClient;

docs/src/test/java/com/example/webtestclient/CustomEncoding.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@
2020
import org.junit.Rule;
2121

2222
import org.springframework.beans.factory.annotation.Autowired;
23+
import org.springframework.context.ApplicationContext;
2324
import org.springframework.restdocs.JUnitRestDocumentation;
2425
import org.springframework.test.web.reactive.server.WebTestClient;
25-
import org.springframework.web.context.WebApplicationContext;
2626

2727
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.documentationConfiguration;
2828

@@ -34,7 +34,7 @@ public class CustomEncoding {
3434
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
3535

3636
@Autowired
37-
private WebApplicationContext context;
37+
private ApplicationContext context;
3838

3939
@SuppressWarnings("unused")
4040
private WebTestClient webTestClient;

docs/src/test/java/com/example/webtestclient/CustomFormat.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,10 +20,10 @@
2020
import org.junit.Rule;
2121

2222
import org.springframework.beans.factory.annotation.Autowired;
23+
import org.springframework.context.ApplicationContext;
2324
import org.springframework.restdocs.JUnitRestDocumentation;
2425
import org.springframework.restdocs.templates.TemplateFormats;
2526
import org.springframework.test.web.reactive.server.WebTestClient;
26-
import org.springframework.web.context.WebApplicationContext;
2727

2828
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.documentationConfiguration;
2929

@@ -35,7 +35,7 @@ public class CustomFormat {
3535
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
3636

3737
@Autowired
38-
private WebApplicationContext context;
38+
private ApplicationContext context;
3939

4040
@SuppressWarnings("unused")
4141
private WebTestClient webTestClient;

docs/src/test/java/com/example/webtestclient/CustomUriConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@
2020
import org.junit.Rule;
2121

2222
import org.springframework.beans.factory.annotation.Autowired;
23+
import org.springframework.context.ApplicationContext;
2324
import org.springframework.restdocs.JUnitRestDocumentation;
2425
import org.springframework.test.web.reactive.server.WebTestClient;
25-
import org.springframework.web.context.WebApplicationContext;
2626

2727
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.documentationConfiguration;
2828

@@ -35,7 +35,7 @@ public class CustomUriConfiguration {
3535
private WebTestClient webTestClient;
3636

3737
@Autowired
38-
private WebApplicationContext context;
38+
private ApplicationContext context;
3939

4040
// tag::custom-uri-configuration[]
4141
@Before

docs/src/test/java/com/example/webtestclient/EveryTestPreprocessing.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,9 +19,9 @@
1919
import org.junit.Before;
2020
import org.junit.Rule;
2121

22+
import org.springframework.context.ApplicationContext;
2223
import org.springframework.restdocs.JUnitRestDocumentation;
2324
import org.springframework.test.web.reactive.server.WebTestClient;
24-
import org.springframework.web.context.WebApplicationContext;
2525

2626
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
2727
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
@@ -37,7 +37,7 @@ public class EveryTestPreprocessing {
3737
@Rule
3838
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
3939

40-
private WebApplicationContext context;
40+
private ApplicationContext context;
4141

4242
// tag::setup[]
4343
private WebTestClient webTestClient;

docs/src/test/java/com/example/webtestclient/ExampleApplicationJUnit5Tests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,10 +19,10 @@
1919
import org.junit.jupiter.api.BeforeEach;
2020
import org.junit.jupiter.api.extension.ExtendWith;
2121

22+
import org.springframework.context.ApplicationContext;
2223
import org.springframework.restdocs.RestDocumentationContextProvider;
2324
import org.springframework.restdocs.RestDocumentationExtension;
2425
import org.springframework.test.web.reactive.server.WebTestClient;
25-
import org.springframework.web.context.WebApplicationContext;
2626

2727
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.documentationConfiguration;
2828

@@ -34,9 +34,9 @@ public class ExampleApplicationJUnit5Tests {
3434
private WebTestClient webTestClient;
3535

3636
@BeforeEach
37-
public void setUp(WebApplicationContext webApplicationContext,
37+
public void setUp(ApplicationContext applicationContext,
3838
RestDocumentationContextProvider restDocumentation) {
39-
this.webTestClient = WebTestClient.bindToApplicationContext(webApplicationContext)
39+
this.webTestClient = WebTestClient.bindToApplicationContext(applicationContext)
4040
.configureClient()
4141
.filter(documentationConfiguration(restDocumentation)) // <1>
4242
.build();

docs/src/test/java/com/example/webtestclient/ExampleApplicationTestNgTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,9 +22,9 @@
2222
import org.testng.annotations.BeforeMethod;
2323

2424
import org.springframework.beans.factory.annotation.Autowired;
25+
import org.springframework.context.ApplicationContext;
2526
import org.springframework.restdocs.ManualRestDocumentation;
2627
import org.springframework.test.web.reactive.server.WebTestClient;
27-
import org.springframework.web.context.WebApplicationContext;
2828

2929
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.documentationConfiguration;
3030

@@ -37,7 +37,7 @@ public class ExampleApplicationTestNgTests {
3737
private WebTestClient webTestClient;
3838

3939
@Autowired
40-
private WebApplicationContext context;
40+
private ApplicationContext context;
4141

4242
@BeforeMethod
4343
public void setUp(Method method) {

docs/src/test/java/com/example/webtestclient/ExampleApplicationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@
2020
import org.junit.Rule;
2121

2222
import org.springframework.beans.factory.annotation.Autowired;
23+
import org.springframework.context.ApplicationContext;
2324
import org.springframework.restdocs.JUnitRestDocumentation;
2425
import org.springframework.test.web.reactive.server.WebTestClient;
25-
import org.springframework.web.context.WebApplicationContext;
2626

2727
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.documentationConfiguration;
2828

@@ -36,7 +36,7 @@ public class ExampleApplicationTests {
3636
private WebTestClient webTestClient;
3737

3838
@Autowired
39-
private WebApplicationContext context;
39+
private ApplicationContext context;
4040

4141
@Before
4242
public void setUp() {

0 commit comments

Comments
 (0)