Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ZEPPELIN-5950] Migrate sparql to Junit5 #4644

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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