You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2023/07/05 18:35:30 UTC
[db-jdo] branch main updated: JDO-829: api: Migrate JUnit tests to version 5 (#80)
This is an automated email from the ASF dual-hosted git repository.
mbo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/db-jdo.git
The following commit(s) were added to refs/heads/main by this push:
new 372876a2 JDO-829: api: Migrate JUnit tests to version 5 (#80)
372876a2 is described below
commit 372876a2380f28ec271d2cd9e0efcbb616d8c6d8
Author: Michael Bouschen <mb...@apache.org>
AuthorDate: Wed Jul 5 20:35:26 2023 +0200
JDO-829: api: Migrate JUnit tests to version 5 (#80)
* JDO-829: api: Migrate JUnit tests to version 5
* JDO-829: api: Migrate JUnit tests to version 5
Formatting changes.
* JDO-829: api: Migrate JUnit tests to version 5
Removed code in comments.
---
api/pom.xml | 9 +-
.../test/java/javax/jdo/AbstractJDOConfigTest.java | 8 +-
api/src/test/java/javax/jdo/EnhancerTest.java | 332 ++++++-------
.../test/java/javax/jdo/JDOHelperConfigTest.java | 306 +++++-------
api/src/test/java/javax/jdo/JDOHelperTest.java | 541 ++++++++++-----------
api/src/test/java/javax/jdo/ObjectStateTest.java | 49 +-
api/src/test/java/javax/jdo/PMFMapMapTest.java | 62 +--
.../java/javax/jdo/identity/ByteIdentityTest.java | 123 ++---
.../java/javax/jdo/identity/CharIdentityTest.java | 134 ++---
.../java/javax/jdo/identity/IntIdentityTest.java | 121 ++---
.../java/javax/jdo/identity/LongIdentityTest.java | 125 ++---
.../javax/jdo/identity/ObjectIdentityTest.java | 423 ++++++++--------
.../java/javax/jdo/identity/ShortIdentityTest.java | 121 ++---
.../jdo/identity/SingleFieldIdentityTest.java | 39 +-
.../javax/jdo/identity/StringIdentityTest.java | 76 +--
.../jdo/listener/InstanceLifecycleEventTest.java | 103 ++--
api/src/test/java/javax/jdo/schema/XMLTest.java | 18 +-
.../test/java/javax/jdo/spi/JDOImplHelperTest.java | 189 +++----
.../java/javax/jdo/spi/StateInterrogationTest.java | 222 +++++----
api/src/test/java/javax/jdo/util/AbstractTest.java | 6 +-
.../java/javax/jdo/util/BatchResultPrinter.java | 111 -----
.../test/java/javax/jdo/util/BatchTestRunner.java | 145 ------
parent-pom/pom.xml | 13 +-
23 files changed, 1500 insertions(+), 1776 deletions(-)
diff --git a/api/pom.xml b/api/pom.xml
index ef42e3ca..732ed5b9 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -42,8 +42,13 @@
<artifactId>glassfish-corba-omgapi</artifactId>
</dependency>
<dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java b/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java
index 04cec026..74da20d4 100644
--- a/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java
+++ b/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java
@@ -17,6 +17,8 @@
package javax.jdo;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.net.URL;
import java.util.Enumeration;
import java.util.Map;
@@ -104,15 +106,15 @@ public abstract class AbstractJDOConfigTest extends AbstractTest {
String actualValue = (String) actual.get(key);
assertEquals(
+ expectedValue,
+ actualValue,
"Actual property at key ["
+ key
+ "] with value ["
+ actualValue
+ "] not equal to expected value ["
+ expectedValue
- + "]",
- expectedValue,
- actualValue);
+ + "]");
}
}
diff --git a/api/src/test/java/javax/jdo/EnhancerTest.java b/api/src/test/java/javax/jdo/EnhancerTest.java
index 3cb84e72..2e627276 100644
--- a/api/src/test/java/javax/jdo/EnhancerTest.java
+++ b/api/src/test/java/javax/jdo/EnhancerTest.java
@@ -17,6 +17,10 @@
package javax.jdo;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -27,14 +31,16 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.jdo.util.AbstractTest;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
/**
* Tests class javax.jdo.Enhancer (Enhancer main class).
*
* <p>
*/
-public class EnhancerTest extends AbstractTest {
+class EnhancerTest extends AbstractTest {
/** The path delimiter for constructing classpaths. */
private static final String PATH_DELIMITER = System.getProperty("path.separator");
@@ -42,236 +48,208 @@ public class EnhancerTest extends AbstractTest {
/** The maven basedir identifying the directory of the execution environment. */
private static final String BASEDIR = System.getProperty("basedir");
- /**
- * Main
- *
- * @param args command line arguments
- */
- public static void main(String args[]) {
- BatchTestRunner.run(EnhancerTest.class);
- }
-
- public void testUsageOption() {
- // invoke enhancer with a usage option
- InvocationResult result = invokeEnhancer("?");
- String outputString = result.getOutputString();
- String errorString = result.getErrorString();
- assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
- assertTrue(
- "Expected Usage message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("javax.jdo.Enhancer"));
- }
-
- public void testHelpOption() {
+ @ParameterizedTest
+ @ValueSource(strings = {"?", "-help", "-h"})
+ void testUsageOptions(String option) {
// invoke enhancer with a usage option
- InvocationResult result = invokeEnhancer("-help");
+ InvocationResult result = invokeEnhancer(option);
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
- "Expected Usage message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("javax.jdo.Enhancer"));
+ outputString.contains("javax.jdo.Enhancer"),
+ "Expected Usage message from out:\n" + outputString + " with err:\n" + errorString);
}
- public void testHOption() {
- // invoke enhancer with a usage option
- InvocationResult result = invokeEnhancer("-h");
- String outputString = result.getOutputString();
- String errorString = result.getErrorString();
- assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
- assertTrue(
- "Expected Usage message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("javax.jdo.Enhancer"));
- }
-
- public void testInvalidOption() {
+ @Test
+ void testInvalidOption() {
// invoke enhancer with an invalid option
InvocationResult result = invokeEnhancer("-poo");
- assertEquals("Wrong return value ", Constants.ENHANCER_USAGE_ERROR, result.getExitValue());
+ assertEquals(Constants.ENHANCER_USAGE_ERROR, result.getExitValue(), "Wrong return value ");
String errorString = result.getErrorString();
assertTrue(
- "Expected Usage message from err:\n" + errorString,
- errorString.contains("javax.jdo.Enhancer"));
+ errorString.contains("javax.jdo.Enhancer"),
+ "Expected Usage message from err:\n" + errorString);
}
- public void testProperties() {
+ @Test
+ void testProperties() {
// invoke enhancer with verbose option
InvocationResult result = invokeEnhancer("-v");
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
+ outputString.contains(Constants.PROPERTY_ENHANCER_VENDOR_NAME),
"Expected MockEnhancer vendor message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains(Constants.PROPERTY_ENHANCER_VENDOR_NAME));
+ + errorString);
assertTrue(
+ outputString.contains(Constants.PROPERTY_ENHANCER_VERSION_NUMBER),
"Expected MockEnhancer version message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains(Constants.PROPERTY_ENHANCER_VERSION_NUMBER));
+ + errorString);
assertTrue(
+ outputString.contains("Mock Enhancer"),
"Expected MockEnhancer vendor message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("Mock Enhancer"));
+ + errorString);
assertTrue(
+ outputString.contains("2.3.0"),
"Expected MockEnhancer vendor message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("2.3.0"));
+ + errorString);
assertTrue(
+ outputString.contains("MockKey"),
"Expected MockEnhancer properties message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("MockKey"));
+ + errorString);
}
- public void testVOption() {
+ @ParameterizedTest
+ @ValueSource(strings = {"-v", "-verbose"})
+ void testVerboseOptions(String option) {
// invoke enhancer with verbose option
- InvocationResult result = invokeEnhancer("-v");
+ InvocationResult result = invokeEnhancer(option);
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
- "Expected Enhancer class message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("javax.jdo.MockEnhancer"));
- }
-
- public void testVerboseOption() {
- // invoke enhancer with verbose option
- InvocationResult result = invokeEnhancer("-verbose");
- String outputString = result.getOutputString();
- String errorString = result.getErrorString();
- assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
- assertTrue(
- "Expected Enhancer class message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("javax.jdo.MockEnhancer"));
+ outputString.contains("javax.jdo.MockEnhancer"),
+ "Expected Enhancer class message from out:\n"
+ + outputString
+ + " with err:\n"
+ + errorString);
}
- public void testVerboseClasses() {
+ @Test
+ void testVerboseClasses() {
// invoke enhancer with .class parameter
InvocationResult result = invokeEnhancer("-v some.class");
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
- "Expected class message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("some.class"));
+ outputString.contains("some.class"),
+ "Expected class message from out:\n" + outputString + " with err:\n" + errorString);
assertTrue(
- "Expected number of classes from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("1"));
+ outputString.contains("1"),
+ "Expected number of classes from out:\n" + outputString + " with err:\n" + errorString);
}
- public void testVerboseJars() {
+ @Test
+ void testVerboseJars() {
// invoke enhancer with a .jar parameter
InvocationResult result = invokeEnhancer("-v some.jar");
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
- "Expected jar message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("some.jar"));
+ outputString.contains("some.jar"),
+ "Expected jar message from out:\n" + outputString + " with err:\n" + errorString);
assertTrue(
- "Expected number of jars from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("1"));
+ outputString.contains("1"),
+ "Expected number of jars from out:\n" + outputString + " with err:\n" + errorString);
}
- public void testVerboseJDOs() {
+ @Test
+ void testVerboseJDOs() {
// invoke enhancer with a .jdo parameter
InvocationResult result = invokeEnhancer("-v some.jdo");
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
- "Expected jdo message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("some.jdo"));
+ outputString.contains("some.jdo"),
+ "Expected jdo message from out:\n" + outputString + " with err:\n" + errorString);
assertTrue(
- "Expected number of jdos from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("1"));
+ outputString.contains("1"),
+ "Expected number of jdos from out:\n" + outputString + " with err:\n" + errorString);
}
- public void testVerboseAll() {
+ @Test
+ void testVerboseAll() {
// invoke enhancer with multiple parameters
InvocationResult result = invokeEnhancer("-v some.class some.jar some.jdo");
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
- "Expected jdo message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("some.jdo"));
+ outputString.contains("some.jdo"),
+ "Expected jdo message from out:\n" + outputString + " with err:\n" + errorString);
assertTrue(
- "Expected jar message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("some.jar"));
+ outputString.contains("some.jar"),
+ "Expected jar message from out:\n" + outputString + " with err:\n" + errorString);
assertTrue(
- "Expected class message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("some.class"));
+ outputString.contains("some.class"),
+ "Expected class message from out:\n" + outputString + " with err:\n" + errorString);
assertTrue(
- "Expected number of elements from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("3"));
+ outputString.contains("3"),
+ "Expected number of elements from out:\n" + outputString + " with err:\n" + errorString);
}
- public void testVerboseCheckonlyAll() {
+ @Test
+ void testVerboseCheckonlyAll() {
// invoke enhancer with a checkonly option
InvocationResult result = invokeEnhancer("-v -checkonly some.class some.jar some.jdo");
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
- "Expected jdo message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("some.jdo"));
+ outputString.contains("some.jdo"),
+ "Expected jdo message from out:\n" + outputString + " with err:\n" + errorString);
assertTrue(
- "Expected jar message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("some.jar"));
+ outputString.contains("some.jar"),
+ "Expected jar message from out:\n" + outputString + " with err:\n" + errorString);
assertTrue(
- "Expected class message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("some.class"));
+ outputString.contains("some.class"),
+ "Expected class message from out:\n" + outputString + " with err:\n" + errorString);
assertTrue(
- "Expected number of elements from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("3"));
+ outputString.contains("3"),
+ "Expected number of elements from out:\n" + outputString + " with err:\n" + errorString);
}
- public void testMissingPU() {
+ @Test
+ void testMissingPU() {
// invoke enhancer with missing parameter
InvocationResult result = invokeEnhancer("-v -pu");
- assertEquals("Wrong return value ", 3, result.getExitValue());
+ assertEquals(3, result.getExitValue(), "Wrong return value ");
}
- public void testVerbosePU() {
+ @Test
+ void testVerbosePU() {
// invoke enhancer with a pu parameter
InvocationResult result = invokeEnhancer("-v -pu myPU -pu yourPU");
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
- "Expected pu message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("myPU"));
+ outputString.contains("myPU"),
+ "Expected pu message from out:\n" + outputString + " with err:\n" + errorString);
assertTrue(
- "Expected pu message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("yourPU"));
+ outputString.contains("yourPU"),
+ "Expected pu message from out:\n" + outputString + " with err:\n" + errorString);
assertTrue(
- "Expected number of elements from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("2"));
+ outputString.contains("2"),
+ "Expected number of elements from out:\n" + outputString + " with err:\n" + errorString);
}
- public void testClasspath() {
+ @Test
+ void testClasspath() {
// invoke enhancer with a classpath parameter
// JDOHelper must be loadable from this path
// the File.toURI should append "/" to the path, so only "target/classes" is needed
@@ -279,29 +257,31 @@ public class EnhancerTest extends AbstractTest {
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
- "Expected classpath message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("target/classes"));
+ outputString.contains("target/classes"),
+ "Expected classpath message from out:\n" + outputString + " with err:\n" + errorString);
}
- public void testBadClasspath() {
+ @Test
+ void testBadClasspath() {
// invoke enhancer with a bad classpath parameter
// JDOHelper is not loadable from this path
InvocationResult result = invokeEnhancer("-v -cp target");
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 1, result.getExitValue());
+ 1, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
+ errorString.contains("JDOHelper"),
"Expected classpath error message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- errorString.contains("JDOHelper"));
+ + errorString);
}
- public void testClasspathJar() throws IOException, InterruptedException {
+ @Test
+ void testClasspathJar() throws IOException, InterruptedException {
// invoke enhancer with a classpath parameter
// JDOHelper must be loadable from this path
// create the jar file from the target/classes directory
@@ -314,144 +294,148 @@ public class EnhancerTest extends AbstractTest {
Runtime.getRuntime()
.exec("jar -cf " + enhancerJarPathname + " -C " + BASEDIR + "/target/classes .");
int returnCode = create.waitFor();
- assertEquals("jar command returned wrong return code.", 0, returnCode);
+ assertEquals(0, returnCode, "jar command returned wrong return code.");
// find the jdo.jar in target
InvocationResult result = invokeEnhancer("-v -cp " + enhancerJar);
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
- "Expected classpath message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains(enhancerJar));
+ outputString.contains(enhancerJar),
+ "Expected classpath message from out:\n" + outputString + " with err:\n" + errorString);
}
- public void testOutputDirectory() {
+ @Test
+ void testOutputDirectory() {
// invoke enhancer with an output directory parameter
InvocationResult result = invokeEnhancer("-v -d some/output/directory");
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
- "Expected directory message from out:\n" + outputString + " with err:\n" + errorString,
- outputString.contains("some/output/directory"));
+ outputString.contains("some/output/directory"),
+ "Expected directory message from out:\n" + outputString + " with err:\n" + errorString);
}
- public void testMissingOutputDirectory() {
+ @Test
+ void testMissingOutputDirectory() {
// invoke enhancer with missing parameter
InvocationResult result = invokeEnhancer("-v -d");
- assertEquals("Wrong return value ", 3, result.getExitValue());
+ assertEquals(3, result.getExitValue(), "Wrong return value ");
}
- public void testDir() {
+ @Test
+ void testDir() {
// invoke enhancer with directory and not recurse
InvocationResult result =
invokeEnhancer("-v " + BASEDIR + "/target/test-classes/enhancer-test-dir");
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
+ outputString.contains("enhancer-test-dir"),
"Expected directory enhancer-test-dir in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("enhancer-test-dir"));
+ + errorString);
assertTrue(
+ outputString.contains("file1.jdo"),
"Expected file file1.jdo in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("file1.jdo"));
+ + errorString);
assertTrue(
+ outputString.contains("file2.class"),
"Expected file file2.class in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("file2.class"));
+ + errorString);
assertTrue(
+ outputString.contains("file3.jar"),
"Expected file file3.jar in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("file3.jar"));
+ + errorString);
assertFalse(
+ outputString.contains("enhancer-test-subdir"),
"Expected no directory enhancer-test-subdir in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("enhancer-test-subdir"));
+ + errorString);
assertTrue(
+ outputString.contains("3"),
"Expected 3 files to be enhanced in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("3"));
+ + errorString);
}
- public void testDirRecurse() {
+ @Test
+ void testDirRecurse() {
// invoke enhancer with directory and recurse
InvocationResult result =
invokeEnhancer("-v -r " + BASEDIR + "/target/test-classes/enhancer-test-dir");
String outputString = result.getOutputString();
String errorString = result.getErrorString();
assertEquals(
- "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+ 0, result.getExitValue(), "Wrong exit code from Enhancer with stderr:\n" + errorString);
assertTrue(
+ outputString.contains("enhancer-test-dir"),
"Expected directory enhancer-test-dir in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("enhancer-test-dir"));
+ + errorString);
assertTrue(
+ outputString.contains("enhancer-test-subdir"),
"Expected directory enhancer-test-subdir in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("enhancer-test-subdir"));
+ + errorString);
assertTrue(
+ outputString.contains("file1.jdo"),
"Expected file file1.jdo in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("file1.jdo"));
+ + errorString);
assertTrue(
+ outputString.contains("file2.class"),
"Expected file file2.class in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("file2.class"));
+ + errorString);
assertTrue(
+ outputString.contains("file3.jar"),
"Expected file file3.jar in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("file3.jar"));
+ + errorString);
assertTrue(
+ outputString.contains("file4.jdo"),
"Expected file file4.jdo in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("file4.jdo"));
+ + errorString);
assertTrue(
+ outputString.contains("file5.class"),
"Expected file file5.class in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("file5.class"));
+ + errorString);
assertTrue(
+ outputString.contains("file6.jar"),
"Expected file file6.jar in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("file6.jar"));
+ + errorString);
assertTrue(
+ outputString.contains("6"),
"Expected 6 files to be enhanced in message from out:\n"
+ outputString
+ " with err:\n"
- + errorString,
- outputString.contains("6"));
+ + errorString);
}
private InvocationResult invokeEnhancer(String string) {
diff --git a/api/src/test/java/javax/jdo/JDOHelperConfigTest.java b/api/src/test/java/javax/jdo/JDOHelperConfigTest.java
index 9f86c12b..b4cabaf8 100644
--- a/api/src/test/java/javax/jdo/JDOHelperConfigTest.java
+++ b/api/src/test/java/javax/jdo/JDOHelperConfigTest.java
@@ -16,29 +16,23 @@
*/
package javax.jdo;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Map;
-import javax.jdo.util.BatchTestRunner;
-import junit.framework.TestSuite;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+import org.junit.jupiter.params.provider.ValueSource;
/** Tests class javax.jdo.JDOHelper for META-INF/jdoconfig.xml compliance. */
-public class JDOHelperConfigTest extends AbstractJDOConfigTest implements Constants {
-
- public static void main(String args[]) {
- BatchTestRunner.run(JDOHelperConfigTest.class);
- }
-
- /**
- * {@inheritDoc}
- *
- * @return {@inheritDoc}
- */
- public static TestSuite suite() {
- return new TestSuite(JDOHelperConfigTest.class);
- }
+class JDOHelperConfigTest extends AbstractJDOConfigTest implements Constants {
/**
* Builds up a {@link java.util.Map Map} object that contains key parameter values specific to a
@@ -224,44 +218,49 @@ public class JDOHelperConfigTest extends AbstractJDOConfigTest implements Consta
String name = testVariantName == null ? null : expected.get(Constants.PROPERTY_NAME);
Map<Object, Object> actual = JDOHelper.getPropertiesFromJdoconfig(name, loader);
- assertNotNull("No properties found", actual);
+ assertNotNull(actual, "No properties found");
if (checkEqualProperties) {
assertEqualProperties(expected, actual);
}
}
- public void testPositive00_PMF0_BasicPMFConfigUsingOnlyStandardAttributesAndListeners()
+ @Test
+ void testPositive00_PMF0_BasicPMFConfigUsingOnlyStandardAttributesAndListeners()
throws IOException {
doPositiveTest(
new String[] {JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, "positive00.pmf0", 2, 0, true);
}
- public void
+ @Test
+ void
testPositive00_PMF1_BasicPMFConfigUsingOnlyPropertyElementsWithStandardJavaxDotJDOProperties()
throws IOException {
doPositiveTest(
new String[] {JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, "positive00.pmf1", 2, 0, true);
}
- public void testPositive00_PMF2_NestedPropertyElementsWithOnlyStandardAttributeNames()
+ @Test
+ void testPositive00_PMF2_NestedPropertyElementsWithOnlyStandardAttributeNames()
throws IOException {
doPositiveTest(
new String[] {JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, "positive00.pmf2", 2, 0, true);
}
- public void testPositive00_PMF3_StandardAttributesPlusNonstandardPropertiesInPropertyElements()
+ @Test
+ void testPositive00_PMF3_StandardAttributesPlusNonstandardPropertiesInPropertyElements()
throws IOException {
doPositiveTest(
new String[] {JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, "positive00.pmf3", 2, 2, true);
}
- public void testPositive00_PMF4_StandardAttributesPlusNonstandardAttributes() throws IOException {
+ @Test
+ void testPositive00_PMF4_StandardAttributesPlusNonstandardAttributes() throws IOException {
doPositiveTest(
new String[] {JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, "positive00.pmf4", 0, 2, true);
}
- public void testPositive01_DuplicatePUsInDifferentConfigFilesButNotRequested()
- throws IOException {
+ @Test
+ void testPositive01_DuplicatePUsInDifferentConfigFilesButNotRequested() throws IOException {
String[] classpaths =
new String[] {
JDOCONFIG_CLASSPATH_PREFIX + "/Positive01/1a",
@@ -271,11 +270,12 @@ public class JDOHelperConfigTest extends AbstractJDOConfigTest implements Consta
Map<Object, Object> actual =
JDOHelper.getPropertiesFromJdoconfig(
Constants.ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader);
- assertNotNull("Anonymous PMF with no properties returned null", actual);
- assertEquals("Anonymous PMF with no properties had properties", 0, actual.size());
+ assertNotNull(actual, "Anonymous PMF with no properties returned null");
+ assertEquals(0, actual.size(), "Anonymous PMF with no properties had properties");
}
- public void testPositive02_GetAnonymousPMFWithNoProperties() throws IOException {
+ @Test
+ void testPositive02_GetAnonymousPMFWithNoProperties() throws IOException {
URLClassLoader loader =
new JDOConfigTestClassLoader(
@@ -284,49 +284,29 @@ public class JDOHelperConfigTest extends AbstractJDOConfigTest implements Consta
Map<Object, Object> properties =
JDOHelper.getPropertiesFromJdoconfig(
Constants.ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader);
- assertNotNull("Anonymous PMF with no properties returned null", properties);
- assertEquals("Anonymous PMF with no properties had properties", 0, properties.size());
- }
-
- public void testPositive03_PMF0_PMFClassNameViaServicesLookup() throws IOException {
- URLClassLoader loader =
- new JDOConfigTestClassLoader(
- getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive03/");
-
- String expected = "class.positive03.pmf0";
- String actual = getPMFClassNameViaServiceLookup(loader);
-
- assertNotNull("No PMF name found via services lookup", actual);
- assertEquals(expected, actual);
+ assertNotNull(properties, "Anonymous PMF with no properties returned null");
+ assertEquals(0, properties.size(), "Anonymous PMF with no properties had properties");
}
- public void testPositive04_PMF0_PMFClassNameViaServicesLookup() throws IOException {
-
+ @ParameterizedTest
+ @CsvSource({
+ "/Positive03/,class.positive03.pmf0",
+ "/Positive04/,class.positive04.pmf0",
+ "/Positive05/,class.positive05.pmf0"
+ })
+ void testPositive_PMF0_PMFClassNameViaServicesLookup(String path, String expected)
+ throws IOException {
URLClassLoader loader =
new JDOConfigTestClassLoader(
- getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive04/");
-
- String expected = "class.positive04.pmf0";
+ getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + path);
String actual = getPMFClassNameViaServiceLookup(loader);
- assertNotNull("No PMF name found via services lookup", actual);
+ assertNotNull(actual, "No PMF name found via services lookup");
assertEquals(expected, actual);
}
- public void testPositive05_PMF0_PMFClassNameViaServicesLookup() throws IOException {
-
- URLClassLoader loader =
- new JDOConfigTestClassLoader(
- getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive05/");
-
- String expected = "class.positive05.pmf0";
- String actual = getPMFClassNameViaServiceLookup(loader);
-
- assertNotNull("No PMF name found via services lookup", actual);
- assertEquals(expected, actual);
- }
-
- public void testPositive06_PMF0_GetAnonymousPMFProperties() throws IOException {
+ @Test
+ void testPositive06_PMF0_GetAnonymousPMFProperties() throws IOException {
URLClassLoader loader =
new JDOConfigTestClassLoader(
@@ -337,11 +317,12 @@ public class JDOHelperConfigTest extends AbstractJDOConfigTest implements Consta
JDOHelper.getPropertiesFromJdoconfig(
Constants.ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader);
- assertNotNull("No properties found", actual);
+ assertNotNull(actual, "No properties found");
assertEqualProperties(expected, actual);
}
- public void testPositive07_PMF0_GetAnonymousPMFPropertiesWithPUName() throws IOException {
+ @Test
+ void testPositive07_PMF0_GetAnonymousPMFPropertiesWithPUName() throws IOException {
URLClassLoader loader =
new JDOConfigTestClassLoader(
@@ -352,97 +333,65 @@ public class JDOHelperConfigTest extends AbstractJDOConfigTest implements Consta
JDOHelper.getPropertiesFromJdoconfig(
Constants.ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader);
- assertNotNull("No properties found", actual);
+ assertNotNull(actual, "No properties found");
assertEqualProperties(expected, actual);
}
- public void testNegative00_EmptyJDOConfigXML() throws IOException {
- try {
- URLClassLoader loader =
- new JDOConfigTestClassLoader(
- getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative0/");
- JDOHelper.getPersistenceManagerFactory(loader);
- fail("JDOHelper failed to throw JDOFatalUserException");
- } catch (JDOFatalUserException x) {
- // sunny day
- }
- }
-
- public void testNegative01_NoPersistenceUnitsDefined() throws IOException {
- try {
- URLClassLoader loader =
- new JDOConfigTestClassLoader(
- getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative01/");
- JDOHelper.getPersistenceManagerFactory(loader);
- fail("JDOHelper failed to throw JDOFatalUserException");
- } catch (JDOFatalUserException x) {
- // joy, sweet joy
- }
- }
-
- public void testNegative02_DuplicateAnonymousPersistenceUnitsInSameConfig() throws IOException {
- try {
- URLClassLoader loader =
- new JDOConfigTestClassLoader(
- getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative02/");
- JDOHelper.getPersistenceManagerFactory(loader);
- fail("JDOHelper failed to throw JDOFatalUserException");
- } catch (JDOFatalUserException x) {
- // the cockles of my heart warmeth
- }
- }
-
- public void testNegative03_DuplicateNamedPersistenceUnitsInSameConfig() throws IOException {
- try {
- URLClassLoader loader =
- new JDOConfigTestClassLoader(
- getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative03/");
- JDOHelper.getPersistenceManagerFactory("name.negative03", loader);
- fail("JDOHelper failed to throw JDOFatalUserException");
- } catch (JDOFatalUserException x) {
- // warm fuzzies
- }
+ @ParameterizedTest
+ @ValueSource(
+ strings = {
+ "/Negative0/", // EmptyJDOConfigXML
+ "/Negative01/", // NoPersistenceUnitsDefined
+ "/Negative02/", // DuplicateAnonymousPersistenceUnitsInSameConfig
+ "/Negative05/" // DuplicatePropertyInAttributeAndElement
+ })
+ void testNegative(String path) throws IOException {
+ URLClassLoader loader =
+ new JDOConfigTestClassLoader(
+ getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + path);
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(loader),
+ "JDOHelper failed to throw JDOFatalUserException");
}
- public void testNegative04_DuplicatePUNamePropertyInAttributeAndElement() throws IOException {
- try {
- URLClassLoader loader =
- new JDOConfigTestClassLoader(
- getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative04/");
- JDOHelper.getPersistenceManagerFactory("name.negative04.value0", loader);
- fail("JDOHelper failed to throw JDOFatalUserException");
- } catch (JDOFatalUserException x) {
- // no cold pricklies
- }
+ @Test
+ void testNegative03_DuplicateNamedPersistenceUnitsInSameConfig() throws IOException {
+ URLClassLoader loader =
+ new JDOConfigTestClassLoader(
+ getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative03/");
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory("name.negative03", loader),
+ "JDOHelper failed to throw JDOFatalUserException");
}
- public void testNegative05_DuplicatePropertyInAttributeAndElement() throws IOException {
- try {
- URLClassLoader loader =
- new JDOConfigTestClassLoader(
- getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative05/");
- JDOHelper.getPersistenceManagerFactory(loader);
- fail("JDOHelper failed to throw JDOFatalUserException");
- } catch (JDOFatalUserException x) {
- // party!
- }
+ @Test
+ void testNegative04_DuplicatePUNamePropertyInAttributeAndElement() throws IOException {
+ URLClassLoader loader =
+ new JDOConfigTestClassLoader(
+ getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative04/");
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory("name.negative04.value0", loader),
+ "JDOHelper failed to throw JDOFatalUserException");
}
- public void testNegative06_DuplicatePUInDifferentConfigFiles() throws IOException {
- try {
- URLClassLoader loader =
- new JDOConfigTestClassLoader(
- getClass().getClassLoader(),
- JDOCONFIG_CLASSPATH_PREFIX + "/Negative06/6a/",
- JDOCONFIG_CLASSPATH_PREFIX + "/Negative06/6b/");
- JDOHelper.getPersistenceManagerFactory("name.negative06", loader);
- fail("JDOHelper failed to throw JDOFatalUserException");
- } catch (JDOFatalUserException x) {
- // clear blue sky
- }
+ @Test
+ void testNegative06_DuplicatePUInDifferentConfigFiles() throws IOException {
+ URLClassLoader loader =
+ new JDOConfigTestClassLoader(
+ getClass().getClassLoader(),
+ JDOCONFIG_CLASSPATH_PREFIX + "/Negative06/6a/",
+ JDOCONFIG_CLASSPATH_PREFIX + "/Negative06/6b/");
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory("name.negative06", loader),
+ "JDOHelper failed to throw JDOFatalUserException");
}
- public void testNegative07_EmptyServicesFile() throws IOException {
+ @Test
+ void testNegative07_EmptyServicesFile() throws IOException {
JDOConfigTestClassLoader testLoader =
new JDOConfigTestClassLoader(
getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative07/");
@@ -450,21 +399,21 @@ public class JDOHelperConfigTest extends AbstractJDOConfigTest implements Consta
assertNull(shouldBeNull);
}
- public void testNegative08_NoResourcesFound() {
+ @Test
+ void testNegative08_NoResourcesFound() {
String resource = "" + RANDOM.nextLong();
InputStream in = getClass().getClassLoader().getResourceAsStream(resource);
assertNull(in);
// resource pretty much guaranteed not to exist
- try {
- JDOHelper.getPersistenceManagerFactory(resource);
- fail("JDOHelper failed to throw JDOFatalUserException");
- } catch (JDOFatalUserException x) {
- // happy path
- }
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(resource),
+ "JDOHelper failed to throw JDOFatalUserException");
}
- public void testNegative08_ServicesFileWithOnlyComments() throws IOException {
+ @Test
+ void testNegative08_ServicesFileWithOnlyComments() throws IOException {
JDOConfigTestClassLoader testLoader =
new JDOConfigTestClassLoader(
getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative08/");
@@ -472,39 +421,38 @@ public class JDOHelperConfigTest extends AbstractJDOConfigTest implements Consta
assertNull(shouldBeNull);
}
- public void testNegative09_MultipleInvalidClassesInDifferentServicesFiles() throws IOException {
+ @Test
+ void testNegative09_MultipleInvalidClassesInDifferentServicesFiles() throws IOException {
// no class name in Negative09/jdoconfig.xml
// 9a and 9b include services/javax.jdo.PersistenceManagerFactory
// with bad implementations
- try {
- URLClassLoader loader =
- new JDOConfigTestClassLoader(
- getClass().getClassLoader(),
- JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/9a/",
- JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/9b/",
- TEST_CLASSPATH,
- API_CLASSPATH);
- JDOHelper.getPersistenceManagerFactory("name.negative09", loader);
- fail("JDOHelper failed to throw JDOFatalUserException");
- } catch (JDOFatalException x) {
- Throwable[] nestedExceptions = x.getNestedExceptions();
- if (nestedExceptions.length != 2) {
+ URLClassLoader loader =
+ new JDOConfigTestClassLoader(
+ getClass().getClassLoader(),
+ JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/9a/",
+ JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/9b/",
+ TEST_CLASSPATH,
+ API_CLASSPATH);
+ JDOFatalException x =
+ assertThrows(
+ JDOFatalException.class,
+ () -> JDOHelper.getPersistenceManagerFactory("name.negative09", loader),
+ "JDOHelper failed to throw JDOFatalUserException");
+
+ Throwable[] nestedExceptions = x.getNestedExceptions();
+ if (nestedExceptions.length != 2) {
+ appendMessage(
+ "JDOHelper.getPersistenceManagerFactory wrong number of "
+ + "nested exceptions. Expected 2, got "
+ + nestedExceptions.length
+ + "\n"
+ + x);
+ }
+ for (Throwable exception : nestedExceptions) {
+ if (!(exception instanceof JDOFatalException)) {
appendMessage(
- "JDOHelper.getPersistenceManagerFactory wrong number of "
- + "nested exceptions. Expected 2, got "
- + nestedExceptions.length
- + "\n"
- + x);
- }
- for (int i = 0; i < nestedExceptions.length; ++i) {
- Throwable exception = nestedExceptions[i];
- if (!(exception instanceof JDOFatalException)) {
- appendMessage(
- "Nested exception "
- + exception.getClass().getName()
- + " is not a JDOFatalException.");
- }
+ "Nested exception " + exception.getClass().getName() + " is not a JDOFatalException.");
}
}
failOnError();
diff --git a/api/src/test/java/javax/jdo/JDOHelperTest.java b/api/src/test/java/javax/jdo/JDOHelperTest.java
index a4c71886..d1523f69 100644
--- a/api/src/test/java/javax/jdo/JDOHelperTest.java
+++ b/api/src/test/java/javax/jdo/JDOHelperTest.java
@@ -17,6 +17,14 @@
package javax.jdo;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.io.File;
import java.io.InputStream;
import java.util.HashMap;
@@ -24,10 +32,10 @@ import java.util.Map;
import java.util.Properties;
import javax.jdo.pc.PCPoint;
import javax.jdo.util.AbstractTest;
-import javax.jdo.util.BatchTestRunner;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import org.junit.jupiter.api.Test;
/**
* Tests class javax.jdo.JDOHelper.
@@ -35,12 +43,7 @@ import javax.naming.NamingException;
* <p>TBD: implementation of testMakeDirty, TBD: testing interrogative methods for persistent
* instances TBD: getPMF for valid PMF class
*/
-public class JDOHelperTest extends AbstractTest {
-
- /** */
- public static void main(String args[]) {
- BatchTestRunner.run(JDOHelperTest.class);
- }
+class JDOHelperTest extends AbstractTest {
/**
* The purpose of this test is simply to call some of the methods on a constructed instance of
@@ -48,20 +51,21 @@ public class JDOHelperTest extends AbstractTest {
*
* @since 2.1
*/
- public void testConstructor() {
- assertNull("getObjectId(null) returned non-null", JDOHelper.getObjectId(null));
+ @Test
+ void testConstructor() {
+ assertNull(JDOHelper.getObjectId(null), "getObjectId(null) returned non-null");
assertNull(
- "getPersistenceManager(null) returned non-null", JDOHelper.getPersistenceManager(null));
+ JDOHelper.getPersistenceManager(null), "getPersistenceManager(null) returned non-null");
assertNull(
- "getTransactionalObjectId(null) returned non-null",
- JDOHelper.getTransactionalObjectId(null));
- assertNull("getVersion(null) returned non-null", JDOHelper.getVersion(null));
- assertFalse("isDeleted(null) returned non-null", JDOHelper.isDeleted(null));
- assertFalse("isDetached(null) returned non-null", JDOHelper.isDetached(null));
- assertFalse("isDirty(null) returned non-null", JDOHelper.isDirty(null));
- assertFalse("isNew(null) returned non-null", JDOHelper.isNew(null));
- assertFalse("isPersistent(null) returned non-null", JDOHelper.isPersistent(null));
- assertFalse("isTransactional(null) returned non-null", JDOHelper.isTransactional(null));
+ JDOHelper.getTransactionalObjectId(null),
+ "getTransactionalObjectId(null) returned non-null");
+ assertNull(JDOHelper.getVersion(null), "getVersion(null) returned non-null");
+ assertFalse(JDOHelper.isDeleted(null), "isDeleted(null) returned non-null");
+ assertFalse(JDOHelper.isDetached(null), "isDetached(null) returned non-null");
+ assertFalse(JDOHelper.isDirty(null), "isDirty(null) returned non-null");
+ assertFalse(JDOHelper.isNew(null), "isNew(null) returned non-null");
+ assertFalse(JDOHelper.isPersistent(null), "isPersistent(null) returned non-null");
+ assertFalse(JDOHelper.isTransactional(null), "isTransactional(null) returned non-null");
}
/**
@@ -70,442 +74,433 @@ public class JDOHelperTest extends AbstractTest {
*
* @since 2.1
*/
- public void testGetInstance() {
- assertNull("getObjectId(null) returned non-null", JDOHelper.getObjectId(null));
+ @Test
+ void testGetInstance() {
+ assertNull(JDOHelper.getObjectId(null), "getObjectId(null) returned non-null");
assertNull(
- "getPersistenceManager(null) returned non-null", JDOHelper.getPersistenceManager(null));
+ JDOHelper.getPersistenceManager(null), "getPersistenceManager(null) returned non-null");
assertNull(
- "getTransactionalObjectId(null) returned non-null",
- JDOHelper.getTransactionalObjectId(null));
- assertNull("getVersion(null) returned non-null", JDOHelper.getVersion(null));
- assertFalse("isDeleted(null) returned non-null", JDOHelper.isDeleted(null));
- assertFalse("isDetached(null) returned non-null", JDOHelper.isDetached(null));
- assertFalse("isDirty(null) returned non-null", JDOHelper.isDirty(null));
- assertFalse("isNew(null) returned non-null", JDOHelper.isNew(null));
- assertFalse("isPersistent(null) returned non-null", JDOHelper.isPersistent(null));
- assertFalse("isTransactional(null) returned non-null", JDOHelper.isTransactional(null));
+ JDOHelper.getTransactionalObjectId(null),
+ "getTransactionalObjectId(null) returned non-null");
+ assertNull(JDOHelper.getVersion(null), "getVersion(null) returned non-null");
+ assertFalse(JDOHelper.isDeleted(null), "isDeleted(null) returned non-null");
+ assertFalse(JDOHelper.isDetached(null), "isDetached(null) returned non-null");
+ assertFalse(JDOHelper.isDirty(null), "isDirty(null) returned non-null");
+ assertFalse(JDOHelper.isNew(null), "isNew(null) returned non-null");
+ assertFalse(JDOHelper.isPersistent(null), "isPersistent(null) returned non-null");
+ assertFalse(JDOHelper.isTransactional(null), "isTransactional(null) returned non-null");
}
/** */
- public void testGetPM() {
+ @Test
+ void testGetPM() {
PCPoint p = new PCPoint(1, Integer.valueOf(1));
assertNull(
- "JDOHelper.getPersistenceManager should return null pm for non-persistent instance",
- JDOHelper.getPersistenceManager(p));
+ JDOHelper.getPersistenceManager(p),
+ "JDOHelper.getPersistenceManager should return null pm for non-persistent instance");
// TBD: test for persistent instance
}
/** */
- public void testMakeDirty() {
+ @Test
+ void testMakeDirty() {
PCPoint p = new PCPoint(1, Integer.valueOf(1));
JDOHelper.makeDirty(p, "x");
- assertFalse("JDOHelper.makeDirty should ignore non-persistent instance", JDOHelper.isDirty(p));
+ assertFalse(JDOHelper.isDirty(p), "JDOHelper.makeDirty should ignore non-persistent instance");
// TBD: test for persistent instance
}
/** */
- public void testGetObjectId() {
+ @Test
+ void testGetObjectId() {
PCPoint p = new PCPoint(1, Integer.valueOf(1));
assertNull(
- "JDOHelper.getObjectId should return null ObjectId for non-persistent instance",
- JDOHelper.getObjectId(p));
+ JDOHelper.getObjectId(p),
+ "JDOHelper.getObjectId should return null ObjectId for non-persistent instance");
// TBD test JDOHelper.getObjectId(pc) for persistent instance
}
/** */
- public void testGetTransactionObjectId() {
+ @Test
+ void testGetTransactionObjectId() {
PCPoint p = new PCPoint(1, Integer.valueOf(1));
assertNull(
- "JDOHelper.getTransactionalObjectId should return null ObjectId for non-persistent instance",
- JDOHelper.getObjectId(p));
+ JDOHelper.getObjectId(p),
+ "JDOHelper.getTransactionalObjectId should return null ObjectId for non-persistent instance");
// TBD test JDOHelper.getTransactionalObjectId(pc) for persistent instance
}
/** */
- public void testIsDirty() {
+ @Test
+ void testIsDirty() {
PCPoint p = new PCPoint(1, Integer.valueOf(1));
assertFalse(
- "JDOHelper.isDirty should return false for non-persistent instance", JDOHelper.isDirty(p));
+ JDOHelper.isDirty(p), "JDOHelper.isDirty should return false for non-persistent instance");
// TBD test JDOHelper.isDirty(pc) for persistent instance
}
/** */
- public void testIsTransactional() {
+ @Test
+ void testIsTransactional() {
PCPoint p = new PCPoint(1, Integer.valueOf(1));
assertFalse(
- "JDOHelper.isTransactional should return false for non-persistent instance",
- JDOHelper.isTransactional(p));
+ JDOHelper.isTransactional(p),
+ "JDOHelper.isTransactional should return false for non-persistent instance");
// TBD test JDOHelper.isTransactional(pc) for persistent instance
}
/** */
- public void testIsPersistent() {
+ @Test
+ void testIsPersistent() {
PCPoint p = new PCPoint(1, Integer.valueOf(1));
assertFalse(
- "JDOHelper.isPersistent should return false for non-persistent instance",
- JDOHelper.isPersistent(p));
+ JDOHelper.isPersistent(p),
+ "JDOHelper.isPersistent should return false for non-persistent instance");
// TBD test JDOHelper.isPersistent(pc) for persistent instance
}
/** */
- public void testIsNew() {
+ @Test
+ void testIsNew() {
PCPoint p = new PCPoint(1, Integer.valueOf(1));
assertFalse(
- "JDOHelper.isNew should return false for non-persistent instance", JDOHelper.isNew(p));
+ JDOHelper.isNew(p), "JDOHelper.isNew should return false for non-persistent instance");
// TBD test JDOHelper.isNew(pc) for persistent instance
}
/** */
- public void testIsDeleted() {
+ @Test
+ void testIsDeleted() {
PCPoint p = new PCPoint(1, Integer.valueOf(1));
assertFalse(
- "JDOHelper.isDeleted should return false for non-persistent instance",
- JDOHelper.isDeleted(p));
+ JDOHelper.isDeleted(p),
+ "JDOHelper.isDeleted should return false for non-persistent instance");
// TBD test JDOHelper.isDeleted(pc) for persistent instance
}
/** Test null String resource with no class loader. */
- public void testGetPMFNullResource() {
- try {
- JDOHelper.getPersistenceManagerFactory((String) null);
- fail("Null resource name should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFNullResource() {
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory((String) null),
+ "Null resource name should result in JDOFatalUserException");
}
/** Test null String resource with good class loader. */
- public void testGetPMFNullResourceGoodClassLoader() {
- try {
- JDOHelper.getPersistenceManagerFactory((String) null, this.getClass().getClassLoader());
- fail("Null resource name should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFNullResourceGoodClassLoader() {
+ ClassLoader loader = this.getClass().getClassLoader();
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory((String) null, loader),
+ "Null resource name should result in JDOFatalUserException");
}
/** Test bad String resource with no class loader. */
- public void testGetPMFBadResource() {
- try {
- JDOHelper.getPersistenceManagerFactory("Whatever");
- fail("Null resource name should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFBadResource() {
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory("Whatever"),
+ "Null resource name should result in JDOFatalUserException");
}
/** Test null String resource with good class loader. */
- public void testGetPMFBadResourceGoodClassLoader() {
- try {
- JDOHelper.getPersistenceManagerFactory("Whatever", this.getClass().getClassLoader());
- fail("Null resource name should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFBadResourceGoodClassLoader() {
+ ClassLoader loader = this.getClass().getClassLoader();
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory("Whatever", loader),
+ "Null resource name should result in JDOFatalUserException");
}
/** Test null File resource with no class loader. */
- public void testGetPMFNullFile() {
- try {
- JDOHelper.getPersistenceManagerFactory((File) null);
- fail("Null file should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFNullFile() {
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory((File) null),
+ "Null file should result in JDOFatalUserException");
}
/** Test null File resource with good class loader. */
- public void testGetPMFNullFileGoodClassLoader() {
- try {
- JDOHelper.getPersistenceManagerFactory((File) null, this.getClass().getClassLoader());
- fail("Null file should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFNullFileGoodClassLoader() {
+ ClassLoader loader = this.getClass().getClassLoader();
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory((File) null, loader),
+ "Null file should result in JDOFatalUserException");
}
/** Test bad File resource with no class loader. */
- public void testGetPMFBadFile() {
- try {
- JDOHelper.getPersistenceManagerFactory(new File("Whatever"));
- fail("Null file should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFBadFile() {
+ File file = new File("Whatever");
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(file),
+ "Null file should result in JDOFatalUserException");
}
/** Test bad File resource with good class loader. */
- public void testGetPMFBadFileGoodClassLoader() {
- try {
- JDOHelper.getPersistenceManagerFactory(
- new File("Whatever"), this.getClass().getClassLoader());
- fail("Null file should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFBadFileGoodClassLoader() {
+ File file = new File("Whatever");
+ ClassLoader loader = this.getClass().getClassLoader();
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(file, loader),
+ "Null file should result in JDOFatalUserException");
}
/** Test null JNDI resource name with no class loader. */
- public void testGetPMFNullJNDI() {
- try {
- JDOHelper.getPersistenceManagerFactory(null, getInitialContext());
- fail("Null JNDI resource name should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFNullJNDI() {
+ Context context = getInitialContext();
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(null, context),
+ "Null JNDI resource name should result in JDOFatalUserException");
}
/** Test null JNDI resource name with good class loader. */
- public void testGetPMFNullJNDIGoodClassLoader() {
- try {
- JDOHelper.getPersistenceManagerFactory(
- null, getInitialContext(), this.getClass().getClassLoader());
- fail("Null JNDI resource name should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFNullJNDIGoodClassLoader() {
+ Context context = getInitialContext();
+ ClassLoader loader = this.getClass().getClassLoader();
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(null, context, loader),
+ "Null JNDI resource name should result in JDOFatalUserException");
}
/** Test bad JNDI resource name with no class loader. */
- public void testGetPMFBadJNDI() {
- try {
- JDOHelper.getPersistenceManagerFactory("Whatever", getInitialContext());
- fail("Bad JNDI resource name should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFBadJNDI() {
+ Context context = getInitialContext();
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory("Whatever", context),
+ "Bad JNDI resource name should result in JDOFatalUserException");
}
/** Test bad JNDI resource name with good class loader. */
- public void testGetPMFBadJNDIGoodClassLoader() {
- try {
- JDOHelper.getPersistenceManagerFactory(
- "Whatever", getInitialContext(), this.getClass().getClassLoader());
- fail("Bad JNDI resource name should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFBadJNDIGoodClassLoader() {
+ Context context = getInitialContext();
+ ClassLoader loader = this.getClass().getClassLoader();
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory("Whatever", context, loader),
+ "Bad JNDI resource name should result in JDOFatalUserException");
}
/** Test null stream with no class loader. */
- public void testGetPMFNullStream() {
- try {
- JDOHelper.getPersistenceManagerFactory((InputStream) null);
- fail("Null JNDI resource name should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFNullStream() {
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory((InputStream) null),
+ "Null JNDI resource name should result in JDOFatalUserException");
}
/** Test null stream with good class loader. */
- public void testGetPMFNullStreamGoodClassLoader() {
- try {
- JDOHelper.getPersistenceManagerFactory((InputStream) null, this.getClass().getClassLoader());
- fail("Null JNDI resource name should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFNullStreamGoodClassLoader() {
+ ClassLoader loader = this.getClass().getClassLoader();
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory((InputStream) null, loader),
+ "Null JNDI resource name should result in JDOFatalUserException");
}
/** Test null ClassLoader. */
- public void testGetPMFNullClassLoader() {
- try {
- JDOHelper.getPersistenceManagerFactory("Whatever", (ClassLoader) null);
- fail("Null ClassLoader should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFNullClassLoader() {
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory("Whatever", (ClassLoader) null),
+ "Null ClassLoader should result in JDOFatalUserException");
}
/** Test both null ClassLoaders. */
- public void testGetPMFBothNullClassLoader() {
- try {
- JDOHelper.getPersistenceManagerFactory("Whatever", (ClassLoader) null, null);
- fail("Null ClassLoader should result in JDOFatalUserException");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFBothNullClassLoader() {
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory("Whatever", (ClassLoader) null, null),
+ "Null ClassLoader should result in JDOFatalUserException");
}
/** Test missing property javax.jdo.PersistenceManagerFactoryClass. */
- public void testGetPMFNoClassNameProperty() {
- try {
- JDOHelper.getPersistenceManagerFactory(new Properties());
- fail(
- "Missing property PersistenceManagerFactoryClass should result in JDOFatalUserException ");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ @Test
+ void testGetPMFNoClassNameProperty() {
+ Properties props = new Properties();
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(props),
+ "Missing property PersistenceManagerFactoryClass should result in JDOFatalUserException ");
}
/** Test bad PMF class does not exist. */
- public void testBadPMFClassNotFound() {
+ @Test
+ void testBadPMFClassNotFound() {
Properties props = new Properties();
props.put("javax.jdo.PersistenceManagerFactoryClass", "ThisClassDoesNotExist");
- try {
- JDOHelper.getPersistenceManagerFactory(props);
- fail("Bad PersistenceManagerFactoryClass should result in JDOFatalUserException ");
- } catch (JDOFatalUserException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ assertThrows(
+ JDOFatalUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(props),
+ "Bad PersistenceManagerFactoryClass should result in JDOFatalUserException ");
}
/** Test bad PMF class no method getPersistenceManagerFactory(Properties). */
- public void testBadPMFNoGetPMFPropertiesMethod() {
+ @Test
+ void testBadPMFNoGetPMFPropertiesMethod() {
Properties props = new Properties();
props.put(
"javax.jdo.PersistenceManagerFactoryClass", "javax.jdo.JDOHelperTest$BadPMFNoGetPMFMethod");
- try {
- JDOHelper.getPersistenceManagerFactory(props);
- fail("Bad PersistenceManagerFactory should result in JDOFatalInternalException ");
- } catch (JDOFatalInternalException ex) {
- if (ex.getCause() instanceof NoSuchMethodException) {
- if (verbose) println("Caught expected exception " + ex);
- } else {
- fail(
- "Bad PersistenceManagerFactory should result in "
- + "JDOFatalInternalException with nested "
- + "NoSuchMethodException. "
- + "Actual nested exception was "
- + ex);
- }
+ JDOFatalInternalException ex =
+ assertThrows(
+ JDOFatalInternalException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(props).getConnectionFactory(),
+ "Bad PersistenceManagerFactory should result in JDOFatalInternalException ");
+ if (ex.getCause() instanceof NoSuchMethodException) {
+ if (verbose) println("Caught expected exception " + ex);
+ } else {
+ fail(
+ "Bad PersistenceManagerFactory should result in "
+ + "JDOFatalInternalException with nested "
+ + "NoSuchMethodException. "
+ + "Actual nested exception was "
+ + ex);
}
}
/** Test bad PMF class no method getPersistenceManagerFactory(Map). */
- public void testBadPMFNoGetPMFMapMethod() {
+ @Test
+ void testBadPMFNoGetPMFMapMethod() {
Map<String, String> props = new HashMap<>();
props.put(
"javax.jdo.PersistenceManagerFactoryClass", "javax.jdo.JDOHelperTest$BadPMFNoGetPMFMethod");
- try {
- JDOHelper.getPersistenceManagerFactory(props);
- fail("Bad PersistenceManagerFactory should result in JDOFatalInternalException ");
- } catch (JDOFatalInternalException ex) {
- if (ex.getCause() instanceof NoSuchMethodException) {
- if (verbose) println("Caught expected exception " + ex);
- } else {
- fail(
- "Bad PersistenceManagerFactory should result in "
- + "JDOFatalInternalException with nested "
- + "NoSuchMethodException. "
- + "Actual nested exception was "
- + ex);
- }
+ JDOFatalInternalException ex =
+ assertThrows(
+ JDOFatalInternalException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(props),
+ "Bad PersistenceManagerFactory should result in JDOFatalInternalException ");
+ if (ex.getCause() instanceof NoSuchMethodException) {
+ if (verbose) println("Caught expected exception " + ex);
+ } else {
+ fail(
+ "Bad PersistenceManagerFactory should result in "
+ + "JDOFatalInternalException with nested "
+ + "NoSuchMethodException. "
+ + "Actual nested exception was "
+ + ex);
}
}
/** Test bad PMF class non-static getPMF method. */
- public void testBadPMFNonStaticGetPMFMethod() {
+ @Test
+ void testBadPMFNonStaticGetPMFMethod() {
Properties props = new Properties();
props.put(
"javax.jdo.PersistenceManagerFactoryClass",
"javax.jdo.JDOHelperTest$BadPMFNonStaticGetPMFMethod");
- try {
- JDOHelper.getPersistenceManagerFactory(props);
- fail("Bad PersistenceManagerFactoryClass should result in JDOFatalInternalException ");
- } catch (JDOFatalInternalException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ assertThrows(
+ JDOFatalInternalException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(props),
+ "Bad PersistenceManagerFactoryClass should result in JDOFatalInternalException ");
}
/** Test bad PMF class doesn't implement PMF. */
- public void testBadPMFWrongReturnType() {
+ @Test
+ void testBadPMFWrongReturnType() {
Properties props = new Properties();
props.put(
"javax.jdo.PersistenceManagerFactoryClass",
"javax.jdo.JDOHelperTest$BadPMFWrongReturnType");
- try {
- JDOHelper.getPersistenceManagerFactory(props);
- fail("Bad PersistenceManagerFactoryClass should result in JDOFatalInternalException ");
- } catch (JDOFatalInternalException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ assertThrows(
+ JDOFatalInternalException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(props),
+ "Bad PersistenceManagerFactoryClass should result in JDOFatalInternalException ");
}
/** Test bad PMF class getPersistenceManagerFactory throws Exception. */
- public void testBadPMFGetPMFMethodThrowsJDOException() {
+ @Test
+ void testBadPMFGetPMFMethodThrowsJDOException() {
Properties props = new Properties();
props.put(
"javax.jdo.PersistenceManagerFactoryClass",
"javax.jdo.JDOHelperTest$BadPMFGetPMFMethodThrowsJDOException");
- try {
- JDOHelper.getPersistenceManagerFactory(props);
- fail(
- "BadPMFGetPMFMethodThrowsJDOException.GetPersistenceManagerFactory "
- + "should result in JDOUnsupportedOptionException. "
- + "No exception was thrown.");
- } catch (JDOUnsupportedOptionException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ assertThrows(
+ JDOUnsupportedOptionException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(props),
+ "BadPMFGetPMFMethodThrowsJDOException.GetPersistenceManagerFactory "
+ + "should result in JDOUnsupportedOptionException. "
+ + "No exception was thrown.");
}
/** Test bad PMF class getPersistenceManagerFactory returns null. */
- public void testBadPMFGetPMFMethodReturnsNull() {
+ @Test
+ void testBadPMFGetPMFMethodReturnsNull() {
Properties props = new Properties();
props.put(
"javax.jdo.PersistenceManagerFactoryClass",
"javax.jdo.JDOHelperTest$BadPMFGetPMFMethodReturnsNull");
- try {
- JDOHelper.getPersistenceManagerFactory(props);
- fail(
- "BadPMFGetPMFMethodReturnsNull.GetPersistenceManagerFactory "
- + "should result in JDOFatalInternalException. "
- + "No exception was thrown.");
- } catch (JDOFatalInternalException ex) {
- if (verbose) println("Caught expected exception " + ex);
- }
+ assertThrows(
+ JDOFatalInternalException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(props),
+ "BadPMFGetPMFMethodReturnsNull.GetPersistenceManagerFactory "
+ + "should result in JDOFatalInternalException. "
+ + "No exception was thrown.");
}
/** Test that an unknown standard property cause JDOUserException. */
- public void testUnknownStandardProperty() {
+ @Test
+ void testUnknownStandardProperty() {
Properties p = new Properties();
p.setProperty("javax.jdo.unknown.standard.property", "value");
- try {
- JDOHelper.getPersistenceManagerFactory(p);
- fail(
- "testUnknownStandardProperties should result in JDOUserException. "
- + "No exception was thrown.");
- } catch (JDOUserException x) {
- if (verbose) println("Caught expected exception " + x);
- }
+ assertThrows(
+ JDOUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(p),
+ "testUnknownStandardProperties should result in JDOUserException. No exception was thrown.");
}
/** Test that unknown standard properties cause JDOUserException w/nested exceptions. */
- public void testUnknownStandardProperties() {
+ @Test
+ void testUnknownStandardProperties() {
Properties p = new Properties();
p.setProperty("javax.jdo.unknown.standard.property.1", "value");
p.setProperty("javax.jdo.unknown.standard.property.2", "value");
- JDOUserException x = null;
-
- try {
- JDOHelper.getPersistenceManagerFactory(p);
- fail(
- "testUnknownStandardProperties should result in JDOUserException. "
- + "No exception was thrown.");
- } catch (JDOUserException thrown) {
- if (verbose) println("Caught expected exception " + thrown);
- x = thrown;
- }
+ JDOUserException x =
+ assertThrows(
+ JDOUserException.class,
+ () -> JDOHelper.getPersistenceManagerFactory(p),
+ "testUnknownStandardProperties should result in JDOUserException. "
+ + "No exception was thrown.");
Throwable[] nesteds = x.getNestedExceptions();
assertNotNull(nesteds);
- assertEquals("should have been 2 nested exceptions", 2, nesteds.length);
+ assertEquals(2, nesteds.length, "should have been 2 nested exceptions");
for (int i = 0; i < nesteds.length; i++) {
Throwable t = nesteds[i];
assertTrue(
- "nested exception " + i + " should have been JDOUserException",
- t instanceof JDOUserException);
+ t instanceof JDOUserException,
+ "nested exception " + i + " should have been JDOUserException");
}
}
diff --git a/api/src/test/java/javax/jdo/ObjectStateTest.java b/api/src/test/java/javax/jdo/ObjectStateTest.java
index 058f181f..02c1e4dd 100644
--- a/api/src/test/java/javax/jdo/ObjectStateTest.java
+++ b/api/src/test/java/javax/jdo/ObjectStateTest.java
@@ -17,12 +17,14 @@
package javax.jdo;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import javax.jdo.spi.PersistenceCapable;
import javax.jdo.util.AbstractTest;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.Test;
/*
* ObjectStateTest.java
@@ -31,7 +33,7 @@ import javax.jdo.util.BatchTestRunner;
*
* @since 2.1
*/
-public class ObjectStateTest extends AbstractTest {
+class ObjectStateTest extends AbstractTest {
static final int PERSISTENT = 1;
static final int TRANSACTIONAL = 2;
@@ -54,73 +56,82 @@ public class ObjectStateTest extends AbstractTest {
getDeclaredMethod(PersistenceCapable.class, "jdoIsDetached", null);
/** */
- public static void main(String args[]) {
- BatchTestRunner.run(ObjectStateTest.class);
- }
-
- public void testNull() {
+ @Test
+ void testNull() {
PersistenceCapable mock = null;
assertObjectState("null", null, mock);
}
- public void testTransient() {
+ @Test
+ void testTransient() {
PersistenceCapable mock = newMock(0);
assertObjectState("transient", ObjectState.TRANSIENT, mock);
}
- public void testTransientClean() {
+ @Test
+ void testTransientClean() {
PersistenceCapable mock = newMock(TRANSACTIONAL);
assertObjectState("transient-clean", ObjectState.TRANSIENT_CLEAN, mock);
}
- public void testTransientDirty() {
+ @Test
+ void testTransientDirty() {
PersistenceCapable mock = newMock(TRANSACTIONAL + DIRTY);
assertObjectState("transient-dirty", ObjectState.TRANSIENT_DIRTY, mock);
}
- public void testPersistentNew() {
+ @Test
+ void testPersistentNew() {
PersistenceCapable mock = newMock(PERSISTENT + TRANSACTIONAL + NEW + DIRTY);
assertObjectState("persistent-new", ObjectState.PERSISTENT_NEW, mock);
}
- public void testPersistentNontransactional() {
+ @Test
+ void testPersistentNontransactional() {
PersistenceCapable mock = newMock(PERSISTENT);
assertObjectState(
"persistent-nontransactional", ObjectState.HOLLOW_PERSISTENT_NONTRANSACTIONAL, mock);
}
- public void testPersistentNontransactionalDirty() {
+ @Test
+ void testPersistentNontransactionalDirty() {
PersistenceCapable mock = newMock(PERSISTENT + DIRTY);
assertObjectState(
"persistent-nontransactional-dirty", ObjectState.PERSISTENT_NONTRANSACTIONAL_DIRTY, mock);
}
- public void testPersistentClean() {
+ @Test
+ void testPersistentClean() {
PersistenceCapable mock = newMock(PERSISTENT + TRANSACTIONAL);
assertObjectState("persistent-clean", ObjectState.PERSISTENT_CLEAN, mock);
}
- public void testPersistentDirty() {
+ @Test
+ void testPersistentDirty() {
PersistenceCapable mock = newMock(PERSISTENT + TRANSACTIONAL + DIRTY);
assertObjectState("persistent-dirty", ObjectState.PERSISTENT_DIRTY, mock);
}
- public void testPersistentDeleted() {
+ @Test
+ void testPersistentDeleted() {
PersistenceCapable mock = newMock(PERSISTENT + TRANSACTIONAL + DIRTY + DELETED);
assertObjectState("persistent-deleted", ObjectState.PERSISTENT_DELETED, mock);
}
- public void testPersistentNewDeleted() {
+ @Test
+ void testPersistentNewDeleted() {
PersistenceCapable mock = newMock(PERSISTENT + TRANSACTIONAL + NEW + DIRTY + DELETED);
assertObjectState("persistent-new-deleted", ObjectState.PERSISTENT_NEW_DELETED, mock);
}
- public void testDetachedClean() {
+ @Test
+ void testDetachedClean() {
PersistenceCapable mock = newMock(DETACHED);
assertObjectState("detached-clean", ObjectState.DETACHED_CLEAN, mock);
}
- public void testDetachedDirty() {
+ @Test
+ void testDetachedDirty() {
PersistenceCapable mock = newMock(DETACHED + DIRTY);
assertObjectState("detached-dirty", ObjectState.DETACHED_DIRTY, mock);
}
diff --git a/api/src/test/java/javax/jdo/PMFMapMapTest.java b/api/src/test/java/javax/jdo/PMFMapMapTest.java
index 5196483a..11f1c50d 100644
--- a/api/src/test/java/javax/jdo/PMFMapMapTest.java
+++ b/api/src/test/java/javax/jdo/PMFMapMapTest.java
@@ -16,20 +16,21 @@
*/
package javax.jdo;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
-import javax.jdo.util.BatchTestRunner;
-import junit.framework.TestSuite;
+import org.junit.jupiter.api.Test;
/**
* Tests class javax.jdo.JDOHelper for calls to the impl's static method
* getPersistenceManagerFactory(Map overrides, Map props).
*/
-public class PMFMapMapTest extends AbstractJDOConfigTest {
+class PMFMapMapTest extends AbstractJDOConfigTest {
private static final String EXPECTED_FACTORY2_NAME = "Jane Doe";
private static final String EXPECTED_FACTORY2_NAME_4_NAMED_PMF = "Larry";
@@ -40,19 +41,6 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
private static final String PMF_SERVICE_CLASS = "javax.jdo.stub.StubPMF";
private static final String PROPERTIES_FILE = "propsfile.props";
- public static void main(String args[]) {
- BatchTestRunner.run(PMFMapMapTest.class);
- }
-
- /**
- * {@inheritDoc}
- *
- * @return {@inheritDoc}
- */
- public static TestSuite suite() {
- return new TestSuite(PMFMapMapTest.class);
- }
-
/*
* static PersistenceManagerFactory getPersistenceManagerFactory() Get the
* anonymous PersistenceManagerFactory configured via the standard
@@ -60,7 +48,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* thread's context class loader to locate the configuration file
* resource(s).
*/
- public void testJDOConfigXML() throws IOException {
+ @Test
+ void testJDOConfigXML() throws IOException {
ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR);
ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader();
@@ -82,7 +71,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* PersistenceManagerFactory configured via the standard configuration file
* resource "META-INF/jdoconfig.xml", using the given class loader.
*/
- public void testJDOConfigXMLWithLoader() throws IOException {
+ @Test
+ void testJDOConfigXMLWithLoader() throws IOException {
ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR);
@@ -99,7 +89,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* java.io.File propsFile) Returns a PersistenceManagerFactory configured
* based on the properties stored in the file at propsFile.
*/
- public void testPropsFile() throws IOException {
+ @Test
+ void testPropsFile() throws IOException {
ClassLoader resourceClassLoader = createResourceClassLoader(PROPS_DIR);
ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader();
@@ -121,7 +112,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* PersistenceManagerFactory configured based on the properties stored in
* the file at propsFile.
*/
- public void testPropsFileAndLoader() throws IOException {
+ @Test
+ void testPropsFileAndLoader() throws IOException {
ClassLoader resourceClassLoader = createResourceClassLoader(PROPS_DIR);
@@ -139,7 +131,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* java.io.InputStream stream) Returns a PersistenceManagerFactory
* configured based on the Properties stored in the input stream at stream.
*/
- public void testInputStream() throws IOException {
+ @Test
+ void testInputStream() throws IOException {
Properties props = new Properties();
props.setProperty(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_SERVICE_CLASS);
props.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME);
@@ -172,7 +165,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* PersistenceManagerFactory configured based on the Properties stored in
* the input stream at stream.
*/
- public void testInputStreamWithLoader() throws IOException {
+ @Test
+ void testInputStreamWithLoader() throws IOException {
Properties props = new Properties();
props.setProperty(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_SERVICE_CLASS);
props.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME);
@@ -202,7 +196,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* Properties instance, using the current thread's context class loader to
* locate the PersistenceManagerFactory class.
*/
- public void testProperties() throws IOException {
+ @Test
+ void testProperties() throws IOException {
Properties props = new Properties();
props.setProperty(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_SERVICE_CLASS);
props.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME);
@@ -225,7 +220,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* java.util.Map<?,?> props, java.lang.ClassLoader pmfClassLoader) Get a
* PersistenceManagerFactory based on a Map and a class loader.
*/
- public void testPropertiesAndLoader() throws IOException {
+ @Test
+ void testPropertiesAndLoader() throws IOException {
Properties props = new Properties();
props.setProperty(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_SERVICE_CLASS);
props.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME);
@@ -245,7 +241,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* (java.util.Map<?,?> overrides, java.lang.String name) Returns a named
* PersistenceManagerFactory or persistence unit.
*/
- public void testNamedPMFWithOverrides() throws IOException {
+ @Test
+ void testNamedPMFWithOverrides() throws IOException {
Properties overrides = new Properties();
overrides.setProperty(
Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME_WITH_OVERRIDE);
@@ -270,7 +267,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* java.lang.ClassLoader resourceLoader) Returns a named
* PersistenceManagerFactory or persistence unit.
*/
- public void testNamedPMFWithOverridesAndLoader() throws IOException {
+ @Test
+ void testNamedPMFWithOverridesAndLoader() throws IOException {
Properties overrides = new Properties();
overrides.setProperty(
Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME_WITH_OVERRIDE);
@@ -296,7 +294,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* javax.persistence.EntityManagerFactory cast to a
* PersistenceManagerFactory.
*/
- public void testNamedPMFWithOverridesAndTwoLoaders() throws IOException {
+ @Test
+ void testNamedPMFWithOverridesAndTwoLoaders() throws IOException {
Properties overrides = new Properties();
overrides.setProperty(
Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME_WITH_OVERRIDE);
@@ -319,7 +318,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* java.lang.String name) Returns a named PersistenceManagerFactory or
* persistence unit.
*/
- public void testNamedPMF() throws IOException {
+ @Test
+ void testNamedPMF() throws IOException {
ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR);
ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader();
@@ -340,7 +340,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* (java.lang.String name, java.lang.ClassLoader loader) Returns a named
* PersistenceManagerFactory or persistence unit.
*/
- public void testNamedPMFWithLoader() throws IOException {
+ @Test
+ void testNamedPMFWithLoader() throws IOException {
ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR);
@@ -359,7 +360,8 @@ public class PMFMapMapTest extends AbstractJDOConfigTest {
* java.lang.ClassLoader pmfLoader) Returns a named
* PersistenceManagerFactory or persistence unit.
*/
- public void testNamedPMFWithTwoLoaders() throws IOException {
+ @Test
+ void testNamedPMFWithTwoLoaders() throws IOException {
ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR);
ClassLoader pmfLoader = getClass().getClassLoader();
diff --git a/api/src/test/java/javax/jdo/identity/ByteIdentityTest.java b/api/src/test/java/javax/jdo/identity/ByteIdentityTest.java
index 3018c206..83a8039d 100644
--- a/api/src/test/java/javax/jdo/identity/ByteIdentityTest.java
+++ b/api/src/test/java/javax/jdo/identity/ByteIdentityTest.java
@@ -22,64 +22,66 @@
package javax.jdo.identity;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.jdo.JDONullIdentityException;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.Test;
/** */
-public class ByteIdentityTest extends SingleFieldIdentityTest {
+class ByteIdentityTest extends SingleFieldIdentityTest {
/** Creates a new instance of ByteIdentityTest */
public ByteIdentityTest() {}
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- BatchTestRunner.run(ByteIdentityTest.class);
- }
-
- public void testConstructor() {
+ @Test
+ void testConstructor() {
ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1);
ByteIdentity c2 = new ByteIdentity(Object.class, (byte) 1);
ByteIdentity c3 = new ByteIdentity(Object.class, (byte) 2);
- assertEquals("Equal ByteIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ByteIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ByteIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ByteIdentity instances compare equal");
}
- public void testByteConstructor() {
+ @Test
+ void testByteConstructor() {
ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1);
ByteIdentity c2 = new ByteIdentity(Object.class, Byte.valueOf((byte) 1));
ByteIdentity c3 = new ByteIdentity(Object.class, Byte.valueOf((byte) 2));
- assertEquals("Equal ByteIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ByteIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ByteIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ByteIdentity instances compare equal");
}
- public void testToStringConstructor() {
+ @Test
+ void testToStringConstructor() {
ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1);
ByteIdentity c2 = new ByteIdentity(Object.class, c1.toString());
- assertEquals("Equal ByteIdentity instances compare not equal.", c1, c2);
+ assertEquals(c1, c2, "Equal ByteIdentity instances compare not equal.");
}
- public void testStringConstructor() {
+ @Test
+ void testStringConstructor() {
ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1);
ByteIdentity c2 = new ByteIdentity(Object.class, "1");
ByteIdentity c3 = new ByteIdentity(Object.class, "2");
- assertEquals("Equal ByteIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ByteIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ByteIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ByteIdentity instances compare equal");
}
- public void testIllegalStringConstructor() {
- try {
- new ByteIdentity(Object.class, "b");
- } catch (IllegalArgumentException iae) {
- return; // good
- }
- fail("No exception caught for illegal String.");
+ @Test
+ void testIllegalStringConstructor() {
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ new ByteIdentity(Object.class, "b");
+ },
+ "No exception caught for illegal String.");
}
- public void testSerialized() {
+ @Test
+ void testSerialized() {
ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1);
ByteIdentity c2 = new ByteIdentity(Object.class, "1");
ByteIdentity c3 = new ByteIdentity(Object.class, "2");
@@ -87,55 +89,56 @@ public class ByteIdentityTest extends SingleFieldIdentityTest {
Object sc1 = scis[0];
Object sc2 = scis[1];
Object sc3 = scis[2];
- assertEquals("Equal ByteIdentity instances compare not equal.", c1, sc1);
- assertEquals("Equal ByteIdentity instances compare not equal.", c2, sc2);
- assertEquals("Equal ByteIdentity instances compare not equal.", sc1, c2);
- assertEquals("Equal ByteIdentity instances compare not equal.", sc2, c1);
- assertNotEquals("Not equal ByteIdentity instances compare equal.", c1, sc3);
- assertNotEquals("Not equal ByteIdentity instances compare equal.", sc1, c3);
- assertNotEquals("Not equal ByteIdentity instances compare equal.", sc1, sc3);
- assertNotEquals("Not equal ByteIdentity instances compare equal.", sc3, sc1);
+ assertEquals(c1, sc1, "Equal ByteIdentity instances compare not equal.");
+ assertEquals(c2, sc2, "Equal ByteIdentity instances compare not equal.");
+ assertEquals(sc1, c2, "Equal ByteIdentity instances compare not equal.");
+ assertEquals(sc2, c1, "Equal ByteIdentity instances compare not equal.");
+ assertNotEquals(c1, sc3, "Not equal ByteIdentity instances compare equal.");
+ assertNotEquals(sc1, c3, "Not equal ByteIdentity instances compare equal.");
+ assertNotEquals(sc1, sc3, "Not equal ByteIdentity instances compare equal.");
+ assertNotEquals(sc3, sc1, "Not equal ByteIdentity instances compare equal.");
}
- public void testGetKeyAsObjectPrimitive() {
+ @Test
+ void testGetKeyAsObjectPrimitive() {
ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1);
- assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Byte.valueOf((byte) 1));
+ assertEquals(c1.getKeyAsObject(), Byte.valueOf((byte) 1), "keyAsObject doesn't match.");
}
- public void testGetKeyAsObject() {
+ @Test
+ void testGetKeyAsObject() {
ByteIdentity c1 = new ByteIdentity(Object.class, Byte.valueOf((byte) 1));
- assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Byte.valueOf((byte) 1));
+ assertEquals(c1.getKeyAsObject(), Byte.valueOf((byte) 1), "keyAsObject doesn't match.");
}
- public void testBadConstructorNullByteParam() {
- try {
- new ByteIdentity(Object.class, (Byte) null);
- } catch (JDONullIdentityException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
+ @Test
+ void testBadConstructorNullByteParam() {
+ assertThrows(
+ JDONullIdentityException.class,
+ () -> new ByteIdentity(Object.class, (Byte) null),
+ "Failed to catch expected exception.");
}
- public void testBadConstructorNullStringParam() {
- try {
- new ByteIdentity(Object.class, (String) null);
- } catch (JDONullIdentityException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
+ @Test
+ void testBadConstructorNullStringParam() {
+ assertThrows(
+ JDONullIdentityException.class,
+ () -> new ByteIdentity(Object.class, (String) null),
+ "Failed to catch expected exception.");
}
- public void testCompareTo() {
+ @Test
+ void testCompareTo() {
ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1);
ByteIdentity c2 = new ByteIdentity(Object.class, (byte) 1);
ByteIdentity c3 = new ByteIdentity(Object.class, (byte) 2);
ByteIdentity c4 = new ByteIdentity(Class.class, (byte) 1);
- assertEquals("Equal ByteIdentity instances compare not equal.", 0, c1.compareTo(c2));
+ assertEquals(0, c1.compareTo(c2), "Equal ByteIdentity instances compare not equal.");
assertTrue(
- "Not equal ByteIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0);
+ c1.compareTo(c3) < 0, "Not equal ByteIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal ByteIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0);
+ c3.compareTo(c1) > 0, "Not equal ByteIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal ByteIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0);
+ c1.compareTo(c4) > 0, "Not equal ByteIdentity instances have wrong compareTo result");
}
}
diff --git a/api/src/test/java/javax/jdo/identity/CharIdentityTest.java b/api/src/test/java/javax/jdo/identity/CharIdentityTest.java
index ae37de76..a9dd4f09 100644
--- a/api/src/test/java/javax/jdo/identity/CharIdentityTest.java
+++ b/api/src/test/java/javax/jdo/identity/CharIdentityTest.java
@@ -22,75 +22,74 @@
package javax.jdo.identity;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.jdo.JDONullIdentityException;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.Test;
/**
* @author clr
*/
-public class CharIdentityTest extends SingleFieldIdentityTest {
+class CharIdentityTest extends SingleFieldIdentityTest {
/** Creates a new instance of CharIdentityTest */
public CharIdentityTest() {}
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- BatchTestRunner.run(CharIdentityTest.class);
- }
-
- public void testConstructor() {
+ @Test
+ void testConstructor() {
CharIdentity c1 = new CharIdentity(Object.class, 'a');
CharIdentity c2 = new CharIdentity(Object.class, 'a');
CharIdentity c3 = new CharIdentity(Object.class, 'b');
- assertEquals("Equal CharIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal CharIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal CharIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal CharIdentity instances compare equal");
}
- public void testCharacterConstructor() {
+ @Test
+ void testCharacterConstructor() {
CharIdentity c1 = new CharIdentity(Object.class, 'a');
CharIdentity c2 = new CharIdentity(Object.class, Character.valueOf('a'));
CharIdentity c3 = new CharIdentity(Object.class, Character.valueOf('b'));
- assertEquals("Equal CharIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal CharIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal CharIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal CharIdentity instances compare equal");
}
- public void testToStringConstructor() {
+ @Test
+ void testToStringConstructor() {
CharIdentity c1 = new CharIdentity(Object.class, 'a');
CharIdentity c2 = new CharIdentity(Object.class, c1.toString());
- assertEquals("Equal CharIdentity instances compare not equal.", c1, c2);
+ assertEquals(c1, c2, "Equal CharIdentity instances compare not equal.");
}
- public void testStringConstructor() {
+ @Test
+ void testStringConstructor() {
CharIdentity c1 = new CharIdentity(Object.class, 'a');
CharIdentity c2 = new CharIdentity(Object.class, "a");
CharIdentity c3 = new CharIdentity(Object.class, "b");
- assertEquals("Equal CharIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal CharIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal CharIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal CharIdentity instances compare equal");
}
- public void testStringConstructorTooLong() {
- try {
- new CharIdentity(Object.class, "ab");
- } catch (IllegalArgumentException iae) {
- return; // good
- }
- fail("No exception caught for String too long.");
+ @Test
+ void testStringConstructorTooLong() {
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new CharIdentity(Object.class, "ab"),
+ "No exception caught for String too long.");
}
- public void testStringConstructorTooShort() {
- try {
- new CharIdentity(Object.class, "");
- } catch (IllegalArgumentException iae) {
- return; // good
- }
- fail("No exception caught for String too short.");
+ @Test
+ void testStringConstructorTooShort() {
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new CharIdentity(Object.class, ""),
+ "No exception caught for String too short.");
}
- public void testSerialized() {
+ @Test
+ void testSerialized() {
CharIdentity c1 = new CharIdentity(Object.class, 'a');
CharIdentity c2 = new CharIdentity(Object.class, "a");
CharIdentity c3 = new CharIdentity(Object.class, "b");
@@ -98,55 +97,56 @@ public class CharIdentityTest extends SingleFieldIdentityTest {
Object sc1 = scis[0];
Object sc2 = scis[1];
Object sc3 = scis[2];
- assertEquals("Equal CharIdentity instances compare not equal.", c1, sc1);
- assertEquals("Equal CharIdentity instances compare not equal.", c2, sc2);
- assertEquals("Equal CharIdentity instances compare not equal.", sc1, c2);
- assertEquals("Equal CharIdentity instances compare not equal.", sc2, c1);
- assertNotEquals("Not equal CharIdentity instances compare equal.", c1, sc3);
- assertNotEquals("Not equal CharIdentity instances compare equal.", sc1, c3);
- assertNotEquals("Not equal CharIdentity instances compare equal.", sc1, sc3);
- assertNotEquals("Not equal CharIdentity instances compare equal.", sc3, sc1);
+ assertEquals(c1, sc1, "Equal CharIdentity instances compare not equal.");
+ assertEquals(c2, sc2, "Equal CharIdentity instances compare not equal.");
+ assertEquals(sc1, c2, "Equal CharIdentity instances compare not equal.");
+ assertEquals(sc2, c1, "Equal CharIdentity instances compare not equal.");
+ assertNotEquals(c1, sc3, "Not equal CharIdentity instances compare equal.");
+ assertNotEquals(sc1, c3, "Not equal CharIdentity instances compare equal.");
+ assertNotEquals(sc1, sc3, "Not equal CharIdentity instances compare equal.");
+ assertNotEquals(sc3, sc1, "Not equal CharIdentity instances compare equal.");
}
- public void testGetKeyAsObjectPrimitive() {
+ @Test
+ void testGetKeyAsObjectPrimitive() {
CharIdentity c1 = new CharIdentity(Object.class, '1');
- assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Character.valueOf('1'));
+ assertEquals(c1.getKeyAsObject(), Character.valueOf('1'), "keyAsObject doesn't match.");
}
- public void testGetKeyAsObject() {
+ @Test
+ void testGetKeyAsObject() {
CharIdentity c1 = new CharIdentity(Object.class, Character.valueOf('1'));
- assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Character.valueOf('1'));
+ assertEquals(c1.getKeyAsObject(), Character.valueOf('1'), "keyAsObject doesn't match.");
}
- public void testBadConstructorNullCharacterParam() {
- try {
- new CharIdentity(Object.class, (Character) null);
- } catch (JDONullIdentityException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
+ @Test
+ void testBadConstructorNullCharacterParam() {
+ assertThrows(
+ JDONullIdentityException.class,
+ () -> new CharIdentity(Object.class, (Character) null),
+ "Failed to catch expected exception.");
}
- public void testBadConstructorNullStringParam() {
- try {
- new CharIdentity(Object.class, (String) null);
- } catch (JDONullIdentityException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
+ @Test
+ void testBadConstructorNullStringParam() {
+ assertThrows(
+ JDONullIdentityException.class,
+ () -> new CharIdentity(Object.class, (String) null),
+ "Failed to catch expected exception.");
}
- public void testCompareTo() {
+ @Test
+ void testCompareTo() {
CharIdentity c1 = new CharIdentity(Object.class, '1');
CharIdentity c2 = new CharIdentity(Object.class, '1');
CharIdentity c3 = new CharIdentity(Object.class, '2');
CharIdentity c4 = new CharIdentity(Class.class, '1');
- assertEquals("Equal CharIdentity instances compare not equal.", 0, c1.compareTo(c2));
+ assertEquals(0, c1.compareTo(c2), "Equal CharIdentity instances compare not equal.");
assertTrue(
- "Not equal CharIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0);
+ c1.compareTo(c3) < 0, "Not equal CharIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal CharIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0);
+ c3.compareTo(c1) > 0, "Not equal CharIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal CharIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0);
+ c1.compareTo(c4) > 0, "Not equal CharIdentity instances have wrong compareTo result");
}
}
diff --git a/api/src/test/java/javax/jdo/identity/IntIdentityTest.java b/api/src/test/java/javax/jdo/identity/IntIdentityTest.java
index 299058a5..e26c4266 100644
--- a/api/src/test/java/javax/jdo/identity/IntIdentityTest.java
+++ b/api/src/test/java/javax/jdo/identity/IntIdentityTest.java
@@ -22,64 +22,64 @@
package javax.jdo.identity;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.jdo.JDONullIdentityException;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.Test;
/** */
-public class IntIdentityTest extends SingleFieldIdentityTest {
+class IntIdentityTest extends SingleFieldIdentityTest {
/** Creates a new instance of IntIdentityTest */
public IntIdentityTest() {}
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- BatchTestRunner.run(IntIdentityTest.class);
- }
-
- public void testConstructor() {
+ @Test
+ void testConstructor() {
IntIdentity c1 = new IntIdentity(Object.class, 1);
IntIdentity c2 = new IntIdentity(Object.class, 1);
IntIdentity c3 = new IntIdentity(Object.class, 2);
- assertEquals("Equal IntIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal IntIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal IntIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal IntIdentity instances compare equal");
}
- public void testIntegerConstructor() {
+ @Test
+ void testIntegerConstructor() {
IntIdentity c1 = new IntIdentity(Object.class, 1);
IntIdentity c2 = new IntIdentity(Object.class, Integer.valueOf(1));
IntIdentity c3 = new IntIdentity(Object.class, Integer.valueOf(2));
- assertEquals("Equal intIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal IntIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal intIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal IntIdentity instances compare equal");
}
- public void testToStringConstructor() {
+ @Test
+ void testToStringConstructor() {
IntIdentity c1 = new IntIdentity(Object.class, 1);
IntIdentity c2 = new IntIdentity(Object.class, c1.toString());
- assertEquals("Equal IntIdentity instances compare not equal.", c1, c2);
+ assertEquals(c1, c2, "Equal IntIdentity instances compare not equal.");
}
- public void testStringConstructor() {
+ @Test
+ void testStringConstructor() {
IntIdentity c1 = new IntIdentity(Object.class, 1);
IntIdentity c2 = new IntIdentity(Object.class, "1");
IntIdentity c3 = new IntIdentity(Object.class, "2");
- assertEquals("Equal IntIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal IntIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal IntIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal IntIdentity instances compare equal");
}
- public void testIllegalStringConstructor() {
- try {
- new IntIdentity(Object.class, "b");
- } catch (IllegalArgumentException iae) {
- return; // good
- }
- fail("No exception caught for illegal String.");
+ @Test
+ void testIllegalStringConstructor() {
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new IntIdentity(Object.class, "b"),
+ "No exception caught for illegal String.");
}
- public void testSerialized() {
+ @Test
+ void testSerialized() {
IntIdentity c1 = new IntIdentity(Object.class, 1);
IntIdentity c2 = new IntIdentity(Object.class, "1");
IntIdentity c3 = new IntIdentity(Object.class, "2");
@@ -87,52 +87,53 @@ public class IntIdentityTest extends SingleFieldIdentityTest {
Object sc1 = scis[0];
Object sc2 = scis[1];
Object sc3 = scis[2];
- assertEquals("Equal IntIdentity instances compare not equal.", c1, sc1);
- assertEquals("Equal IntIdentity instances compare not equal.", c2, sc2);
- assertEquals("Equal IntIdentity instances compare not equal.", sc1, c2);
- assertEquals("Equal IntIdentity instances compare not equal.", sc2, c1);
- assertNotEquals("Not equal InrIdentity instances compare equal.", c1, sc3);
- assertNotEquals("Not equal IntIdentity instances compare equal.", sc1, c3);
- assertNotEquals("Not equal IntIdentity instances compare equal.", sc1, sc3);
- assertNotEquals("Not equal IntIdentity instances compare equal.", sc3, sc1);
+ assertEquals(c1, sc1, "Equal IntIdentity instances compare not equal.");
+ assertEquals(c2, sc2, "Equal IntIdentity instances compare not equal.");
+ assertEquals(sc1, c2, "Equal IntIdentity instances compare not equal.");
+ assertEquals(sc2, c1, "Equal IntIdentity instances compare not equal.");
+ assertNotEquals(c1, sc3, "Not equal InrIdentity instances compare equal.");
+ assertNotEquals(sc1, c3, "Not equal IntIdentity instances compare equal.");
+ assertNotEquals(sc1, sc3, "Not equal IntIdentity instances compare equal.");
+ assertNotEquals(sc3, sc1, "Not equal IntIdentity instances compare equal.");
}
- public void testGetKeyAsObjectPrimitive() {
+ @Test
+ void testGetKeyAsObjectPrimitive() {
IntIdentity c1 = new IntIdentity(Object.class, 1);
- assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Integer.valueOf(1));
+ assertEquals(c1.getKeyAsObject(), Integer.valueOf(1), "keyAsObject doesn't match.");
}
- public void testGetKeyAsObject() {
+ @Test
+ void testGetKeyAsObject() {
IntIdentity c1 = new IntIdentity(Object.class, Integer.valueOf(1));
- assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Integer.valueOf(1));
+ assertEquals(c1.getKeyAsObject(), Integer.valueOf(1), "keyAsObject doesn't match.");
}
- public void testBadConstructorNullIntegerParam() {
- try {
- new IntIdentity(Object.class, (Integer) null);
- } catch (JDONullIdentityException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
+ @Test
+ void testBadConstructorNullIntegerParam() {
+ assertThrows(
+ JDONullIdentityException.class,
+ () -> new IntIdentity(Object.class, (Integer) null),
+ "Failed to catch expected exception.");
}
- public void testBadConstructorNullStringParam() {
- try {
- new IntIdentity(Object.class, (String) null);
- } catch (JDONullIdentityException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
+ @Test
+ void testBadConstructorNullStringParam() {
+ assertThrows(
+ JDONullIdentityException.class,
+ () -> new IntIdentity(Object.class, (String) null),
+ "Failed to catch expected exception.");
}
- public void testCompareTo() {
+ @Test
+ void testCompareTo() {
IntIdentity c1 = new IntIdentity(Object.class, 1);
IntIdentity c2 = new IntIdentity(Object.class, 1);
IntIdentity c3 = new IntIdentity(Object.class, 2);
IntIdentity c4 = new IntIdentity(Class.class, 1);
- assertEquals("Equal IntIdentity instances compare not equal.", 0, c1.compareTo(c2));
- assertTrue("Not equal IntIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0);
- assertTrue("Not equal IntIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0);
- assertTrue("Not equal IntIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0);
+ assertEquals(0, c1.compareTo(c2), "Equal IntIdentity instances compare not equal.");
+ assertTrue(c1.compareTo(c3) < 0, "Not equal IntIdentity instances have wrong compareTo result");
+ assertTrue(c3.compareTo(c1) > 0, "Not equal IntIdentity instances have wrong compareTo result");
+ assertTrue(c1.compareTo(c4) > 0, "Not equal IntIdentity instances have wrong compareTo result");
}
}
diff --git a/api/src/test/java/javax/jdo/identity/LongIdentityTest.java b/api/src/test/java/javax/jdo/identity/LongIdentityTest.java
index 3f373956..5a8c0629 100644
--- a/api/src/test/java/javax/jdo/identity/LongIdentityTest.java
+++ b/api/src/test/java/javax/jdo/identity/LongIdentityTest.java
@@ -22,66 +22,66 @@
package javax.jdo.identity;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.jdo.JDONullIdentityException;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.Test;
/** */
-public class LongIdentityTest extends SingleFieldIdentityTest {
+class LongIdentityTest extends SingleFieldIdentityTest {
/** Creates a new instance of LongIdentityTest */
public LongIdentityTest() {}
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- BatchTestRunner.run(LongIdentityTest.class);
- }
-
- public void testConstructor() {
+ @Test
+ void testConstructor() {
LongIdentity c1 = new LongIdentity(Object.class, 1);
LongIdentity c2 = new LongIdentity(Object.class, 1);
LongIdentity c3 = new LongIdentity(Object.class, 2);
LongIdentity c4 = new LongIdentity(Object.class, 0x100000001L);
- assertEquals("Equal LongIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal LongIdentity instances compare equal", c1, c3);
- assertNotEquals("Not equal LongIdentity instances compare equal", c4, c1);
+ assertEquals(c1, c2, "Equal LongIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal LongIdentity instances compare equal");
+ assertNotEquals(c4, c1, "Not equal LongIdentity instances compare equal");
}
- public void testLongConstructor() {
+ @Test
+ void testLongConstructor() {
LongIdentity c1 = new LongIdentity(Object.class, 1);
LongIdentity c2 = new LongIdentity(Object.class, Long.valueOf(1));
LongIdentity c3 = new LongIdentity(Object.class, Long.valueOf(2));
- assertEquals("Equal LongIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal LongIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal LongIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal LongIdentity instances compare equal");
}
- public void testToStringConstructor() {
+ @Test
+ void testToStringConstructor() {
LongIdentity c1 = new LongIdentity(Object.class, Long.MAX_VALUE);
LongIdentity c2 = new LongIdentity(Object.class, c1.toString());
- assertEquals("Equal LongIdentity instances compare not equal.", c1, c2);
+ assertEquals(c1, c2, "Equal LongIdentity instances compare not equal.");
}
- public void testStringConstructor() {
+ @Test
+ void testStringConstructor() {
LongIdentity c1 = new LongIdentity(Object.class, 1);
LongIdentity c2 = new LongIdentity(Object.class, "1");
LongIdentity c3 = new LongIdentity(Object.class, "2");
- assertEquals("Equal LongIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal LongIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal LongIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal LongIdentity instances compare equal");
}
- public void testIllegalStringConstructor() {
- try {
- new LongIdentity(Object.class, "b");
- } catch (IllegalArgumentException iae) {
- return; // good
- }
- fail("No exception caught for illegal String.");
+ @Test
+ void testIllegalStringConstructor() {
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new LongIdentity(Object.class, "b"),
+ "No exception caught for illegal String.");
}
- public void testSerialized() {
+ @Test
+ void testSerialized() {
LongIdentity c1 = new LongIdentity(Object.class, 1);
LongIdentity c2 = new LongIdentity(Object.class, "1");
LongIdentity c3 = new LongIdentity(Object.class, "2");
@@ -89,58 +89,59 @@ public class LongIdentityTest extends SingleFieldIdentityTest {
Object sc1 = scis[0];
Object sc2 = scis[1];
Object sc3 = scis[2];
- assertEquals("Equal LongIdentity instances compare not equal.", c1, sc1);
- assertEquals("Equal LongIdentity instances compare not equal.", c2, sc2);
- assertEquals("Equal LongIdentity instances compare not equal.", sc1, c2);
- assertEquals("Equal LongIdentity instances compare not equal.", sc2, c1);
- assertNotEquals("Not equal LongIdentity instances compare equal.", c1, sc3);
- assertNotEquals("Not equal LongIdentity instances compare equal.", sc1, c3);
- assertNotEquals("Not equal LongIdentity instances compare equal.", sc1, sc3);
- assertNotEquals("Not equal LongIdentity instances compare equal.", sc3, sc1);
+ assertEquals(c1, sc1, "Equal LongIdentity instances compare not equal.");
+ assertEquals(c2, sc2, "Equal LongIdentity instances compare not equal.");
+ assertEquals(sc1, c2, "Equal LongIdentity instances compare not equal.");
+ assertEquals(sc2, c1, "Equal LongIdentity instances compare not equal.");
+ assertNotEquals(c1, sc3, "Not equal LongIdentity instances compare equal.");
+ assertNotEquals(sc1, c3, "Not equal LongIdentity instances compare equal.");
+ assertNotEquals(sc1, sc3, "Not equal LongIdentity instances compare equal.");
+ assertNotEquals(sc3, sc1, "Not equal LongIdentity instances compare equal.");
}
- public void testGetKeyAsObjectPrimitive() {
+ @Test
+ void testGetKeyAsObjectPrimitive() {
LongIdentity c1 = new LongIdentity(Object.class, 1L);
- assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Long.valueOf(1L));
+ assertEquals(c1.getKeyAsObject(), Long.valueOf(1L), "keyAsObject doesn't match.");
}
- public void testGetKeyAsObject() {
+ @Test
+ void testGetKeyAsObject() {
LongIdentity c1 = new LongIdentity(Object.class, Long.valueOf(1L));
- assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Long.valueOf(1L));
+ assertEquals(c1.getKeyAsObject(), Long.valueOf(1L), "keyAsObject doesn't match.");
}
- public void testBadConstructorNullShortParam() {
- try {
- new LongIdentity(Object.class, (Long) null);
- } catch (JDONullIdentityException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
+ @Test
+ void testBadConstructorNullShortParam() {
+ assertThrows(
+ JDONullIdentityException.class,
+ () -> new LongIdentity(Object.class, (Long) null),
+ "Failed to catch expected exception.");
}
- public void testBadConstructorNullStringParam() {
- try {
- new LongIdentity(Object.class, (String) null);
- } catch (JDONullIdentityException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
+ @Test
+ void testBadConstructorNullStringParam() {
+ assertThrows(
+ JDONullIdentityException.class,
+ () -> new LongIdentity(Object.class, (String) null),
+ "Failed to catch expected exception.");
}
- public void testCompareTo() {
+ @Test
+ void testCompareTo() {
LongIdentity c1 = new LongIdentity(Object.class, 1);
LongIdentity c2 = new LongIdentity(Object.class, 1);
LongIdentity c3 = new LongIdentity(Object.class, 2);
LongIdentity c4 = new LongIdentity(Class.class, 1);
LongIdentity c5 = new LongIdentity(Object.class, 0x100000001L);
- assertEquals("Equal LongIdentity instances compare not equal.", 0, c1.compareTo(c2));
+ assertEquals(0, c1.compareTo(c2), "Equal LongIdentity instances compare not equal.");
assertTrue(
- "Not equal LongIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0);
+ c1.compareTo(c3) < 0, "Not equal LongIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal LongIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0);
+ c3.compareTo(c1) > 0, "Not equal LongIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal LongIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0);
+ c1.compareTo(c4) > 0, "Not equal LongIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal LongIdentity instances have wrong compareTo result", c5.compareTo(c1) > 0);
+ c5.compareTo(c1) > 0, "Not equal LongIdentity instances have wrong compareTo result");
}
}
diff --git a/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java b/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java
index 94f9cbb2..2177d9fa 100644
--- a/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java
+++ b/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java
@@ -21,7 +21,11 @@
*/
package javax.jdo.identity;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
@@ -38,10 +42,10 @@ import javax.jdo.JDONullIdentityException;
import javax.jdo.JDOUserException;
import javax.jdo.LegacyJava;
import javax.jdo.spi.JDOImplHelper;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.Test;
/** */
-public class ObjectIdentityTest extends SingleFieldIdentityTest {
+class ObjectIdentityTest extends SingleFieldIdentityTest {
/** The JDOImplHelper instance used for Date formatting. */
private static final JDOImplHelper helper = doPrivileged(JDOImplHelper::getInstance);
@@ -61,190 +65,195 @@ public class ObjectIdentityTest extends SingleFieldIdentityTest {
/** Creates a new instance of ObjectIdentityTest */
public ObjectIdentityTest() {}
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- BatchTestRunner.run(ObjectIdentityTest.class);
- }
-
- public void testConstructor() {
+ @Test
+ void testConstructor() {
ObjectIdentity c1 = new ObjectIdentity(Object.class, new IdClass(1));
ObjectIdentity c2 = new ObjectIdentity(Object.class, new IdClass(1));
ObjectIdentity c3 = new ObjectIdentity(Object.class, new IdClass(2));
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ObjectIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ObjectIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ObjectIdentity instances compare equal");
}
- public void testIntegerConstructor() {
+ @Test
+ void testIntegerConstructor() {
ObjectIdentity c1 = new ObjectIdentity(Object.class, Integer.valueOf(1));
ObjectIdentity c2 = new ObjectIdentity(Object.class, Integer.valueOf(1));
ObjectIdentity c3 = new ObjectIdentity(Object.class, Integer.valueOf(2));
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ObjectIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ObjectIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ObjectIdentity instances compare equal");
}
- public void testLongConstructor() {
+ @Test
+ void testLongConstructor() {
ObjectIdentity c1 = new ObjectIdentity(Object.class, Long.valueOf(1));
ObjectIdentity c2 = new ObjectIdentity(Object.class, Long.valueOf(1));
ObjectIdentity c3 = new ObjectIdentity(Object.class, Long.valueOf(2));
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ObjectIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ObjectIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ObjectIdentity instances compare equal");
}
- public void testDateConstructor() {
+ @Test
+ void testDateConstructor() {
ObjectIdentity c1 = new ObjectIdentity(Object.class, new Date(1));
ObjectIdentity c2 = new ObjectIdentity(Object.class, new Date(1));
ObjectIdentity c3 = new ObjectIdentity(Object.class, new Date(2));
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ObjectIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ObjectIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ObjectIdentity instances compare equal");
}
- public void testLocaleConstructor() {
+ @Test
+ void testLocaleConstructor() {
ObjectIdentity c1 = new ObjectIdentity(Object.class, Locale.US);
ObjectIdentity c2 = new ObjectIdentity(Object.class, Locale.US);
ObjectIdentity c3 = new ObjectIdentity(Object.class, Locale.GERMANY);
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ObjectIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ObjectIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ObjectIdentity instances compare equal");
}
- public void testCurrencyConstructor() {
+ @Test
+ void testCurrencyConstructor() {
if (!isClassLoadable("java.util.Currency")) return;
ObjectIdentity c1 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.US));
ObjectIdentity c2 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.US));
ObjectIdentity c3 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.GERMANY));
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ObjectIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ObjectIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ObjectIdentity instances compare equal");
}
- public void testStringConstructor() {
+ @Test
+ void testStringConstructor() {
ObjectIdentity c1 =
new ObjectIdentity(Object.class, "javax.jdo.identity.ObjectIdentityTest$IdClass:1");
ObjectIdentity c2 =
new ObjectIdentity(Object.class, "javax.jdo.identity.ObjectIdentityTest$IdClass:1");
ObjectIdentity c3 =
new ObjectIdentity(Object.class, "javax.jdo.identity.ObjectIdentityTest$IdClass:2");
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ObjectIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ObjectIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ObjectIdentity instances compare equal");
}
- public void testToStringConstructor() {
+ @Test
+ void testToStringConstructor() {
ObjectIdentity c1 = new ObjectIdentity(Object.class, new IdClass(1));
ObjectIdentity c2 = new ObjectIdentity(Object.class, c1.toString());
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2);
+ assertEquals(c1, c2, "Equal ObjectIdentity instances compare not equal.");
}
- public void testDateCompareTo() {
+ @Test
+ void testDateCompareTo() {
ObjectIdentity c1 = new ObjectIdentity(Object.class, new Date(1));
ObjectIdentity c2 = new ObjectIdentity(Object.class, new Date(1));
ObjectIdentity c3 = new ObjectIdentity(Object.class, new Date(2));
ObjectIdentity c4 = new ObjectIdentity(Class.class, new Date(1));
- assertEquals("Equal ObjectIdentity instances compare not equal.", 0, c1.compareTo(c2));
+ assertEquals(0, c1.compareTo(c2), "Equal ObjectIdentity instances compare not equal.");
assertTrue(
- "Not equal ObjectIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0);
+ c1.compareTo(c3) < 0, "Not equal ObjectIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal ObjectIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0);
+ c3.compareTo(c1) > 0, "Not equal ObjectIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal ObjectIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0);
- }
-
- public void testBadStringConstructorNullClass() {
- try {
- new ObjectIdentity(null, "1");
- } catch (NullPointerException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
- }
-
- public void testBadStringConstructorNullParam() {
- try {
- new ObjectIdentity(Object.class, null);
- } catch (JDONullIdentityException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
- }
-
- public void testBadStringConstructorTooShort() {
- try {
- new ObjectIdentity(Object.class, "xx");
- } catch (JDOUserException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
- }
-
- public void testBadStringConstructorNoDelimiter() {
- try {
- new ObjectIdentity(Object.class, "xxxxxxxxx");
- } catch (JDOUserException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
- }
-
- public void testBadStringConstructorBadClassName() {
- try {
- new ObjectIdentity(Object.class, "xx:yy");
- } catch (JDOUserException ex) {
- validateNestedException(ex, ClassNotFoundException.class);
- return;
- }
- fail("Failed to catch expected ClassNotFoundException.");
- }
-
- public void testBadStringConstructorNoStringConstructor() {
- try {
- new ObjectIdentity(
- Object.class, "javax.jdo.identity.ObjectIdentityTest$BadIdClassNoStringConstructor:yy");
- } catch (JDOUserException ex) {
- validateNestedException(ex, NoSuchMethodException.class);
- return;
- }
- fail("Failed to catch expected NoSuchMethodException.");
- }
-
- public void testBadStringConstructorNoPublicStringConstructor() {
- try {
- new ObjectIdentity(
- Object.class,
- "javax.jdo.identity.ObjectIdentityTest$BadIdClassNoPublicStringConstructor:yy");
- } catch (JDOUserException ex) {
- validateNestedException(ex, NoSuchMethodException.class);
- return;
- }
- fail("Failed to catch expected NoSuchMethodException.");
- }
-
- public void testBadStringConstructorIllegalArgument() {
- try {
- new ObjectIdentity(Object.class, "javax.jdo.identity.ObjectIdentityTest$IdClass:yy");
- } catch (JDOUserException ex) {
- validateNestedException(ex, InvocationTargetException.class);
- return;
- }
- fail("Failed to catch expected InvocationTargetException.");
- }
-
- public void testStringDateConstructor() {
+ c1.compareTo(c4) > 0, "Not equal ObjectIdentity instances have wrong compareTo result");
+ }
+
+ @Test
+ void testBadStringConstructorNullClass() {
+ assertThrows(
+ NullPointerException.class,
+ () -> new ObjectIdentity(null, "1"),
+ "Failed to catch expected exception.");
+ }
+
+ @Test
+ void testBadStringConstructorNullParam() {
+ assertThrows(
+ JDONullIdentityException.class,
+ () -> new ObjectIdentity(Object.class, null),
+ "Failed to catch expected exception.");
+ }
+
+ @Test
+ void testBadStringConstructorTooShort() {
+ assertThrows(
+ JDOUserException.class,
+ () -> new ObjectIdentity(Object.class, "xx"),
+ "Failed to catch expected exception.");
+ }
+
+ @Test
+ void testBadStringConstructorNoDelimiter() {
+ assertThrows(
+ JDOUserException.class,
+ () -> new ObjectIdentity(Object.class, "xxxxxxxxx"),
+ "Failed to catch expected exception.");
+ }
+
+ @Test
+ void testBadStringConstructorBadClassName() {
+ JDOUserException ex =
+ assertThrows(
+ JDOUserException.class,
+ () -> new ObjectIdentity(Object.class, "xx:yy"),
+ "Failed to catch expected ClassNotFoundException.");
+ validateNestedException(ex, ClassNotFoundException.class);
+ }
+
+ @Test
+ void testBadStringConstructorNoStringConstructor() {
+ JDOUserException ex =
+ assertThrows(
+ JDOUserException.class,
+ () ->
+ new ObjectIdentity(
+ Object.class,
+ "javax.jdo.identity.ObjectIdentityTest$BadIdClassNoStringConstructor:yy"),
+ "Failed to catch expected NoSuchMethodException.");
+ validateNestedException(ex, NoSuchMethodException.class);
+ }
+
+ @Test
+ void testBadStringConstructorNoPublicStringConstructor() {
+ JDOUserException ex =
+ assertThrows(
+ JDOUserException.class,
+ () ->
+ new ObjectIdentity(
+ Object.class,
+ "javax.jdo.identity.ObjectIdentityTest$BadIdClassNoPublicStringConstructor:yy"),
+ "Failed to catch expected NoSuchMethodException.");
+ validateNestedException(ex, NoSuchMethodException.class);
+ }
+
+ @Test
+ void testBadStringConstructorIllegalArgument() {
+ JDOUserException ex =
+ assertThrows(
+ JDOUserException.class,
+ () ->
+ new ObjectIdentity(
+ Object.class, "javax.jdo.identity.ObjectIdentityTest$IdClass:yy"),
+ "Failed to catch expected InvocationTargetException.");
+ validateNestedException(ex, InvocationTargetException.class);
+ }
+
+ @Test
+ void testStringDateConstructor() {
SimpleDateFormat usDateFormat = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a", Locale.US);
helper.registerDateFormat(usDateFormat);
// construct date instance for 1.1.1970 00:00:00
Calendar cal = Calendar.getInstance(Locale.US);
cal.clear();
- cal.set(1970, 0, 1, 0, 0, 0);
+ cal.set(1970, Calendar.JANUARY, 1, 0, 0, 0);
Date date = cal.getTime();
ObjectIdentity c1 = new ObjectIdentity(Object.class, "java.util.Date:Jan 01, 1970 00:00:00 AM");
ObjectIdentity c2 = new ObjectIdentity(Object.class, date);
- assertEquals("Equal ObjectIdentity instances compare not equal.", 0, c1.compareTo(c2));
+ assertEquals(0, c1.compareTo(c2), "Equal ObjectIdentity instances compare not equal.");
helper.registerDateFormat(DateFormat.getDateTimeInstance());
}
- public void testStringDefaultDateConstructor() {
+ @Test
+ void testStringDefaultDateConstructor() {
DateFormat dateFormat = DateFormat.getDateTimeInstance();
Calendar cal = Calendar.getInstance();
// nullify millisecond field since dateFormat does not take milliseconds into account
@@ -254,61 +263,66 @@ public class ObjectIdentityTest extends SingleFieldIdentityTest {
ObjectIdentity c1 = new ObjectIdentity(Object.class, "java.util.Date:" + dateAsString);
ObjectIdentity c2 = new ObjectIdentity(Object.class, date);
- assertEquals("Equal ObjectIdentity instances compare not equal.", 0, c1.compareTo(c2));
+ assertEquals(0, c1.compareTo(c2), "Equal ObjectIdentity instances compare not equal.");
}
- public void testBadStringDateConstructor() {
- try {
- new ObjectIdentity(Object.class, "java.util.Date:Jop 1, 1970 00:00:00");
- } catch (JDOUserException ex) {
- return;
- }
- fail("Failed to catch expected Exception.");
+ @Test
+ void testBadStringDateConstructor() {
+ assertThrows(
+ JDOUserException.class,
+ () -> new ObjectIdentity(Object.class, "java.util.Date:Jop 1, 1970 00:00:00"),
+ "Failed to catch expected Exception.");
}
- public void testStringLocaleConstructorLanguage() {
+ @Test
+ void testStringLocaleConstructorLanguage() {
if (!isClassLoadable("java.util.Currency")) return;
SingleFieldIdentity<ObjectIdentity> c1 =
new ObjectIdentity(Object.class, "java.util.Locale:en");
assertEquals(new Locale("en"), c1.getKeyAsObject());
}
- public void testStringLocaleConstructorCountry() {
+ @Test
+ void testStringLocaleConstructorCountry() {
SingleFieldIdentity<ObjectIdentity> c1 =
new ObjectIdentity(Object.class, "java.util.Locale:_US");
assertEquals(new Locale("", "US"), c1.getKeyAsObject());
}
- public void testStringLocaleConstructorLanguageCountry() {
+ @Test
+ void testStringLocaleConstructorLanguageCountry() {
SingleFieldIdentity<ObjectIdentity> c1 =
new ObjectIdentity(Object.class, "java.util.Locale:en_US");
assertEquals(new Locale("en", "US"), c1.getKeyAsObject());
}
- public void testStringLocaleConstructorLanguageCountryVariant() {
+ @Test
+ void testStringLocaleConstructorLanguageCountryVariant() {
SingleFieldIdentity<ObjectIdentity> c1 =
new ObjectIdentity(Object.class, "java.util.Locale:en_US_MAC");
assertEquals(new Locale("en", "US", "MAC"), c1.getKeyAsObject());
}
- public void testStringCurrencyConstructor() {
+ @Test
+ void testStringCurrencyConstructor() {
if (!isClassLoadable("java.util.Currency")) return;
ObjectIdentity c1 = new ObjectIdentity(Object.class, "java.util.Currency:USD");
- assertEquals("Expected USD currency", Currency.getInstance("USD"), c1.getKeyAsObject());
+ assertEquals(Currency.getInstance("USD"), c1.getKeyAsObject(), "Expected USD currency");
}
- public void testBadStringCurrencyConstructor() {
+ @Test
+ void testBadStringCurrencyConstructor() {
if (!isClassLoadable("java.util.Currency")) return;
- try {
- new ObjectIdentity(Object.class, "java.util.Currency:NowhereInTheWorld");
- } catch (JDOUserException ex) {
- validateNestedException(ex, IllegalArgumentException.class);
- return;
- }
- fail("Failed to catch expected IllegalArgumentException.");
+ JDOUserException ex =
+ assertThrows(
+ JDOUserException.class,
+ () -> new ObjectIdentity(Object.class, "java.util.Currency:NowhereInTheWorld"),
+ "Failed to catch expected IllegalArgumentException.");
+ validateNestedException(ex, IllegalArgumentException.class);
}
- public void testSerializedIdClass() {
+ @Test
+ void testSerializedIdClass() {
ObjectIdentity c1 = new ObjectIdentity(Object.class, new IdClass(1));
ObjectIdentity c2 = new ObjectIdentity(Object.class, new IdClass(1));
ObjectIdentity c3 = new ObjectIdentity(Object.class, new IdClass(2));
@@ -316,17 +330,18 @@ public class ObjectIdentityTest extends SingleFieldIdentityTest {
Object sc1 = scis[0];
Object sc2 = scis[1];
Object sc3 = scis[2];
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, sc1);
- assertEquals("Equal ObjectIdentity instances compare not equal.", c2, sc2);
- assertEquals("Equal ObjectIdentity instances compare not equal.", sc1, c2);
- assertEquals("Equal ObjectIdentity instances compare not equal.", sc2, c1);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", c1, sc3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc1, c3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc1, sc3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc3, sc1);
- }
-
- public void testSerializedBigDecimal() {
+ assertEquals(c1, sc1, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(c2, sc2, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(sc1, c2, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(sc2, c1, "Equal ObjectIdentity instances compare not equal.");
+ assertNotEquals(c1, sc3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc1, c3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc1, sc3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc3, sc1, "Not equal ObjectIdentity instances compare equal.");
+ }
+
+ @Test
+ void testSerializedBigDecimal() {
ObjectIdentity c1 = new ObjectIdentity(Object.class, new BigDecimal("123456789.012"));
ObjectIdentity c2 = new ObjectIdentity(Object.class, new BigDecimal("123456789.012"));
ObjectIdentity c3 = new ObjectIdentity(Object.class, new BigDecimal("123456789.01"));
@@ -334,17 +349,18 @@ public class ObjectIdentityTest extends SingleFieldIdentityTest {
Object sc1 = scis[0];
Object sc2 = scis[1];
Object sc3 = scis[2];
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, sc1);
- assertEquals("Equal ObjectIdentity instances compare not equal.", c2, sc2);
- assertEquals("Equal ObjectIdentity instances compare not equal.", sc1, c2);
- assertEquals("Equal ObjectIdentity instances compare not equal.", sc2, c1);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", c1, sc3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc1, c3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc1, sc3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc3, sc1);
- }
-
- public void testSerializedCurrency() {
+ assertEquals(c1, sc1, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(c2, sc2, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(sc1, c2, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(sc2, c1, "Equal ObjectIdentity instances compare not equal.");
+ assertNotEquals(c1, sc3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc1, c3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc1, sc3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc3, sc1, "Not equal ObjectIdentity instances compare equal.");
+ }
+
+ @Test
+ void testSerializedCurrency() {
if (!isClassLoadable("java.util.Currency")) return;
ObjectIdentity c1 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.US));
ObjectIdentity c2 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.US));
@@ -353,17 +369,18 @@ public class ObjectIdentityTest extends SingleFieldIdentityTest {
Object sc1 = scis[0];
Object sc2 = scis[1];
Object sc3 = scis[2];
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, sc1);
- assertEquals("Equal ObjectIdentity instances compare not equal.", c2, sc2);
- assertEquals("Equal ObjectIdentity instances compare not equal.", sc1, c2);
- assertEquals("Equal ObjectIdentity instances compare not equal.", sc2, c1);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", c1, sc3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc1, c3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc1, sc3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc3, sc1);
- }
-
- public void testSerializedDate() {
+ assertEquals(c1, sc1, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(c2, sc2, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(sc1, c2, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(sc2, c1, "Equal ObjectIdentity instances compare not equal.");
+ assertNotEquals(c1, sc3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc1, c3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc1, sc3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc3, sc1, "Not equal ObjectIdentity instances compare equal.");
+ }
+
+ @Test
+ void testSerializedDate() {
ObjectIdentity c1 = new ObjectIdentity(Object.class, new Date(1));
ObjectIdentity c2 = new ObjectIdentity(Object.class, "java.util.Date:1");
ObjectIdentity c3 = new ObjectIdentity(Object.class, new Date(2));
@@ -371,17 +388,18 @@ public class ObjectIdentityTest extends SingleFieldIdentityTest {
Object sc1 = scis[0];
Object sc2 = scis[1];
Object sc3 = scis[2];
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, sc1);
- assertEquals("Equal ObjectIdentity instances compare not equal.", c2, sc2);
- assertEquals("Equal ObjectIdentity instances compare not equal.", sc1, c2);
- assertEquals("Equal ObjectIdentity instances compare not equal.", sc2, c1);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", c1, sc3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc1, c3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc1, sc3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc3, sc1);
- }
-
- public void testSerializedLocale() {
+ assertEquals(c1, sc1, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(c2, sc2, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(sc1, c2, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(sc2, c1, "Equal ObjectIdentity instances compare not equal.");
+ assertNotEquals(c1, sc3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc1, c3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc1, sc3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc3, sc1, "Not equal ObjectIdentity instances compare equal.");
+ }
+
+ @Test
+ void testSerializedLocale() {
ObjectIdentity c1 = new ObjectIdentity(Object.class, Locale.US);
ObjectIdentity c2 = new ObjectIdentity(Object.class, Locale.US);
ObjectIdentity c3 = new ObjectIdentity(Object.class, Locale.GERMANY);
@@ -389,19 +407,20 @@ public class ObjectIdentityTest extends SingleFieldIdentityTest {
Object sc1 = scis[0];
Object sc2 = scis[1];
Object sc3 = scis[2];
- assertEquals("Equal ObjectIdentity instances compare not equal.", c1, sc1);
- assertEquals("Equal ObjectIdentity instances compare not equal.", c2, sc2);
- assertEquals("Equal ObjectIdentity instances compare not equal.", sc1, c2);
- assertEquals("Equal ObjectIdentity instances compare not equal.", sc2, c1);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", c1, sc3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc1, c3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc1, sc3);
- assertNotEquals("Not equal ObjectIdentity instances compare equal.", sc3, sc1);
- }
-
- public void testGetKeyAsObject() {
+ assertEquals(c1, sc1, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(c2, sc2, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(sc1, c2, "Equal ObjectIdentity instances compare not equal.");
+ assertEquals(sc2, c1, "Equal ObjectIdentity instances compare not equal.");
+ assertNotEquals(c1, sc3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc1, c3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc1, sc3, "Not equal ObjectIdentity instances compare equal.");
+ assertNotEquals(sc3, sc1, "Not equal ObjectIdentity instances compare equal.");
+ }
+
+ @Test
+ void testGetKeyAsObject() {
ObjectIdentity c1 = new ObjectIdentity(Object.class, new IdClass(1));
- assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), new IdClass(1));
+ assertEquals(c1.getKeyAsObject(), new IdClass(1), "keyAsObject doesn't match.");
}
private <T> void validateNestedException(JDOUserException ex, Class<T> expected) {
diff --git a/api/src/test/java/javax/jdo/identity/ShortIdentityTest.java b/api/src/test/java/javax/jdo/identity/ShortIdentityTest.java
index c13ededb..53ad3cb9 100644
--- a/api/src/test/java/javax/jdo/identity/ShortIdentityTest.java
+++ b/api/src/test/java/javax/jdo/identity/ShortIdentityTest.java
@@ -22,64 +22,64 @@
package javax.jdo.identity;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.jdo.JDONullIdentityException;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.Test;
/** */
-public class ShortIdentityTest extends SingleFieldIdentityTest {
+class ShortIdentityTest extends SingleFieldIdentityTest {
/** Creates a new instance of ShortIdentityTest */
public ShortIdentityTest() {}
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- BatchTestRunner.run(ShortIdentityTest.class);
- }
-
- public void testConstructor() {
+ @Test
+ void testConstructor() {
ShortIdentity c1 = new ShortIdentity(Object.class, (short) 1);
ShortIdentity c2 = new ShortIdentity(Object.class, (short) 1);
ShortIdentity c3 = new ShortIdentity(Object.class, (short) 2);
- assertEquals("Equal ShortIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ShortIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ShortIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ShortIdentity instances compare equal");
}
- public void testShortConstructor() {
+ @Test
+ void testShortConstructor() {
ShortIdentity c1 = new ShortIdentity(Object.class, (short) 1);
ShortIdentity c2 = new ShortIdentity(Object.class, Short.valueOf((short) 1));
ShortIdentity c3 = new ShortIdentity(Object.class, Short.valueOf((short) 2));
- assertEquals("Equal ShortIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ShortIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ShortIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ShortIdentity instances compare equal");
}
- public void testToStringConstructor() {
+ @Test
+ void testToStringConstructor() {
ShortIdentity c1 = new ShortIdentity(Object.class, Short.MAX_VALUE);
ShortIdentity c2 = new ShortIdentity(Object.class, c1.toString());
- assertEquals("Equal ShortIdentity instances compare not equal.", c1, c2);
+ assertEquals(c1, c2, "Equal ShortIdentity instances compare not equal.");
}
- public void testStringConstructor() {
+ @Test
+ void testStringConstructor() {
ShortIdentity c1 = new ShortIdentity(Object.class, (short) 1);
ShortIdentity c2 = new ShortIdentity(Object.class, "1");
ShortIdentity c3 = new ShortIdentity(Object.class, "2");
- assertEquals("Equal ShortIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal ShortIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal ShortIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal ShortIdentity instances compare equal");
}
- public void testIllegalStringConstructor() {
- try {
- new ShortIdentity(Object.class, "b");
- } catch (IllegalArgumentException iae) {
- return; // good
- }
- fail("No exception caught for illegal String.");
+ @Test
+ void testIllegalStringConstructor() {
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new ShortIdentity(Object.class, "b"),
+ "No exception caught for illegal String.");
}
- public void testSerialized() {
+ @Test
+ void testSerialized() {
ShortIdentity c1 = new ShortIdentity(Object.class, (short) 1);
ShortIdentity c2 = new ShortIdentity(Object.class, "1");
ShortIdentity c3 = new ShortIdentity(Object.class, "2");
@@ -87,55 +87,56 @@ public class ShortIdentityTest extends SingleFieldIdentityTest {
Object sc1 = scis[0];
Object sc2 = scis[1];
Object sc3 = scis[2];
- assertEquals("Equal ShortIdentity instances compare not equal.", c1, sc1);
- assertEquals("Equal ShortIdentity instances compare not equal.", c2, sc2);
- assertEquals("Equal ShortIdentity instances compare not equal.", sc1, c2);
- assertEquals("Equal ShortIdentity instances compare not equal.", sc2, c1);
- assertNotEquals("Not equal ShortIdentity instances compare equal.", c1, sc3);
- assertNotEquals("Not equal ShortIdentity instances compare equal.", sc1, c3);
- assertNotEquals("Not equal ShortIdentity instances compare equal.", sc1, sc3);
- assertNotEquals("Not equal ShortIdentity instances compare equal.", sc3, sc1);
+ assertEquals(c1, sc1, "Equal ShortIdentity instances compare not equal.");
+ assertEquals(c2, sc2, "Equal ShortIdentity instances compare not equal.");
+ assertEquals(sc1, c2, "Equal ShortIdentity instances compare not equal.");
+ assertEquals(sc2, c1, "Equal ShortIdentity instances compare not equal.");
+ assertNotEquals(c1, sc3, "Not equal ShortIdentity instances compare equal.");
+ assertNotEquals(sc1, c3, "Not equal ShortIdentity instances compare equal.");
+ assertNotEquals(sc1, sc3, "Not equal ShortIdentity instances compare equal.");
+ assertNotEquals(sc3, sc1, "Not equal ShortIdentity instances compare equal.");
}
- public void testGetKeyAsObjectPrimitive() {
+ @Test
+ void testGetKeyAsObjectPrimitive() {
ShortIdentity c1 = new ShortIdentity(Object.class, (short) 1);
- assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Short.valueOf((short) 1));
+ assertEquals(c1.getKeyAsObject(), Short.valueOf((short) 1), "keyAsObject doesn't match.");
}
- public void testGetKeyAsObject() {
+ @Test
+ void testGetKeyAsObject() {
ShortIdentity c1 = new ShortIdentity(Object.class, Short.valueOf((short) 1));
- assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Short.valueOf((short) 1));
+ assertEquals(c1.getKeyAsObject(), Short.valueOf((short) 1), "keyAsObject doesn't match.");
}
- public void testBadConstructorNullShortParam() {
- try {
- new ShortIdentity(Object.class, (Short) null);
- } catch (JDONullIdentityException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
+ @Test
+ void testBadConstructorNullShortParam() {
+ assertThrows(
+ JDONullIdentityException.class,
+ () -> new ShortIdentity(Object.class, (Short) null),
+ "Failed to catch expected exception.");
}
- public void testBadConstructorNullStringParam() {
- try {
- new ShortIdentity(Object.class, (String) null);
- } catch (JDONullIdentityException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
+ @Test
+ void testBadConstructorNullStringParam() {
+ assertThrows(
+ JDONullIdentityException.class,
+ () -> new ShortIdentity(Object.class, (String) null),
+ "Failed to catch expected exception.");
}
- public void testCompareTo() {
+ @Test
+ void testCompareTo() {
ShortIdentity c1 = new ShortIdentity(Object.class, (short) 1);
ShortIdentity c2 = new ShortIdentity(Object.class, (short) 1);
ShortIdentity c3 = new ShortIdentity(Object.class, (short) 2);
ShortIdentity c4 = new ShortIdentity(Class.class, (short) 1);
- assertEquals("Equal ShortIdentity instances compare not equal.", 0, c1.compareTo(c2));
+ assertEquals(0, c1.compareTo(c2), "Equal ShortIdentity instances compare not equal.");
assertTrue(
- "Not equal ShortIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0);
+ c1.compareTo(c3) < 0, "Not equal ShortIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal ShortIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0);
+ c3.compareTo(c1) > 0, "Not equal ShortIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal ShortIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0);
+ c1.compareTo(c4) > 0, "Not equal ShortIdentity instances have wrong compareTo result");
}
}
diff --git a/api/src/test/java/javax/jdo/identity/SingleFieldIdentityTest.java b/api/src/test/java/javax/jdo/identity/SingleFieldIdentityTest.java
index dc8d8775..b2256024 100644
--- a/api/src/test/java/javax/jdo/identity/SingleFieldIdentityTest.java
+++ b/api/src/test/java/javax/jdo/identity/SingleFieldIdentityTest.java
@@ -22,15 +22,19 @@
package javax.jdo.identity;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import javax.jdo.util.AbstractTest;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.Test;
/** */
-public class SingleFieldIdentityTest extends AbstractTest {
+class SingleFieldIdentityTest extends AbstractTest {
ConcreteTestIdentity cti1;
ConcreteTestIdentity cti2;
@@ -43,23 +47,18 @@ public class SingleFieldIdentityTest extends AbstractTest {
/** Creates a new instance of SingleFieldIdentityTest */
public SingleFieldIdentityTest() {}
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- BatchTestRunner.run(SingleFieldIdentityTest.class);
- }
-
- public void testConstructor() {
+ @Test
+ void testConstructor() {
cti1 = new ConcreteTestIdentity(Object.class);
cti2 = new ConcreteTestIdentity(Object.class);
cti3 = new ConcreteTestIdentity(Class.class);
- assertEquals("Equal identity instances compare not equal.", cti1, cti2);
- if (cti1.equals(cti3)) fail("Not equal identity instances compare equal.");
+ assertEquals(cti1, cti2, "Equal identity instances compare not equal.");
+ assertFalse(cti1.equals(cti3), "Not equal identity instances compare equal.");
}
- public void testSerialized() {
+ @Test
+ void testSerialized() {
cti1 = new ConcreteTestIdentity(Object.class);
cti2 = new ConcreteTestIdentity(Object.class);
cti3 = new ConcreteTestIdentity(Class.class);
@@ -67,13 +66,13 @@ public class SingleFieldIdentityTest extends AbstractTest {
scti1 = sctis[0];
scti2 = sctis[1];
scti3 = sctis[2];
- assertEquals("Deserialized instance compare not equal.", cti1, scti1);
- assertEquals("Deserialized instance compare not equal.", cti2, scti2);
- assertEquals("Deserialized instance compare not equal.", cti3, scti3);
- assertEquals("Deserialized instance compare not equal.", scti1, cti1);
- assertEquals("Deserialized instance compare not equal.", scti2, cti2);
- assertEquals("Deserialized instance compare not equal.", scti3, cti3);
- if (scti1.equals(scti3)) fail("Not equal identity instances compare equal.");
+ assertEquals(cti1, scti1, "Deserialized instance compare not equal.");
+ assertEquals(cti2, scti2, "Deserialized instance compare not equal.");
+ assertEquals(cti3, scti3, "Deserialized instance compare not equal.");
+ assertEquals(scti1, cti1, "Deserialized instance compare not equal.");
+ assertEquals(scti2, cti2, "Deserialized instance compare not equal.");
+ assertEquals(scti3, cti3, "Deserialized instance compare not equal.");
+ assertFalse(scti1.equals(scti3), "Not equal identity instances compare equal.");
}
protected Object[] writeReadSerialized(Object[] in) {
diff --git a/api/src/test/java/javax/jdo/identity/StringIdentityTest.java b/api/src/test/java/javax/jdo/identity/StringIdentityTest.java
index fd729b67..71f0c9a5 100644
--- a/api/src/test/java/javax/jdo/identity/StringIdentityTest.java
+++ b/api/src/test/java/javax/jdo/identity/StringIdentityTest.java
@@ -22,39 +22,38 @@
package javax.jdo.identity;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.jdo.JDONullIdentityException;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.Test;
/** */
-public class StringIdentityTest extends SingleFieldIdentityTest {
+class StringIdentityTest extends SingleFieldIdentityTest {
/** Creates a new instance of StringIdentityTest */
public StringIdentityTest() {}
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- BatchTestRunner.run(StringIdentityTest.class);
- }
-
- public void testConstructor() {
+ @Test
+ void testConstructor() {
StringIdentity c1 = new StringIdentity(Object.class, "1");
StringIdentity c2 = new StringIdentity(Object.class, "1");
StringIdentity c3 = new StringIdentity(Object.class, "2");
- assertEquals("Equal StringIdentity instances compare not equal.", c1, c2);
- assertNotEquals("Not equal StringIdentity instances compare equal", c1, c3);
+ assertEquals(c1, c2, "Equal StringIdentity instances compare not equal.");
+ assertNotEquals(c1, c3, "Not equal StringIdentity instances compare equal");
}
- public void testToStringConstructor() {
+ @Test
+ void testToStringConstructor() {
StringIdentity c1 = new StringIdentity(Object.class, "Now who's talking!");
StringIdentity c2 = new StringIdentity(Object.class, c1.toString());
- assertEquals("Equal StringIdentity instances compare not equal.", c1, c2);
+ assertEquals(c1, c2, "Equal StringIdentity instances compare not equal.");
}
- public void testSerialized() {
+ @Test
+ void testSerialized() {
StringIdentity c1 = new StringIdentity(Object.class, "1");
StringIdentity c2 = new StringIdentity(Object.class, "1");
StringIdentity c3 = new StringIdentity(Object.class, "2");
@@ -62,41 +61,42 @@ public class StringIdentityTest extends SingleFieldIdentityTest {
Object sc1 = scis[0];
Object sc2 = scis[1];
Object sc3 = scis[2];
- assertEquals("Equal StringIdentity instances compare not equal.", c1, sc1);
- assertEquals("Equal StringIdentity instances compare not equal.", c2, sc2);
- assertEquals("Equal StringIdentity instances compare not equal.", sc1, c2);
- assertEquals("Equal StringIdentity instances compare not equal.", sc2, c1);
- assertNotEquals("Not equal StringIdentity instances compare equal.", c1, sc3);
- assertNotEquals("Not equal StringIdentity instances compare equal.", sc1, c3);
- assertNotEquals("Not equal StringIdentity instances compare equal.", sc1, sc3);
- assertNotEquals("Not equal StringIdentity instances compare equal.", sc3, sc1);
+ assertEquals(c1, sc1, "Equal StringIdentity instances compare not equal.");
+ assertEquals(c2, sc2, "Equal StringIdentity instances compare not equal.");
+ assertEquals(sc1, c2, "Equal StringIdentity instances compare not equal.");
+ assertEquals(sc2, c1, "Equal StringIdentity instances compare not equal.");
+ assertNotEquals(c1, sc3, "Not equal StringIdentity instances compare equal.");
+ assertNotEquals(sc1, c3, "Not equal StringIdentity instances compare equal.");
+ assertNotEquals(sc1, sc3, "Not equal StringIdentity instances compare equal.");
+ assertNotEquals(sc3, sc1, "Not equal StringIdentity instances compare equal.");
}
- public void testGetKeyAsObject() {
+ @Test
+ void testGetKeyAsObject() {
StringIdentity c1 = new StringIdentity(Object.class, "1");
- assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), "1");
+ assertEquals("1", c1.getKeyAsObject(), "keyAsObject doesn't match.");
}
- public void testBadConstructorNullParam() {
- try {
- new StringIdentity(Object.class, null);
- } catch (JDONullIdentityException ex) {
- return;
- }
- fail("Failed to catch expected exception.");
+ @Test
+ void testBadConstructorNullParam() {
+ assertThrows(
+ JDONullIdentityException.class,
+ () -> new StringIdentity(Object.class, null),
+ "Failed to catch expected exception.");
}
- public void testCompareTo() {
+ @Test
+ void testCompareTo() {
StringIdentity c1 = new StringIdentity(Object.class, "1");
StringIdentity c2 = new StringIdentity(Object.class, "1");
StringIdentity c3 = new StringIdentity(Object.class, "2");
StringIdentity c4 = new StringIdentity(Class.class, "1");
- assertEquals("Equal StringIdentity instances compare not equal.", 0, c1.compareTo(c2));
+ assertEquals(0, c1.compareTo(c2), "Equal StringIdentity instances compare not equal.");
assertTrue(
- "Not equal StringIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0);
+ c1.compareTo(c3) < 0, "Not equal StringIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal StringIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0);
+ c3.compareTo(c1) > 0, "Not equal StringIdentity instances have wrong compareTo result");
assertTrue(
- "Not equal StringIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0);
+ c1.compareTo(c4) > 0, "Not equal StringIdentity instances have wrong compareTo result");
}
}
diff --git a/api/src/test/java/javax/jdo/listener/InstanceLifecycleEventTest.java b/api/src/test/java/javax/jdo/listener/InstanceLifecycleEventTest.java
index c8372198..a0fc5410 100644
--- a/api/src/test/java/javax/jdo/listener/InstanceLifecycleEventTest.java
+++ b/api/src/test/java/javax/jdo/listener/InstanceLifecycleEventTest.java
@@ -22,14 +22,18 @@
package javax.jdo.listener;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import javax.jdo.util.AbstractTest;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.Test;
/**
* Tests that instances of InstanceLifecycleEvent can be created and that the source, type, and
* target instances are correct.
*/
-public class InstanceLifecycleEventTest extends AbstractTest {
+class InstanceLifecycleEventTest extends AbstractTest {
final Object created = new Object();
final Object loaded = new Object();
@@ -45,80 +49,81 @@ public class InstanceLifecycleEventTest extends AbstractTest {
/** Creates a new instance of SingleFieldIdentityTest */
public InstanceLifecycleEventTest() {}
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- BatchTestRunner.run(InstanceLifecycleEventTest.class);
- }
-
- public void testConstructorCreateEvent() {
+ @Test
+ void testConstructorCreateEvent() {
InstanceLifecycleEvent e = new InstanceLifecycleEvent(created, InstanceLifecycleEvent.CREATE);
- assertSame("Create source differs.", created, e.getSource());
- assertEquals("Create type differs.", InstanceLifecycleEvent.CREATE, e.getEventType());
+ assertSame(created, e.getSource(), "Create source differs.");
+ assertEquals(InstanceLifecycleEvent.CREATE, e.getEventType(), "Create type differs.");
}
- public void testConstructorLoadEvent() {
+ @Test
+ void testConstructorLoadEvent() {
InstanceLifecycleEvent e = new InstanceLifecycleEvent(loaded, InstanceLifecycleEvent.LOAD);
- assertSame("Load source differs.", loaded, e.getSource());
- assertEquals("Load type differs.", InstanceLifecycleEvent.LOAD, e.getEventType());
+ assertSame(loaded, e.getSource(), "Load source differs.");
+ assertEquals(InstanceLifecycleEvent.LOAD, e.getEventType(), "Load type differs.");
}
- public void testConstructorStoreEvent() {
+ @Test
+ void testConstructorStoreEvent() {
InstanceLifecycleEvent e = new InstanceLifecycleEvent(stored, InstanceLifecycleEvent.STORE);
- assertSame("Store source differs.", stored, e.getSource());
- assertEquals("Store type differs.", InstanceLifecycleEvent.STORE, e.getEventType());
+ assertSame(stored, e.getSource(), "Store source differs.");
+ assertEquals(InstanceLifecycleEvent.STORE, e.getEventType(), "Store type differs.");
}
- public void testConstructorClearEvent() {
+ @Test
+ void testConstructorClearEvent() {
InstanceLifecycleEvent e = new InstanceLifecycleEvent(cleared, InstanceLifecycleEvent.CLEAR);
- assertSame("Clear source differs.", cleared, e.getSource());
- assertEquals("Clear type differs.", InstanceLifecycleEvent.CLEAR, e.getEventType());
+ assertSame(cleared, e.getSource(), "Clear source differs.");
+ assertEquals(InstanceLifecycleEvent.CLEAR, e.getEventType(), "Clear type differs.");
}
- public void testConstructorDeleteEvent() {
+ @Test
+ void testConstructorDeleteEvent() {
InstanceLifecycleEvent e = new InstanceLifecycleEvent(deleted, InstanceLifecycleEvent.DELETE);
- assertSame("Delete source differs.", deleted, e.getSource());
- assertEquals("Delete type differs.", InstanceLifecycleEvent.DELETE, e.getEventType());
+ assertSame(deleted, e.getSource(), "Delete source differs.");
+ assertEquals(InstanceLifecycleEvent.DELETE, e.getEventType(), "Delete type differs.");
}
- public void testConstructorDirtyEvent() {
+ @Test
+ void testConstructorDirtyEvent() {
InstanceLifecycleEvent e = new InstanceLifecycleEvent(dirtied, InstanceLifecycleEvent.DIRTY);
- assertSame("Dirty source differs.", dirtied, e.getSource());
- assertEquals("Dirty type differs.", InstanceLifecycleEvent.DIRTY, e.getEventType());
+ assertSame(dirtied, e.getSource(), "Dirty source differs.");
+ assertEquals(InstanceLifecycleEvent.DIRTY, e.getEventType(), "Dirty type differs.");
}
- public void testConstructorDetachEvent() {
+ @Test
+ void testConstructorDetachEvent() {
InstanceLifecycleEvent e =
new InstanceLifecycleEvent(detached, InstanceLifecycleEvent.DETACH, detachTarget);
- assertSame("Detach source differs.", detached, e.getSource());
- assertEquals("Detach type differs.", InstanceLifecycleEvent.DETACH, e.getEventType());
- assertSame("Detach target differs.", detachTarget, e.getTarget());
+ assertSame(detached, e.getSource(), "Detach source differs.");
+ assertEquals(InstanceLifecycleEvent.DETACH, e.getEventType(), "Detach type differs.");
+ assertSame(detachTarget, e.getTarget(), "Detach target differs.");
}
- public void testConstructorAttachEvent() {
+ @Test
+ void testConstructorAttachEvent() {
InstanceLifecycleEvent e =
new InstanceLifecycleEvent(attached, InstanceLifecycleEvent.ATTACH, attachTarget);
- assertSame("Attach source differs.", attached, e.getSource());
- assertEquals("Attach type differs.", InstanceLifecycleEvent.ATTACH, e.getEventType());
- assertSame("Attach target differs.", attachTarget, e.getTarget());
+ assertSame(attached, e.getSource(), "Attach source differs.");
+ assertEquals(InstanceLifecycleEvent.ATTACH, e.getEventType(), "Attach type differs.");
+ assertSame(attachTarget, e.getTarget(), "Attach target differs.");
}
- public void testIllegalConstructorTooSmall() {
- try {
- new InstanceLifecycleEvent(new Object(), -1);
- } catch (IllegalArgumentException e) {
- return; // good catch
- }
- fail("Invalid event did not throw IllegalArgumentException.");
+ @Test
+ void testIllegalConstructorTooSmall() {
+ Object o = new Object();
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new InstanceLifecycleEvent(o, -1),
+ "Invalid event did not throw IllegalArgumentException.");
}
- public void testIllegalConstructorTooBig() {
- try {
- new InstanceLifecycleEvent(new Object(), 8);
- } catch (IllegalArgumentException e) {
- return; // good catch
- }
- fail("Invalid event did not throw IllegalArgumentException.");
+ @Test
+ void testIllegalConstructorTooBig() {
+ Object o = new Object();
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new InstanceLifecycleEvent(o, 8),
+ "Invalid event did not throw IllegalArgumentException.");
}
}
diff --git a/api/src/test/java/javax/jdo/schema/XMLTest.java b/api/src/test/java/javax/jdo/schema/XMLTest.java
index a4d7339c..38f4e81d 100644
--- a/api/src/test/java/javax/jdo/schema/XMLTest.java
+++ b/api/src/test/java/javax/jdo/schema/XMLTest.java
@@ -20,15 +20,15 @@ package javax.jdo.schema;
import java.io.File;
import java.io.FilenameFilter;
import javax.jdo.util.AbstractTest;
-import javax.jdo.util.BatchTestRunner;
import javax.jdo.util.XMLTestUtil;
+import org.junit.jupiter.api.Test;
/**
* Tests schema files.
*
* <p>
*/
-public class XMLTest extends AbstractTest {
+class XMLTest extends AbstractTest {
/** */
protected static final String BASEDIR = System.getProperty("basedir", ".");
@@ -77,20 +77,17 @@ public class XMLTest extends AbstractTest {
return dir.listFiles(filter);
}
- /** */
- public static void main(String args[]) {
- BatchTestRunner.run(XMLTest.class);
- }
-
/** Test XSD files jdo.xsd, orm.xsd, and jdoquery.xsd. */
- public void testXSD() {
+ @Test
+ void testXSD() {
XMLTestUtil util = new XMLTestUtil();
appendMessage(util.checkXMLNonValidating(XSD_FILES));
failOnError();
}
/** Test XSD based .jdo, .orm and .jdoquery files. */
- public void testXSDBased() {
+ @Test
+ void testXSDBased() {
XMLTestUtil util = new XMLTestUtil();
appendMessage(util.checkXML(positiveXSDJDO, true));
appendMessage(util.checkXML(negativeXSDJDO, false));
@@ -102,7 +99,8 @@ public class XMLTest extends AbstractTest {
}
/** Test DTD based .jdo, .orm and .jdoquery files. */
- public void testDTDBased() {
+ @Test
+ void testDTDBased() {
XMLTestUtil util = new XMLTestUtil();
appendMessage(util.checkXML(positiveDTDJDO, true));
appendMessage(util.checkXML(negativeDTDJDO, false));
diff --git a/api/src/test/java/javax/jdo/spi/JDOImplHelperTest.java b/api/src/test/java/javax/jdo/spi/JDOImplHelperTest.java
index f0a4df47..f359d0c0 100644
--- a/api/src/test/java/javax/jdo/spi/JDOImplHelperTest.java
+++ b/api/src/test/java/javax/jdo/spi/JDOImplHelperTest.java
@@ -17,13 +17,21 @@
package javax.jdo.spi;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.Collection;
import java.util.Properties;
import javax.jdo.Constants;
import javax.jdo.JDOUserException;
import javax.jdo.pc.PCPoint;
import javax.jdo.util.AbstractTest;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Tests class javax.jdo.spi.JDOImplHelper.
@@ -31,60 +39,43 @@ import javax.jdo.util.BatchTestRunner;
* <p>Missing: testNewInstance + testNewObjectIdInstance Missing: tests for JDOImplHelper methods:
* copyKeyFieldsToObjectId and copyKeyFieldsFromObjectId.
*/
-public class JDOImplHelperTest extends AbstractTest {
+class JDOImplHelperTest extends AbstractTest {
/** */
private RegisterClassEvent event;
/** */
- public static void main(String args[]) {
- BatchTestRunner.run(JDOImplHelperTest.class);
- }
-
- /** */
- public void setUp() {
+ @BeforeEach
+ void setUp() {
// make sure PCClass is loaded before any tests are run
new PCPoint(1, Integer.valueOf(1));
}
/** */
- public void testGetFieldNames() {
+ @Test
+ void testGetFieldNames() {
JDOImplHelper implHelper = JDOImplHelper.getInstance();
String[] fieldNames = implHelper.getFieldNames(PCPoint.class);
- if (fieldNames == null) {
- fail("array of field names is null");
- }
- if (fieldNames.length != 2) {
- fail("Unexpected length of fieldNames; expected 2, got " + fieldNames.length);
- }
- if (!fieldNames[0].equals("x")) {
- fail("Unexpected field; expected x, got " + fieldNames[0]);
- }
- if (!fieldNames[1].equals("y")) {
- fail("Unexpected field; expected y, got " + fieldNames[1]);
- }
+ assertNotNull(fieldNames, "array of field names is null");
+ assertEquals(2, fieldNames.length, "Unexpected length of fieldNames");
+ assertEquals("x", fieldNames[0], "Unexpected field");
+ assertEquals("y", fieldNames[1], "Unexpected field");
}
/** */
- public void testGetFieldTypes() {
+ @Test
+ void testGetFieldTypes() {
JDOImplHelper implHelper = JDOImplHelper.getInstance();
Class<?>[] fieldTypes = implHelper.getFieldTypes(PCPoint.class);
- if (fieldTypes == null) {
- fail("array of field types is null");
- }
- if (fieldTypes.length != 2) {
- fail("Unexpected length of fieldTypes; expected 2, got " + fieldTypes.length);
- }
- if (fieldTypes[0] != int.class) {
- fail("Unexpected field type; expected int, got " + fieldTypes[0]);
- }
- if (fieldTypes[1] != Integer.class) {
- fail("Unexpected field type; expected Integer, got " + fieldTypes[1]);
- }
+ assertNotNull(fieldTypes, "array of field types is null");
+ assertEquals(2, fieldTypes.length, "Unexpected length of fieldTypes");
+ assertEquals(int.class, fieldTypes[0], "Unexpected field type");
+ assertEquals(Integer.class, fieldTypes[1], "Unexpected field type");
}
/** */
- public void testGetFieldFlags() {
+ @Test
+ void testGetFieldFlags() {
byte expected =
(byte)
(PersistenceCapable.CHECK_READ
@@ -93,56 +84,50 @@ public class JDOImplHelperTest extends AbstractTest {
JDOImplHelper implHelper = JDOImplHelper.getInstance();
byte[] fieldFlags = implHelper.getFieldFlags(PCPoint.class);
- if (fieldFlags == null) {
- fail("array of field flags is null");
- }
- if (fieldFlags.length != 2) {
- fail("Unexpected length of fieldFlags; expected 2, got " + fieldFlags.length);
- }
- if (fieldFlags[0] != expected) {
- fail("Unexpected field flag; expected " + expected + ", got " + fieldFlags[0]);
- }
- if (fieldFlags[1] != expected) {
- fail("Unexpected field flag; expected " + expected + ", got " + fieldFlags[1]);
- }
+ assertNotNull(fieldFlags, "array of field flags is null");
+ assertEquals(2, fieldFlags.length, "Unexpected length of fieldFlags");
+ assertEquals(expected, fieldFlags[0], "Unexpected field flag");
+ assertEquals(expected, fieldFlags[1], "Unexpected field flag");
}
/** */
- public void testGetPCSuperclass() {
+ @Test
+ void testGetPCSuperclass() {
JDOImplHelper implHelper = JDOImplHelper.getInstance();
Class<?> pcSuper = implHelper.getPersistenceCapableSuperclass(PCPoint.class);
- if (pcSuper != null) {
- fail("Wrong pc superclass of PCPoint; expected null, got " + pcSuper);
- }
+ assertNull(pcSuper, "Wrong pc superclass of PCPoint");
}
/** */
- public void testNewInstance() {
+ @Test
+ void testNewInstance() {
JDOImplHelper implHelper = JDOImplHelper.getInstance();
PersistenceCapable pcpoint = implHelper.newInstance(PCPoint.class, null);
- assertTrue("instance created by newInstance is not a PCPoint", pcpoint instanceof PCPoint);
+ assertTrue(pcpoint instanceof PCPoint, "instance created by newInstance is not a PCPoint");
pcpoint = implHelper.newInstance(PCPoint.class, null, null);
- assertTrue("instance created by newInstance is not a PCPoint", pcpoint instanceof PCPoint);
+ assertTrue(pcpoint instanceof PCPoint, "instance created by newInstance is not a PCPoint");
}
/** */
- public void testNewObjectIdInstance() {
+ @Test
+ void testNewObjectIdInstance() {
JDOImplHelper implHelper = JDOImplHelper.getInstance();
Object oid = implHelper.newObjectIdInstance(PCPoint.class);
- // The ObjrectId od javax.jdo.pc.PCPoint is always null
- assertNull("Unexpected non-null ObjectId of PCPoint", oid);
+ // The ObjectId od javax.jdo.pc.PCPoint is always null
+ assertNull(oid, "Unexpected non-null ObjectId of PCPoint");
}
/** */
- public void testClassRegistration() {
+ @Test
+ void testClassRegistration() {
JDOImplHelper implHelper = JDOImplHelper.getInstance();
Collection<Class<?>> registeredClasses = implHelper.getRegisteredClasses();
+
// test whether PCPoint is registered
- if (!registeredClasses.contains(PCPoint.class)) {
- fail("Missing registration of pc class PCPoint");
- }
+ assertTrue(
+ registeredClasses.contains(PCPoint.class), "Missing registration of pc class PCPoint");
// Save registered meta data for restoring
String[] fieldNames = implHelper.getFieldNames(PCPoint.class);
@@ -151,19 +136,15 @@ public class JDOImplHelperTest extends AbstractTest {
Class<?> pcSuperclass = implHelper.getPersistenceCapableSuperclass(PCPoint.class);
// test unregisterClass with null parameter
- try {
- implHelper.unregisterClass(null);
- fail("Missing exception when calling unregisterClass(null)");
- } catch (NullPointerException ex) {
- // expected exception => OK
- }
+ assertThrows(
+ NullPointerException.class,
+ () -> implHelper.unregisterClass(null),
+ "Missing exception when calling unregisterClass(null)");
// test unregister PCPoint class
implHelper.unregisterClass(PCPoint.class);
registeredClasses = implHelper.getRegisteredClasses();
- if (registeredClasses.contains(PCPoint.class)) {
- fail("PCPoint still registered");
- }
+ assertFalse(registeredClasses.contains(PCPoint.class), "PCPoint still registered");
// register PCPoint again
JDOImplHelper.registerClass(
@@ -171,7 +152,8 @@ public class JDOImplHelperTest extends AbstractTest {
}
/** */
- public void testClassListenerRegistration() {
+ @Test
+ void testClassListenerRegistration() {
JDOImplHelper implHelper = JDOImplHelper.getInstance();
// add listener and check event
@@ -180,66 +162,52 @@ public class JDOImplHelperTest extends AbstractTest {
implHelper.addRegisterClassListener(listener);
JDOImplHelper.registerClass(
JDOImplHelperTest.class, new String[0], new Class[0], new byte[0], null, null);
- if (event == null) {
- fail("Missing event ");
- }
+ assertNotNull(event, "Missing event ");
// remove listener and check event
event = null;
implHelper.removeRegisterClassListener(listener);
JDOImplHelper.registerClass(
JDOImplHelperTest.class, new String[0], new Class[0], new byte[0], null, null);
- if (event != null) {
- fail("Unexpected event " + event);
- }
+ assertNull(event, "Unexpected event ");
}
/** Test that an unknown standard property causes JDOUserException. */
- public void testUnknownStandardProperty() {
+ @Test
+ void testUnknownStandardProperty() {
Properties p = new Properties();
p.setProperty("javax.jdo.unknown.standard.property", "value");
- JDOUserException x = null;
-
- try {
- JDOImplHelper.assertOnlyKnownStandardProperties(p);
- fail(
- "testUnknownStandardProperty should result in JDOUserException. "
- + "No exception was thrown.");
- } catch (JDOUserException thrown) {
- if (verbose) println("Caught expected exception " + thrown);
- x = thrown;
- }
- assertNull("should have had no nested exceptions", x.getNestedExceptions());
+ JDOUserException thrown =
+ assertThrows(
+ JDOUserException.class,
+ () -> JDOImplHelper.assertOnlyKnownStandardProperties(p),
+ "testUnknownStandardProperty should result in JDOUserException. No exception was thrown.");
+ assertNull(thrown.getNestedExceptions(), "should have had no nested exceptions");
}
/** Test that unknown standard properties cause JDOUserException w/nested exceptions. */
- public void testUnknownStandardProperties() {
+ @Test
+ void testUnknownStandardProperties() {
Properties p = new Properties();
p.setProperty("javax.jdo.unknown.standard.property.1", "value");
p.setProperty("javax.jdo.unknown.standard.property.2", "value");
- JDOUserException x = null;
-
- try {
- JDOImplHelper.assertOnlyKnownStandardProperties(p);
- fail(
- "testUnknownStandardProperties should result in JDOUserException. "
- + "No exception was thrown.");
- } catch (JDOUserException thrown) {
- if (verbose) println("Caught expected exception " + thrown);
- x = thrown;
- }
+ JDOUserException thrown =
+ assertThrows(
+ JDOUserException.class,
+ () -> JDOImplHelper.assertOnlyKnownStandardProperties(p),
+ "testUnknownStandardProperties should result in JDOUserException. No exception was thrown.");
- Throwable[] nesteds = x.getNestedExceptions();
+ Throwable[] nesteds = thrown.getNestedExceptions();
assertNotNull(nesteds);
- assertEquals("should have been 2 nested exceptions", 2, nesteds.length);
+ assertEquals(2, nesteds.length, "should have been 2 nested exceptions");
for (int i = 0; i < nesteds.length; i++) {
Throwable t = nesteds[i];
assertTrue(
- "nested exception " + i + " should have been JDOUserException",
- t instanceof JDOUserException);
+ t instanceof JDOUserException,
+ "nested exception " + i + " should have been JDOUserException");
}
}
@@ -247,7 +215,8 @@ public class JDOImplHelperTest extends AbstractTest {
* Test that unknown non-standard properties & well-formed listener properties don't cause
* JDOUserException.
*/
- public void testUnknownNonStandardPropertiesAndListeners() {
+ @Test
+ void testUnknownNonStandardPropertiesAndListeners() {
Properties p = new Properties();
p.put("unknown.property", "value");
p.put(new Object(), "value");
@@ -256,7 +225,8 @@ public class JDOImplHelperTest extends AbstractTest {
}
/** Test that all JDO standard properties don't cause JDOUserException. */
- public void testOnlyStandardProperties() {
+ @Test
+ void testOnlyStandardProperties() {
Properties props = new Properties();
for (String p : JDOImplHelper.USER_CONFIGURABLE_STANDARD_PROPERTIES) {
props.setProperty(p, p);
@@ -265,7 +235,8 @@ public class JDOImplHelperTest extends AbstractTest {
}
/** Test that an known standard property in mixed case succeeds. */
- public void testKnownStandardPropertyThatDiffersInCaseOnly() {
+ @Test
+ void testKnownStandardPropertyThatDiffersInCaseOnly() {
Properties p = new Properties();
p.setProperty("JaVaX.jDo.oPtIoN.CoNNectionDRiVerNamE", "value");
p.setProperty("jAvAx.JdO.lIsTeNeR.InstaNceLifeCycleLisTener.foo.Bar", "");
diff --git a/api/src/test/java/javax/jdo/spi/StateInterrogationTest.java b/api/src/test/java/javax/jdo/spi/StateInterrogationTest.java
index 8c41353e..7f623767 100644
--- a/api/src/test/java/javax/jdo/spi/StateInterrogationTest.java
+++ b/api/src/test/java/javax/jdo/spi/StateInterrogationTest.java
@@ -17,12 +17,19 @@
package javax.jdo.spi;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.util.AbstractTest;
-import javax.jdo.util.BatchTestRunner;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
/**
* This class tests the StateInterrogation interface. The test is in several parts:
@@ -38,230 +45,247 @@ import javax.jdo.util.BatchTestRunner;
* to return the correct replies. We use a java.lang.reflect.Proxy for the getPersistenceManager
* call because it's too much work to mock it.
*/
-public class StateInterrogationTest extends AbstractTest {
+class StateInterrogationTest extends AbstractTest {
private final JDOImplHelper implHelper = JDOImplHelper.getInstance();
/** Creates a new instance of StateInterrogationTest */
public StateInterrogationTest() {}
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- BatchTestRunner.run(StateInterrogationTest.class);
- }
-
- public void testGetObjectIdNull() {
+ @Test
+ void testGetObjectIdNull() {
Object id2 = JDOHelper.getObjectId(nbcpc2);
- assertNull("ObjectId should be null before addStateInterrogations", id2);
+ assertNull(id2, "ObjectId should be null before addStateInterrogations");
addStateInterrogations();
Object id = JDOHelper.getObjectId(Boolean.TRUE);
- assertNull("ObjectId should be null for non-pc instances", id);
+ assertNull(id, "ObjectId should be null for non-pc instances");
}
- public void testGetObjectId() {
+ @Test
+ void testGetObjectId() {
addStateInterrogations();
Object id2 = JDOHelper.getObjectId(nbcpc2);
- assertNotNull("ObjectId should not be null", id2);
- assertEquals("ObjectId should be 2", 2, id2.hashCode());
+ assertNotNull(id2, "ObjectId should not be null");
+ assertEquals(2, id2.hashCode(), "ObjectId should be 2");
Object id20 = JDOHelper.getObjectId(nbcpc2);
- assertEquals("ObjectIds from same object should be equal", id2, id20);
+ assertEquals(id2, id20, "ObjectIds from same object should be equal");
}
- public void testRemoveStateInterrogation() {
+ @Test
+ void testRemoveStateInterrogation() {
addStateInterrogations();
Object id2 = JDOHelper.getObjectId(nbcpc2);
- assertNotNull("ObjectId should not be null", id2);
- assertEquals("ObjectId should be 2", 2, id2.hashCode());
+ assertNotNull(id2, "ObjectId should not be null");
+ assertEquals(2, id2.hashCode(), "ObjectId should be 2");
implHelper.removeStateInterrogation(si2);
implHelper.removeStateInterrogation(si0);
Object id21 = JDOHelper.getObjectId(nbcpc2);
- assertNull("ObjectId should be null after RemoveStateInterrogation", id21);
+ assertNull(id21, "ObjectId should be null after RemoveStateInterrogation");
Object id1 = JDOHelper.getObjectId(nbcpc1);
- assertNotNull("ObjectId should not be null", id1);
- assertEquals("ObjectId should be 1", 1, id1.hashCode());
+ assertNotNull(id1, "ObjectId should not be null");
+ assertEquals(1, id1.hashCode(), "ObjectId should be 1");
}
- public void testGetTransactionalObjectIdNull() {
+ @Test
+ void testGetTransactionalObjectIdNull() {
Object id2 = JDOHelper.getTransactionalObjectId(nbcpc2);
- assertNull("TransactionalObjectId should be null before addStateInterrogations", id2);
+ assertNull(id2, "TransactionalObjectId should be null before addStateInterrogations");
addStateInterrogations();
Object id = JDOHelper.getTransactionalObjectId(Boolean.TRUE);
- assertNull("TransactionalObjectId should be null for non-pc instances", id);
+ assertNull(id, "TransactionalObjectId should be null for non-pc instances");
}
- public void testGetTransactionalObjectId() {
+ @Test
+ void testGetTransactionalObjectId() {
addStateInterrogations();
Object id2 = JDOHelper.getTransactionalObjectId(nbcpc2);
- assertNotNull("TransactionalObjectId should not be null", id2);
- assertEquals("TransactionalObjectId should be 2", 2, id2.hashCode());
+ assertNotNull(id2, "TransactionalObjectId should not be null");
+ assertEquals(2, id2.hashCode(), "TransactionalObjectId should be 2");
Object id20 = JDOHelper.getTransactionalObjectId(nbcpc2);
- assertEquals("TransactionalObjectIds from same object should be equal", id2, id20);
+ assertEquals(id2, id20, "TransactionalObjectIds from same object should be equal");
}
- public void testGetPersistenceManagerNull() {
+ @Test
+ void testGetPersistenceManagerNull() {
Object pm2 = JDOHelper.getPersistenceManager(nbcpc2);
- assertNull("PersistenceManager should be null before addStateInterrogations", pm2);
+ assertNull(pm2, "PersistenceManager should be null before addStateInterrogations");
addStateInterrogations();
Object pm = JDOHelper.getPersistenceManager(Boolean.TRUE);
- assertNull("PersistenceManager should be null for non-pc instances", pm);
+ assertNull(pm, "PersistenceManager should be null for non-pc instances");
}
- public void testGetPersistenceManager() {
+ @Test
+ void testGetPersistenceManager() {
addStateInterrogations();
Object pm2 = JDOHelper.getPersistenceManager(nbcpc2);
- assertNotNull("PersistenceManager should not be null", pm2);
- assertEquals("PersistenceManager should be 2", 2, pm2.hashCode());
+ assertNotNull(pm2, "PersistenceManager should not be null");
+ assertEquals(2, pm2.hashCode(), "PersistenceManager should be 2");
Object pm20 = JDOHelper.getPersistenceManager(nbcpc2);
- assertEquals("PersistenceManagers from same object should be equal", pm2, pm20);
+ assertEquals(pm2, pm20, "PersistenceManagers from same object should be equal");
}
- public void testGetVersionNull() {
+ @Test
+ void testGetVersionNull() {
Object id2 = JDOHelper.getVersion(nbcpc2);
- assertNull("Version should be null before addStateInterrogations", id2);
+ assertNull(id2, "Version should be null before addStateInterrogations");
addStateInterrogations();
Object id = JDOHelper.getVersion(Boolean.TRUE);
- assertNull("Version should be null for non-pc instances", id);
+ assertNull(id, "Version should be null for non-pc instances");
}
- public void testGetVersion() {
+ @Test
+ void testGetVersion() {
addStateInterrogations();
Object id2 = JDOHelper.getVersion(nbcpc2);
- assertNotNull("Version should not be null", id2);
- assertEquals("Version should be 2", 2, id2.hashCode());
+ assertNotNull(id2, "Version should not be null");
+ assertEquals(2, id2.hashCode(), "Version should be 2");
Object id20 = JDOHelper.getVersion(nbcpc2);
- assertEquals("Versions from same object should be equal", id2, id20);
+ assertEquals(id2, id20, "Versions from same object should be equal");
}
- public void testIsDeletedFalse() {
+ @Test
+ void testIsDeletedFalse() {
assertFalse(
- "IsDeleted should be false before addStateInterrogations", JDOHelper.isDeleted(nbcpc2));
+ JDOHelper.isDeleted(nbcpc2), "IsDeleted should be false before addStateInterrogations");
addStateInterrogations();
assertFalse(
- "IsDeleted should be false for non-pc instances", JDOHelper.isDeleted(Boolean.TRUE));
+ JDOHelper.isDeleted(Boolean.TRUE), "IsDeleted should be false for non-pc instances");
implHelper.removeStateInterrogation(si2);
assertFalse(
- "IsDeleted should be false after removeStateInterrogations", JDOHelper.isDeleted(nbcpc2));
+ JDOHelper.isDeleted(nbcpc2), "IsDeleted should be false after removeStateInterrogations");
}
- public void testIsDeletedMine() {
+ @Test
+ void testIsDeletedMine() {
addStateInterrogations();
- assertTrue("IsDeleted should be true for nbcpc1", JDOHelper.isDeleted(nbcpc1));
- assertFalse("IsDeleted should be false for nbcpc2", JDOHelper.isDeleted(nbcpc2));
+ assertTrue(JDOHelper.isDeleted(nbcpc1), "IsDeleted should be true for nbcpc1");
+ assertFalse(JDOHelper.isDeleted(nbcpc2), "IsDeleted should be false for nbcpc2");
}
- public void testIsDetachedFalse() {
+ @Test
+ void testIsDetachedFalse() {
assertFalse(
- "IsDetached should be false before addStateInterrogations", JDOHelper.isDetached(nbcpc2));
+ JDOHelper.isDetached(nbcpc2), "IsDetached should be false before addStateInterrogations");
addStateInterrogations();
assertFalse(
- "IsDetached should be false for non-pc instances", JDOHelper.isDetached(Boolean.TRUE));
+ JDOHelper.isDetached(Boolean.TRUE), "IsDetached should be false for non-pc instances");
implHelper.removeStateInterrogation(si2);
assertFalse(
- "IsDetached should be false after removeStateInterrogations", JDOHelper.isDetached(nbcpc2));
+ JDOHelper.isDetached(nbcpc2), "IsDetached should be false after removeStateInterrogations");
}
- public void testIsDetachedMine() {
+ @Test
+ void testIsDetachedMine() {
addStateInterrogations();
- assertTrue("IsDetached should be true for nbcpc1", JDOHelper.isDetached(nbcpc1));
- assertFalse("IsDetached should be false for nbcpc2", JDOHelper.isDetached(nbcpc2));
+ assertTrue(JDOHelper.isDetached(nbcpc1), "IsDetached should be true for nbcpc1");
+ assertFalse(JDOHelper.isDetached(nbcpc2), "IsDetached should be false for nbcpc2");
}
- public void testIsDirtyFalse() {
- assertFalse("IsDirty should be false before addStateInterrogations", JDOHelper.isDirty(nbcpc2));
+ @Test
+ void testIsDirtyFalse() {
+ assertFalse(JDOHelper.isDirty(nbcpc2), "IsDirty should be false before addStateInterrogations");
addStateInterrogations();
- assertFalse("IsDirty should be false for non-pc instances", JDOHelper.isDirty(Boolean.TRUE));
+ assertFalse(JDOHelper.isDirty(Boolean.TRUE), "IsDirty should be false for non-pc instances");
implHelper.removeStateInterrogation(si2);
nbcpc2.setDirty(true);
assertFalse(
- "IsDirty should be false after removeStateInterrogations", JDOHelper.isDirty(nbcpc2));
+ JDOHelper.isDirty(nbcpc2), "IsDirty should be false after removeStateInterrogations");
nbcpc2.setDirty(false);
}
- public void testIsDirtyMine() {
+ @Test
+ void testIsDirtyMine() {
addStateInterrogations();
nbcpc1.setDirty(true);
- assertTrue("IsDirty should be true for nbcpc1 after setDirty(true)", JDOHelper.isDirty(nbcpc1));
+ assertTrue(JDOHelper.isDirty(nbcpc1), "IsDirty should be true for nbcpc1 after setDirty(true)");
nbcpc1.setDirty(false);
assertFalse(
- "IsDirty should be false for nbcpc1 after setDirty(false)", JDOHelper.isDirty(nbcpc1));
- assertFalse("IsDirty should be false for nbcpc2", JDOHelper.isDirty(nbcpc2));
+ JDOHelper.isDirty(nbcpc1), "IsDirty should be false for nbcpc1 after setDirty(false)");
+ assertFalse(JDOHelper.isDirty(nbcpc2), "IsDirty should be false for nbcpc2");
}
- public void testIsNewFalse() {
- assertFalse("IsNew should be false before addStateInterrogations", JDOHelper.isNew(nbcpc2));
+ @Test
+ void testIsNewFalse() {
+ assertFalse(JDOHelper.isNew(nbcpc2), "IsNew should be false before addStateInterrogations");
addStateInterrogations();
- assertFalse("IsNew should be false for non-pc instances", JDOHelper.isNew(Boolean.TRUE));
+ assertFalse(JDOHelper.isNew(Boolean.TRUE), "IsNew should be false for non-pc instances");
implHelper.removeStateInterrogation(si2);
- assertFalse("IsNew should be false after removeStateInterrogations", JDOHelper.isNew(nbcpc2));
+ assertFalse(JDOHelper.isNew(nbcpc2), "IsNew should be false after removeStateInterrogations");
}
- public void testIsNewMine() {
+ @Test
+ void testIsNewMine() {
addStateInterrogations();
- assertTrue("IsNew should be true for nbcpc1", JDOHelper.isNew(nbcpc1));
- assertFalse("IsNew should be false for nbcpc2", JDOHelper.isNew(nbcpc2));
+ assertTrue(JDOHelper.isNew(nbcpc1), "IsNew should be true for nbcpc1");
+ assertFalse(JDOHelper.isNew(nbcpc2), "IsNew should be false for nbcpc2");
}
- public void testIsPersistentFalse() {
+ @Test
+ void testIsPersistentFalse() {
assertFalse(
- "IsPersistent should be false before addStateInterrogations",
- JDOHelper.isPersistent(nbcpc2));
+ JDOHelper.isPersistent(nbcpc2),
+ "IsPersistent should be false before addStateInterrogations");
addStateInterrogations();
assertFalse(
- "IsPersistent should be false for non-pc instances", JDOHelper.isPersistent(Boolean.TRUE));
+ JDOHelper.isPersistent(Boolean.TRUE), "IsPersistent should be false for non-pc instances");
implHelper.removeStateInterrogation(si2);
assertFalse(
- "IsPersistent should be false after removeStateInterrogations",
- JDOHelper.isPersistent(nbcpc2));
+ JDOHelper.isPersistent(nbcpc2),
+ "IsPersistent should be false after removeStateInterrogations");
}
- public void testIsPersistentMine() {
+ @Test
+ void testIsPersistentMine() {
addStateInterrogations();
- assertTrue("IsPersistent should be true for nbcpc1", JDOHelper.isPersistent(nbcpc1));
- assertFalse("IsPersistent should be false for nbcpc2", JDOHelper.isPersistent(nbcpc2));
+ assertTrue(JDOHelper.isPersistent(nbcpc1), "IsPersistent should be true for nbcpc1");
+ assertFalse(JDOHelper.isPersistent(nbcpc2), "IsPersistent should be false for nbcpc2");
}
- public void testIsTransactionalFalse() {
+ @Test
+ void testIsTransactionalFalse() {
assertFalse(
- "IsTransactional should be false before addStateInterrogations",
- JDOHelper.isTransactional(nbcpc2));
+ JDOHelper.isTransactional(nbcpc2),
+ "IsTransactional should be false before addStateInterrogations");
addStateInterrogations();
assertFalse(
- "IsTransactional should be false for non-pc instances",
- JDOHelper.isTransactional(Boolean.TRUE));
+ JDOHelper.isTransactional(Boolean.TRUE),
+ "IsTransactional should be false for non-pc instances");
implHelper.removeStateInterrogation(si2);
assertFalse(
- "IsTransactional should be false after removeStateInterrogations",
- JDOHelper.isTransactional(nbcpc2));
+ JDOHelper.isTransactional(nbcpc2),
+ "IsTransactional should be false after removeStateInterrogations");
}
- public void testIsTransactionalMine() {
+ @Test
+ void testIsTransactionalMine() {
addStateInterrogations();
- assertTrue("IsTransactional should be true for nbcpc1", JDOHelper.isTransactional(nbcpc1));
- assertFalse("IsTransactional should be false for nbcpc2", JDOHelper.isTransactional(nbcpc2));
+ assertTrue(JDOHelper.isTransactional(nbcpc1), "IsTransactional should be true for nbcpc1");
+ assertFalse(JDOHelper.isTransactional(nbcpc2), "IsTransactional should be false for nbcpc2");
}
- public void testMakeDirtyFalse() {
+ @Test
+ void testMakeDirtyFalse() {
JDOHelper.makeDirty(nbcpc2, "");
nbcpc2.setDirty(true);
- assertFalse("IsDirty should be false before addStateInterrogations", JDOHelper.isDirty(nbcpc2));
+ assertFalse(JDOHelper.isDirty(nbcpc2), "IsDirty should be false before addStateInterrogations");
addStateInterrogations();
implHelper.removeStateInterrogation(si2);
nbcpc2.setDirty(false);
JDOHelper.makeDirty(nbcpc2, "");
assertFalse(
- "IsDirty should be false after removeStateInterrogations", JDOHelper.isDirty(nbcpc2));
+ JDOHelper.isDirty(nbcpc2), "IsDirty should be false after removeStateInterrogations");
}
- public void testMakeDirtyMine() {
+ @Test
+ void testMakeDirtyMine() {
addStateInterrogations();
JDOHelper.makeDirty(nbcpc1, "");
- assertTrue("IsDirty should be true for nbcpc1", JDOHelper.isDirty(nbcpc1));
+ assertTrue(JDOHelper.isDirty(nbcpc1), "IsDirty should be true for nbcpc1");
nbcpc1.setDirty(false);
- assertFalse("IsDirty should be false after setDirty(false)", JDOHelper.isDirty(nbcpc1));
+ assertFalse(JDOHelper.isDirty(nbcpc1), "IsDirty should be false after setDirty(false)");
}
+ @AfterEach
public void tearDown() {
removeStateInterrogations();
}
@@ -476,9 +500,9 @@ public class StateInterrogationTest extends AbstractTest {
public Object invoke(Object obj, java.lang.reflect.Method method, Object[] params)
throws Throwable {
String name = method.getName();
- if (name == "hashCode") {
+ if ("hashCode".equals(name)) {
return Integer.valueOf(id);
- } else if (name == "equals") {
+ } else if ("equals".equals(name)) {
Object other = params[0];
if (!(other instanceof PersistenceManager)) return Boolean.FALSE;
int otherid = Proxy.getInvocationHandler(other).hashCode();
diff --git a/api/src/test/java/javax/jdo/util/AbstractTest.java b/api/src/test/java/javax/jdo/util/AbstractTest.java
index 7ca9e7c2..e3fcb1df 100644
--- a/api/src/test/java/javax/jdo/util/AbstractTest.java
+++ b/api/src/test/java/javax/jdo/util/AbstractTest.java
@@ -17,12 +17,13 @@
package javax.jdo.util;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.io.PrintStream;
import javax.jdo.Constants;
-import junit.framework.TestCase;
/** */
-public abstract class AbstractTest extends TestCase implements Constants {
+public abstract class AbstractTest implements Constants {
/** */
protected static final PrintStream OUT = System.out;
@@ -32,7 +33,6 @@ public abstract class AbstractTest extends TestCase implements Constants {
/** Construct and initialize from properties. */
protected AbstractTest() {
- super(null);
verbose = Boolean.getBoolean("verbose");
}
diff --git a/api/src/test/java/javax/jdo/util/BatchResultPrinter.java b/api/src/test/java/javax/jdo/util/BatchResultPrinter.java
deleted file mode 100644
index a73feed3..00000000
--- a/api/src/test/java/javax/jdo/util/BatchResultPrinter.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package javax.jdo.util;
-
-import java.io.PrintStream;
-import junit.framework.AssertionFailedError;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-import junit.textui.ResultPrinter;
-
-/**
- * Default result printer implementation for running tests in batch mode.
- *
- * @author Michael Bouschen
- */
-public class BatchResultPrinter extends ResultPrinter {
- /** */
- public BatchResultPrinter(PrintStream writer) {
- super(writer);
- }
-
- /** Called in case of a test error. */
- public void addError(Test test, Throwable t) {
- getWriter().print(" ERROR");
- }
-
- /** Called in case of a test failure. */
- public void addFailure(Test test, AssertionFailedError t) {
- getWriter().print(" FAILURE");
- }
-
- /** Called when a test case is finished. */
- public void endTest(Test test) {
- getWriter().println();
- }
-
- /**
- * Called when a test case is started.
- *
- * @param test test case
- */
- public void startTest(Test test) {
- String testName;
- if (test instanceof TestCase) {
- testName = getClassBaseName(test) + "." + ((TestCase) test).getName();
- } else {
- testName = test.toString();
- }
- getWriter().print("RUN " + testName);
- }
-
- /**
- * @param runTime time
- */
- protected void printHeader(long runTime) {
- getWriter().println("Time: " + elapsedTimeAsString(runTime));
- }
-
- /**
- * @param result the result
- */
- protected void printFooter(TestResult result) {
- if (result.wasSuccessful()) {
- getWriter().print("OK");
- getWriter()
- .println(" (" + result.runCount() + " test" + (result.runCount() == 1 ? "" : "s") + ")");
-
- } else {
- getWriter().println("FAILURES!!!");
- getWriter()
- .println(
- "Tests run: "
- + result.runCount()
- + ", Failures: "
- + result.failureCount()
- + ", Errors: "
- + result.errorCount());
- }
- }
-
- // helper method
-
- /**
- * @return Name of the class of the given object without package prefix
- */
- private String getClassBaseName(Object obj) {
- if (obj == null) return null;
- String className = obj.getClass().getName();
- int index = className.lastIndexOf('.');
- if (index != -1) {
- className = className.substring(index + 1);
- }
- return className;
- }
-}
diff --git a/api/src/test/java/javax/jdo/util/BatchTestRunner.java b/api/src/test/java/javax/jdo/util/BatchTestRunner.java
deleted file mode 100644
index 7a271111..00000000
--- a/api/src/test/java/javax/jdo/util/BatchTestRunner.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package javax.jdo.util;
-
-import java.io.PrintStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
-import junit.textui.ResultPrinter;
-import junit.textui.TestRunner;
-
-/**
- * TestRunner class for running a single test or a test suite in batch mode. The format of the test
- * output is specified by the result printer class. The main method sets an exit code according to
- * the test result:
- *
- * <ul>
- * <li><code>0</code>: success
- * <li><code>1</code>: failure, the test shows an unexpected behavior
- * <li><code>2</code>: exception, the test throws an unhandled excption
- * </ul>
- *
- * @author Michael Bouschen
- */
-public class BatchTestRunner extends TestRunner {
- /** Name of the system property to specify the result printer class. */
- public static final String RESULTPRINTER_PROPERTY = "ResultPrinterClass";
-
- /** Default of the system property ResultPrinterClass. */
- public static final String RESULTPRINTER_DEFAULT = BatchResultPrinter.class.getName();
-
- /**
- * Constructor. It creates a result printer instance based on the system property and delegates to
- * the constructor taking a result printer argument.
- */
- public BatchTestRunner() {
- super();
- setPrinter(getResultPrinter());
- }
-
- /** Constructor. Uses tehe specified resultPrinter to format the test result. */
- public BatchTestRunner(ResultPrinter resultPrinter) {
- super(resultPrinter);
- }
-
- /**
- * Runs all test methods from the specified class.
- *
- * @param clazz
- */
- public static void run(Class<? extends TestCase> clazz) {
- run(new TestSuite(clazz));
- }
-
- /** Runs the specified test. */
- public static TestResult run(Test test) {
- return new BatchTestRunner().doRun(test);
- }
-
- /** Runs the specified test and waits until the user types RETURN. */
- public static void runAndWait(Test suite) {
- new BatchTestRunner().doRun(suite, true);
- }
-
- /**
- * Runs in batch mode and sets an exit code. If the specified String array includes a single fully
- * qualified class name, this test class is executed. If it is empty it runs the TestListSuite.
- */
- public static void main(String args[]) {
- BatchTestRunner aTestRunner = new BatchTestRunner();
- try {
- /*
- if ((args == null) || args.length == 0)
- args = new String[] { TestListSuite.class.getName() };
- */
- TestResult r = aTestRunner.start(args);
- if (!r.wasSuccessful()) System.exit(FAILURE_EXIT);
- System.exit(SUCCESS_EXIT);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- System.exit(EXCEPTION_EXIT);
- }
- }
-
- /** Returns a result printer instance. n instance of tCheck the system property */
- protected ResultPrinter getResultPrinter() {
- String className = System.getProperty(RESULTPRINTER_PROPERTY);
- if (className != null) {
- className = className.trim();
- if (className.length() != 0) {
- String msg = null;
- try {
- // get class instance
- Class<?> clazz = Class.forName(className);
- // constructor taking PrintStream arg
- Constructor<?> ctor = clazz.getConstructor(new Class[] {PrintStream.class});
- // create instance
- return (ResultPrinter) ctor.newInstance(new Object[] {System.out});
- } catch (ClassNotFoundException ex) {
- // specified ResultPrinter class not
- msg = "Cannot find specified result printer class " + className + ".";
- } catch (NoSuchMethodException ex) {
- msg = "Class " + className + " does not provide constructor taking a PrintStream.";
- } catch (InstantiationException ex) {
- msg = "Class " + className + " is abstract.";
- } catch (IllegalAccessException ex) {
- msg = "Constructor taking a PrintStream of class " + className + " is not accessible.";
- } catch (InvocationTargetException ex) {
- msg = "Constructor call results in exception " + ex + ".";
- }
-
- // ResultPrinter class specified, but not avaiable
- System.out.println(msg);
- ResultPrinter printer = getDefaultResultPrinter();
- System.out.println("Using default result printer of class " + printer.getClass().getName());
- }
- }
-
- // ResultPrinter class not specified => use default
- return getDefaultResultPrinter();
- }
-
- /** Returns an instance of the default result printer class BatchResultPrinter. */
- protected ResultPrinter getDefaultResultPrinter() {
- return new BatchResultPrinter(System.out);
- }
-}
diff --git a/parent-pom/pom.xml b/parent-pom/pom.xml
index 95802056..ab6d8468 100644
--- a/parent-pom/pom.xml
+++ b/parent-pom/pom.xml
@@ -196,10 +196,21 @@
<artifactId>javax.transaction-api</artifactId>
<version>1.3</version>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>5.9.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ <version>5.9.3</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
- <version>5.8.2</version>
+ <version>5.9.3</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>