File tree 2 files changed +67
-0
lines changed
spring-5/src/test/java/com/baeldung/jupiter
2 files changed +67
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .baeldung .jupiter ;
2
+
3
+ import static org .junit .Assert .assertNotNull ;
4
+
5
+ import org .junit .jupiter .api .Test ;
6
+ import org .springframework .beans .factory .annotation .Autowired ;
7
+ import org .springframework .context .ApplicationContext ;
8
+ import org .springframework .context .annotation .Configuration ;
9
+ import org .springframework .test .context .junit .jupiter .SpringJUnitConfig ;
10
+
11
+ /**
12
+ * @SpringJUnitConfig(SpringJUnitConfigTest.Config.class) is equivalent to:
13
+ *
14
+ * @ExtendWith(SpringExtension.class)
15
+ * @ContextConfiguration(classes = SpringJUnitConfigTest.Config.class )
16
+ *
17
+ */
18
+ @ SpringJUnitConfig (SpringJUnitConfigTest .Config .class )
19
+ public class SpringJUnitConfigTest {
20
+
21
+ @ Configuration
22
+ static class Config {
23
+ }
24
+
25
+ @ Autowired
26
+ private ApplicationContext applicationContext ;
27
+
28
+ @ Test
29
+ void givenAppContext_WhenInjected_ThenItShouldNotBeNull () {
30
+ assertNotNull (applicationContext );
31
+ }
32
+
33
+ }
Original file line number Diff line number Diff line change
1
+ package com .baeldung .jupiter ;
2
+
3
+ import static org .junit .Assert .assertNotNull ;
4
+
5
+ import org .junit .jupiter .api .Test ;
6
+ import org .springframework .beans .factory .annotation .Autowired ;
7
+ import org .springframework .context .annotation .Configuration ;
8
+ import org .springframework .test .context .junit .jupiter .web .SpringJUnitWebConfig ;
9
+ import org .springframework .web .context .WebApplicationContext ;
10
+
11
+ /**
12
+ * @SpringJUnitWebConfig(SpringJUnitWebConfigTest.Config.class) is equivalent to:
13
+ *
14
+ * @ExtendWith(SpringExtension.class)
15
+ * @WebAppConfiguration
16
+ * @ContextConfiguration(classes = SpringJUnitWebConfigTest.Config.class )
17
+ *
18
+ */
19
+ @ SpringJUnitWebConfig (SpringJUnitWebConfigTest .Config .class )
20
+ public class SpringJUnitWebConfigTest {
21
+
22
+ @ Configuration
23
+ static class Config {
24
+ }
25
+
26
+ @ Autowired
27
+ private WebApplicationContext webAppContext ;
28
+
29
+ @ Test
30
+ void givenWebAppContext_WhenInjected_ThenItShouldNotBeNull () {
31
+ assertNotNull (webAppContext );
32
+ }
33
+
34
+ }
You can’t perform that action at this time.
0 commit comments