This is an automated email from the ASF dual-hosted git repository. afs pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/jena.git
commit 8f91c400468f0af2b3375bddae62309e2d3b2a01 Author: Thomas Thelen <[email protected]> AuthorDate: Wed Aug 5 06:59:30 2026 -0700 GH-2340: Migrate jena-fuseki-geosparql tests to JUnit 5 Convert the module's tests from JUnit 4 (vintage engine) to JUnit Jupiter and drop the vintage dependency in favour of junit-jupiter (managed by the root BOM). Annotation and assertion imports move to org.junit.jupiter; @Test(expected=...) becomes assertThrows. Remove empty IDE-generated lifecycle methods and constructors. --- jena-fuseki2/jena-fuseki-geosparql/pom.xml | 5 +- .../galbiston/rdf_tables/cli/ArgsConfigTest.java | 54 +++++++--------------- .../datatypes/DatatypeControllerTest.java | 23 +-------- .../rdf_tables/file/FileConverterTest.java | 22 ++------- .../apache/jena/fuseki/geosparql/EmptyTest.java | 23 +++------ .../org/apache/jena/fuseki/geosparql/MainTest.java | 21 +++------ .../org/apache/jena/fuseki/geosparql/TDB2Test.java | 21 +++------ .../org/apache/jena/fuseki/geosparql/TDBTest.java | 21 +++------ .../fuseki/geosparql/cli/RDFFileParameterTest.java | 32 ++----------- .../fuseki/geosparql/cli/TabFileParameterTest.java | 32 ++----------- 10 files changed, 59 insertions(+), 195 deletions(-) diff --git a/jena-fuseki2/jena-fuseki-geosparql/pom.xml b/jena-fuseki2/jena-fuseki-geosparql/pom.xml index 1f986115a8..b3cc5d2cc0 100644 --- a/jena-fuseki2/jena-fuseki-geosparql/pom.xml +++ b/jena-fuseki2/jena-fuseki-geosparql/pom.xml @@ -95,10 +95,9 @@ <scope>runtime</scope> </dependency> - <!-- Tests are JUnit4 --> <dependency> - <groupId>org.junit.vintage</groupId> - <artifactId>junit-vintage-engine</artifactId> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> <scope>test</scope> </dependency> diff --git a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/ext/io/github/galbiston/rdf_tables/cli/ArgsConfigTest.java b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/ext/io/github/galbiston/rdf_tables/cli/ArgsConfigTest.java index e1805c35bc..a6cd55b033 100644 --- a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/ext/io/github/galbiston/rdf_tables/cli/ArgsConfigTest.java +++ b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/ext/io/github/galbiston/rdf_tables/cli/ArgsConfigTest.java @@ -21,12 +21,9 @@ import com.beust.jcommander.JCommander; import com.beust.jcommander.ParameterException; import org.apache.jena.riot.RDFFormat; -import org.junit.After; -import org.junit.AfterClass; -import static org.junit.Assert.assertEquals; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; /** * @@ -34,25 +31,6 @@ import org.junit.Test; */ public class ArgsConfigTest { - public ArgsConfigTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of getOutputFormat method, of class ArgsConfig. */ @@ -232,23 +210,25 @@ public class ArgsConfigTest { /** * Test of getInputDelimiter method, of class ArgsConfig. */ - @Test(expected = ParameterException.class) + @Test public void testGetInputDelimiter_reserved() { //System.out"getInputDelimiter_reserved"); ArgsConfig args = new ArgsConfig(); String[] argv = {"-i", "test.rdf", "-l", "|"}; - JCommander.newBuilder() - .addObject(args) - .build() - .parse(argv); - - String expResult = ","; - String result = args.getInputDelimiter(); - - ////System.out"Exp: " + expResult); - ////System.out"Res: " + result); - assertEquals(expResult, result); + assertThrows(ParameterException.class, () -> { + JCommander.newBuilder() + .addObject(args) + .build() + .parse(argv); + + String expResult = ","; + String result = args.getInputDelimiter(); + + ////System.out"Exp: " + expResult); + ////System.out"Res: " + result); + assertEquals(expResult, result); + }); } } diff --git a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/ext/io/github/galbiston/rdf_tables/datatypes/DatatypeControllerTest.java b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/ext/io/github/galbiston/rdf_tables/datatypes/DatatypeControllerTest.java index 1e35d06fbe..b8b17e3e96 100644 --- a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/ext/io/github/galbiston/rdf_tables/datatypes/DatatypeControllerTest.java +++ b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/ext/io/github/galbiston/rdf_tables/datatypes/DatatypeControllerTest.java @@ -17,12 +17,12 @@ */ package org.apache.jena.ext.io.github.galbiston.rdf_tables.datatypes; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.jena.datatypes.xsd.impl.XSDBaseNumericType; import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.ResourceFactory; -import org.junit.*; +import org.junit.jupiter.api.Test; /** * @@ -30,25 +30,6 @@ import org.junit.*; */ public class DatatypeControllerTest { - public DatatypeControllerTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of createLiteral DateTime method, of class DataTypeExtract. */ diff --git a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/ext/io/github/galbiston/rdf_tables/file/FileConverterTest.java b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/ext/io/github/galbiston/rdf_tables/file/FileConverterTest.java index a8dbc8036e..bdfbe4f4f4 100644 --- a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/ext/io/github/galbiston/rdf_tables/file/FileConverterTest.java +++ b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/ext/io/github/galbiston/rdf_tables/file/FileConverterTest.java @@ -17,7 +17,7 @@ */ package org.apache.jena.ext.io.github.galbiston.rdf_tables.file; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.File; import java.net.URL; @@ -31,7 +31,8 @@ import org.apache.jena.ext.io.github.galbiston.rdf_tables.datatypes.PrefixContro import org.apache.jena.rdf.model.*; import org.apache.jena.vocabulary.RDF; import org.apache.jena.vocabulary.RDFS; -import org.junit.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * @@ -41,10 +42,7 @@ public class FileConverterTest { private static Model testModel; - public FileConverterTest() { - } - - @BeforeClass + @BeforeAll public static void setUpClass() { URL u = FileConverterTest.class.getClassLoader().getResource("TestData.csv"); // These URLs have the file name as an encoded string. @@ -56,18 +54,6 @@ public class FileConverterTest { FileConverter.writeToModel(inputFile, testModel); } - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of Age method, of class FileConverter. Check int datatype. */ diff --git a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/EmptyTest.java b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/EmptyTest.java index 3793144bcd..f29cffe57f 100644 --- a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/EmptyTest.java +++ b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/EmptyTest.java @@ -21,14 +21,16 @@ package org.apache.jena.fuseki.geosparql; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.List; import com.beust.jcommander.JCommander; -import org.junit.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.apache.jena.atlas.web.HttpException; import org.apache.jena.fuseki.geosparql.cli.ArgsConfig; @@ -48,10 +50,7 @@ public class EmptyTest { private static GeosparqlServer SERVER; - public EmptyTest() { - } - - @BeforeClass + @BeforeAll public static void setUpClass() throws DatasetException, SpatialIndexException { String[] args = {"-u", "--port", "4049"}; @@ -95,21 +94,11 @@ public class EmptyTest { } } - - - @AfterClass + @AfterAll public static void tearDownClass() { SERVER.shutdown(); } - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of empty dataset. */ diff --git a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/MainTest.java b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/MainTest.java index a07097c7fe..27e924494f 100644 --- a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/MainTest.java +++ b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/MainTest.java @@ -20,14 +20,16 @@ */ package org.apache.jena.fuseki.geosparql; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.List; import com.beust.jcommander.JCommander; -import org.junit.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.apache.jena.fuseki.geosparql.cli.ArgsConfig; import org.apache.jena.geosparql.spatial.SpatialIndexException; @@ -45,10 +47,7 @@ public class MainTest { private static GeosparqlServer SERVER; - public MainTest() { - } - - @BeforeClass + @BeforeAll public static void setUpClass() throws DatasetException, SpatialIndexException { String[] args = {"-rf", "geosparql_test.rdf>xml", "-i", "--port", "4048"}; @@ -66,21 +65,13 @@ public class MainTest { SERVER.start(); } - @AfterClass + @AfterAll public static void tearDownClass() { try { SERVER.shutdown(); } catch (Throwable th) {} } - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of main method, of class Main. */ diff --git a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/TDB2Test.java b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/TDB2Test.java index ef61e9a31f..3b00508b89 100644 --- a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/TDB2Test.java +++ b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/TDB2Test.java @@ -20,7 +20,7 @@ */ package org.apache.jena.fuseki.geosparql; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.nio.file.Files; @@ -30,7 +30,9 @@ import java.util.List; import com.beust.jcommander.JCommander; -import org.junit.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.apache.jena.fuseki.geosparql.cli.ArgsConfig; import org.apache.jena.geosparql.spatial.SpatialIndexException; @@ -45,10 +47,7 @@ public class TDB2Test { private static GeosparqlServer SERVER; - public TDB2Test() { - } - - @BeforeClass + @BeforeAll public static void setUpClass() throws DatasetException, SpatialIndexException, IOException { Path tempTDBDir = Files.createTempDirectory("geospoarql"); String[] args = {"-rf", "geosparql_test.rdf>xml", "-i", "-t", tempTDBDir.toAbsolutePath().toString(), "-t2", "--port", "4047"}; @@ -67,21 +66,13 @@ public class TDB2Test { SERVER.start(); } - @AfterClass + @AfterAll public static void tearDownClass() { try { SERVER.shutdown(); } catch (Throwable th) {} } - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of main method, of class Main. */ diff --git a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/TDBTest.java b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/TDBTest.java index 676e9255ae..43814dbe04 100644 --- a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/TDBTest.java +++ b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/TDBTest.java @@ -20,7 +20,7 @@ */ package org.apache.jena.fuseki.geosparql; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.nio.file.Files; @@ -30,7 +30,9 @@ import java.util.List; import com.beust.jcommander.JCommander; -import org.junit.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.apache.jena.fuseki.geosparql.cli.ArgsConfig; import org.apache.jena.geosparql.spatial.SpatialIndexException; @@ -45,10 +47,7 @@ public class TDBTest { private static GeosparqlServer SERVER; - public TDBTest() { - } - - @BeforeClass + @BeforeAll public static void setUpClass() throws DatasetException, SpatialIndexException, IOException { Path tempTDBDir = Files.createTempDirectory("geospoarql"); String[] args = {"-rf", "geosparql_test.rdf>xml", "-i", "-t", tempTDBDir.toAbsolutePath().toString(), "-t2", "--port", "4047"}; @@ -67,21 +66,13 @@ public class TDBTest { SERVER.start(); } - @AfterClass + @AfterAll public static void tearDownClass() { try { SERVER.shutdown(); } catch (Throwable th) {} } - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of main method, of class Main. */ diff --git a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/RDFFileParameterTest.java b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/RDFFileParameterTest.java index ceea93f80d..a3db24611e 100644 --- a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/RDFFileParameterTest.java +++ b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/RDFFileParameterTest.java @@ -25,34 +25,12 @@ import java.io.File; import java.util.Arrays; import java.util.List; import org.apache.jena.riot.RDFFormat; -import org.junit.After; -import org.junit.AfterClass; -import static org.junit.Assert.assertEquals; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; public class RDFFileParameterTest { - public RDFFileParameterTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of convert method, of class RDFFileParameter. */ @@ -88,13 +66,13 @@ public class RDFFileParameterTest { /** * Test of validate method, of class RDFFileParameter. */ - @Test(expected = ParameterException.class) + @Test public void testValidate() { //System.out.println("validate"); String name = "--rdf_file"; String value = "test.rdf>xml#test"; RDFFileParameter instance = new RDFFileParameter(); - instance.validate(name, value); + assertThrows(ParameterException.class, () -> instance.validate(name, value)); } } diff --git a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/TabFileParameterTest.java b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/TabFileParameterTest.java index 696113ba49..559cce3951 100644 --- a/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/TabFileParameterTest.java +++ b/jena-fuseki2/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/TabFileParameterTest.java @@ -24,34 +24,12 @@ import com.beust.jcommander.ParameterException; import java.io.File; import java.util.Arrays; import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import static org.junit.Assert.assertEquals; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; public class TabFileParameterTest { - public TabFileParameterTest() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of convert method, of class TabFileParameter. */ @@ -87,13 +65,13 @@ public class TabFileParameterTest { /** * Test of validate method, of class TabFileParameter. */ - @Test(expected = ParameterException.class) + @Test public void testValidate() { //System.out.println("validate"); String name = "--tab_file"; String value = "test.csv|COMMA#test"; TabFileParameter instance = new TabFileParameter(); - instance.validate(name, value); + assertThrows(ParameterException.class, () -> instance.validate(name, value)); } }
