diff --git a/jaxb-ri/bundles/core/pom.xml b/jaxb-ri/bundles/core/pom.xml index 245f17971..45b04e7cb 100644 --- a/jaxb-ri/bundles/core/pom.xml +++ b/jaxb-ri/bundles/core/pom.xml @@ -57,8 +57,8 @@ provided - junit - junit + org.junit.jupiter + junit-jupiter-engine test diff --git a/jaxb-ri/bundles/core/src/test/java/jaxb/core/test/OSGiBundleVersionTest.java b/jaxb-ri/bundles/core/src/test/java/jaxb/core/test/OSGiBundleVersionTest.java index db08954e4..9c01a043c 100644 --- a/jaxb-ri/bundles/core/src/test/java/jaxb/core/test/OSGiBundleVersionTest.java +++ b/jaxb-ri/bundles/core/src/test/java/jaxb/core/test/OSGiBundleVersionTest.java @@ -10,27 +10,28 @@ package jaxb.core.test; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.util.jar.JarFile; import java.util.jar.Manifest; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Tests if MANIFEST Bundle-Version has correct version format. * * @author Martin Vojtek */ -public class OSGiBundleVersionTest extends TestCase { - - public OSGiBundleVersionTest(String name) { - super(name); - } +public class OSGiBundleVersionTest { + @Test public void testJaxbOsgiBundleVersion() throws IOException { String osgiJar = System.getProperty("osgi.dist"); - assertNotNull("osgi.dist not set", osgiJar); + assertNotNull(osgiJar, "osgi.dist not set"); checkVersion(new File(osgiJar + ".jar")); } @@ -40,7 +41,7 @@ private void checkVersion(File f) throws IOException { String version = mf.getMainAttributes().getValue("Bundle-Version"); assertNotNull(version); String[] v = version.split("\\."); - assertTrue("only or is allowed but was: <" + version + ">", v.length <= 4); + assertTrue(v.length <= 4, "only or is allowed but was: <" + version + ">"); for (int i = 0; i < (4 == v.length ? v.length - 1 : v.length); i++) { try { Integer.parseInt(v[i]); diff --git a/jaxb-ri/bundles/jxc/pom.xml b/jaxb-ri/bundles/jxc/pom.xml index 072f6a63d..18fdc5759 100644 --- a/jaxb-ri/bundles/jxc/pom.xml +++ b/jaxb-ri/bundles/jxc/pom.xml @@ -65,8 +65,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-engine test diff --git a/jaxb-ri/bundles/jxc/src/test/java/jaxb/jxc/test/OSGiBundleVersionTest.java b/jaxb-ri/bundles/jxc/src/test/java/jaxb/jxc/test/OSGiBundleVersionTest.java index 4f5154efa..c5475350c 100644 --- a/jaxb-ri/bundles/jxc/src/test/java/jaxb/jxc/test/OSGiBundleVersionTest.java +++ b/jaxb-ri/bundles/jxc/src/test/java/jaxb/jxc/test/OSGiBundleVersionTest.java @@ -10,27 +10,28 @@ package jaxb.jxc.test; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.util.jar.JarFile; import java.util.jar.Manifest; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Tests if MANIFEST Bundle-Version has correct version format. * * @author Martin Vojtek */ -public class OSGiBundleVersionTest extends TestCase { - - public OSGiBundleVersionTest(String name) { - super(name); - } +public class OSGiBundleVersionTest { + @Test public void testJaxbOsgiBundleVersion() throws IOException { String osgiJar = System.getProperty("osgi.dist"); - assertNotNull("osgi.dist not set", osgiJar); + assertNotNull(osgiJar, "osgi.dist not set"); checkVersion(new File(osgiJar + ".jar")); } @@ -40,7 +41,7 @@ private void checkVersion(File f) throws IOException { String version = mf.getMainAttributes().getValue("Bundle-Version"); assertNotNull(version); String[] v = version.split("\\."); - assertTrue("only or is allowed but was: <" + version + ">", v.length <= 4); + assertTrue(v.length <= 4, "only or is allowed but was: <" + version + ">"); for (int i = 0; i < (4 == v.length ? v.length - 1 : v.length); i++) { try { Integer.parseInt(v[i]); diff --git a/jaxb-ri/bundles/osgi/osgi/pom.xml b/jaxb-ri/bundles/osgi/osgi/pom.xml index bb6dfeb22..405c0c3cf 100644 --- a/jaxb-ri/bundles/osgi/osgi/pom.xml +++ b/jaxb-ri/bundles/osgi/osgi/pom.xml @@ -132,8 +132,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-engine test diff --git a/jaxb-ri/bundles/osgi/osgi/src/test/java/jaxb/osgi/test/OSGiBundleVersionTest.java b/jaxb-ri/bundles/osgi/osgi/src/test/java/jaxb/osgi/test/OSGiBundleVersionTest.java index 625649f58..009c7af72 100644 --- a/jaxb-ri/bundles/osgi/osgi/src/test/java/jaxb/osgi/test/OSGiBundleVersionTest.java +++ b/jaxb-ri/bundles/osgi/osgi/src/test/java/jaxb/osgi/test/OSGiBundleVersionTest.java @@ -10,27 +10,28 @@ package jaxb.osgi.test; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.util.jar.JarFile; import java.util.jar.Manifest; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Tests if MANIFEST Bundle-Version has correct version format. * * @author Martin Vojtek */ -public class OSGiBundleVersionTest extends TestCase { - - public OSGiBundleVersionTest(String name) { - super(name); - } +public class OSGiBundleVersionTest { + @Test public void testJaxbOsgiBundleVersion() throws IOException { String osgiJar = System.getProperty("osgi.dist"); - assertNotNull("osgi.dist not set", osgiJar); + assertNotNull(osgiJar, "osgi.dist not set"); checkVersion(new File(osgiJar + ".jar")); } @@ -40,7 +41,7 @@ private void checkVersion(File f) throws IOException { String version = mf.getMainAttributes().getValue("Bundle-Version"); assertNotNull(version); String[] v = version.split("\\."); - assertTrue("only or is allowed but was: <" + version + ">", v.length <= 4); + assertTrue(v.length <= 4, "only or is allowed but was: <" + version + ">"); for (int i = 0; i < (4 == v.length ? v.length - 1 : v.length); i++) { try { Integer.parseInt(v[i]); diff --git a/jaxb-ri/bundles/runtime/pom.xml b/jaxb-ri/bundles/runtime/pom.xml index 5146dbc50..323487d00 100644 --- a/jaxb-ri/bundles/runtime/pom.xml +++ b/jaxb-ri/bundles/runtime/pom.xml @@ -54,8 +54,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-engine test diff --git a/jaxb-ri/bundles/runtime/src/test/java/jaxb/runtime/test/OSGiBundleVersionTest.java b/jaxb-ri/bundles/runtime/src/test/java/jaxb/runtime/test/OSGiBundleVersionTest.java index 14ac487e7..0b94d4f55 100644 --- a/jaxb-ri/bundles/runtime/src/test/java/jaxb/runtime/test/OSGiBundleVersionTest.java +++ b/jaxb-ri/bundles/runtime/src/test/java/jaxb/runtime/test/OSGiBundleVersionTest.java @@ -10,27 +10,28 @@ package jaxb.runtime.test; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.util.jar.JarFile; import java.util.jar.Manifest; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Tests if MANIFEST Bundle-Version has correct version format. * * @author Martin Vojtek */ -public class OSGiBundleVersionTest extends TestCase { - - public OSGiBundleVersionTest(String name) { - super(name); - } +public class OSGiBundleVersionTest { + @Test public void testJaxbOsgiBundleVersion() throws IOException { String osgiJar = System.getProperty("osgi.dist"); - assertNotNull("osgi.dist not set", osgiJar); + assertNotNull(osgiJar, "osgi.dist not set"); checkVersion(new File(osgiJar + ".jar")); } @@ -40,7 +41,7 @@ private void checkVersion(File f) throws IOException { String version = mf.getMainAttributes().getValue("Bundle-Version"); assertNotNull(version); String[] v = version.split("\\."); - assertTrue("only or is allowed but was: <" + version + ">", v.length <= 4); + assertTrue(v.length <= 4, "only or is allowed but was: <" + version + ">"); for (int i = 0; i < (4 == v.length ? v.length - 1 : v.length); i++) { try { Integer.parseInt(v[i]); diff --git a/jaxb-ri/bundles/xjc/pom.xml b/jaxb-ri/bundles/xjc/pom.xml index 957cb3cb7..608e8b897 100644 --- a/jaxb-ri/bundles/xjc/pom.xml +++ b/jaxb-ri/bundles/xjc/pom.xml @@ -91,8 +91,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-engine test diff --git a/jaxb-ri/bundles/xjc/src/test/java/jaxb/xjc/test/OSGiBundleVersionTest.java b/jaxb-ri/bundles/xjc/src/test/java/jaxb/xjc/test/OSGiBundleVersionTest.java index 013b23557..5d04cd7b8 100644 --- a/jaxb-ri/bundles/xjc/src/test/java/jaxb/xjc/test/OSGiBundleVersionTest.java +++ b/jaxb-ri/bundles/xjc/src/test/java/jaxb/xjc/test/OSGiBundleVersionTest.java @@ -10,24 +10,25 @@ package jaxb.xjc.test; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.util.jar.JarFile; import java.util.jar.Manifest; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Tests if MANIFEST Bundle-Version has correct version format. * * @author Martin Vojtek */ -public class OSGiBundleVersionTest extends TestCase { - - public OSGiBundleVersionTest(String name) { - super(name); - } +public class OSGiBundleVersionTest { + @Test public void testJaxbOsgiBundleVersion() throws IOException { String osgiJar = System.getProperty("osgi.dist"); assertNotNull("osgi.dist not set", osgiJar); @@ -40,7 +41,7 @@ private void checkVersion(File f) throws IOException { String version = mf.getMainAttributes().getValue("Bundle-Version"); assertNotNull(version); String[] v = version.split("\\."); - assertTrue("only or is allowed but was: <" + version + ">", v.length <= 4); + assertTrue(v.length <= 4, "only or is allowed but was: <" + version + ">"); for (int i = 0; i < (4 == v.length ? v.length - 1 : v.length); i++) { try { Integer.parseInt(v[i]); diff --git a/jaxb-ri/codemodel/codemodel/pom.xml b/jaxb-ri/codemodel/codemodel/pom.xml index dc5600b07..802134cc9 100644 --- a/jaxb-ri/codemodel/codemodel/pom.xml +++ b/jaxb-ri/codemodel/codemodel/pom.xml @@ -34,9 +34,9 @@ - junit - junit - 4.13.2 + org.junit.jupiter + junit-jupiter-engine + 5.11.4 test diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/Issue1505Test.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/Issue1505Test.java index f5c94acb5..95d197aa3 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/Issue1505Test.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/Issue1505Test.java @@ -10,10 +10,10 @@ package com.sun.codemodel; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -import org.junit.Ignore; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class Issue1505Test { @@ -75,7 +75,7 @@ public void test9() { } @Test - @Ignore("Not supported") + @Disabled("Not supported") public void test10() { checks("java.util.Map"); } @@ -111,7 +111,7 @@ public void test16() { } @Test - @Ignore("Not supported") + @Disabled("Not supported") public void test17() { checks("M"); } diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JExportsTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JExportsTest.java index d194fcc2a..2cb84b707 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JExportsTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JExportsTest.java @@ -10,12 +10,13 @@ package com.sun.codemodel; -import org.junit.Test; import com.sun.codemodel.JModuleDirective.Type; +import org.junit.jupiter.api.Test; + import static com.sun.codemodel.JModuleTest.EOL; import static com.sun.codemodel.JModuleTest.PKG_NAME; import static com.sun.codemodel.JModuleTest.normalizeWhiteSpaces; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test Java module {@code exports} directive. @@ -23,11 +24,6 @@ */ public class JExportsTest extends JTestModuleDirective { - /** - * Default constructor. - */ - public JExportsTest() {} - /** * Test of getType method to make sure that it returns ExportsDirective. */ diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JModsTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JModsTest.java index b4204b260..04260aa3d 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JModsTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JModsTest.java @@ -10,11 +10,11 @@ package com.sun.codemodel; -import static org.junit.Assert.assertArrayEquals; +import org.junit.jupiter.api.Test; import java.lang.reflect.Modifier; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; public class JModsTest { static final int ALL_JMODS = JMod.PUBLIC | JMod.PROTECTED | JMod.PRIVATE diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JModuleTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JModuleTest.java index be494624f..ac3c8e0e9 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JModuleTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JModuleTest.java @@ -10,13 +10,17 @@ package com.sun.codemodel; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import java.io.CharArrayWriter; import java.io.PrintWriter; import java.util.regex.Pattern; -import org.junit.After; -import org.junit.Test; -import static org.junit.Assert.*; -import org.junit.Before; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Test Java module. @@ -57,16 +61,10 @@ static String normalizeWhiteSpaces(final String str) { return WH_SPACES.matcher(str).replaceAll(" "); } - /** - * Creates an instance of Java module test. - */ - public JModuleTest() { - } - /** * Initialize test. */ - @Before + @BeforeEach public void setUp() { openOutput(); } @@ -74,7 +72,7 @@ public void setUp() { /** * Cleanup test. */ - @After + @AfterEach public void tearDown() { closeOutput(); } @@ -137,7 +135,7 @@ public void test_exports() { final JPackage pkg = new JPackage(PKG_NAME, cm); instance._exports(pkg); JModuleDirective directive = directivesSingleElementCheck(instance); - assertTrue(directive instanceof JExportsDirective); + assertInstanceOf(JExportsDirective.class, directive); assertEquals(PKG_NAME, directive.name); } @@ -149,7 +147,7 @@ public void test_requires() { final JModule instance = new JModule(MODULE_NAME); instance._requires(DEP_MODULE_NAME); JModuleDirective directive = directivesSingleElementCheck(instance); - assertTrue(directive instanceof JRequiresDirective); + assertInstanceOf(JRequiresDirective.class, directive); assertEquals(DEP_MODULE_NAME, directive.name); } diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JRequiresTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JRequiresTest.java index c00839d35..14b72939b 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JRequiresTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JRequiresTest.java @@ -10,11 +10,12 @@ package com.sun.codemodel; -import org.junit.Test; +import org.junit.jupiter.api.Test; + import static com.sun.codemodel.JModuleTest.EOL; import static com.sun.codemodel.JModuleTest.MODULE_NAME; import static com.sun.codemodel.JModuleTest.normalizeWhiteSpaces; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test Java module {@code requires} directive for module dependency. diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JTestModuleDirective.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JTestModuleDirective.java index b2e039f54..e0cde8836 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JTestModuleDirective.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/JTestModuleDirective.java @@ -10,10 +10,11 @@ package com.sun.codemodel; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + import java.io.CharArrayWriter; import java.io.PrintWriter; -import org.junit.After; -import org.junit.Before; /** * Common Java module directive testing code. @@ -35,7 +36,7 @@ public JTestModuleDirective() {} /** * Initialize test. */ - @Before + @BeforeEach public void setUp() { openOutput(); } @@ -43,7 +44,7 @@ public void setUp() { /** * Cleanup test. */ - @After + @AfterEach public void tearDown() { closeOutput(); } diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/AnnotationUseTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/AnnotationUseTest.java index d94fdc61b..6f73509a9 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/AnnotationUseTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/AnnotationUseTest.java @@ -10,14 +10,6 @@ package com.sun.codemodel.tests; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.util.Collection; - -import org.junit.Assert; -import org.junit.Test; - import com.sun.codemodel.JAnnotationArrayMember; import com.sun.codemodel.JAnnotationUse; import com.sun.codemodel.JAnnotationWriter; @@ -27,12 +19,22 @@ import com.sun.codemodel.JFieldVar; import com.sun.codemodel.JMod; import com.sun.codemodel.writer.SingleStreamCodeWriter; +import org.junit.jupiter.api.Test; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.Collection; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * A test program for the annotation use features Note: Not all the generated * code would make sense but just checking in all the different ways you can use * an annotation - * + * * @author Bhakti Mehta */ public class AnnotationUseTest { @@ -90,10 +92,10 @@ public void main() throws Exception { // test typed annotation writer XmlElementW w = cls.annotate2(XmlElementW.class); - Assert.assertEquals(w, w); - Assert.assertEquals(System.identityHashCode(w), w.hashCode()); + assertEquals(w, w); + assertEquals(System.identityHashCode(w), w.hashCode()); w.toString(); - Assert.assertEquals(XmlElement.class, w.getAnnotationType()); + assertEquals(XmlElement.class, w.getAnnotationType()); w.ns("##default").value("foobar"); // adding an annotation as a member value pair @@ -105,11 +107,11 @@ public void main() throws Exception { private JAnnotationUse tstremoveAnnotation(JCodeModel cm, JDefinedClass cls, JAnnotationUse use) { Collection anns = cls.annotations(); - Assert.assertTrue(anns.contains(use)); - Assert.assertTrue(cls.removeAnnotation(use)); + assertTrue(anns.contains(use)); + assertTrue(cls.removeAnnotation(use)); Collection annsUpdated = cls.annotations(); - Assert.assertFalse(annsUpdated.contains(use)); - Assert.assertFalse(cls.removeAnnotation(use)); + assertFalse(annsUpdated.contains(use)); + assertFalse(cls.removeAnnotation(use)); use = cls.annotate(cm.ref(Retention.class)); return use; } @@ -135,26 +137,26 @@ interface XmlElementW extends JAnnotationWriter { * ********************************************************************* * Generates this * ********************************************************************** - * + * * @java.lang.annotation.Retention(value1 = * java.lang.annotation.RetentionPolicy.RUNTIME, value = Test.Iamenum.GOOD) * @XmlElement(ns = "##default", value = "foobar") * public class Test { - * + * * @java.lang.annotation.Retention(foo = @java.lang.annotation.Target(junk = 7) - * + * * , targetNamespace = 5, namesno = { 4, 5, 6 }, values = * {@java.lang.annotation.Target(type = java.lang.Integer) , * @java.lang.annotation.Target(type = java.lang.Float) }, names = {"Bob", * "Rob", "Ted"}, name = "book") private double y; - * + * * public void foo() { } - * + * * public enum Iamenum { - * + * * BAD, GOOD; } - * + * * } - * + * * } */ diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/AnonymousClassTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/AnonymousClassTest.java index 09e3f826e..f2052023e 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/AnonymousClassTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/AnonymousClassTest.java @@ -10,19 +10,18 @@ package com.sun.codemodel.tests; -import java.util.Iterator; - -import org.junit.Test; - import com.sun.codemodel.JCodeModel; import com.sun.codemodel.JDefinedClass; import com.sun.codemodel.JExpr; import com.sun.codemodel.JMethod; import com.sun.codemodel.JMod; import com.sun.codemodel.writer.SingleStreamCodeWriter; +import org.junit.jupiter.api.Test; + +import java.util.Iterator; /** - * + * * @author * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) */ diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/ForEachTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/ForEachTest.java index c8487e3c5..3e068941c 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/ForEachTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/ForEachTest.java @@ -10,13 +10,6 @@ package com.sun.codemodel.tests; -import java.io.ByteArrayOutputStream; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; - -import org.junit.Assert; -import org.junit.Test; - import com.sun.codemodel.JClass; import com.sun.codemodel.JCodeModel; import com.sun.codemodel.JDefinedClass; @@ -27,13 +20,20 @@ import com.sun.codemodel.JMod; import com.sun.codemodel.JVar; import com.sun.codemodel.writer.SingleStreamCodeWriter; +import org.junit.jupiter.api.Test; + +import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.assertTrue; /** - * + * * Simple program to test the generation of the enhanced for loop in jdk 1.5 - * + * * @author Bhakti Mehta Bhakti.Mehta@sun.com - * + * */ public class ForEachTest { @@ -65,6 +65,6 @@ public void main() throws Exception { cm.build(new SingleStreamCodeWriter(baos)); String result = baos.toString(StandardCharsets.UTF_8); System.out.println(result); - Assert.assertTrue(result.contains("ArrayList alist = new ArrayList<>();")); + assertTrue(result.contains("ArrayList alist = new ArrayList<>();")); } } diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/InnerClassTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/InnerClassTest.java index 4761e4edc..ac8cdf8e6 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/InnerClassTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/InnerClassTest.java @@ -10,13 +10,12 @@ package com.sun.codemodel.tests; -import org.junit.Test; - import com.sun.codemodel.JClassAlreadyExistsException; import com.sun.codemodel.JCodeModel; import com.sun.codemodel.JDefinedClass; import com.sun.codemodel.JMod; import com.sun.codemodel.tests.util.CodeModelTestsUtils; +import org.junit.jupiter.api.Test; public class InnerClassTest { @@ -26,9 +25,9 @@ public void innerClassesAreImported() throws JClassAlreadyExistsException { JDefinedClass aClass = codeModel._class("org.test.DaTestClass"); // JDefinedClass daInner = aClass._class("Inner"); -// Assert.assertEquals("org.test.DaTestClass.Inner", daInner.fullName()); -// Assert.assertEquals("org.test.DaTestClass$Inner", daInner.binaryName()); -// Assert.assertEquals("Inner", daInner.name()); +// assertEquals("org.test.DaTestClass.Inner", daInner.fullName()); +// assertEquals("org.test.DaTestClass$Inner", daInner.binaryName()); +// assertEquals("Inner", daInner.name()); // aClass.method(JMod.PUBLIC, daInner, "getInner"); final JDefinedClass otherClass = codeModel diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JAnnotationUseTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JAnnotationUseTest.java index a25dbb168..9a093f991 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JAnnotationUseTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JAnnotationUseTest.java @@ -10,27 +10,27 @@ package com.sun.codemodel.tests; -import org.junit.Assert; -import org.junit.Test; - import com.sun.codemodel.JAnnotationUse; import com.sun.codemodel.JClassAlreadyExistsException; import com.sun.codemodel.JCodeModel; import com.sun.codemodel.JDefinedClass; import com.sun.codemodel.JExpr; import com.sun.codemodel.tests.util.CodeModelTestsUtils; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class JAnnotationUseTest { @Test public void generatesGenericParam() throws JClassAlreadyExistsException { - + final JCodeModel codeModel = new JCodeModel(); final JDefinedClass testClass = codeModel._class("Test"); final JAnnotationUse suppressWarningAnnotation = testClass.annotate(SuppressWarnings.class); suppressWarningAnnotation.param("value", JExpr.lit("unused")); - - Assert.assertEquals("@java.lang.SuppressWarnings(\"unused\")", CodeModelTestsUtils.generate(suppressWarningAnnotation)); + + assertEquals("@java.lang.SuppressWarnings(\"unused\")", CodeModelTestsUtils.generate(suppressWarningAnnotation)); } diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JCodeModelTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JCodeModelTest.java index 1f90deec2..ed419d589 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JCodeModelTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JCodeModelTest.java @@ -11,12 +11,13 @@ package com.sun.codemodel.tests; import com.sun.codemodel.JCodeModel; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; /** * @author Kohsuke Kawaguchi */ -public class JCodeModelTest extends TestCase { +public class JCodeModelTest { + @Test public void testParseArray() throws Exception { JCodeModel cm = new JCodeModel(); cm.parseType("java.util.ArrayList[]"); diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JCommentTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JCommentTest.java index b96d190ab..633b6fd4e 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JCommentTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JCommentTest.java @@ -15,16 +15,18 @@ import com.sun.codemodel.JDefinedClass; import com.sun.codemodel.JDocComment; import com.sun.codemodel.writer.OutputStreamCodeWriter; + import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * * @author lukas */ -public class JCommentTest extends TestCase { +public class JCommentTest { public void testJavadoc() throws Throwable { JCodeModel model = new JCodeModel(); diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JDefinedClassInstanceInitTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JDefinedClassInstanceInitTest.java index ec211ea05..353466943 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JDefinedClassInstanceInitTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JDefinedClassInstanceInitTest.java @@ -10,24 +10,23 @@ package com.sun.codemodel.tests; -import static org.junit.Assert.assertNotNull; +import com.sun.codemodel.JCodeModel; +import com.sun.codemodel.JDefinedClass; +import com.sun.codemodel.JExpr; +import com.sun.codemodel.JFieldVar; +import com.sun.codemodel.JMod; +import com.sun.codemodel.writer.OutputStreamCodeWriter; import japa.parser.JavaParser; import japa.parser.ast.CompilationUnit; import japa.parser.ast.body.ClassOrInterfaceDeclaration; import japa.parser.ast.body.InitializerDeclaration; import japa.parser.ast.body.TypeDeclaration; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import org.junit.Test; - -import com.sun.codemodel.JCodeModel; -import com.sun.codemodel.JDefinedClass; -import com.sun.codemodel.JExpr; -import com.sun.codemodel.JFieldVar; -import com.sun.codemodel.JMod; -import com.sun.codemodel.writer.OutputStreamCodeWriter; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class JDefinedClassInstanceInitTest { diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JExprTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JExprTest.java index d09e9f5ac..3865a9f54 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JExprTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JExprTest.java @@ -12,38 +12,40 @@ import com.sun.codemodel.JExpr; import com.sun.codemodel.tests.util.CodeModelTestsUtils; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; -import org.junit.Assert; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * JExpr tests. */ -public class JExprTest extends TestCase { +public class JExprTest { /** * Tests double literal expression. */ + @Test public void testLitDouble() throws Exception { - Assert.assertTrue(CodeModelTestsUtils.toString( + assertTrue(CodeModelTestsUtils.toString( JExpr.lit(Double.POSITIVE_INFINITY)).endsWith( "POSITIVE_INFINITY")); - Assert.assertTrue(CodeModelTestsUtils.toString( + assertTrue(CodeModelTestsUtils.toString( JExpr.lit(Double.NEGATIVE_INFINITY)).endsWith( "NEGATIVE_INFINITY")); - Assert.assertTrue(CodeModelTestsUtils.toString(JExpr.lit(Double.NaN)) + assertTrue(CodeModelTestsUtils.toString(JExpr.lit(Double.NaN)) .endsWith("NaN")); } + @Test public void testLitFloat() throws Exception { - Assert.assertTrue(CodeModelTestsUtils.toString( + assertTrue(CodeModelTestsUtils.toString( JExpr.lit(Float.POSITIVE_INFINITY)).endsWith( "POSITIVE_INFINITY")); - Assert.assertTrue(CodeModelTestsUtils.toString( + assertTrue(CodeModelTestsUtils.toString( JExpr.lit(Float.NEGATIVE_INFINITY)).endsWith( "NEGATIVE_INFINITY")); - Assert.assertTrue(CodeModelTestsUtils.toString(JExpr.lit(Float.NaN)) + assertTrue(CodeModelTestsUtils.toString(JExpr.lit(Float.NaN)) .endsWith("NaN")); } diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JMethodTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JMethodTest.java index 3fa286fe2..648300a05 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JMethodTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/JMethodTest.java @@ -10,14 +10,15 @@ package com.sun.codemodel.tests; -import org.junit.Assert; -import org.junit.Test; - import com.sun.codemodel.JCodeModel; import com.sun.codemodel.JDefinedClass; import com.sun.codemodel.JMethod; import com.sun.codemodel.JMod; import com.sun.codemodel.JVar; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; public class JMethodTest { @@ -29,7 +30,7 @@ public void main() throws Exception { JVar foo = m.param(String.class, "foo"); - Assert.assertEquals(1, m.params().size()); - Assert.assertSame(foo, m.params().get(0)); + assertEquals(1, m.params().size()); + assertSame(foo, m.params().get(0)); } } diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/NestedClassTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/NestedClassTest.java index 3efcd3447..e174072e8 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/NestedClassTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/NestedClassTest.java @@ -10,11 +10,10 @@ package com.sun.codemodel.tests; -import org.junit.Test; - import com.sun.codemodel.JCodeModel; import com.sun.codemodel.JDefinedClass; import com.sun.codemodel.writer.SingleStreamCodeWriter; +import org.junit.jupiter.api.Test; /** * @author Kohsuke Kawaguchi diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/PackageAnnotationTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/PackageAnnotationTest.java index c36db8ac2..5e27ca9e4 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/PackageAnnotationTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/PackageAnnotationTest.java @@ -9,16 +9,18 @@ */ package com.sun.codemodel.tests; -import java.io.IOException; -import java.lang.annotation.Inherited; - -import org.junit.Test; - import com.sun.codemodel.JCodeModel; import com.sun.codemodel.JPackage; import com.sun.codemodel.writer.SingleStreamCodeWriter; +import org.junit.jupiter.api.Test; + import java.io.ByteArrayOutputStream; -import org.junit.Assert; +import java.io.IOException; +import java.lang.annotation.Inherited; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Kohsuke Kawaguchi @@ -37,11 +39,11 @@ public void noEmptyPInfo() throws IOException { // https://github.com/eclipse-ee4j/jaxb-ri/issues/1039 JCodeModel cm = new JCodeModel(); JPackage pkg = cm._package("bar"); - Assert.assertEquals(0, cm.countArtifacts()); - Assert.assertNotNull(pkg.annotations()); - Assert.assertEquals(0, cm.countArtifacts()); + assertEquals(0, cm.countArtifacts()); + assertNotNull(pkg.annotations()); + assertEquals(0, cm.countArtifacts()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); cm.build(new SingleStreamCodeWriter(baos)); - Assert.assertTrue(baos.toString().trim().isEmpty()); + assertTrue(baos.toString().trim().isEmpty()); } } diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/PackageJavadocTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/PackageJavadocTest.java index 79213c75b..30ac90515 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/PackageJavadocTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/PackageJavadocTest.java @@ -10,18 +10,17 @@ package com.sun.codemodel.tests; -import java.io.IOException; - -import org.junit.Test; - import com.sun.codemodel.JCodeModel; import com.sun.codemodel.writer.SingleStreamCodeWriter; +import org.junit.jupiter.api.Test; + +import java.io.IOException; /** * @author Kohsuke Kawaguchi */ public class PackageJavadocTest { - + @Test public void main() throws IOException { JCodeModel cm = new JCodeModel(); diff --git a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/VarArgsTest.java b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/VarArgsTest.java index e88a360b4..8b2c1f91c 100644 --- a/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/VarArgsTest.java +++ b/jaxb-ri/codemodel/codemodel/src/test/java/com/sun/codemodel/tests/VarArgsTest.java @@ -10,13 +10,20 @@ package com.sun.codemodel.tests; -import org.junit.Test; - -import com.sun.codemodel.*; +import com.sun.codemodel.JClass; +import com.sun.codemodel.JCodeModel; +import com.sun.codemodel.JDefinedClass; +import com.sun.codemodel.JExpr; +import com.sun.codemodel.JFieldRef; +import com.sun.codemodel.JForLoop; +import com.sun.codemodel.JMethod; +import com.sun.codemodel.JMod; +import com.sun.codemodel.JVar; import com.sun.codemodel.writer.SingleStreamCodeWriter; +import org.junit.jupiter.api.Test; /** - * + * * Simple program to test the generation of * the varargs feature in jdk 1.5 * @author Bhakti Mehta Bhakti.Mehta@sun.com @@ -29,7 +36,7 @@ * public class Test { - public void foo(java.lang.String param1, + public void foo(java.lang.String param1, java.lang.Integer param2, java.lang.String param5, java.lang.Object... param3) { for (int count = 0; (count<(param3.length)); count ++) { @@ -57,34 +64,34 @@ public void main() throws Exception { m.param(Integer.class, "param2"); JVar var = m.varParam(Object.class, "param3"); System.out.println("First varParam " + var); - + // checking for param after varParam it behaves ok //JVar[] var1 = m.varParam(Float.class, "param4"); JClass string = cm.ref(String.class); JClass stringArray = string.array(); // JVar param5 = m.param(String.class, "param5"); - + JForLoop forloop = m.body()._for(); - + JVar $count = forloop.init(cm.INT, "count", JExpr.lit(0)); - + forloop.test($count.lt(JExpr.direct("param3.length"))); forloop.update($count.incr()); - + JFieldRef out = cm.ref(System.class).staticRef("out"); - -// JVar typearray = + +// JVar typearray = m.listVarParam(); - + // JInvocation invocation = forloop.body().invoke(out, "println").arg( JExpr.direct("param3[count]")); - + JMethod main = cls.method(JMod.PUBLIC | JMod.STATIC, cm.VOID, "main"); main.param(stringArray, "args"); main.body().directStatement("new Test().foo(new String(\"Param1\"),new Integer(5),null,new String(\"Param3\"),new String(\"Param4\"));" );//new String("Param1"))"");// "new Integer(5),+// "null," +// "new String("first")," +// " new String("Second"))"); - + cm.build(new SingleStreamCodeWriter(System.out)); } catch (Exception e) { e.printStackTrace(); diff --git a/jaxb-ri/core/pom.xml b/jaxb-ri/core/pom.xml index b35d8263c..d1a6c61ac 100644 --- a/jaxb-ri/core/pom.xml +++ b/jaxb-ri/core/pom.xml @@ -58,8 +58,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-engine test diff --git a/jaxb-ri/core/src/test/java/org/glassfish/jaxb/core/UtilsTest.java b/jaxb-ri/core/src/test/java/org/glassfish/jaxb/core/UtilsTest.java index 0c7b710f2..d530ed71d 100644 --- a/jaxb-ri/core/src/test/java/org/glassfish/jaxb/core/UtilsTest.java +++ b/jaxb-ri/core/src/test/java/org/glassfish/jaxb/core/UtilsTest.java @@ -10,10 +10,13 @@ package org.glassfish.jaxb.core; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; -public class UtilsTest extends TestCase { - +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class UtilsTest { + + @Test public void testGetClassLogger() { assertEquals(UtilsTest.class.getName(), Utils.getClassLogger().getName()); } diff --git a/jaxb-ri/core/src/test/java/org/glassfish/jaxb/core/unmarshaller/DOMScannerTest.java b/jaxb-ri/core/src/test/java/org/glassfish/jaxb/core/unmarshaller/DOMScannerTest.java index 82d378579..6167334ab 100644 --- a/jaxb-ri/core/src/test/java/org/glassfish/jaxb/core/unmarshaller/DOMScannerTest.java +++ b/jaxb-ri/core/src/test/java/org/glassfish/jaxb/core/unmarshaller/DOMScannerTest.java @@ -10,15 +10,7 @@ package org.glassfish.jaxb.core.unmarshaller; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -27,12 +19,19 @@ import org.xml.sax.Locator; import org.xml.sax.SAXException; -import junit.framework.TestCase; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -public class DOMScannerTest extends TestCase { - +public class DOMScannerTest { + + @Test public void testParentDefaultNamespace() throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = dbf.newDocumentBuilder(); @@ -40,7 +39,7 @@ public void testParentDefaultNamespace() throws ParserConfigurationException, SA Document doc = builder.parse(is); NodeList testElems = doc.getElementsByTagName("test"); Node testElem = testElems.item(0); - + DOMScanner scanner = new DOMScanner(); MockContentHandler mockHandler = new MockContentHandler(); Map assertMapping = new HashMap<>(); @@ -51,14 +50,14 @@ public void testParentDefaultNamespace() throws ParserConfigurationException, SA scanner.setContentHandler(mockHandler); scanner.scan(testElem); } - + private static class MockContentHandler implements ContentHandler { - + private Map prefixMapping = new HashMap<>(); - + private Map assertMapping = new HashMap<>(); private String assertElement = null; - + public void setAssertion(String elementName, Map mapping) { this.assertElement = elementName; this.assertMapping.putAll(mapping); @@ -66,17 +65,17 @@ public void setAssertion(String elementName, Map mapping) { @Override public void setDocumentLocator(Locator locator) { - + } @Override public void startDocument() { - + } @Override public void endDocument() { - + } @Override @@ -92,35 +91,35 @@ public void endPrefixMapping(String prefix) { @Override public void startElement(String uri, String localName, String qName, Attributes atts) { if (assertElement != null && assertElement.equals(localName)) { - assertEquals("Prefix mapping does not match expected mapping", prefixMapping, assertMapping); + assertEquals(prefixMapping, assertMapping, "Prefix mapping does not match expected mapping"); } } @Override public void endElement(String uri, String localName, String qName) { - + } @Override public void characters(char[] ch, int start, int length) { - + } @Override public void ignorableWhitespace(char[] ch, int start, int length) { - + } @Override public void processingInstruction(String target, String data) { - + } @Override public void skippedEntity(String name) { - + } - + } } diff --git a/jaxb-ri/external/pom.xml b/jaxb-ri/external/pom.xml index 154258957..4a74848cd 100644 --- a/jaxb-ri/external/pom.xml +++ b/jaxb-ri/external/pom.xml @@ -102,14 +102,19 @@ - junit - junit - 4.13.2 + org.junit.jupiter + junit-jupiter-engine + 5.11.4 - xmlunit - xmlunit - 1.6 + org.xmlunit + xmlunit-jakarta-jaxb-impl + 2.10.0 + + + org.xmlunit + xmlunit-assertj3 + 2.10.0 net.java.dev.msv diff --git a/jaxb-ri/external/relaxng-datatype/pom.xml b/jaxb-ri/external/relaxng-datatype/pom.xml index 9a87b7967..409d7cfb9 100644 --- a/jaxb-ri/external/relaxng-datatype/pom.xml +++ b/jaxb-ri/external/relaxng-datatype/pom.xml @@ -38,8 +38,8 @@ true - junit - junit + org.junit.jupiter + junit-jupiter-engine test diff --git a/jaxb-ri/external/relaxng-datatype/src/test/java/com/sun/tools/rngdatatype/helpers/DatatypeLibraryLoaderTest.java b/jaxb-ri/external/relaxng-datatype/src/test/java/com/sun/tools/rngdatatype/helpers/DatatypeLibraryLoaderTest.java index 150f9eba3..b59cd0912 100644 --- a/jaxb-ri/external/relaxng-datatype/src/test/java/com/sun/tools/rngdatatype/helpers/DatatypeLibraryLoaderTest.java +++ b/jaxb-ri/external/relaxng-datatype/src/test/java/com/sun/tools/rngdatatype/helpers/DatatypeLibraryLoaderTest.java @@ -13,24 +13,22 @@ import com.sun.tools.rngdatatype.Datatype; import com.sun.tools.rngdatatype.DatatypeException; import com.sun.tools.rngdatatype.DatatypeLibrary; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class DatatypeLibraryLoaderTest { +import static org.junit.jupiter.api.Assertions.assertNotNull; - public DatatypeLibraryLoaderTest() { - } +public class DatatypeLibraryLoaderTest { @Test public void createExternalDatatypeLibrary() { org.relaxng.datatype.helpers.DatatypeLibraryLoader extLibraryLoader = new org.relaxng.datatype.helpers.DatatypeLibraryLoader(); org.relaxng.datatype.DatatypeLibrary extDatatypeLibrary = extLibraryLoader.createDatatypeLibrary("http://www.w3.org/2001/XMLSchema-datatypes"); - Assert.assertNotNull(extDatatypeLibrary); + assertNotNull(extDatatypeLibrary); try { org.relaxng.datatype.Datatype aFloat = extDatatypeLibrary.createDatatype("float"); - Assert.assertNotNull(aFloat); + assertNotNull(aFloat); Object value = aFloat.createValue("150", null); - Assert.assertNotNull(value); + assertNotNull(value); } catch (org.relaxng.datatype.DatatypeException e) { throw new RuntimeException(e); } @@ -41,12 +39,12 @@ public void createExternalDatatypeLibrary() { public void createJAXBDatatypeLibrary() { DatatypeLibraryLoader libraryLoader = new DatatypeLibraryLoader(); DatatypeLibrary datatypeLibrary = libraryLoader.createDatatypeLibrary("http://www.w3.org/2001/XMLSchema-datatypes"); - Assert.assertNotNull(datatypeLibrary); + assertNotNull(datatypeLibrary); try { Datatype aFloat = datatypeLibrary.createDatatype("float"); - Assert.assertNotNull(aFloat); + assertNotNull(aFloat); Object value = aFloat.createValue("150", null); - Assert.assertNotNull(value); + assertNotNull(value); } catch (DatatypeException e) { throw new RuntimeException(e); } diff --git a/jaxb-ri/external/rngom/pom.xml b/jaxb-ri/external/rngom/pom.xml index 9f82a0b81..19e9ba44b 100644 --- a/jaxb-ri/external/rngom/pom.xml +++ b/jaxb-ri/external/rngom/pom.xml @@ -60,16 +60,20 @@ - junit - junit + org.junit.jupiter + junit-jupiter-engine test - xmlunit - xmlunit + org.xmlunit + xmlunit-jakarta-jaxb-impl + test + + + org.xmlunit + xmlunit-assertj3 test - diff --git a/jaxb-ri/external/rngom/src/test/java/com/sun/tools/rngom/digested/DXMLPrinterTest.java b/jaxb-ri/external/rngom/src/test/java/com/sun/tools/rngom/digested/DXMLPrinterTest.java index 8c4e39296..41506d43d 100644 --- a/jaxb-ri/external/rngom/src/test/java/com/sun/tools/rngom/digested/DXMLPrinterTest.java +++ b/jaxb-ri/external/rngom/src/test/java/com/sun/tools/rngom/digested/DXMLPrinterTest.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2004-2011 - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights @@ -21,14 +21,17 @@ */ package com.sun.tools.rngom.digested; -import junit.framework.TestCase; -import org.custommonkey.xmlunit.XMLAssert; +import org.junit.jupiter.api.Test; +import org.xmlunit.assertj3.XmlAssert; import java.io.File; import java.io.FileReader; import java.io.Reader; -public class DXMLPrinterTest extends TestCase { +import static org.junit.jupiter.api.Assertions.fail; + + +public class DXMLPrinterTest { @SuppressWarnings("CallToThreadDumpStack") protected void test(String resource) throws Exception { System.out.println(resource); @@ -40,16 +43,17 @@ protected void test(String resource) throws Exception { in += ".rng"; Reader input = new FileReader(in); Reader output = new FileReader(out); - XMLAssert.assertXMLEqual(input, output); + XmlAssert.assertThat(input).and(output).areSimilar(); input.close(); output.close(); new File(out).delete(); } catch (Exception e) { e.printStackTrace(); - assertTrue("Unexpected exception", false); + fail("Unexpected exception", e); } } + @Test public void testXmlNS() throws Exception { test("xmlns.rng"); } diff --git a/jaxb-ri/jxc/pom.xml b/jaxb-ri/jxc/pom.xml index 2de11bec6..21514ee7d 100644 --- a/jaxb-ri/jxc/pom.xml +++ b/jaxb-ri/jxc/pom.xml @@ -70,8 +70,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-engine test diff --git a/jaxb-ri/jxc/src/test/java/com/sun/tools/jxc/SchemaAntTaskTestBase.java b/jaxb-ri/jxc/src/test/java/com/sun/tools/jxc/SchemaAntTaskTestBase.java index 878907310..b80dc6fea 100644 --- a/jaxb-ri/jxc/src/test/java/com/sun/tools/jxc/SchemaAntTaskTestBase.java +++ b/jaxb-ri/jxc/src/test/java/com/sun/tools/jxc/SchemaAntTaskTestBase.java @@ -10,14 +10,25 @@ package com.sun.tools.jxc; -import junit.framework.TestCase; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; -import java.io.*; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; + +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Yan GAO (gaoyan.gao@oracle.com) */ -public abstract class SchemaAntTaskTestBase extends TestCase { +public abstract class SchemaAntTaskTestBase { protected File projectDir; protected File srcDir; protected File buildDir; @@ -26,28 +37,26 @@ public abstract class SchemaAntTaskTestBase extends TestCase { public abstract String getBuildScript(); - @Override - protected void setUp() throws Exception { - super.setUp(); - projectDir = new File(System.getProperty("java.io.tmpdir"), getClass().getSimpleName() + "-" + getName()); + @BeforeEach + protected void setUp(TestInfo info) throws Exception { + projectDir = new File(System.getProperty("java.io.tmpdir"), getClass().getSimpleName() + "-" + info.getDisplayName()); if (projectDir.exists() && projectDir.isDirectory()) { delDir(projectDir); } srcDir = new File(projectDir, "src"); buildDir = new File(projectDir, "build"); - assertTrue("project dir created", projectDir.mkdirs()); + assertTrue(projectDir.mkdirs(), "project dir created"); script = copy(projectDir, getBuildScript(), SchemaAntTaskTestBase.class.getResourceAsStream("resources/" + getBuildScript())); } - @Override + @AfterEach protected void tearDown() throws Exception { - super.tearDown(); if (tryDelete) { delDir(srcDir); delDir(buildDir); script.delete(); - assertTrue("project dir exists", projectDir.delete()); + assertTrue(projectDir.delete(), "project dir exists"); } } diff --git a/jaxb-ri/jxc/src/test/java/com/sun/tools/jxc/SchemaTaskTest.java b/jaxb-ri/jxc/src/test/java/com/sun/tools/jxc/SchemaTaskTest.java index 48a2c6979..6cd041d2e 100644 --- a/jaxb-ri/jxc/src/test/java/com/sun/tools/jxc/SchemaTaskTest.java +++ b/jaxb-ri/jxc/src/test/java/com/sun/tools/jxc/SchemaTaskTest.java @@ -10,10 +10,17 @@ package com.sun.tools.jxc; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * @author Yan GAO (gaoyan.gao@oracle.com) */ @@ -28,8 +35,9 @@ public String getBuildScript() { } @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + protected void setUp(TestInfo info) throws Exception { + super.setUp(info); pkg = new File(srcDir, "test"); metainf = new File(buildDir, "META-INF"); assertTrue(pkg.mkdirs()); @@ -37,15 +45,18 @@ protected void setUp() throws Exception { } @Override + @AfterEach protected void tearDown() throws Exception { super.tearDown(); } + @Test public void testFork() throws IOException { copy(pkg, "MyTrackingOrder.java", SchemaTaskTest.class.getResourceAsStream("resources/MyTrackingOrder.java_")); assertEquals(0, AntExecutor.exec(script, "schemagen-fork")); } + @Test public void testAddmodules() throws IOException { copy(pkg, "MyTrackingOrder.java", SchemaTaskTest.class.getResourceAsStream("resources/MyTrackingOrder.java_")); assertEquals(0, AntExecutor.exec(script, "schemagen-addmodules")); diff --git a/jaxb-ri/pom.xml b/jaxb-ri/pom.xml index 4904adbc8..882f13ac1 100644 --- a/jaxb-ri/pom.xml +++ b/jaxb-ri/pom.xml @@ -89,7 +89,7 @@ 11 ${maven.compiler.release} - 4.13.2 + 5.11.4 ${project.build.directory}/mods @@ -123,8 +123,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-engine ${junit.version} diff --git a/jaxb-ri/runtime/impl/pom.xml b/jaxb-ri/runtime/impl/pom.xml index 20c972e36..839741144 100644 --- a/jaxb-ri/runtime/impl/pom.xml +++ b/jaxb-ri/runtime/impl/pom.xml @@ -63,8 +63,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-engine test diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/DatatypeConverterImplTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/DatatypeConverterImplTest.java index 480b65c9f..633d8260b 100644 --- a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/DatatypeConverterImplTest.java +++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/DatatypeConverterImplTest.java @@ -10,48 +10,51 @@ package org.glassfish.jaxb.runtime; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DatatypeConverterImplTest { @Test @SuppressWarnings({"deprecation"}) public void testParseBoolean() { - Assert.assertNull(DatatypeConverterImpl._parseBoolean(null)); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("11")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("1A")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("non")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("fals")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("falses")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("false s")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("falst")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("tru")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("trux")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("truu")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("truxx")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("truth")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("truelle")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("truec")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("true c")); - Assert.assertNull(DatatypeConverterImpl._parseBoolean("oui")); + assertNull(DatatypeConverterImpl._parseBoolean(null)); + assertNull(DatatypeConverterImpl._parseBoolean("")); + assertNull(DatatypeConverterImpl._parseBoolean("11")); + assertNull(DatatypeConverterImpl._parseBoolean("1A")); + assertNull(DatatypeConverterImpl._parseBoolean("non")); + assertNull(DatatypeConverterImpl._parseBoolean("fals")); + assertNull(DatatypeConverterImpl._parseBoolean("falses")); + assertNull(DatatypeConverterImpl._parseBoolean("false s")); + assertNull(DatatypeConverterImpl._parseBoolean("falst")); + assertNull(DatatypeConverterImpl._parseBoolean("tru")); + assertNull(DatatypeConverterImpl._parseBoolean("trux")); + assertNull(DatatypeConverterImpl._parseBoolean("truu")); + assertNull(DatatypeConverterImpl._parseBoolean("truxx")); + assertNull(DatatypeConverterImpl._parseBoolean("truth")); + assertNull(DatatypeConverterImpl._parseBoolean("truelle")); + assertNull(DatatypeConverterImpl._parseBoolean("truec")); + assertNull(DatatypeConverterImpl._parseBoolean("true c")); + assertNull(DatatypeConverterImpl._parseBoolean("oui")); - Assert.assertFalse(DatatypeConverterImpl._parseBoolean("0")); - Assert.assertFalse(DatatypeConverterImpl._parseBoolean(" 0")); - Assert.assertFalse(DatatypeConverterImpl._parseBoolean(" 0 ")); - Assert.assertFalse(DatatypeConverterImpl._parseBoolean("0 ")); - Assert.assertTrue(DatatypeConverterImpl._parseBoolean("1")); - Assert.assertTrue(DatatypeConverterImpl._parseBoolean(" 1")); - Assert.assertTrue(DatatypeConverterImpl._parseBoolean(" 1 ")); - Assert.assertTrue(DatatypeConverterImpl._parseBoolean("1 ")); - Assert.assertFalse(DatatypeConverterImpl._parseBoolean("false")); - Assert.assertFalse(DatatypeConverterImpl._parseBoolean(" false")); - Assert.assertFalse(DatatypeConverterImpl._parseBoolean("false ")); - Assert.assertFalse(DatatypeConverterImpl._parseBoolean(" false ")); - Assert.assertTrue(DatatypeConverterImpl._parseBoolean("true")); - Assert.assertTrue(DatatypeConverterImpl._parseBoolean(" true")); - Assert.assertTrue(DatatypeConverterImpl._parseBoolean("true ")); - Assert.assertTrue(DatatypeConverterImpl._parseBoolean(" true ")); + assertFalse(DatatypeConverterImpl._parseBoolean("0")); + assertFalse(DatatypeConverterImpl._parseBoolean(" 0")); + assertFalse(DatatypeConverterImpl._parseBoolean(" 0 ")); + assertFalse(DatatypeConverterImpl._parseBoolean("0 ")); + assertTrue(DatatypeConverterImpl._parseBoolean("1")); + assertTrue(DatatypeConverterImpl._parseBoolean(" 1")); + assertTrue(DatatypeConverterImpl._parseBoolean(" 1 ")); + assertTrue(DatatypeConverterImpl._parseBoolean("1 ")); + assertFalse(DatatypeConverterImpl._parseBoolean("false")); + assertFalse(DatatypeConverterImpl._parseBoolean(" false")); + assertFalse(DatatypeConverterImpl._parseBoolean("false ")); + assertFalse(DatatypeConverterImpl._parseBoolean(" false ")); + assertTrue(DatatypeConverterImpl._parseBoolean("true")); + assertTrue(DatatypeConverterImpl._parseBoolean(" true")); + assertTrue(DatatypeConverterImpl._parseBoolean("true ")); + assertTrue(DatatypeConverterImpl._parseBoolean(" true ")); } } diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/marshaller/XMLWriterTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/marshaller/XMLWriterTest.java index 8bfde83d2..a5fdc5bf4 100644 --- a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/marshaller/XMLWriterTest.java +++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/marshaller/XMLWriterTest.java @@ -12,8 +12,7 @@ import org.glassfish.jaxb.core.marshaller.DumbEscapeHandler; import org.glassfish.jaxb.core.marshaller.XMLWriter; -import junit.framework.TestCase; -import junit.textui.TestRunner; +import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; import org.xml.sax.helpers.AttributesImpl; @@ -21,43 +20,39 @@ import java.io.StringReader; import java.io.StringWriter; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Manual test of XMLWriter. */ -public class XMLWriterTest extends TestCase { - - public XMLWriterTest(String name) { - super(name); - } - - public static void main(String[] args) { - TestRunner.run(XMLWriterTest.class); - } +public class XMLWriterTest { + @Test public void testBasicOps() throws Exception { StringWriter sw = new StringWriter(); XMLWriter w = new XMLWriter(sw, "US-ASCII", DumbEscapeHandler.theInstance ); w.startDocument(); w.startElement("","root","root",new AttributesImpl()); - + w.startPrefixMapping("ns1","aaa"); w.startPrefixMapping("ns2","bbb"); w.startPrefixMapping("ns3","ccc"); - + w.startElement("ccc","child","ns3:child",new AttributesImpl()); w.endElement("ccc","child","ns3:child"); w.endPrefixMapping("ns2"); w.endPrefixMapping("ns1"); - + w.endElement("","root","root"); w.endDocument(); - + checkWellformedness(sw.toString()); } - + // test if the empty tag optimization is happening. - public void testEmptyTag() throws Exception { + @Test + public void testEmptyTag() throws Exception { StringWriter sw = new StringWriter(); XMLWriter w = new XMLWriter(sw, "US-ASCII", DumbEscapeHandler.theInstance ); w.startDocument(); @@ -70,13 +65,13 @@ public void testEmptyTag() throws Exception { w.endDocument(); String body = sw.toString(); - + checkWellformedness(body); // cut XML header body = body.substring(body.indexOf("?>")+2); assertEquals( "", body); - + } /** Checks the well-formedness of XML. */ @@ -84,6 +79,6 @@ private void checkWellformedness(String xml) throws Exception { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); spf.newSAXParser().getXMLReader().parse( - new InputSource(new StringReader(xml))); + new InputSource(new StringReader(xml))); } } diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/unmarshaller/CrLfMarshalUnmarshalTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/unmarshaller/CrLfMarshalUnmarshalTest.java index 571a810d1..e4189c865 100644 --- a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/unmarshaller/CrLfMarshalUnmarshalTest.java +++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/unmarshaller/CrLfMarshalUnmarshalTest.java @@ -19,9 +19,8 @@ import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlType; -import org.junit.Assert; -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 javax.xml.parsers.DocumentBuilder; @@ -34,6 +33,8 @@ import java.io.StringReader; import java.io.StringWriter; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class CrLfMarshalUnmarshalTest { private static final String VALUE = "abc\r\nd\re\nf"; @@ -41,7 +42,7 @@ public class CrLfMarshalUnmarshalTest { private Marshaller fMarshaller; private Unmarshaller fUnmarshaller; - @Before + @BeforeEach public void setUp() throws Exception { JAXBContext ctx = JAXBContext.newInstance(Bean.class); fMarshaller = ctx.createMarshaller(); @@ -59,8 +60,8 @@ public void testWriter() throws Exception { String resultXml = sw.toString(); System.out.println(resultXml); Bean resultElem = (Bean) fUnmarshaller.unmarshal(new StringReader(resultXml)); - Assert.assertEquals(VALUE, resultElem.getAttributeString()); - Assert.assertEquals(VALUE, resultElem.getElementString()); + assertEquals(VALUE, resultElem.getAttributeString()); + assertEquals(VALUE, resultElem.getElementString()); } @Test @@ -77,8 +78,8 @@ public void testDomAndTransform() throws Exception { String resultXml = sw.toString(); System.out.println(resultXml); Bean resultElem = (Bean) fUnmarshaller.unmarshal(new StringReader(resultXml)); - Assert.assertEquals(VALUE, resultElem.getAttributeString()); - Assert.assertEquals(VALUE, resultElem.getElementString()); + assertEquals(VALUE, resultElem.getAttributeString()); + assertEquals(VALUE, resultElem.getElementString()); } @XmlAccessorType(XmlAccessType.FIELD) diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/unmarshaller/UnmarshallingXmlAnyElementMixedWithWhitespacesTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/unmarshaller/UnmarshallingXmlAnyElementMixedWithWhitespacesTest.java index 34fb0119e..968a03f61 100644 --- a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/unmarshaller/UnmarshallingXmlAnyElementMixedWithWhitespacesTest.java +++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/unmarshaller/UnmarshallingXmlAnyElementMixedWithWhitespacesTest.java @@ -25,8 +25,8 @@ import jakarta.xml.bind.annotation.XmlMixed; import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlValue; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.w3c.dom.Element; import javax.xml.transform.stream.StreamSource; @@ -36,8 +36,8 @@ import java.nio.charset.StandardCharsets; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; public class UnmarshallingXmlAnyElementMixedWithWhitespacesTest { @@ -75,7 +75,7 @@ public class UnmarshallingXmlAnyElementMixedWithWhitespacesTest { private static JAXBContext context; - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { context = JAXBContext.newInstance(MixedContent.class); } @@ -126,8 +126,8 @@ public void shouldParseAndSerializeKeepingWhitespacesOnMixedWithElementRefs() th String actual = serializeObject(element); // then assertEquals(MIXED_CONTENT_EXPECTED, actual); - assertTrue(element.getValue().elements.get(0) instanceof String); - assertTrue(element.getValue().elements.get(1) instanceof Document); + assertInstanceOf(String.class, element.getValue().elements.get(0)); + assertInstanceOf(Document.class, element.getValue().elements.get(1)); } private String serializeObject(JAXBElement element) throws JAXBException { diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/BackupWithParentNamespaceTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/BackupWithParentNamespaceTest.java index 4551f83da..12a21e5e0 100644 --- a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/BackupWithParentNamespaceTest.java +++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/BackupWithParentNamespaceTest.java @@ -10,20 +10,21 @@ package org.glassfish.jaxb.runtime.v2; -import java.io.StringReader; -import java.util.HashMap; -import java.util.Map; - import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlType; - import org.glassfish.jaxb.runtime.api.JAXBRIContext; +import org.junit.jupiter.api.Test; + +import java.io.StringReader; +import java.util.HashMap; +import java.util.Map; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; -public class BackupWithParentNamespaceTest extends TestCase { +public class BackupWithParentNamespaceTest { @XmlRootElement(name = "root", namespace = "http://example.org") static class Root { @@ -34,7 +35,7 @@ static class Root { @XmlType(namespace = "http://example.org") static class Nested { @XmlElement(namespace = "http://example.org") - String bar; + String bar; } // bug#25092248/21667799/JAXB-867: lookup loader by parent namespace also @@ -44,15 +45,16 @@ static class Nested { // by SPEC unmarshaller should fail, but due to JAXB-867 there were few releases (from 2.2.5 to 2.3 (not including) // that handled it gracefully, so some clients rely on this behavior and need support for this further on // this is fullfilled with org.glassfish.jaxb.backupWithParentNamespace system property + @Test public void test1() throws Exception { Map properties = new HashMap<>(); properties.put(JAXBRIContext.BACKUP_WITH_PARENT_NAMESPACE, Boolean.TRUE); JAXBContext c = JAXBContext.newInstance(new Class[] {Root.class}, properties); Root root = (Root) c.createUnmarshaller().unmarshal(new StringReader("bar")); - assertNotNull("root", root); + assertNotNull(root, "root"); Nested foo = root.foo; - assertNotNull("foo", foo); + assertNotNull(foo, "foo"); assertEquals("bar", foo.bar); } } diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/CompositeStructureTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/CompositeStructureTest.java index 9702b8ae5..2fe71d51d 100644 --- a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/CompositeStructureTest.java +++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/CompositeStructureTest.java @@ -10,29 +10,30 @@ package org.glassfish.jaxb.runtime.v2; -import java.util.Arrays; -import java.io.StringWriter; -import java.util.Collections; - import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.annotation.adapters.HexBinaryAdapter; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import javax.xml.namespace.QName; - import org.glassfish.jaxb.runtime.api.Bridge; import org.glassfish.jaxb.runtime.api.CompositeStructure; import org.glassfish.jaxb.runtime.api.JAXBRIContext; import org.glassfish.jaxb.runtime.api.TypeReference; +import org.junit.jupiter.api.Test; + +import javax.xml.namespace.QName; +import java.io.StringWriter; +import java.util.Arrays; +import java.util.Collections; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Kohsuke Kawaguchi */ -public class CompositeStructureTest extends TestCase { +public class CompositeStructureTest { // this annotation is just so that we can pass it to tr4. @XmlJavaTypeAdapter(HexBinaryAdapter.class) + @Test public void test1() throws Exception { TypeReference tr1 = new TypeReference(new QName("","foo"),String.class); TypeReference tr2 = new TypeReference(new QName("","bar"),int.class); diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/runtime/InheritanceTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/runtime/InheritanceTest.java index b9f436395..dd79346e0 100644 --- a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/runtime/InheritanceTest.java +++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/runtime/InheritanceTest.java @@ -10,11 +10,13 @@ package org.glassfish.jaxb.runtime.v2.runtime; -import java.io.StringWriter; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.Marshaller; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import java.io.StringWriter; + +import static org.junit.jupiter.api.Assertions.assertFalse; public class InheritanceTest { @@ -28,6 +30,6 @@ public void aTest() throws Throwable { StringWriter stringWriter = new StringWriter(); marshaller.marshal(child, stringWriter); String xmlAsString = stringWriter.toString(); - Assert.assertFalse(xmlAsString.contains("parent")); + assertFalse(xmlAsString.contains("parent")); } } diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/ConstTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/ConstTest.java index 0d88e33b6..c79ca4a0f 100644 --- a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/ConstTest.java +++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/runtime/reflect/opt/ConstTest.java @@ -10,17 +10,20 @@ package org.glassfish.jaxb.runtime.v2.runtime.reflect.opt; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -public class ConstTest extends TestCase { +import static org.junit.jupiter.api.Assertions.assertTrue; +public class ConstTest { + + @Test public void testFieldsFinal() { for(Field f : Const.class.getDeclaredFields()) { if (!f.isSynthetic()){ - assertTrue("Field [" +f.getName()+ "] must be final!", Modifier.isFinal(f.getModifiers())); + assertTrue(Modifier.isFinal(f.getModifiers()), "Field [" +f.getName()+ "] must be final!"); } } } diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/schemagen/MarshallingAbstractTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/schemagen/MarshallingAbstractTest.java index b46d2fde4..fca63770d 100644 --- a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/schemagen/MarshallingAbstractTest.java +++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/schemagen/MarshallingAbstractTest.java @@ -10,12 +10,10 @@ package org.glassfish.jaxb.runtime.v2.schemagen; -import org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.JaxbContainer; -import org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.JaxbDistribution; -import org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.JaxbEnvironmentModel; -import org.junit.Assert; -import org.junit.Test; - +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.Marshaller; +import jakarta.xml.bind.Unmarshaller; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlElement; @@ -24,30 +22,27 @@ import jakarta.xml.bind.annotation.XmlSeeAlso; import jakarta.xml.bind.annotation.XmlType; import jakarta.xml.bind.annotation.XmlValue; +import org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.JaxbConcreteContainer; +import org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.JaxbConcreteDeployment; +import org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.JaxbContainer; +import org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.JaxbDistribution; +import org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.JaxbEnvironmentModel; +import org.junit.jupiter.api.Test; + import javax.xml.XMLConstants; -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.JAXBElement; -import jakarta.xml.bind.Marshaller; -import jakarta.xml.bind.Unmarshaller; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; - -import org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.JaxbConcreteContainer; -import org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.JaxbConcreteDeployment; - import java.io.StringReader; import java.io.StringWriter; import java.util.ArrayList; import java.util.Collection; -import junit.framework.TestCase; -import junit.textui.TestRunner; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; -public class MarshallingAbstractTest extends TestCase { - public static void main(String[] args) { - TestRunner.run(MarshallingAbstractTest.class); - } +public class MarshallingAbstractTest { @XmlSeeAlso({B.class, C.class}) abstract static class A { @@ -100,7 +95,7 @@ public void testMarshalSingleElement() throws Exception { + " B1\n" + " C1\n" + "\n"; - Assert.assertEquals(resultWriter.toString(), expectedXml1); + assertEquals(expectedXml1, resultWriter.toString()); } @Test @@ -123,7 +118,7 @@ public void testMarshalCollection() throws Exception { + " C1\n" + "\n"; marshaller.marshal(mapping, resultWriter); - Assert.assertEquals(resultWriter.toString(), expectedXml2); + assertEquals(expectedXml2, resultWriter.toString()); } @Test @@ -136,9 +131,9 @@ public void testUnmarshalSingleElement() throws Exception { + " C1\n" + "\n"; JAXBElement element = unmarshaller.unmarshal(new StreamSource(new StringReader(sourceXml1)), Mapping.class); - Assert.assertNotNull(element.getValue()); - Assert.assertEquals(B.class, element.getValue().element1.getClass()); - Assert.assertEquals(C.class, element.getValue().element2.getClass()); + assertNotNull(element.getValue()); + assertEquals(B.class, element.getValue().element1.getClass()); + assertEquals(C.class, element.getValue().element2.getClass()); } @Test @@ -157,10 +152,10 @@ public void testUnmarshalCollection() throws Exception { try { JAXBElement element = unmarshaller.unmarshal(new StreamSource(new StringReader(sourceXml2)), Mapping.class); - Assert.assertEquals(2, element.getValue().list.size()); + assertEquals(2, element.getValue().list.size()); } catch (Throwable e) { - Assert.fail(); + fail(); } } @@ -265,7 +260,7 @@ public void testXmlIDRefMarshal() throws Exception { " \n" + "\n"; - Assert.assertEquals(resultWriter.toString(), expectedXml); + assertEquals(expectedXml, resultWriter.toString()); } } diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/schemagen/XmlSchemaGeneratorTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/schemagen/XmlSchemaGeneratorTest.java index 74bdf2a85..955a627bb 100644 --- a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/schemagen/XmlSchemaGeneratorTest.java +++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/schemagen/XmlSchemaGeneratorTest.java @@ -10,6 +10,13 @@ package org.glassfish.jaxb.runtime.v2.schemagen; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.MarshalException; +import jakarta.xml.bind.SchemaOutputResolver; +import org.junit.jupiter.api.Test; + +import javax.xml.transform.Result; +import javax.xml.transform.stream.StreamResult; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -22,20 +29,13 @@ import java.util.HashMap; import java.util.Map; -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.SchemaOutputResolver; -import jakarta.xml.bind.MarshalException; -import javax.xml.transform.Result; -import javax.xml.transform.stream.StreamResult; - -import junit.framework.TestCase; -import junit.textui.TestRunner; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; -public class XmlSchemaGeneratorTest extends TestCase { - public static void main(String[] args) { - TestRunner.run(XmlSchemaGeneratorTest.class); - } +public class XmlSchemaGeneratorTest { + @Test public void testStackoverflow() throws Exception { Map properties = new HashMap<>(); JAXBContext c = JAXBContext.newInstance(new Class[] {Foo.class}, properties); @@ -50,6 +50,7 @@ public void testStackoverflow() throws Exception { } } + @Test public void test2() throws Exception { try { JAXBContext context = JAXBContext.newInstance(NSParent.class); @@ -77,6 +78,7 @@ private static boolean checkNamespaces() throws Exception { return false; } + @Test public void test1() throws Exception { String[] uris = { "http://foo.org/a/b/c", "http://bar.org/d/e/f", "http://foo.org/a/b/c", "true", diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/util/CollisionCheckStackTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/util/CollisionCheckStackTest.java index 9ab92f5e9..5a8628423 100644 --- a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/util/CollisionCheckStackTest.java +++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/util/CollisionCheckStackTest.java @@ -10,12 +10,16 @@ package org.glassfish.jaxb.runtime.v2.util; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Kohsuke Kawaguchi */ -public class CollisionCheckStackTest extends TestCase { +public class CollisionCheckStackTest { + @Test public void test1() { CollisionCheckStack s = new CollisionCheckStack<>(); assertFalse(s.push("foo")); @@ -31,6 +35,7 @@ public void test1() { /** * Tests the reallocation and reset. */ + @Test public void test2() { CollisionCheckStack s = new CollisionCheckStack<>(); diff --git a/jaxb-ri/tools/osgi_tests/parent/src/main/java/jaxb/osgi_test/JaxbOsgiTest.java b/jaxb-ri/tools/osgi_tests/parent/src/main/java/jaxb/osgi_test/JaxbOsgiTest.java index 5921dc07c..f38d6746a 100644 --- a/jaxb-ri/tools/osgi_tests/parent/src/main/java/jaxb/osgi_test/JaxbOsgiTest.java +++ b/jaxb-ri/tools/osgi_tests/parent/src/main/java/jaxb/osgi_test/JaxbOsgiTest.java @@ -24,7 +24,7 @@ public abstract class JaxbOsgiTest extends OSGiTestCase { protected void checkBundle(Bundle bundle) { - assertEquals("Bundle " + bundle.getSymbolicName() + " isn't active", bundle.getState(), Bundle.ACTIVE); + assertEquals("Bundle " + bundle.getSymbolicName() + " isn't active", Bundle.ACTIVE, bundle.getState()); } protected void checkClassInBundle(String className, Bundle bundle) { diff --git a/jaxb-ri/xjc/pom.xml b/jaxb-ri/xjc/pom.xml index 608335837..62999c699 100644 --- a/jaxb-ri/xjc/pom.xml +++ b/jaxb-ri/xjc/pom.xml @@ -53,8 +53,8 @@ jaxb-core - junit - junit + org.junit.jupiter + junit-jupiter-engine test diff --git a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/CodeGenTest.java b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/CodeGenTest.java index dfd2341f1..96f5a185f 100644 --- a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/CodeGenTest.java +++ b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/CodeGenTest.java @@ -22,6 +22,8 @@ import com.sun.tools.xjc.api.SchemaCompiler; import com.sun.tools.xjc.api.XJC; import com.sun.tools.xjc.util.Util; +import org.junit.jupiter.api.Test; +import org.xml.sax.InputSource; import java.io.ByteArrayOutputStream; import java.io.File; @@ -36,20 +38,21 @@ import java.nio.charset.StandardCharsets; import java.util.Iterator; -import junit.framework.TestCase; -import org.junit.Assert; -import org.xml.sax.InputSource; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test code generated by the {@link SchemaCompiler}. * * @author lukas */ -public class CodeGenTest extends TestCase { +public class CodeGenTest { // See com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl protected static final String XML_API_TEST = "xjc-api.test"; + @Test public void testGh1460_Gh1064() throws Throwable { SchemaCompiler sc = XJC.createSchemaCompiler(); sc.forcePackageName("ghbugs.b1460"); @@ -62,15 +65,16 @@ public void testGh1460_Gh1064() throws Throwable { // wrong initialization of multi-dim array // https://github.com/eclipse-ee4j/jaxb-ri/issues/1460 - assertTrue(method, method.contains("new byte[len][]")); + assertTrue(method.contains("new byte[len][]"), method); // null check in setter // https://github.com/eclipse-ee4j/jaxb-ri/issues/1064 - assertTrue(method, method.contains("if (values == null) {")); - assertTrue(method, method.contains("this.binaryAttr = null;")); - assertTrue(method, method.contains("return ;")); + assertTrue(method.contains("if (values == null) {"), method); + assertTrue(method.contains("this.binaryAttr = null;"), method); + assertTrue(method.contains("return ;"), method); } + @Test public void testGh1460_Gh1064_jaxb21() throws Throwable { SchemaCompiler sc = XJC.createSchemaCompiler(); sc.setErrorListener(new ConsoleErrorReporter()); @@ -84,13 +88,13 @@ public void testGh1460_Gh1064_jaxb21() throws Throwable { // wrong initialization of multi-dim array // https://github.com/eclipse-ee4j/jaxb-ri/issues/1460 - assertTrue(method, method.contains("new byte[len][]")); + assertTrue(method.contains("new byte[len][]"), method); // null check in setter // https://github.com/eclipse-ee4j/jaxb-ri/issues/1064 - assertTrue(method, method.contains("if (values == null) {")); - assertTrue(method, method.contains("this.binaryAttr = null;")); - assertTrue(method, method.contains("return ;")); + assertTrue(method.contains("if (values == null) {"), method); + assertTrue(method.contains("this.binaryAttr = null;"), method); + assertTrue(method.contains("return ;"), method); } /** @@ -102,6 +106,7 @@ public void testGh1460_Gh1064_jaxb21() throws Throwable { * @see Issue #1748 * @see Issue #1750 */ + @Test public void testIssue1750() throws FileNotFoundException, URISyntaxException { String schemaFileName = "/schemas/issue1750/schema.xsd"; String packageName = "org.example.issue1750"; @@ -119,11 +124,11 @@ public void testIssue1750() throws FileNotFoundException, URISyntaxException { ErrorListener errorListener = new ConsoleErrorReporter(); JCodeModel cm = model.generateCode(extensions, errorListener); JDefinedClass dc = cm._getClass(someClassName); - assertNotNull(someClassName, dc); + assertNotNull(dc, someClassName); // Assert serialVersionUID - assertTrue(suidFieldName, dc.fields().containsKey(suidFieldName)); - assertNotNull(suidFieldName + " value", dc.fields().get(suidFieldName)); + assertTrue(dc.fields().containsKey(suidFieldName), suidFieldName); + assertNotNull(dc.fields().get(suidFieldName), suidFieldName + " value"); // Assert Class includes narrow type Iterator conIter = dc.constructors(); @@ -141,6 +146,7 @@ public void testIssue1750() throws FileNotFoundException, URISyntaxException { * * @see Issue #1785 */ + @Test public void testIssue1785() throws FileNotFoundException, URISyntaxException, IOException { String schemaFileName = "/schemas/issue1785/document.xsd"; String packageName = "org.example.issue1785"; @@ -161,11 +167,11 @@ public void testIssue1785() throws FileNotFoundException, URISyntaxException, IO // Assert Document class is modeled. JDefinedClass dc = cm._getClass(documentName); - assertNotNull(documentName, dc); + assertNotNull(dc, documentName); // Assert serialVersionUID - assertTrue(suidFieldName, dc.fields().containsKey(suidFieldName)); - assertNotNull(suidFieldName + " value", dc.fields().get(suidFieldName)); + assertTrue(dc.fields().containsKey(suidFieldName), suidFieldName); + assertNotNull(dc.fields().get(suidFieldName), suidFieldName + " value"); // Generate the Document classes to a directory, for review. if ( Util.getSystemProperty(XML_API_TEST) != null ) { @@ -210,7 +216,7 @@ private void assertNonEmptyJavadocBlocks(String cmString) throws IOException { int javadocLen = javadocBlock.toString().trim().length(); // Assert current javadoc block length is not zero! - Assert.assertNotEquals("Empty javadoc at " + lineNo, 0, javadocLen); + assertNotEquals(0, javadocLen, "Empty javadoc at " + lineNo); javadocBlock = null; } else diff --git a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/OptionsJUTest.java b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/OptionsJUTest.java index 240c55b86..7784abd07 100644 --- a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/OptionsJUTest.java +++ b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/OptionsJUTest.java @@ -15,7 +15,9 @@ import com.sun.codemodel.JDefinedClass; import com.sun.codemodel.JMod; import com.sun.istack.tools.DefaultAuthenticator; -import junit.framework.TestCase; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.FileInputStream; @@ -26,32 +28,32 @@ import java.util.logging.Level; import java.util.logging.Logger; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * * @author Lukas Jungmann */ -public class OptionsJUTest extends TestCase { +public class OptionsJUTest { private Options o; - public OptionsJUTest(String testName) { - super(testName); - } - - @Override + @BeforeEach protected void setUp() throws Exception { - super.setUp(); o = new Options(); o.targetDir = new File(System.getProperty("java.io.tmpdir"), "jxc_optionsTest"); o.targetDir.mkdirs(); } - @Override + @AfterEach protected void tearDown() throws Exception { - super.tearDown(); delDirs(o.targetDir); } + @Test public void testCreateCodeWriter() throws JClassAlreadyExistsException, IOException { Locale locale = Locale.getDefault(); try { @@ -76,7 +78,7 @@ public void testCreateCodeWriter() throws JClassAlreadyExistsException, IOExcept System.out.println("==="); System.out.println(inStr); System.out.println("==="); - assertTrue("Got: '" + inStr + "'", inStr.contains("// This f")); + assertTrue(inStr.contains("// This f"), "Got: '" + inStr + "'"); //test UTF-16 o.noFileHeader = true; @@ -89,7 +91,7 @@ public void testCreateCodeWriter() throws JClassAlreadyExistsException, IOExcept fis.close(); cls.delete(); inStr = new String(in, StandardCharsets.UTF_16); - assertTrue("Got: '" + inStr + "'", inStr.contains("package t")); + assertTrue(inStr.contains("package t"), "Got: '" + inStr + "'"); //test default encoding o.noFileHeader = false; @@ -103,12 +105,13 @@ public void testCreateCodeWriter() throws JClassAlreadyExistsException, IOExcept fis.close(); cls.delete(); inStr = new String(in, Charset.defaultCharset().name()); - assertTrue("Got: '" + inStr + "'", inStr.contains("// This f")); + assertTrue(inStr.contains("// This f"), "Got: '" + inStr + "'"); } finally { Locale.setDefault(locale); } } + @Test public void testProxySettings() throws Exception { Options opts = new Options(); File grammar = File.createTempFile("jaxbproxytest", "xsd"); diff --git a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/XjcAntTaskTestBase.java b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/XjcAntTaskTestBase.java index 93fd1085a..21c773600 100644 --- a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/XjcAntTaskTestBase.java +++ b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/XjcAntTaskTestBase.java @@ -10,15 +10,28 @@ package com.sun.tools.xjc; -import junit.framework.TestCase; -import java.io.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; + +import static org.junit.jupiter.api.Assertions.assertTrue; /** * * @author Yan GAO. * All rights reserved. */ -public abstract class XjcAntTaskTestBase extends TestCase { +public abstract class XjcAntTaskTestBase { protected File projectDir; protected File srcDir; protected File buildDir; @@ -27,26 +40,24 @@ public abstract class XjcAntTaskTestBase extends TestCase { public abstract String getBuildScript(); - @Override - protected void setUp() throws Exception { - super.setUp(); - projectDir = new File(System.getProperty("java.io.tmpdir"), getClass().getSimpleName() + "-" + getName()); + @BeforeEach + protected void setUp(TestInfo info) throws Exception { + projectDir = new File(System.getProperty("java.io.tmpdir"), getClass().getSimpleName() + "-" + info.getDisplayName()); if (projectDir.exists() && projectDir.isDirectory()) { OptionsJUTest.delDirs(projectDir); } srcDir = new File(projectDir, "src"); buildDir = new File(projectDir, "build"); - assertTrue("project dir created", projectDir.mkdirs()); + assertTrue(projectDir.mkdirs(), "project dir created"); script = copy(projectDir, getBuildScript(), XjcAntTaskTestBase.class.getResourceAsStream("resources/" + getBuildScript())); } - @Override + @AfterEach protected void tearDown() throws Exception { - super.tearDown(); if (tryDelete) { OptionsJUTest.delDirs(srcDir, buildDir); script.delete(); - assertTrue("project dir exists", projectDir.delete()); + assertTrue(projectDir.delete(), "project dir exists"); } } diff --git a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/XjcDtdPluginTest.java b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/XjcDtdPluginTest.java index e98d73d8b..ed1fad628 100644 --- a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/XjcDtdPluginTest.java +++ b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/XjcDtdPluginTest.java @@ -15,8 +15,7 @@ import com.sun.tools.xjc.model.Model; import com.sun.tools.xjc.outline.Outline; import com.sun.tools.xjc.util.ErrorReceiverFilter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -24,6 +23,8 @@ import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class XjcDtdPluginTest { @Test public void testCallPostProcessModelOnPlugin() { @@ -76,9 +77,9 @@ public void postProcessModel(Model model, ErrorHandler errorHandler) { new ErrorReceiverFilter() ); - Assert.assertTrue( - "DTD model did not call postProcessModel hook of the plugin", - wasPostProcessModelHookCalled[0] - ); + assertTrue( + wasPostProcessModelHookCalled[0], + "DTD model did not call postProcessModel hook of the plugin" + ); } } diff --git a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/XjcTaskTest.java b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/XjcTaskTest.java index da5c69ee1..e5e71e90b 100644 --- a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/XjcTaskTest.java +++ b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/XjcTaskTest.java @@ -10,10 +10,18 @@ package com.sun.tools.xjc; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * @author Yan GAO (gaoyan.gao@oracle.com) */ @@ -27,9 +35,10 @@ public String getBuildScript() { return "xjc.xml"; } + @BeforeEach @Override - protected void setUp() throws Exception { - super.setUp(); + protected void setUp(TestInfo info) throws Exception { + super.setUp(info); pkg = new File(srcDir, "test"); metainf = new File(buildDir, "META-INF"); schema = copy(projectDir, "simple.xsd", XjcTaskTest.class.getResourceAsStream("resources/simple.xsd")); @@ -37,6 +46,7 @@ protected void setUp() throws Exception { assertTrue(metainf.mkdirs()); } + @AfterEach @Override protected void tearDown() throws Exception { if (tryDelete) { @@ -45,16 +55,19 @@ protected void tearDown() throws Exception { super.tearDown(); } + @Test public void testFork() throws FileNotFoundException, IOException { if (is9()){ assertEquals(0, AntExecutor.exec(script, "xjc-fork")); } } + @Test public void testWithoutFork() throws IOException { assertEquals(0, AntExecutor.exec(script, "xjc-no-fork")); } + @Test public void testAddmodules() throws IOException { if (is9()){ assertEquals(0, AntExecutor.exec(script, "xjc-addmodules")); diff --git a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/reader/RingJUTest.java b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/reader/RingJUTest.java index c63635c14..825d4f75d 100644 --- a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/reader/RingJUTest.java +++ b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/reader/RingJUTest.java @@ -14,19 +14,17 @@ */ package com.sun.tools.xjc.reader; -import junit.framework.TestCase; -import junit.textui.TestRunner; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNull; /** * * @author snajper */ -public class RingJUTest extends TestCase { - - public static void main(String[] args) { - TestRunner.run(RingJUTest.class); - } +public class RingJUTest { + @Test public void test1() throws InterruptedException { Ring r = Ring.get(); assertNull(r); @@ -39,5 +37,5 @@ public void test1() throws InterruptedException { r = Ring.get(); assertNull(r); } - + } diff --git a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/reader/TypeUtilJUTest.java b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/reader/TypeUtilJUTest.java index 03ef10125..84d909ce6 100644 --- a/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/reader/TypeUtilJUTest.java +++ b/jaxb-ri/xjc/src/test/java/com/sun/tools/xjc/reader/TypeUtilJUTest.java @@ -10,22 +10,20 @@ package com.sun.tools.xjc.reader; -import java.util.List; - import com.sun.codemodel.JCodeModel; import com.sun.codemodel.JType; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; -import junit.textui.TestRunner; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Kohsuke Kawaguchi */ -public class TypeUtilJUTest extends TestCase { - public static void main(String[] args) { - TestRunner.run(TypeUtilJUTest.class); - } +public class TypeUtilJUTest { + @Test public void test1() { JCodeModel cm = new JCodeModel(); JType t = TypeUtil.getCommonBaseType(cm, diff --git a/jaxb-ri/xsom/pom.xml b/jaxb-ri/xsom/pom.xml index 0bee81d69..72aa8321d 100644 --- a/jaxb-ri/xsom/pom.xml +++ b/jaxb-ri/xsom/pom.xml @@ -71,7 +71,7 @@ ${maven.compiler.release} ${project.version} - 4.13.2 + 5.11.4 -Xlint:all,-rawtypes,-unchecked @@ -92,8 +92,8 @@ ${relaxng.version} - junit - junit + org.junit.jupiter + junit-jupiter-engine ${junit.version} test diff --git a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/AbstractXSOMTest.java b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/AbstractXSOMTest.java index 1b5bfe5fa..eae881d1c 100644 --- a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/AbstractXSOMTest.java +++ b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/AbstractXSOMTest.java @@ -10,16 +10,15 @@ * SPDX-License-Identifier: BSD-3-Clause */ -import com.sun.xml.xsom.parser.XmlFactory; -import junit.framework.TestCase; import com.sun.xml.xsom.XSSchemaSet; import com.sun.xml.xsom.parser.XSOMParser; +import com.sun.xml.xsom.parser.XmlFactory; import org.xml.sax.SAXException; /** * @author Kohsuke Kawaguchi */ -public abstract class AbstractXSOMTest extends TestCase { +public abstract class AbstractXSOMTest { /** * Loads a schema set from XSDs in the resource. */ diff --git a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/SCDTest.java b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/SCDTest.java index 6d0708dd7..0e9ee0978 100644 --- a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/SCDTest.java +++ b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/SCDTest.java @@ -10,11 +10,14 @@ * SPDX-License-Identifier: BSD-3-Clause */ -import com.sun.xml.xsom.XSSchemaSet; import com.sun.xml.xsom.XSComponent; +import com.sun.xml.xsom.XSSchemaSet; +import org.junit.jupiter.api.Test; import java.util.Collection; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * @author Kohsuke Kawaguchi */ @@ -22,6 +25,7 @@ public class SCDTest extends AbstractXSOMTest { /** * Taken from spec examples in section 4.2.16 */ + @Test public void testSpec() throws Exception { XSSchemaSet s = load("scdtest.xsd"); diff --git a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/XSOMParserTest.java b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/XSOMParserTest.java index 1b7f1ea0a..be1f31b02 100644 --- a/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/XSOMParserTest.java +++ b/jaxb-ri/xsom/src/test/java/com/sun/xml/xsom/test/XSOMParserTest.java @@ -19,11 +19,12 @@ */ import com.sun.xml.xsom.XSSchemaSet; -import com.sun.xml.xsom.parser.XSOMParser; import com.sun.xml.xsom.parser.SchemaDocument; +import com.sun.xml.xsom.parser.XSOMParser; import com.sun.xml.xsom.parser.XmlFactory; -import junit.framework.*; -import org.junit.Ignore; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; import java.net.URL; @@ -33,17 +34,14 @@ * * @author Farrukh S. Najmi */ -public class XSOMParserTest extends TestCase { +public class XSOMParserTest { private static String docURLStr = "https://docs.oasis-open.org/regrep/v3.0/schema/lcm.xsd"; //private static String docURLStr = "http://ebxmlrr.sourceforge.net/private/sun/irs/ContactMechanism/IRS-ContactMechanismCommonAggregateComponents-1.0.xsd"; private static URL docURL = null; private static XSOMParser instance = null; - public XSOMParserTest(String testName) { - super(testName); - } - + @BeforeEach protected void setUp() throws Exception { if (docURL == null) { docURL = new URL(docURLStr); @@ -52,18 +50,14 @@ protected void setUp() throws Exception { } } + @AfterEach protected void tearDown() throws Exception { } - public static Test suite() { - TestSuite suite = new TestSuite(XSOMParserTest.class); - - return suite; - } - /** * Test of parse method, of class com.sun.xml.xsom.parser.XSOMParser. */ + @Test public void testParse() throws Exception { System.out.println("parse"); @@ -79,6 +73,7 @@ public void testParse() throws Exception { /** * Test of getDocuments method, of class com.sun.xml.xsom.parser.XSOMParser. */ + @Test public void testGetDocuments() { System.out.println("getDocuments"); @@ -100,6 +95,7 @@ public void testGetDocuments() { /** * Test of getResult method, of class com.sun.xml.xsom.parser.XSOMParser. */ + @Test public void testGetResult() throws Exception { System.out.println("getResult");