Browse Source

Switch focus to JUnit Jupiter in testing examples

pull/28468/head
Sam Brannen 4 years ago
parent
commit
bf8a54decf
  1. 6
      spring-context/src/main/java/org/springframework/context/annotation/Configuration.java
  2. 14
      spring-test/src/main/java/org/springframework/test/context/ContextHierarchy.java

6
spring-context/src/main/java/org/springframework/context/annotation/Configuration.java

@ -356,16 +356,16 @@ import org.springframework.stereotype.Component;
* {@code @Component} classes. * {@code @Component} classes.
* *
* <pre class="code"> * <pre class="code">
* &#064;RunWith(SpringRunner.class) * &#064;ExtendWith(SpringExtension.class)
* &#064;ContextConfiguration(classes = {AppConfig.class, DatabaseConfig.class}) * &#064;ContextConfiguration(classes = {AppConfig.class, DatabaseConfig.class})
* public class MyTests { * class MyTests {
* *
* &#064;Autowired MyBean myBean; * &#064;Autowired MyBean myBean;
* *
* &#064;Autowired DataSource dataSource; * &#064;Autowired DataSource dataSource;
* *
* &#064;Test * &#064;Test
* public void test() { * void test() {
* // assertions against myBean ... * // assertions against myBean ...
* } * }
* }</pre> * }</pre>

14
spring-test/src/main/java/org/springframework/test/context/ContextHierarchy.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -42,16 +42,16 @@ import java.lang.annotation.Target;
* the one for the child context (i.e., the lowest context in the hierarchy). * the one for the child context (i.e., the lowest context in the hierarchy).
* *
* <pre class="code"> * <pre class="code">
* &#064;RunWith(SpringRunner.class) * &#064;ExtendWith(SpringExtension.class)
* &#064;WebAppConfiguration * &#064;WebAppConfiguration
* &#064;ContextHierarchy({ * &#064;ContextHierarchy({
* &#064;ContextConfiguration(classes = TestAppConfig.class), * &#064;ContextConfiguration(classes = TestAppConfig.class),
* &#064;ContextConfiguration(classes = WebConfig.class) * &#064;ContextConfiguration(classes = WebConfig.class)
* }) * })
* public class ControllerIntegrationTests { * class ControllerIntegrationTests {
* *
* &#064;Autowired * &#064;Autowired
* private WebApplicationContext wac; * WebApplicationContext wac;
* *
* // ... * // ...
* }</pre> * }</pre>
@ -71,7 +71,7 @@ import java.lang.annotation.Target;
* the parent context for each of the contexts loaded for the concrete subclasses. * the parent context for each of the contexts loaded for the concrete subclasses.
* *
* <pre class="code"> * <pre class="code">
* &#064;RunWith(SpringRunner.class) * &#064;ExtendWith(SpringExtension.class)
* &#064;WebAppConfiguration * &#064;WebAppConfiguration
* &#064;ContextConfiguration("file:src/main/webapp/WEB-INF/applicationContext.xml") * &#064;ContextConfiguration("file:src/main/webapp/WEB-INF/applicationContext.xml")
* public abstract class AbstractWebTests {} * public abstract class AbstractWebTests {}
@ -98,7 +98,7 @@ import java.lang.annotation.Target;
* "/order-config.xml"}</code>. * "/order-config.xml"}</code>.
* *
* <pre class="code"> * <pre class="code">
* &#064;RunWith(SpringRunner.class) * &#064;ExtendWith(SpringExtension.class)
* &#064;ContextHierarchy({ * &#064;ContextHierarchy({
* &#064;ContextConfiguration(name = "parent", locations = "/app-config.xml"), * &#064;ContextConfiguration(name = "parent", locations = "/app-config.xml"),
* &#064;ContextConfiguration(name = "child", locations = "/user-config.xml") * &#064;ContextConfiguration(name = "child", locations = "/user-config.xml")
@ -119,7 +119,7 @@ import java.lang.annotation.Target;
* context loaded from {@code "/app-config.xml"}. * context loaded from {@code "/app-config.xml"}.
* *
* <pre class="code"> * <pre class="code">
* &#064;RunWith(SpringRunner.class) * &#064;ExtendWith(SpringExtension.class)
* &#064;ContextHierarchy({ * &#064;ContextHierarchy({
* &#064;ContextConfiguration(name = "parent", locations = "/app-config.xml"), * &#064;ContextConfiguration(name = "parent", locations = "/app-config.xml"),
* &#064;ContextConfiguration(name = "child", locations = "/user-config.xml") * &#064;ContextConfiguration(name = "child", locations = "/user-config.xml")

Loading…
Cancel
Save