Skip to content

Commit

Permalink
JDO-830: Migrate JUnit tests in tck to version 5 (#85)
Browse files Browse the repository at this point in the history
* JDO-830: First TCK version using JUnit 5

* JDO-830: refactor RunTCK

* JDO-830: migrate to JUnit 5.10.0

* JDO-830: review comments

* JDO-830: review comments

- Import class instead of static import of static methods
- Remove unused constants
- Bug Fix in RunTCK when checking jdo.tck.classes value

* JDO-830: review comments

DN logging and TCK class logging files should not be empty

* JDO-830: review comments

Formatting changes
  • Loading branch information
mboapache committed Nov 21, 2023
1 parent 31fa167 commit 36d08ff
Show file tree
Hide file tree
Showing 567 changed files with 3,268 additions and 7,683 deletions.
5 changes: 2 additions & 3 deletions api/src/test/java/javax/jdo/AbstractJDOConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@

package javax.jdo;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.net.URL;
import java.util.Enumeration;
import java.util.Map;
import java.util.Random;
import javax.jdo.util.AbstractTest;
import org.junit.jupiter.api.Assertions;

public abstract class AbstractJDOConfigTest extends AbstractTest {

Expand Down Expand Up @@ -105,7 +104,7 @@ static void assertEqualProperties(Map<?, ?> expected, Map<?, ?> actual) {
String expectedValue = (String) entry.getValue();
String actualValue = (String) actual.get(key);

assertEquals(
Assertions.assertEquals(
expectedValue,
actualValue,
"Actual property at key ["
Expand Down
132 changes: 65 additions & 67 deletions api/src/test/java/javax/jdo/EnhancerTest.java

Large diffs are not rendered by default.

43 changes: 20 additions & 23 deletions api/src/test/java/javax/jdo/JDOHelperConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@
*/
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 org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
Expand Down Expand Up @@ -218,7 +214,7 @@ protected void doPositiveTest(
String name = testVariantName == null ? null : expected.get(Constants.PROPERTY_NAME);
Map<Object, Object> actual = JDOHelper.getPropertiesFromJdoconfig(name, loader);

assertNotNull(actual, "No properties found");
Assertions.assertNotNull(actual, "No properties found");
if (checkEqualProperties) {
assertEqualProperties(expected, actual);
}
Expand Down Expand Up @@ -270,8 +266,8 @@ void testPositive01_DuplicatePUsInDifferentConfigFilesButNotRequested() throws I
Map<Object, Object> actual =
JDOHelper.getPropertiesFromJdoconfig(
Constants.ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader);
assertNotNull(actual, "Anonymous PMF with no properties returned null");
assertEquals(0, actual.size(), "Anonymous PMF with no properties had properties");
Assertions.assertNotNull(actual, "Anonymous PMF with no properties returned null");
Assertions.assertEquals(0, actual.size(), "Anonymous PMF with no properties had properties");
}

@Test
Expand All @@ -284,8 +280,9 @@ void testPositive02_GetAnonymousPMFWithNoProperties() throws IOException {
Map<Object, Object> properties =
JDOHelper.getPropertiesFromJdoconfig(
Constants.ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader);
assertNotNull(properties, "Anonymous PMF with no properties returned null");
assertEquals(0, properties.size(), "Anonymous PMF with no properties had properties");
Assertions.assertNotNull(properties, "Anonymous PMF with no properties returned null");
Assertions.assertEquals(
0, properties.size(), "Anonymous PMF with no properties had properties");
}

@ParameterizedTest
Expand All @@ -301,8 +298,8 @@ void testPositive_PMF0_PMFClassNameViaServicesLookup(String path, String expecte
getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + path);
String actual = getPMFClassNameViaServiceLookup(loader);

assertNotNull(actual, "No PMF name found via services lookup");
assertEquals(expected, actual);
Assertions.assertNotNull(actual, "No PMF name found via services lookup");
Assertions.assertEquals(expected, actual);
}

@Test
Expand All @@ -317,7 +314,7 @@ void testPositive06_PMF0_GetAnonymousPMFProperties() throws IOException {
JDOHelper.getPropertiesFromJdoconfig(
Constants.ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader);

assertNotNull(actual, "No properties found");
Assertions.assertNotNull(actual, "No properties found");
assertEqualProperties(expected, actual);
}

Expand All @@ -333,7 +330,7 @@ void testPositive07_PMF0_GetAnonymousPMFPropertiesWithPUName() throws IOExceptio
JDOHelper.getPropertiesFromJdoconfig(
Constants.ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader);

assertNotNull(actual, "No properties found");
Assertions.assertNotNull(actual, "No properties found");
assertEqualProperties(expected, actual);
}

Expand All @@ -349,7 +346,7 @@ void testNegative(String path) throws IOException {
URLClassLoader loader =
new JDOConfigTestClassLoader(
getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + path);
assertThrows(
Assertions.assertThrows(
JDOFatalUserException.class,
() -> JDOHelper.getPersistenceManagerFactory(loader),
"JDOHelper failed to throw JDOFatalUserException");
Expand All @@ -360,7 +357,7 @@ void testNegative03_DuplicateNamedPersistenceUnitsInSameConfig() throws IOExcept
URLClassLoader loader =
new JDOConfigTestClassLoader(
getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative03/");
assertThrows(
Assertions.assertThrows(
JDOFatalUserException.class,
() -> JDOHelper.getPersistenceManagerFactory("name.negative03", loader),
"JDOHelper failed to throw JDOFatalUserException");
Expand All @@ -371,7 +368,7 @@ void testNegative04_DuplicatePUNamePropertyInAttributeAndElement() throws IOExce
URLClassLoader loader =
new JDOConfigTestClassLoader(
getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative04/");
assertThrows(
Assertions.assertThrows(
JDOFatalUserException.class,
() -> JDOHelper.getPersistenceManagerFactory("name.negative04.value0", loader),
"JDOHelper failed to throw JDOFatalUserException");
Expand All @@ -384,7 +381,7 @@ void testNegative06_DuplicatePUInDifferentConfigFiles() throws IOException {
getClass().getClassLoader(),
JDOCONFIG_CLASSPATH_PREFIX + "/Negative06/6a/",
JDOCONFIG_CLASSPATH_PREFIX + "/Negative06/6b/");
assertThrows(
Assertions.assertThrows(
JDOFatalUserException.class,
() -> JDOHelper.getPersistenceManagerFactory("name.negative06", loader),
"JDOHelper failed to throw JDOFatalUserException");
Expand All @@ -396,17 +393,17 @@ void testNegative07_EmptyServicesFile() throws IOException {
new JDOConfigTestClassLoader(
getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative07/");
String shouldBeNull = getPMFClassNameViaServiceLookup(testLoader);
assertNull(shouldBeNull);
Assertions.assertNull(shouldBeNull);
}

@Test
void testNegative08_NoResourcesFound() {
String resource = "" + RANDOM.nextLong();
InputStream in = getClass().getClassLoader().getResourceAsStream(resource);
assertNull(in);
Assertions.assertNull(in);

// resource pretty much guaranteed not to exist
assertThrows(
Assertions.assertThrows(
JDOFatalUserException.class,
() -> JDOHelper.getPersistenceManagerFactory(resource),
"JDOHelper failed to throw JDOFatalUserException");
Expand All @@ -418,7 +415,7 @@ void testNegative08_ServicesFileWithOnlyComments() throws IOException {
new JDOConfigTestClassLoader(
getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative08/");
String shouldBeNull = getPMFClassNameViaServiceLookup(testLoader);
assertNull(shouldBeNull);
Assertions.assertNull(shouldBeNull);
}

@Test
Expand All @@ -435,7 +432,7 @@ void testNegative09_MultipleInvalidClassesInDifferentServicesFiles() throws IOEx
TEST_CLASSPATH,
API_CLASSPATH);
JDOFatalException x =
assertThrows(
Assertions.assertThrows(
JDOFatalException.class,
() -> JDOHelper.getPersistenceManagerFactory("name.negative09", loader),
"JDOHelper failed to throw JDOFatalUserException");
Expand Down

0 comments on commit 36d08ff

Please sign in to comment.