Skip to content

Commit

Permalink
[#385] move to junit5
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentschoelens authored and mattrpav committed Sep 11, 2024
1 parent 88e7473 commit 48318e2
Show file tree
Hide file tree
Showing 201 changed files with 1,389 additions and 1,461 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import java.util.Collection;
import java.util.LinkedList;

import junit.framework.TestCase;

import org.junit.jupiter.api.Test;
import org.jvnet.jaxb.annox.model.XAnnotation;
import org.jvnet.jaxb.annox.model.annotation.field.XAnnotationField;
import org.jvnet.hyperjaxb3.annotation.util.AnnotationUtils;

public class AnnotationUtilsTest extends TestCase {
public class AnnotationUtilsTest {

@Test
public void testA() throws Exception {

final Collection<XAnnotation<?>> a = new LinkedList<XAnnotation<?>>();
Expand All @@ -21,11 +21,12 @@ public void testA() throws Exception {
a.toArray(new XAnnotation[a.size()]), Override.class);
}

@Test
public void testB() throws Exception {

final Collection<XAnnotation<?>> a = new LinkedList<XAnnotation<?>>();
XAnnotationField<Annotation[]> xa = AnnotationUtils.create("test",
a.toArray(new XAnnotation[a.size()]), Override.class);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.util.Arrays;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.jvnet.hyperjaxb3.ejb.strategy.annotate.CreateXAnnotations;

import jakarta.xml.ns.persistence.orm.AttributeOverride;
Expand All @@ -26,6 +26,6 @@ public void createsAttributeOverrides()
ao1.setColumn(new Column());
ao1.getColumn().setName("column_b");
List<AttributeOverride> aos = Arrays.asList(ao0, ao1);
Assert.assertNotNull(createXAnnotations.createAttributeOverrides(aos));
Assertions.assertNotNull(createXAnnotations.createAttributeOverrides(aos));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import java.net.URL;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.jvnet.hyperjaxb3.xsom.SimpleTypeAnalyzer;

import com.sun.xml.xsom.XSSchemaSet;
Expand All @@ -13,7 +13,7 @@

import javax.xml.parsers.SAXParserFactory;

public class SimpleTypesAnalyzerTest extends TestCase {
public class SimpleTypesAnalyzerTest {

public static final String NS = "urn:org.jvnet.hyperjaxb3.xsom.tests";

Expand Down Expand Up @@ -43,12 +43,12 @@ public XSSchemaSet getSchemaSet() {
return schemaSet;
}

@Override
@BeforeEach
protected void setUp() throws Exception {
super.setUp();
schemaSet = parse(SCHEMA_RESOURCE);
}

@Test
public void testLength() throws Exception {

// XSSimpleType simpleType = schema.getSimpleType("length");
Expand All @@ -67,37 +67,37 @@ public void testLength() throws Exception {
final XSSimpleType totalDigits = schemaSet.getSimpleType(NS, "totalDigits");
final XSSimpleType fractionDigits = schemaSet.getSimpleType(NS, "fractionDigits");

Assert.assertEquals(Long.valueOf(5), SimpleTypeAnalyzer
Assertions.assertEquals(Long.valueOf(5), SimpleTypeAnalyzer
.getMinLength(minLength));
Assert.assertEquals(null, SimpleTypeAnalyzer.getMaxLength(minLength));
Assert.assertEquals(null, SimpleTypeAnalyzer.getLength(minLength));
Assertions.assertEquals(null, SimpleTypeAnalyzer.getMaxLength(minLength));
Assertions.assertEquals(null, SimpleTypeAnalyzer.getLength(minLength));

Assert.assertEquals(Long.valueOf(5), SimpleTypeAnalyzer
Assertions.assertEquals(Long.valueOf(5), SimpleTypeAnalyzer
.getMinLength(maxLength));
Assert.assertEquals(Long.valueOf(10), SimpleTypeAnalyzer
Assertions.assertEquals(Long.valueOf(10), SimpleTypeAnalyzer
.getMaxLength(maxLength));
Assert.assertEquals(null, SimpleTypeAnalyzer.getLength(maxLength));
Assertions.assertEquals(null, SimpleTypeAnalyzer.getLength(maxLength));

Assert.assertEquals(Long.valueOf(5), SimpleTypeAnalyzer
Assertions.assertEquals(Long.valueOf(5), SimpleTypeAnalyzer
.getMinLength(length));
Assert.assertEquals(Long.valueOf(10), SimpleTypeAnalyzer
Assertions.assertEquals(Long.valueOf(10), SimpleTypeAnalyzer
.getMaxLength(length));
Assert.assertEquals(Long.valueOf(8), SimpleTypeAnalyzer
Assertions.assertEquals(Long.valueOf(8), SimpleTypeAnalyzer
.getLength(length));

Assert.assertEquals(Long.valueOf(5), SimpleTypeAnalyzer
Assertions.assertEquals(Long.valueOf(5), SimpleTypeAnalyzer
.getTotalDigits(digits));
Assert.assertEquals(Long.valueOf(2), SimpleTypeAnalyzer
Assertions.assertEquals(Long.valueOf(2), SimpleTypeAnalyzer
.getFractionDigits(digits));

Assert.assertEquals(Long.valueOf(3), SimpleTypeAnalyzer
Assertions.assertEquals(Long.valueOf(3), SimpleTypeAnalyzer
.getTotalDigits(totalDigits));
Assert.assertEquals(null, SimpleTypeAnalyzer
Assertions.assertEquals(null, SimpleTypeAnalyzer
.getFractionDigits(totalDigits));

Assert.assertEquals(null, SimpleTypeAnalyzer
Assertions.assertEquals(null, SimpleTypeAnalyzer
.getTotalDigits(fractionDigits));
Assert.assertEquals(Long.valueOf(2), SimpleTypeAnalyzer
Assertions.assertEquals(Long.valueOf(2), SimpleTypeAnalyzer
.getFractionDigits(fractionDigits));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter;

import junit.framework.TestCase;

import com.sun.tools.xjc.model.CAdapter;
import com.sun.tools.xjc.model.CBuiltinLeafInfo;
import com.sun.tools.xjc.model.TypeUse;
import com.sun.tools.xjc.model.TypeUseFactory;
import org.junit.jupiter.api.Test;

public class TypeUseTest extends TestCase {
public class TypeUseTest {

@Test
public void testEquals() throws Exception {

final CAdapter adapter = new CAdapter(NormalizedStringAdapter.class,
Expand Down
4 changes: 2 additions & 2 deletions hyperjaxb/ejb/roundtrip/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.commons.lang3.SystemUtils;
import org.junit.jupiter.api.Test;
import org.jvnet.jaxb.test.AbstractSamplesTest;
import org.jvnet.jaxb.xml.bind.ContextPathAware;

Expand Down Expand Up @@ -84,8 +85,11 @@ protected ClassLoader getContextClassLoader() {
};
}

@Test
public void testSamples() throws Exception {
samplesTest.testSamples();
if (samplesTest != null) {
samplesTest.testSamples();
}
}

protected JAXBContext createContext() throws JAXBException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.Persistence;

import junit.framework.TestCase;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

/**
* Roundtrip test case.
*
* @author Aleksei Valikov
*/
public abstract class AbstractEntityManagerTest extends TestCase {
public abstract class AbstractEntityManagerTest {

protected Log logger = LogFactory.getLog(getClass());

Expand All @@ -37,15 +37,20 @@ public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) {
this.entityManagerFactory = entityManagerFactory;
}

@BeforeEach
public void setUp() throws Exception {
super.setUp();
final EntityManagerFactory emf = getEntityManagerFactory();
if (emf == null || !emf.isOpen() || lastTestClass != getClass()) {
setEntityManagerFactory(createEntityManagerFactory());
lastTestClass = getClass();
}
}


@AfterEach
public void tearDown() throws Exception {
}

public String getPersistenceUnitName() {
final Package _package = getClass().getPackage();
final String name = _package.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.Unmarshaller;

import org.junit.jupiter.api.Assertions;
import org.jvnet.hyperjaxb3.ejb.util.EntityUtils;
import org.jvnet.jaxb.lang.ContextUtils;
import org.jvnet.jaxb.lang.EqualsStrategy;
Expand Down Expand Up @@ -131,9 +132,10 @@ public boolean equals(ObjectLocator leftLocator,

};
;
assertTrue("Objects must be equal.", strategy.equals(
Assertions.assertTrue(strategy.equals(
new DefaultRootObjectLocator(object),
new DefaultRootObjectLocator(loadedObject), object,
loadedObject, true, true));
loadedObject, true, true),
"Objects must be equal.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

import jakarta.persistence.EntityManager;

import org.junit.jupiter.api.Test;
import org.jvnet.hyperjaxb3.ejb.cascadedids.tests.Department.DepartmentId;
import org.jvnet.hyperjaxb3.ejb.test.AbstractEntityManagerTest;

public class EntityManagerTest extends AbstractEntityManagerTest {

@Test
public void testIt() throws Exception {

final Company company = new Company();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import jakarta.persistence.EntityManager;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.jvnet.hyperjaxb3.ejb.test.AbstractEntityManagerTest;

public class EntityManagerTest extends AbstractEntityManagerTest {

@Test
public void testIt() throws Exception {
final A a1 = new A();
final B b1 = new B();
Expand All @@ -27,8 +30,8 @@ public void testIt() throws Exception {

final A a3 = load("A");

assertEquals(a3.getD(), a2.getD());
assertEquals(a3.getB().getC(), a2.getB().getC());
Assertions.assertEquals(a3.getD(), a2.getD());
Assertions.assertEquals(a3.getB().getC(), a2.getB().getC());
}

public void save(A a) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.jvnet.hyperjaxb3.ejb.test.tests;

import junit.framework.TestCase;

import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;

public class JavaReflectionManagerTest extends TestCase {
public class JavaReflectionManagerTest {

@org.junit.jupiter.api.Test
public void testXClass() throws Exception {

final JavaReflectionManager manager = new JavaReflectionManager();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package org.jvnet.hyperjaxb3.hibernate.tests.hhh;

import static org.junit.Assert.assertNotNull;

import java.io.IOException;
import java.util.Properties;

import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.Persistence;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class EntityManagerFactoryTest {

Expand All @@ -20,7 +18,7 @@ public void entityManagerFactoryCreated() throws IOException {
final String persistenceUnitName = getClass().getPackage().getName();
final EntityManagerFactory entityManagerFactory = Persistence
.createEntityManagerFactory(persistenceUnitName, properties);
assertNotNull(entityManagerFactory);
Assertions.assertNotNull(entityManagerFactory);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

import java.math.BigDecimal;

import junit.framework.TestCase;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class NumberEqualsTest extends TestCase {
public class NumberEqualsTest {
@Test
public void testBigDecimal() throws Exception {

final BigDecimal a = new BigDecimal("2.001");
final BigDecimal b = new BigDecimal("2.0010");
assertTrue(a.compareTo(b) == 0);

Assertions.assertTrue(a.compareTo(b) == 0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

import junit.framework.TestCase;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.jupiter.api.Test;

public class XMLGregorianCalendarTest {

public class XMLGregorianCalendarTest extends TestCase {

protected Log logger = LogFactory.getLog(getClass());

private DatatypeFactory datatypeFactory;
Expand All @@ -25,6 +24,7 @@ public DatatypeFactory getDatatypeFactory() {
return datatypeFactory;
}

@Test
public void testIt() {

final XMLGregorianCalendar calendar = getDatatypeFactory()
Expand Down
Loading

0 comments on commit 48318e2

Please sign in to comment.