diff --git a/marklogic-junit5/src/main/java/com/marklogic/junit5/AbstractMarkLogicTest.java b/marklogic-junit5/src/main/java/com/marklogic/junit5/AbstractMarkLogicTest.java index c270519..4f9de76 100644 --- a/marklogic-junit5/src/main/java/com/marklogic/junit5/AbstractMarkLogicTest.java +++ b/marklogic-junit5/src/main/java/com/marklogic/junit5/AbstractMarkLogicTest.java @@ -31,7 +31,7 @@ * This class depends on a DatabaseClient, and how that is provided must be defined by the subclass. *

*/ -public abstract class AbstractMarkLogicTest extends LoggingObject implements HasMarkLogicVersion { +public abstract class AbstractMarkLogicTest extends LoggingObject implements MarkLogicVersionSupplier { /** * Subclass must define how a connection is made to (presumably) the test database. @@ -46,7 +46,8 @@ public abstract class AbstractMarkLogicTest extends LoggingObject implements Has */ @Override public MarkLogicVersion getMarkLogicVersion() { - return MarkLogicVersion.getVersion(getDatabaseClient()); + String version = getDatabaseClient().newServerEval().javascript("xdmp.version()").evalAs(String.class); + return new MarkLogicVersion(version); } /** diff --git a/marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersion.java b/marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersion.java index a78fd35..b6fe4b3 100644 --- a/marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersion.java +++ b/marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersion.java @@ -3,8 +3,6 @@ */ package com.marklogic.junit5; -import com.marklogic.client.DatabaseClient; - /** * Parses a MarkLogic version string - i.e. from xdmp.version() - into its major, minor, and patch values. */ @@ -14,9 +12,8 @@ public class MarkLogicVersion { private final static String SEMVER_PATTERN = "^[0-9]+\\.[0-9]+\\.[0-9]+"; private final static String NIGHTLY_SEMVER_PATTERN = "^[0-9]+\\.[0-9]+\\.[0-9]{8}"; - // For non-semver releases. + // For non-semver releases, such as MarkLogic 10 and earlier.. private final static String MAJOR_WITH_MINOR_PATTERN = "^.*-(.+)$"; - private final static String VERSION_WITH_PATCH_PATTERN = "^.*-(.+)\\..*"; private final static String NIGHTLY_BUILD_PATTERN = "[^-]+-(\\d{4})(\\d{2})(\\d{2})"; @@ -24,11 +21,6 @@ public class MarkLogicVersion { private final Integer minor; private final Integer patch; private final boolean nightly; - - public static MarkLogicVersion getVersion(DatabaseClient client) { - String version = client.newServerEval().javascript("xdmp.version()").evalAs(String.class); - return new MarkLogicVersion(version); - } public MarkLogicVersion(String version) { if (version.matches(NIGHTLY_SEMVER_PATTERN)) { diff --git a/marklogic-junit5/src/main/java/com/marklogic/junit5/HasMarkLogicVersion.java b/marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersionSupplier.java similarity index 79% rename from marklogic-junit5/src/main/java/com/marklogic/junit5/HasMarkLogicVersion.java rename to marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersionSupplier.java index 296838a..a1debfe 100644 --- a/marklogic-junit5/src/main/java/com/marklogic/junit5/HasMarkLogicVersion.java +++ b/marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersionSupplier.java @@ -6,7 +6,7 @@ /** * @since 1.5.0 */ -public interface HasMarkLogicVersion { +public interface MarkLogicVersionSupplier { MarkLogicVersion getMarkLogicVersion(); } diff --git a/marklogic-junit5/src/main/java/com/marklogic/junit5/VersionExecutionCondition.java b/marklogic-junit5/src/main/java/com/marklogic/junit5/VersionExecutionCondition.java index 701b28d..949ead2 100644 --- a/marklogic-junit5/src/main/java/com/marklogic/junit5/VersionExecutionCondition.java +++ b/marklogic-junit5/src/main/java/com/marklogic/junit5/VersionExecutionCondition.java @@ -26,10 +26,10 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con if (!testInstance.isPresent()) { throw new RuntimeException(getClass() + " can only be used when a test instance is present."); } - if (!(testInstance.get() instanceof HasMarkLogicVersion)) { - throw new RuntimeException(testInstance.getClass() + " must implement " + HasMarkLogicVersion.class.getName()); + if (!(testInstance.get() instanceof MarkLogicVersionSupplier)) { + throw new RuntimeException(testInstance.getClass() + " must implement " + MarkLogicVersionSupplier.class.getName()); } - markLogicVersion = ((HasMarkLogicVersion) context.getTestInstance().get()).getMarkLogicVersion(); + markLogicVersion = ((MarkLogicVersionSupplier) context.getTestInstance().get()).getMarkLogicVersion(); } return evaluateVersion(markLogicVersion); }