Migrate rest of test suite from JUnit 4 to JUnit Jupiter

This commit migrates the rest of Spring's test suite to JUnit Jupiter,
except spring-test which will be migrated in a separate commit.

See gh-23451
This commit is contained in:
Sam Brannen
2019-08-13 12:57:37 +02:00
parent 3df85c783f
commit 3f3e41923f
1487 changed files with 5428 additions and 4782 deletions

View File

@@ -28,8 +28,8 @@ import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stax.StAXResult;
import javax.xml.transform.stream.StreamResult;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -54,7 +54,7 @@ public abstract class AbstractMarshallerTests<M extends Marshaller> {
protected Object flights;
@Before
@BeforeEach
public final void setUp() throws Exception {
marshaller = createMarshaller();
flights = createFlights();

View File

@@ -30,8 +30,8 @@ import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamSource;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
@@ -54,7 +54,7 @@ public abstract class AbstractUnmarshallerTests<U extends Unmarshaller> {
"<tns:flights xmlns:tns=\"http://samples.springframework.org/flight\">" +
"<tns:flight><tns:number>42</tns:number></tns:flight></tns:flights>";
@Before
@BeforeEach
public final void setUp() throws Exception {
unmarshaller = createUnmarshaller();
}

View File

@@ -16,7 +16,7 @@
package org.springframework.oxm.config;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

View File

@@ -34,7 +34,7 @@ import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.xml.sax.Attributes;

View File

@@ -27,7 +27,7 @@ import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

View File

@@ -19,15 +19,15 @@ package org.springframework.oxm.jibx;
import java.io.StringWriter;
import javax.xml.transform.stream.StreamResult;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnJre;
import org.springframework.oxm.AbstractMarshallerTests;
import org.springframework.tests.XmlContent;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.condition.JRE.JAVA_8;
/**
* NOTE: These tests fail under Eclipse/IDEA because JiBX binding does not occur by
@@ -37,15 +37,9 @@ import static org.junit.Assume.assumeTrue;
* @author Sam Brannen
*/
@Deprecated
@EnabledOnJre(JAVA_8) // JiBX compiler is currently not compatible with JDK 9
public class JibxMarshallerTests extends AbstractMarshallerTests<JibxMarshaller> {
@BeforeClass
public static void compilerAssumptions() {
// JiBX compiler is currently not compatible with JDK 9
assumeTrue(System.getProperty("java.version").startsWith("1.8."));
}
@Override
protected JibxMarshaller createMarshaller() throws Exception {
JibxMarshaller marshaller = new JibxMarshaller();

View File

@@ -19,13 +19,13 @@ package org.springframework.oxm.jibx;
import java.io.ByteArrayInputStream;
import javax.xml.transform.stream.StreamSource;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnJre;
import org.springframework.oxm.AbstractUnmarshallerTests;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.condition.JRE.JAVA_8;
/**
* NOTE: These tests fail under Eclipse/IDEA because JiBX binding does
@@ -35,6 +35,7 @@ import static org.junit.Assume.assumeTrue;
* @author Sam Brannen
*/
@Deprecated
@EnabledOnJre(JAVA_8) // JiBX compiler is currently not compatible with JDK 9
public class JibxUnmarshallerTests extends AbstractUnmarshallerTests<JibxMarshaller> {
protected static final String INPUT_STRING_WITH_SPECIAL_CHARACTERS =
@@ -42,13 +43,6 @@ public class JibxUnmarshallerTests extends AbstractUnmarshallerTests<JibxMarshal
"<tns:flight><tns:airline>Air Libert\u00e9</tns:airline><tns:number>42</tns:number></tns:flight></tns:flights>";
@BeforeClass
public static void compilerAssumptions() {
// JiBX compiler is currently not compatible with JDK 9
assumeTrue(System.getProperty("java.version").startsWith("1.8."));
}
@Override
protected JibxMarshaller createUnmarshaller() throws Exception {
JibxMarshaller unmarshaller = new JibxMarshaller();

View File

@@ -43,9 +43,8 @@ import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
import com.thoughtworks.xstream.io.json.JsonWriter;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -78,7 +77,7 @@ public class XStreamMarshallerTests {
private Flight flight;
@Before
@BeforeEach
public void createMarshaller() {
marshaller = new XStreamMarshaller();
Map<String, String> aliases = new HashMap<>();
@@ -236,7 +235,6 @@ public class XStreamMarshallerTests {
}
@Test
@Ignore("Fails on JDK 8 build 108")
public void aliasesByTypeStringClassMap() throws Exception {
Map<String, Class<?>> aliases = new HashMap<>();
aliases.put("flight", Flight.class);
@@ -250,7 +248,6 @@ public class XStreamMarshallerTests {
}
@Test
@Ignore("Fails on JDK 8 build 108")
public void aliasesByTypeStringStringMap() throws Exception {
Map<String, String> aliases = new HashMap<>();
aliases.put("flight", Flight.class.getName());

View File

@@ -28,8 +28,8 @@ import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
@@ -46,7 +46,7 @@ public class XStreamUnmarshallerTests {
private XStreamMarshaller unmarshaller;
@Before
@BeforeEach
public void createUnmarshaller() throws Exception {
unmarshaller = new XStreamMarshaller();
Map<String, Class<?>> aliases = new HashMap<>();