Skip to content

Commit

Permalink
[ZEPPELIN-5950] Migrate sparql to Junit5 (#4644)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reamer authored Sep 11, 2023
1 parent 6181bfe commit 989bb21
Showing 1 changed file with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

package org.apache.zeppelin.sparql;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.apache.jena.fuseki.Fuseki;
import org.apache.jena.fuseki.main.FusekiServer;
import org.apache.jena.fuseki.server.DataAccessPointRegistry;
Expand All @@ -28,18 +25,19 @@
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;

import org.junit.AfterClass;
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.assertTrue;

import java.util.Properties;

import org.apache.zeppelin.interpreter.InterpreterResult;
import org.apache.zeppelin.interpreter.InterpreterResult.Code;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;


public class SparqlJenaEngineTest {
class SparqlJenaEngineTest {
private static int port;

private static FusekiServer server;
Expand All @@ -52,7 +50,7 @@ public class SparqlJenaEngineTest {

private static final String DATA_FILE = "data.ttl";

@BeforeClass
@BeforeAll
public static void setUp() {
port = Fuseki.choosePort();

Expand All @@ -71,22 +69,22 @@ public static void setUp() {
server.start();
}

@AfterClass
@AfterAll
public static void tearDown() {
if (server != null) {
server.stop();
}
}

@Before
@BeforeEach
public void setUpProperties() {
properties = new Properties();
properties.put(SparqlInterpreter.SPARQL_ENGINE_TYPE, ENGINE);
properties.put(SparqlInterpreter.SPARQL_SERVICE_ENDPOINT, HOST + ":" + port + DATASET);
}

@Test
public void testWrongQuery() {
void testWrongQuery() {
SparqlInterpreter interpreter = new SparqlInterpreter(properties);
interpreter.open();

Expand All @@ -95,7 +93,7 @@ public void testWrongQuery() {
}

@Test
public void testSuccessfulRawQuery() {
void testSuccessfulRawQuery() {
properties.put(SparqlInterpreter.SPARQL_REPLACE_URIS, "false");
properties.put(SparqlInterpreter.SPARQL_REMOVE_DATATYPES, "false");
SparqlInterpreter interpreter = new SparqlInterpreter(properties);
Expand Down Expand Up @@ -128,7 +126,7 @@ public void testSuccessfulRawQuery() {
}

@Test
public void testSuccessfulReplaceRemoveQuery() {
void testSuccessfulReplaceRemoveQuery() {
properties.put(SparqlInterpreter.SPARQL_REPLACE_URIS, "true");
properties.put(SparqlInterpreter.SPARQL_REMOVE_DATATYPES, "true");
SparqlInterpreter interpreter = new SparqlInterpreter(properties);
Expand Down Expand Up @@ -161,7 +159,7 @@ public void testSuccessfulReplaceRemoveQuery() {
}

@Test
public void testRemoteEndpoint() {
void testRemoteEndpoint() {
properties.put(SparqlInterpreter.SPARQL_SERVICE_ENDPOINT, "http://dbpedia.org/sparql");
SparqlInterpreter interpreter = new SparqlInterpreter(properties);
interpreter.open();
Expand All @@ -178,7 +176,7 @@ public void testRemoteEndpoint() {
}

@Test
public void testEndpointMalformed() {
void testEndpointMalformed() {
properties.put(SparqlInterpreter.SPARQL_SERVICE_ENDPOINT, "tsohlacol");
SparqlInterpreter interpreter = new SparqlInterpreter(properties);
interpreter.open();
Expand All @@ -189,7 +187,7 @@ public void testEndpointMalformed() {
}

@Test
public void testEndpointNotFound() {
void testEndpointNotFound() {
properties.put(SparqlInterpreter.SPARQL_SERVICE_ENDPOINT, "http://tsohlacol/");
SparqlInterpreter interpreter = new SparqlInterpreter(properties);
interpreter.open();
Expand Down

0 comments on commit 989bb21

Please sign in to comment.