Merge pull request #11687 from hkhan/JAVA-9425-fix-sirix-integration-tests
[JAVA-9425] Fix failing integration tests in Sirix module
This commit is contained in:
commit
08101f8e2d
|
@ -1,17 +1,9 @@
|
|||
package io.sirix.tutorial.json;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
import org.sirix.access.ResourceConfiguration;
|
||||
|
@ -19,27 +11,29 @@ import org.sirix.service.json.serialize.JsonSerializer;
|
|||
import org.sirix.service.json.shredder.JsonShredder;
|
||||
import org.sirix.settings.VersioningType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public final class CreateJsonDatabaseIntegrationTest {
|
||||
|
||||
private static final Path JSON_DIRECTORY = Paths.get("src", "test", "resources", "json");
|
||||
|
||||
private static final String TMP_DIRECTORY = System.getProperty("java.io.tmpdir");
|
||||
|
||||
private static final Path DATABASE_PATH = Paths.get(TMP_DIRECTORY, "sirix", "json-database");
|
||||
|
||||
private static final String COMPLEX_JSON =
|
||||
"{\"problems\":[{\"Diabetes\":[{\"medications\":[{\"medicationsClasses\":[{\"className\":[{\"associatedDrug\":[{\"name\":\"asprin\",\"dose\":\"\",\"strength\":\"500 mg\"}],\"associatedDrug#2\":[{\"name\":\"somethingElse\",\"dose\":\"\",\"strength\":\"500 mg\"}]}],\"className2\":[{\"associatedDrug\":[{\"name\":\"asprin\",\"dose\":\"\",\"strength\":\"500 mg\"}],\"associatedDrug#2\":[{\"name\":\"somethingElse\",\"dose\":\"\",\"strength\":\"500 mg\"}]}]}]}],\"labs\":[{\"missing_field\":\"missing_value\"}]}],\"Asthma\":[{}]}]}";
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
}
|
||||
@Rule
|
||||
public TemporaryFolder tempDirectory = new TemporaryFolder();
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
private Path databasePath;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
databasePath = Paths.get(tempDirectory.getRoot().getPath(), "sirix", "json-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,10 +41,10 @@ public final class CreateJsonDatabaseIntegrationTest {
|
|||
final var pathToJsonFile = JSON_DIRECTORY.resolve("complex1.json");
|
||||
|
||||
// Create an empty JSON database.
|
||||
Databases.createJsonDatabase(new DatabaseConfiguration(DATABASE_PATH));
|
||||
Databases.createJsonDatabase(new DatabaseConfiguration(databasePath));
|
||||
|
||||
// Open the database.
|
||||
try (final var database = Databases.openJsonDatabase(DATABASE_PATH)) {
|
||||
try (final var database = Databases.openJsonDatabase(databasePath)) {
|
||||
// Create a resource to store a JSON-document.
|
||||
database.createResource(ResourceConfiguration.newBuilder("resource")
|
||||
.useTextCompression(false)
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
package io.sirix.tutorial.json;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
import org.sirix.api.ResourceManager;
|
||||
|
@ -23,28 +16,29 @@ import org.sirix.axis.temporal.PastAxis;
|
|||
import org.sirix.axis.visitor.VisitorDescendantAxis;
|
||||
import org.sirix.node.immutable.json.ImmutableObjectKeyNode;
|
||||
|
||||
public final class CreateVersionedJsonResourceAndQueryIntegrationTest {
|
||||
private static final String TMP_DIRECTORY = System.getProperty("java.io.tmpdir");
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
private static final Path DATABASE_PATH = Paths.get(TMP_DIRECTORY, "sirix", "json-database");
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public final class CreateVersionedJsonResourceAndQueryIntegrationTest {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tempDirectory = new TemporaryFolder();
|
||||
|
||||
private Path databasePath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
public void setUp() {
|
||||
databasePath = Paths.get(tempDirectory.getRoot().getPath(), "sirix", "json-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createVersionedResourceAndQueryWithTheVisitoDescendantAxis() throws IOException {
|
||||
Databases.createJsonDatabase(new DatabaseConfiguration(DATABASE_PATH));
|
||||
public void createVersionedResourceAndQueryWithTheVisitoDescendantAxis() {
|
||||
Databases.createJsonDatabase(new DatabaseConfiguration(databasePath));
|
||||
|
||||
try (final var database = Databases.openJsonDatabase(DATABASE_PATH)) {
|
||||
try (final var database = Databases.openJsonDatabase(databasePath)) {
|
||||
VersionedJsonDocumentCreator.create(database);
|
||||
|
||||
try (final var manager = database.openResourceManager("resource");
|
||||
|
|
|
@ -1,42 +1,36 @@
|
|||
package io.sirix.tutorial.json;
|
||||
|
||||
import org.brackit.xquery.atomic.QNm;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.brackit.xquery.atomic.QNm;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
|
||||
public final class CreateVersionedJsonResourceIntegrationTest {
|
||||
|
||||
private static final String TMP_DIRECTORY = System.getProperty("java.io.tmpdir");
|
||||
@Rule
|
||||
public TemporaryFolder tempDirectory = new TemporaryFolder();
|
||||
|
||||
private static final Path DATABASE_PATH = Paths.get(TMP_DIRECTORY, "sirix", "json-database");
|
||||
private Path databasePath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
public void setUp() {
|
||||
databasePath = Paths.get(tempDirectory.getRoot().getPath(), "sirix", "json-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createVersionedDatabaseAndCheckAllRevisions() {
|
||||
Databases.createJsonDatabase(new DatabaseConfiguration(DATABASE_PATH));
|
||||
Databases.createJsonDatabase(new DatabaseConfiguration(databasePath));
|
||||
|
||||
try (final var database = Databases.openJsonDatabase(DATABASE_PATH)) {
|
||||
try (final var database = Databases.openJsonDatabase(databasePath)) {
|
||||
VersionedJsonDocumentCreator.create(database);
|
||||
|
||||
// Check first revision.
|
||||
|
|
|
@ -1,18 +1,12 @@
|
|||
package io.sirix.tutorial.json;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
import org.sirix.access.ResourceConfiguration;
|
||||
import org.sirix.api.json.JsonNodeReadOnlyTrx;
|
||||
import org.sirix.axis.DescendantAxis;
|
||||
import org.sirix.axis.IncludeSelf;
|
||||
import org.sirix.axis.filter.FilterAxis;
|
||||
|
@ -20,24 +14,23 @@ import org.sirix.axis.filter.json.JsonNameFilter;
|
|||
import org.sirix.service.json.shredder.JsonShredder;
|
||||
import org.sirix.settings.VersioningType;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public final class JsonFilterIntegrationTest {
|
||||
|
||||
private static final Path JSON_DIRECTORY = Paths.get("src", "test", "resources", "json");
|
||||
|
||||
private static final String TMP_DIRECTORY = System.getProperty("java.io.tmpdir");
|
||||
@Rule
|
||||
public TemporaryFolder tempDirectory = new TemporaryFolder();
|
||||
|
||||
private static final Path DATABASE_PATH = Paths.get(TMP_DIRECTORY, "sirix", "json-database");
|
||||
private Path databasePath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
public void setUp() {
|
||||
databasePath = Paths.get(tempDirectory.getRoot().getPath(), "sirix", "json-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -45,10 +38,10 @@ public final class JsonFilterIntegrationTest {
|
|||
final var pathToJsonFile = JSON_DIRECTORY.resolve("complex1.json");
|
||||
|
||||
// Create an empty JSON database.
|
||||
Databases.createJsonDatabase(new DatabaseConfiguration(DATABASE_PATH));
|
||||
Databases.createJsonDatabase(new DatabaseConfiguration(databasePath));
|
||||
|
||||
// Open the database.
|
||||
try (final var database = Databases.openJsonDatabase(DATABASE_PATH)) {
|
||||
try (final var database = Databases.openJsonDatabase(databasePath)) {
|
||||
// Create a resource to store a JSON-document.
|
||||
database.createResource(ResourceConfiguration.newBuilder("resource")
|
||||
.useTextCompression(false)
|
||||
|
@ -70,7 +63,7 @@ public final class JsonFilterIntegrationTest {
|
|||
final var axis = new DescendantAxis(wtx, IncludeSelf.YES);
|
||||
final var filter = new JsonNameFilter(wtx, "associatedDrug");
|
||||
|
||||
for (var filterAxis = new FilterAxis<JsonNodeReadOnlyTrx>(axis, filter); filterAxis.hasNext();) {
|
||||
for (var filterAxis = new FilterAxis<>(axis, filter); filterAxis.hasNext();) {
|
||||
filterAxis.next();
|
||||
foundTimes++;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
package io.sirix.tutorial.json;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
import org.sirix.api.json.JsonResourceManager;
|
||||
import org.sirix.service.json.serialize.JsonSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
|
@ -10,39 +17,27 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
import org.sirix.api.json.JsonResourceManager;
|
||||
import org.sirix.service.json.serialize.JsonSerializer;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SerializeVersionedJsonResourceIntegrationTest {
|
||||
|
||||
private static final Path JSON_TEST_RESULT_DIRECTORY = Paths.get("src", "test", "resources", "json-test-result-strings");
|
||||
|
||||
private static final String TMP_DIRECTORY = System.getProperty("java.io.tmpdir");
|
||||
@Rule
|
||||
public TemporaryFolder tempDirectory = new TemporaryFolder();
|
||||
|
||||
private static final Path DATABASE_PATH = Paths.get(TMP_DIRECTORY, "sirix", "json-database");
|
||||
private Path databasePath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
public void setUp() {
|
||||
databasePath = Paths.get(tempDirectory.getRoot().getPath(), "sirix", "json-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createVersionedResourceAndTestSerializations() throws IOException {
|
||||
Databases.createJsonDatabase(new DatabaseConfiguration(DATABASE_PATH));
|
||||
Databases.createJsonDatabase(new DatabaseConfiguration(databasePath));
|
||||
|
||||
try (final var database = Databases.openJsonDatabase(DATABASE_PATH)) {
|
||||
try (final var database = Databases.openJsonDatabase(databasePath)) {
|
||||
VersionedJsonDocumentCreator.create(database);
|
||||
|
||||
try (final var manager = database.openResourceManager("resource")) {
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
package io.sirix.tutorial.xml;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
import org.sirix.api.ResourceManager;
|
||||
|
@ -25,28 +18,29 @@ import org.sirix.axis.visitor.VisitorDescendantAxis;
|
|||
import org.sirix.node.immutable.xdm.ImmutableElement;
|
||||
import org.sirix.node.immutable.xdm.ImmutableText;
|
||||
|
||||
public final class CreateVersionedXmlResourceAndQueryIntegrationTest {
|
||||
private static final String TMP_DIRECTORY = System.getProperty("java.io.tmpdir");
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
private static final Path DATABASE_PATH = Paths.get(TMP_DIRECTORY, "sirix", "xml-database");
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public final class CreateVersionedXmlResourceAndQueryIntegrationTest {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tempDirectory = new TemporaryFolder();
|
||||
|
||||
private Path databasePath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
public void setUp() {
|
||||
databasePath = Paths.get(tempDirectory.getRoot().getPath(), "sirix", "xml-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createVersionedResourceAndQueryWithTheVisitoDescendantAxis() throws IOException {
|
||||
Databases.createXmlDatabase(new DatabaseConfiguration(DATABASE_PATH));
|
||||
public void createVersionedResourceAndQueryWithTheVisitToDescendantAxis() {
|
||||
Databases.createXmlDatabase(new DatabaseConfiguration(databasePath));
|
||||
|
||||
try (final var database = Databases.openXmlDatabase(DATABASE_PATH)) {
|
||||
try (final var database = Databases.openXmlDatabase(databasePath)) {
|
||||
VersionedXmlDocumentCreator.create(database);
|
||||
|
||||
try (final var manager = database.openResourceManager("resource");
|
||||
|
|
|
@ -1,41 +1,35 @@
|
|||
package io.sirix.tutorial.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.brackit.xquery.atomic.QNm;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public final class CreateVersionedXmlResourceIntegrationTest {
|
||||
|
||||
private static final String TMP_DIRECTORY = System.getProperty("java.io.tmpdir");
|
||||
@Rule
|
||||
public TemporaryFolder tempDirectory = new TemporaryFolder();
|
||||
|
||||
private static final Path DATABASE_PATH = Paths.get(TMP_DIRECTORY, "sirix", "json-database");
|
||||
private Path databasePath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
public void setUp() {
|
||||
databasePath = Paths.get(tempDirectory.getRoot().getPath(), "sirix", "xml-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createVersionedResourceAndCheck() {
|
||||
Databases.createXmlDatabase(new DatabaseConfiguration(DATABASE_PATH));
|
||||
Databases.createXmlDatabase(new DatabaseConfiguration(databasePath));
|
||||
|
||||
try (final var database = Databases.openXmlDatabase(DATABASE_PATH)) {
|
||||
try (final var database = Databases.openXmlDatabase(databasePath)) {
|
||||
VersionedXmlDocumentCreator.create(database);
|
||||
|
||||
// Check first revision.
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
package io.sirix.tutorial.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
import org.sirix.access.ResourceConfiguration;
|
||||
import org.sirix.service.xml.serialize.XmlSerializer;
|
||||
import org.sirix.service.xml.shredder.XmlShredder;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -11,14 +19,7 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
import org.sirix.access.ResourceConfiguration;
|
||||
import org.sirix.service.xml.serialize.XmlSerializer;
|
||||
import org.sirix.service.xml.shredder.XmlShredder;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public final class CreateXmlDatabaseIntegrationTest {
|
||||
|
||||
|
@ -26,20 +27,14 @@ public final class CreateXmlDatabaseIntegrationTest {
|
|||
|
||||
private static final Path XML_DIRECTORY = Paths.get("src", "test", "resources", "xml");
|
||||
|
||||
private static final String TMP_DIRECTORY = System.getProperty("java.io.tmpdir");
|
||||
@Rule
|
||||
public TemporaryFolder tempDirectory = new TemporaryFolder();
|
||||
|
||||
private static final Path DATABASE_PATH = Paths.get(TMP_DIRECTORY, "sirix", "xml-database");
|
||||
private Path databasePath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
public void setUp() {
|
||||
databasePath = Paths.get(tempDirectory.getRoot().getPath(), "sirix", "xml-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,10 +42,10 @@ public final class CreateXmlDatabaseIntegrationTest {
|
|||
final var pathToXmlFile = XML_DIRECTORY.resolve("orga.xml");
|
||||
|
||||
// Create an empty XML database.
|
||||
Databases.createXmlDatabase(new DatabaseConfiguration(DATABASE_PATH));
|
||||
Databases.createXmlDatabase(new DatabaseConfiguration(databasePath));
|
||||
|
||||
// Open the database.
|
||||
try (final var database = Databases.openXmlDatabase(DATABASE_PATH)) {
|
||||
try (final var database = Databases.openXmlDatabase(databasePath)) {
|
||||
// Create a resource to store an XML-document.
|
||||
database.createResource(ResourceConfiguration.newBuilder("resource")
|
||||
.useTextCompression(false)
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
package io.sirix.tutorial.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.After;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
import org.sirix.access.trx.node.HashType;
|
||||
|
@ -17,30 +12,28 @@ import org.sirix.diff.DiffFactory;
|
|||
import org.sirix.diff.DiffFactory.DiffOptimized;
|
||||
import org.sirix.diff.DiffFactory.DiffType;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DiffXmlResourceIntegrationTest {
|
||||
private static final String TMP_DIRECTORY = System.getProperty("java.io.tmpdir");
|
||||
|
||||
private static final Path DATABASE_PATH = Paths.get(TMP_DIRECTORY, "sirix", "xml-database");
|
||||
@Rule
|
||||
public TemporaryFolder tempDirectory = new TemporaryFolder();
|
||||
|
||||
private Path databasePath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
public void setUp() {
|
||||
databasePath = Paths.get(tempDirectory.getRoot().getPath(), "sirix", "xml-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createVersionedResourceAndCheckDiffingOfRevisionOneAndThree() throws IOException {
|
||||
Databases.createXmlDatabase(new DatabaseConfiguration(DATABASE_PATH));
|
||||
public void createVersionedResourceAndCheckDiffingOfRevisionOneAndThree() {
|
||||
Databases.createXmlDatabase(new DatabaseConfiguration(databasePath));
|
||||
|
||||
try (final var database = Databases.openXmlDatabase(DATABASE_PATH)) {
|
||||
try (final var database = Databases.openXmlDatabase(databasePath)) {
|
||||
VersionedXmlDocumentCreator.create(database);
|
||||
|
||||
try (final var manager = database.openResourceManager("resource");
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
package io.sirix.tutorial.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
import org.sirix.access.ResourceConfiguration;
|
||||
|
@ -24,6 +17,15 @@ import org.sirix.axis.filter.FilterAxis;
|
|||
import org.sirix.axis.filter.xml.XdmNameFilter;
|
||||
import org.sirix.service.xml.shredder.XmlShredder;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Note that this simple test shows, that the higher level XQuery-API is much more user-friendly, when chaining
|
||||
* axis is required.
|
||||
|
@ -32,20 +34,14 @@ public class QueryXmlResourceWithConcurrentAxisIntegrationTest {
|
|||
|
||||
private static final Path XML_DIRECTORY = Paths.get("src", "test", "resources", "xml");
|
||||
|
||||
private static final String TMP_DIRECTORY = System.getProperty("java.io.tmpdir");
|
||||
@Rule
|
||||
public TemporaryFolder tempDirectory = new TemporaryFolder();
|
||||
|
||||
private static final Path DATABASE_PATH = Paths.get(TMP_DIRECTORY, "sirix", "xml-database");
|
||||
private Path databasePath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
public void setUp() {
|
||||
databasePath = Paths.get(tempDirectory.getRoot().getPath(), "sirix", "xml-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -53,10 +49,10 @@ public class QueryXmlResourceWithConcurrentAxisIntegrationTest {
|
|||
final var pathToXmlFile = XML_DIRECTORY.resolve("regions.xml");
|
||||
|
||||
// Create an empty XML database.
|
||||
Databases.createXmlDatabase(new DatabaseConfiguration(DATABASE_PATH));
|
||||
Databases.createXmlDatabase(new DatabaseConfiguration(databasePath));
|
||||
|
||||
// Open the database.
|
||||
try (final var database = Databases.openXmlDatabase(DATABASE_PATH)) {
|
||||
try (final var database = Databases.openXmlDatabase(databasePath)) {
|
||||
// Create a resource to store an XML-document.
|
||||
database.createResource(ResourceConfiguration.newBuilder("resource")
|
||||
.useTextCompression(false)
|
||||
|
@ -96,10 +92,10 @@ public class QueryXmlResourceWithConcurrentAxisIntegrationTest {
|
|||
final var resultNumber = 55;
|
||||
|
||||
for (int i = 0; i < resultNumber; i++) {
|
||||
assertEquals(true, axis.hasNext());
|
||||
assertTrue(axis.hasNext());
|
||||
axis.next();
|
||||
}
|
||||
assertEquals(false, axis.hasNext());
|
||||
assertFalse(axis.hasNext());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
package io.sirix.tutorial.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
import org.sirix.api.xml.XmlResourceManager;
|
||||
import org.sirix.service.xml.serialize.XmlSerializer;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -10,39 +17,27 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.sirix.access.DatabaseConfiguration;
|
||||
import org.sirix.access.Databases;
|
||||
import org.sirix.api.xml.XmlResourceManager;
|
||||
import org.sirix.service.xml.serialize.XmlSerializer;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SerializeVersionedXmlResourceIntegrationTest {
|
||||
|
||||
private static final Path XML_TEST_RESULT_DIRECTORY = Paths.get("src", "test", "resources", "xml-test-result-strings");
|
||||
|
||||
private static final String TMP_DIRECTORY = System.getProperty("java.io.tmpdir");
|
||||
@Rule
|
||||
public TemporaryFolder tempDirectory = new TemporaryFolder();
|
||||
|
||||
private static final Path DATABASE_PATH = Paths.get(TMP_DIRECTORY, "sirix", "xml-database");
|
||||
private Path databasePath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (Files.exists(DATABASE_PATH))
|
||||
Databases.removeDatabase(DATABASE_PATH);
|
||||
public void setUp() {
|
||||
databasePath = Paths.get(tempDirectory.getRoot().getPath(), "sirix", "xml-database");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createVersionedResourceAndTestSerializations() throws IOException {
|
||||
Databases.createXmlDatabase(new DatabaseConfiguration(DATABASE_PATH));
|
||||
Databases.createXmlDatabase(new DatabaseConfiguration(databasePath));
|
||||
|
||||
try (final var database = Databases.openXmlDatabase(DATABASE_PATH)) {
|
||||
try (final var database = Databases.openXmlDatabase(databasePath)) {
|
||||
VersionedXmlDocumentCreator.create(database);
|
||||
|
||||
try (final var manager = database.openResourceManager("resource")) {
|
||||
|
|
Loading…
Reference in New Issue