Skip to content

Commit

Permalink
Convert to JUnit5
Browse files Browse the repository at this point in the history
  • Loading branch information
afs committed Dec 20, 2024
1 parent 4ca8996 commit 67bc182
Show file tree
Hide file tree
Showing 52 changed files with 505 additions and 494 deletions.
6 changes: 6 additions & 0 deletions jena-fuseki2/jena-fuseki-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>

<!-- micrometer -->
<dependency>
<groupId>io.micrometer</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@

package org.apache.jena.fuseki;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

import org.apache.jena.fuseki.server.TestDatasetDescriptionMap;
import org.apache.jena.fuseki.server.TestDispatchOnURI;
import org.apache.jena.fuseki.servlets.TestCrossOriginFilterMock;
import org.apache.jena.fuseki.servlets.TestPrefixesCore;

// Most testing needs a server.
@RunWith(Suite.class)
@SuiteClasses({
@Suite
@SelectClasses({
TestValidators.class,
TestDispatchOnURI.class,
TestCrossOriginFilterMock.class,
TestDatasetDescriptionMap.class
TestDatasetDescriptionMap.class,
TestPrefixesCore.class
})
public class TS_FusekiCore {}

Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
* limitations under the License.
*/

package org.apache.jena.fuseki.servlets.prefixes;
package org.apache.jena.fuseki.servlets;

import org.junit.jupiter.api.Test;

import org.apache.jena.fuseki.servlets.prefixes.PrefixUtils;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class UtilsTests {
public class TestPrefixesCore {
@Test
public void prefixIsValidTrue0() {
assertTrue(PrefixUtils.prefixIsValid("prefix1"));
Expand All @@ -48,10 +50,17 @@ public void prefixIsValidTrue3() {
public void prefixIsValidTrue4() {
assertTrue(PrefixUtils.prefixIsValid("ca7--t"));
}

@Test
public void prefixIsValidTrue5() {
assertTrue(PrefixUtils.prefixIsValid("a__b"));
}

@Test
public void prefixIsValidTrue6() {
assertTrue(PrefixUtils.prefixIsValid(""));
}

@Test
public void prefixIsValidFalse0() {
assertFalse(PrefixUtils.prefixIsValid("-prefix1"));
Expand All @@ -64,16 +73,11 @@ public void prefixIsValidFalse1() {

@Test
public void prefixIsValidFalse2() {
assertFalse(PrefixUtils.prefixIsValid(""));
}

@Test
public void prefixIsValidFalse4() {
assertFalse(PrefixUtils.prefixIsValid("c-b--"));
}

@Test
public void prefixIsValidFalse5() {
public void prefixIsValidFalse3() {
assertFalse(PrefixUtils.prefixIsValid("pre/fix"));
}

Expand All @@ -86,5 +90,4 @@ public void uriIsValidTrue0() {
public void uriIsValidFalse0() {
assertFalse(PrefixUtils.uriIsValid("..."));
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ public void serverArgsPrepare(CmdGeneral fusekiCmd, ServerArgs serverArgs) {
@Override
public void prepare(FusekiServer.Builder builder, Set<String> datasetNames, Model configModel) {
// Unpack

// XXX Do better!
FusekiApp.FUSEKI_BASE = null;

// FusekiApp fusekiApp = new FusekiApp();
// //fusekiApp.init();
// String fusekiApp.FUSEKI_BASE

Path path = FusekiApp.setup();

FmtLog.info(LOG, "Fuseki Admin: %s", path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

import org.apache.jena.fuseki.main.TC_FusekiMain;
import org.apache.jena.fuseki.mod.TC_FusekiMods;
import org.apache.jena.fuseki.main.TS_FusekiMain;
import org.apache.jena.fuseki.main.access.TS_SecurityFuseki;
import org.apache.jena.fuseki.main.prefixes.TS_PrefixesService;
import org.apache.jena.fuseki.mod.TS_FusekiMods;

@Suite
@SelectClasses({
TC_FusekiMain.class,
TC_FusekiMods.class
TS_FusekiMain.class,
TS_SecurityFuseki.class,
TS_FusekiMods.class,
TS_PrefixesService.class
})
public class TC_FusekiServer {}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

package org.apache.jena.fuseki.main;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.sparql.core.DatasetGraphFactory;
import org.junit.After;
import org.junit.Before;

/**
* Common setup for running a server with services and an initially empty database.
Expand All @@ -39,7 +40,7 @@ public class AbstractFusekiTest {
protected String serviceGSP_R() { return databaseURL()+"/get"; }
protected String serviceGSP() { return databaseURL()+"/data"; }

@Before public void startServer() {
@BeforeEach public void startServer() {
DatasetGraph dsgTesting = DatasetGraphFactory.createTxnMem();
server = FusekiServer.create()
.port(0)
Expand All @@ -50,7 +51,7 @@ public class AbstractFusekiTest {
.start();
}

@After public void stopServer() {
@AfterEach public void stopServer() {
if ( server != null )
server.stop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
import java.net.Authenticator;
import java.net.http.HttpClient;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

import org.apache.jena.http.auth.AuthLib;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.sparql.core.DatasetGraphFactory;
import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
import org.apache.jena.sparql.exec.http.UpdateExecutionHTTP;
import org.apache.jena.sparql.exec.http.UpdateExecutionHTTPBuilder;
import org.junit.After;
import org.junit.Before;

/**
* Common setup for running a server with an initially empty database with authentication by password file.
Expand All @@ -44,7 +45,7 @@ public class AbstractTestAuth_JDK {
protected String databaseURL() { return server.datasetURL(datasetPath()); }
protected String serverURL() { return server.serverURL(); }

@Before public void startServer() {
@BeforeEach public void startServer() {
String passwordFile = "testing/Access/auth-jdk-passwd";
DatasetGraph dsgTesting = DatasetGraphFactory.createTxnMem();
server = FusekiServer.create()
Expand All @@ -57,7 +58,7 @@ public class AbstractTestAuth_JDK {
server.start();
}

@After public void stopServer() {
@AfterEach public void stopServer() {
if ( server != null )
server.stop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.jena.fuseki.main;

import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.fail;

import org.apache.jena.atlas.web.HttpException;
import org.apache.jena.sparql.engine.http.QueryExceptionHTTP;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

import org.apache.jena.fuseki.main.prefixes.PrefixesServiceTests;
import org.apache.jena.fuseki.main.prefixes.TS_PrefixesService;
import org.apache.jena.fuseki.main.sys.TestFusekiModules;

@Suite
@SelectClasses({

TestPlainServer.class

// This tests modules and modifies the system state.
Expand Down Expand Up @@ -55,7 +54,7 @@
, TestPatchFuseki.class
, TestFusekiCustomScriptFunc.class

, PrefixesServiceTests.class
, TS_PrefixesService.class
, TestMetrics.class
, TestFusekiShaclValidation.class

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.runners.MethodSorters;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.jena.update.UpdateExecution;
import org.apache.jena.update.UpdateRequest;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.runners.MethodSorters;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@

import static org.apache.jena.fuseki.test.HttpTest.expect400;
import static org.apache.jena.fuseki.test.HttpTest.expect404;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

import java.io.IOException;

import org.junit.jupiter.api.Test;

import org.apache.jena.atlas.io.IO;
import org.apache.jena.atlas.web.TypedInputStream;
import org.apache.jena.base.Sys;
Expand All @@ -34,7 +36,6 @@
import org.apache.jena.rdfconnection.RDFConnectionRemote;
import org.apache.jena.rdfconnection.RDFConnectionRemoteBuilder;
import org.apache.jena.sparql.core.Var;
import org.junit.Test;

/** Test server configuration by configuration file */
public class TestConfigFile {
Expand Down Expand Up @@ -371,21 +372,21 @@ private static void assertCxtValue(RDFConnection conn, String contextSymbol, Str

private static void assertCxtValueNotNull(RDFConnection conn, String contextSymbol) {
boolean b = conn.queryAsk(PREFIXES+"ASK { FILTER (afn:context('"+contextSymbol+"') != '' ) }");
assertTrue(contextSymbol, b);
assertTrue(b, contextSymbol);
}

private static void assertCxtValueNull(RDFConnection conn, String contextSymbol) {
boolean b = conn.queryAsk(PREFIXES+"ASK { FILTER (afn:context('"+contextSymbol+"') = '' ) }");
assertTrue("Not null: "+contextSymbol, b);
assertTrue(b, "Not null: "+contextSymbol);
}
private static void assertQueryTrue(RDFConnection conn, String qs) {
boolean b = conn.queryAsk(PREFIXES+qs);
assertTrue(qs, b);
assertTrue(b, qs);
}

private static void assertQueryFalse(RDFConnection conn, String qs) {
boolean b = conn.queryAsk(PREFIXES+qs);
assertFalse(qs, b);
assertFalse(b, qs);
}

private FusekiServer server(int port, String configFile) {
Expand Down
Loading

0 comments on commit 67bc182

Please sign in to comment.