Skip to content

Commit

Permalink
Fix up tests
Browse files Browse the repository at this point in the history
- Add overall test suite
- change version to date based version
- change jar name
  • Loading branch information
zacharywhitley committed Jul 29, 2020
1 parent bac2909 commit c88447d
Show file tree
Hide file tree
Showing 12 changed files with 352 additions and 199 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<modelVersion>4.0.0</modelVersion>

<groupId>com.semantalytics.stardog</groupId>
<artifactId>functions</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>extensions</artifactId>
<version>2020.07.28.1</version>

<developers>
<developer>
Expand Down Expand Up @@ -150,7 +150,7 @@
</repositories>

<build>
<finalName>semantalytics-stardog-${project.artifactId}-${project.version}-sd${stardog.major.version}</finalName>
<finalName>semantalytics-${project.artifactId}-${project.version}-sd${stardog.major.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.complexible.common.protocols.server.Server;
import com.complexible.common.protocols.server.ServerException;
import com.complexible.stardog.Stardog;
import com.complexible.stardog.StardogConfiguration;
import com.complexible.stardog.StardogException;
import com.complexible.stardog.StardogLicense;
import com.complexible.stardog.api.Connection;
import com.complexible.stardog.api.ConnectionConfiguration;
import com.complexible.stardog.api.admin.AdminConnection;
Expand All @@ -27,9 +29,8 @@ public abstract class AbstractStardogTest {
private static Server SERVER;
private static final String DB = "test";
private static int TEST_PORT = 5888;
private static final String STARDOG_HOME = System.getenv("STARDOG_HOME");
private static final String STARDOG_LICENSE_PATH = System.getenv("STARDOG_LICENSE_PATH");
protected Connection connection;
private static final String STARDOG_LICENCE_KEY_FILE_NAME = "stardog-license-key.bin";

@BeforeClass
public static void beforeClass() throws IOException, ServerException {
Expand All @@ -44,31 +45,29 @@ public static void beforeClass() throws IOException, ServerException {
final File TEST_HOME = Files.createTempDir();
TEST_HOME.deleteOnExit();

Files.copy(new File(STARDOG_HOME + "/" + STARDOG_LICENCE_KEY_FILE_NAME),
new File(TEST_HOME, STARDOG_LICENCE_KEY_FILE_NAME));

try {
Files.copy(new File(Resources.getResource("log4j2-test.xml").toURI()), new File(TEST_HOME, "log4j2.xml"));
} catch(URISyntaxException e1) {

}

STARDOG = Stardog.builder().home(TEST_HOME).create();
STARDOG = Stardog.builder()
.set(StardogConfiguration.LICENSE_LOCATION, STARDOG_LICENSE_PATH)
.home(TEST_HOME).create();

SERVER = STARDOG.newServer()
//.set(ServerOptions.SECURITY_DISABLED, true)
.bind(new InetSocketAddress("localhost", TEST_PORT)).start();
}


adminConnection = AdminConnectionConfiguration.toEmbeddedServer()
.credentials("admin", "admin")
.connect();

if (adminConnection.list().contains(DB)) {
adminConnection.drop(DB);
} else {
adminConnection.newDatabase(DB).create();
}

adminConnection.newDatabase(DB).create();
}
}

@AfterClass
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.semantalytics.stardog.kibble;

import com.complexible.common.protocols.server.Server;
import com.complexible.common.protocols.server.ServerException;
import com.complexible.stardog.Stardog;
import com.complexible.stardog.StardogConfiguration;
import com.complexible.stardog.api.Connection;
import com.complexible.stardog.api.admin.AdminConnection;
import com.complexible.stardog.api.admin.AdminConnectionConfiguration;
import com.google.common.io.Files;
import com.semantalytics.stardog.kibble.array.ArrayTestSuite;
import com.semantalytics.stardog.kibble.console.ConsoleTestSuite;
import com.semantalytics.stardog.kibble.geo.geohash.GeohashTestSuite;
import com.semantalytics.stardog.kibble.string.*;
import com.semantalytics.stardog.kibble.string.comparison.StringMetricTestSuite;
import com.semantalytics.stardog.kibble.string.emoji.EmojiTestSuite;
import com.semantalytics.stardog.kibble.string.escape.EscapeTestSuite;
import com.semantalytics.stardog.kibble.string.phonetic.PhoneticTestSuite;
import com.semantalytics.stardog.kibble.string.unescape.UnescapeTestSuite;
import junit.framework.TestCase;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;

@RunWith(Suite.class)
@SuiteClasses({
ArrayTestSuite.class,
ConsoleTestSuite.class,
GeohashTestSuite.class,
StringMetricTestSuite.class,
EmojiTestSuite.class,
EscapeTestSuite.class,
PhoneticTestSuite.class,
UnescapeTestSuite.class,
StringTestSuite.class,
})

public class StardogExtensionsTestSuite extends TestCase {

private static Stardog STARDOG;
private static Server SERVER;
public static final String DB = "test";
public static final int TEST_PORT = 5888;
protected Connection connection;
private static final String STARDOG_LICENSE_PATH = System.getenv("STARDOG_LICENSE_PATH");

@BeforeClass
public static void beforeClass() throws IOException, ServerException {

final File TEST_HOME;

TEST_HOME = Files.createTempDir();
TEST_HOME.deleteOnExit();

STARDOG = Stardog.builder()
.set(StardogConfiguration.LICENSE_LOCATION, STARDOG_LICENSE_PATH)
.home(TEST_HOME).create();

SERVER = STARDOG.newServer()
.bind(new InetSocketAddress("localhost", TEST_PORT))
.start();

final AdminConnection adminConnection = AdminConnectionConfiguration.toEmbeddedServer()
.credentials("admin", "admin")
.connect();

if (adminConnection.list().contains(DB)) {
adminConnection.drop(DB);
}

adminConnection.newDatabase(DB).create();
}

@AfterClass
public static void afterClass() {
if (SERVER != null) {
SERVER.stop();
}
STARDOG.shutdown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.complexible.common.protocols.server.Server;
import com.complexible.common.protocols.server.ServerException;
import com.complexible.stardog.Stardog;
import com.complexible.stardog.StardogConfiguration;
import com.complexible.stardog.StardogException;
import com.complexible.stardog.api.Connection;
import com.complexible.stardog.api.admin.AdminConnection;
import com.complexible.stardog.api.admin.AdminConnectionConfiguration;
Expand Down Expand Up @@ -58,44 +60,51 @@ public class ArrayTestSuite extends TestCase {
private static Server SERVER;
public static final String DB = "test";
public static final int TEST_PORT = 5888;
private static final String STARDOG_HOME = System.getenv("STARDOG_HOME");
protected Connection connection;
private static final String STARDOG_LICENCE_KEY_FILE_NAME = "stardog-license-key.bin";
private static final String STARDOG_LICENSE_PATH = System.getenv("STARDOG_LICENSE_PATH");

@BeforeClass
public static void beforeClass() throws IOException, ServerException {

final File TEST_HOME;
try{
AdminConnectionConfiguration.toEmbeddedServer()
.credentials("admin", "admin")
.connect();
} catch(StardogException e) {

TEST_HOME = Files.createTempDir();
TEST_HOME.deleteOnExit();

Files.copy(new File(STARDOG_HOME + "/" + STARDOG_LICENCE_KEY_FILE_NAME),
new File(TEST_HOME, STARDOG_LICENCE_KEY_FILE_NAME));
final File TEST_HOME;

STARDOG = Stardog.builder().home(TEST_HOME).create();
TEST_HOME = Files.createTempDir();
TEST_HOME.deleteOnExit();

SERVER = STARDOG.newServer()
//.set(ServerOptions.SECURITY_DISABLED, true)
.bind(new InetSocketAddress("localhost", TEST_PORT))
.start();
STARDOG = Stardog.builder()
.set(StardogConfiguration.LICENSE_LOCATION, STARDOG_LICENSE_PATH)
.home(TEST_HOME).create();

final AdminConnection adminConnection = AdminConnectionConfiguration.toEmbeddedServer()
.credentials("admin", "admin")
.connect();
SERVER = STARDOG.newServer()
.bind(new InetSocketAddress("localhost", TEST_PORT))
.start();

if (adminConnection.list().contains(DB)) {
adminConnection.drop(DB);
}
final AdminConnection adminConnection = AdminConnectionConfiguration.toEmbeddedServer()
.credentials("admin", "admin")
.connect();

if (adminConnection.list().contains(DB)) {
adminConnection.drop(DB);
}

adminConnection.newDatabase(DB).create();
adminConnection.newDatabase(DB).create();
}
}

@AfterClass
public static void afterClass() {
if (SERVER != null) {
SERVER.stop();
}
STARDOG.shutdown();
if (STARDOG != null) {
STARDOG.shutdown();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.complexible.common.protocols.server.Server;
import com.complexible.common.protocols.server.ServerException;
import com.complexible.stardog.Stardog;
import com.complexible.stardog.StardogConfiguration;
import com.complexible.stardog.StardogException;
import com.complexible.stardog.api.Connection;
import com.complexible.stardog.api.admin.AdminConnection;
import com.complexible.stardog.api.admin.AdminConnectionConfiguration;
Expand Down Expand Up @@ -72,44 +74,49 @@ public class ConsoleTestSuite extends TestCase {
private static Server SERVER;
public static final String DB = "test";
public static final int TEST_PORT = 5888;
private static final String STARDOG_HOME = System.getenv("STARDOG_HOME");
protected Connection connection;
private static final String STARDOG_LICENCE_KEY_FILE_NAME = "stardog-license-key.bin";
private static final String STARDOG_LICENSE_PATH = System.getenv("STARDOG_LICENSE_PATH");

@BeforeClass
public static void beforeClass() throws IOException, ServerException {
try{
AdminConnectionConfiguration.toEmbeddedServer()
.credentials("admin", "admin")
.connect();
} catch(StardogException e) {

final File TEST_HOME;
final File TEST_HOME;

TEST_HOME = Files.createTempDir();
TEST_HOME.deleteOnExit();
TEST_HOME = Files.createTempDir();
TEST_HOME.deleteOnExit();

Files.copy(new File(STARDOG_HOME + "/" + STARDOG_LICENCE_KEY_FILE_NAME),
new File(TEST_HOME, STARDOG_LICENCE_KEY_FILE_NAME));
STARDOG = Stardog.builder()
.set(StardogConfiguration.LICENSE_LOCATION, STARDOG_LICENSE_PATH)
.home(TEST_HOME).create();

STARDOG = Stardog.builder().home(TEST_HOME).create();
SERVER = STARDOG.newServer()
.bind(new InetSocketAddress("localhost", TEST_PORT))
.start();

SERVER = STARDOG.newServer()
//.set(ServerOptions.SECURITY_DISABLED, true)
.bind(new InetSocketAddress("localhost", TEST_PORT))
.start();
final AdminConnection adminConnection = AdminConnectionConfiguration.toEmbeddedServer()
.credentials("admin", "admin")
.connect();

final AdminConnection adminConnection = AdminConnectionConfiguration.toEmbeddedServer()
.credentials("admin", "admin")
.connect();
if (adminConnection.list().contains(DB)) {
adminConnection.drop(DB);
}

if (adminConnection.list().contains(DB)) {
adminConnection.drop(DB);
adminConnection.newDatabase(DB).create();
}

adminConnection.newDatabase(DB).create();
}

@AfterClass
public static void afterClass() {
if (SERVER != null) {
SERVER.stop();
}
STARDOG.shutdown();
if(STARDOG != null) {
STARDOG.shutdown();
}
}
}
Loading

0 comments on commit c88447d

Please sign in to comment.