Skip to content

Commit 3a8b4ab

Browse files
antoniosanctlukasj
andauthored
fix #267, migrating JUnit 4 to JUnit 5 (#292)
Signed-off-by: Antonio Santos Izaguirre <antoniosanct@gmail.com> Signed-off-by: Antonio <antoniosanct@gmail.com> Co-authored-by: Lukas Jungmann <1069133+lukasj@users.noreply.github.com>
1 parent 5d9a14b commit 3a8b4ab

File tree

12 files changed

+253
-207
lines changed

12 files changed

+253
-207
lines changed

api/src/main/java/jakarta/xml/bind/JAXBIntrospector.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
22
* Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2026 Contributors to the Eclipse Foundation. All rights reserved.
34
*
45
* This program and the accompanying materials are made available under the
56
* terms of the Eclipse Distribution License v. 1.0, which is available at
67
* http://www.eclipse.org/org/documents/edl-v10.php.
78
*
89
* SPDX-License-Identifier: BSD-3-Clause
910
*/
10-
1111
package jakarta.xml.bind;
1212

1313
import javax.xml.namespace.QName;
@@ -72,12 +72,12 @@ protected JAXBIntrospector() {}
7272
* @return The element value of the <code>jaxbElement</code>.
7373
*/
7474
public static Object getValue(Object jaxbElement) {
75-
if (jaxbElement instanceof JAXBElement) {
76-
return ((JAXBElement<?>)jaxbElement).getValue();
77-
} else {
78-
// assume that class of this instance is
79-
// annotated with @XmlRootElement.
80-
return jaxbElement;
81-
}
75+
if (jaxbElement instanceof JAXBElement) {
76+
return ((JAXBElement<?>)jaxbElement).getValue();
77+
} else {
78+
// assume that class of this instance is
79+
// annotated with @XmlRootElement.
80+
return jaxbElement;
81+
}
8282
}
8383
}

jaxb-api-test/pom.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright (c) 2018, 2023 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2018, 2024 Oracle and/or its affiliates. All rights reserved.
5+
Copyright (c) 2026 Contributors to the Eclipse Foundation. All rights reserved.
56
67
This program and the accompanying materials are made available under the
78
terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -30,9 +31,9 @@
3031

3132
<dependencies>
3233
<dependency>
33-
<groupId>junit</groupId>
34-
<artifactId>junit</artifactId>
35-
<version>4.13.2</version>
34+
<groupId>org.junit.jupiter</groupId>
35+
<artifactId>junit-jupiter-params</artifactId>
36+
<version>5.14.2</version>
3637
<scope>test</scope>
3738
</dependency>
3839
<dependency>

jaxb-api-test/src/main/java/module-info.java

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2026 Contributors to the Eclipse Foundation. All rights reserved.
4+
*
5+
* This program and the accompanying materials are made available under the
6+
* terms of the Eclipse Distribution License v. 1.0, which is available at
7+
* http://www.eclipse.org/org/documents/edl-v10.php.
8+
*
9+
* SPDX-License-Identifier: BSD-3-Clause
10+
*/
11+
12+
/**
13+
* Tests for jaxb API.
14+
*/
15+
package jakarta.xml.bind.test;
16+
17+
import java.lang.annotation.ElementType;
18+
import java.lang.annotation.Retention;
19+
import java.lang.annotation.RetentionPolicy;
20+
import java.lang.annotation.Target;
21+
22+
import org.junit.jupiter.params.ParameterizedTest;
23+
import org.junit.jupiter.params.provider.CsvFileSource;
24+
25+
@ParameterizedTest
26+
@CsvFileSource(resources = "/jakarta/xml/bind/test/allScenarios.csv", numLinesToSkip = 9, nullValues = "**")
27+
@Target(ElementType.METHOD)
28+
@Retention(RetentionPolicy.RUNTIME)
29+
public @interface JAXBContextOldParameterized {
30+
31+
}

jaxb-api-test/src/test/java/jakarta/xml/bind/test/JAXBContextServiceProviderNPETest.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2026 Contributors to the Eclipse Foundation. All rights reserved.
34
*
45
* This program and the accompanying materials are made available under the
56
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -10,15 +11,18 @@
1011

1112
package jakarta.xml.bind.test;
1213

13-
import org.junit.Before;
14-
import org.junit.Test;
14+
import jakarta.xml.bind.JAXBContext;
15+
import jakarta.xml.bind.JAXBContextFactory;
16+
import jakarta.xml.bind.JAXBException;
17+
import jakarta.xml.bind.Marshaller;
18+
import jakarta.xml.bind.Unmarshaller;
1519

16-
import jakarta.xml.bind.*;
1720
import java.util.Map;
1821

19-
import static junit.framework.Assert.assertEquals;
20-
import static junit.framework.Assert.assertNotNull;
21-
import static junit.framework.TestCase.fail;
22+
import org.junit.jupiter.api.Assertions;
23+
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.Test;
25+
2226

2327
/**
2428
* regression test for
@@ -57,27 +61,27 @@ public Marshaller createMarshaller() throws JAXBException {
5761
public void testContextPath() {
5862
try {
5963
JAXBContext ctx = JAXBContext.newInstance("whatever", ClassLoader.getSystemClassLoader());
60-
assertNotNull("Expected non-null instance to be returned from the test Factory", ctx);
61-
assertEquals("Expected MyContext instance to be returned from the test Factory", MyContext.class, ctx.getClass());
64+
Assertions.assertNotNull(ctx,"Expected non-null instance to be returned from the test Factory");
65+
Assertions.assertEquals(MyContext.class, ctx.getClass(), "Expected MyContext instance to be returned from the test Factory");
6266
} catch (Throwable t) {
6367
t.printStackTrace();
64-
fail("Not expected to fail!");
68+
Assertions.fail("Not expected to fail!");
6569
}
6670
}
6771

6872
@Test
6973
public void testClasses() {
7074
try {
71-
JAXBContext ctx = JAXBContext.newInstance(new Class[0]);
72-
assertNotNull("Expected non-null instance to be returned from the test Factory", ctx);
73-
assertEquals("Expected MyContext instance to be returned from the test Factory", MyContext.class, ctx.getClass());
75+
JAXBContext ctx = JAXBContext.newInstance(new Class<?>[0]);
76+
Assertions.assertNotNull(ctx, "Expected non-null instance to be returned from the test Factory");
77+
Assertions.assertEquals(MyContext.class, ctx.getClass(), "Expected MyContext instance to be returned from the test Factory");
7478
} catch (Throwable t) {
7579
t.printStackTrace();
76-
fail("Not expected to fail!");
80+
Assertions.fail("Not expected to fail!");
7781
}
7882
}
7983

80-
@Before
84+
@BeforeEach
8185
public void setup() {
8286
System.setProperty("jakarta.xml.bind.JAXBContextFactory", "jakarta.xml.bind.test.JAXBContextServiceProviderNPETest$Factory");
8387
}

0 commit comments

Comments
 (0)