From 648c9a755e89c5e9f18152a279700ae0c5618622 Mon Sep 17 00:00:00 2001 From: Sebastian Toepfer <61313468+sebastian-toepfer@users.noreply.github.com> Date: Thu, 18 Jan 2024 17:46:48 +0100 Subject: [PATCH] remove own testengine for junit it doesn't works correctly in combination with pitest. --- pom.xml | 1 - testsuite-junit-platform-engine/pom.xml | 82 ---------- .../junit/SchemaTestValidatorLoader.java | 32 ---- .../junit/engine/ExecuteableTest.java | 30 ---- .../engine/ImmutableTestDescription.java | 81 ---------- .../engine/JsonSchemaSuiteTestDescriptor.java | 93 ----------- .../JsonSchemaSuitesTestDescriptor.java | 151 ------------------ .../engine/JsonSchemaTestDescriptor.java | 130 --------------- .../engine/JsonSchemaTestSuiteEngine.java | 76 --------- .../testsuite/junit/engine/Resource.java | 68 -------- .../testsuite/junit/engine/Resources.java | 121 -------------- .../src/main/java/module-info.java | 36 ----- .../org.junit.platform.engine.TestEngine | 1 - .../engine/FakeSchemaTestValidatorLoader.java | 11 -- .../JsonSchemaSuiteTestDescriptorTest.java | 71 -------- .../JsonSchemaSuitesTestDescriptorTest.java | 88 ---------- .../engine/JsonSchemaTestDescriptorTest.java | 53 ------ .../engine/JsonSchemaTestSuiteEngineTest.java | 45 ------ .../testsuite/junit/engine/ResourceTest.java | 67 -------- .../testsuite/junit/engine/ResourcesTest.java | 55 ------- ....testsuite.junit.SchemaTestValidatorLoader | 1 - .../test/resources/tests/boolean_schema.json | 34 ---- .../test/resources/tests/test_resource.json | 3 - 23 files changed, 1330 deletions(-) delete mode 100644 testsuite-junit-platform-engine/pom.xml delete mode 100644 testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/SchemaTestValidatorLoader.java delete mode 100644 testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ExecuteableTest.java delete mode 100644 testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ImmutableTestDescription.java delete mode 100644 testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuiteTestDescriptor.java delete mode 100644 testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuitesTestDescriptor.java delete mode 100644 testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestDescriptor.java delete mode 100644 testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestSuiteEngine.java delete mode 100644 testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/Resource.java delete mode 100644 testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/Resources.java delete mode 100644 testsuite-junit-platform-engine/src/main/java/module-info.java delete mode 100644 testsuite-junit-platform-engine/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine delete mode 100644 testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/FakeSchemaTestValidatorLoader.java delete mode 100644 testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuiteTestDescriptorTest.java delete mode 100644 testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuitesTestDescriptorTest.java delete mode 100644 testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestDescriptorTest.java delete mode 100644 testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestSuiteEngineTest.java delete mode 100644 testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ResourceTest.java delete mode 100644 testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ResourcesTest.java delete mode 100644 testsuite-junit-platform-engine/src/test/resources/META-INF/services/io.github.sebastiantoepfer.jsonschema.testsuite.junit.SchemaTestValidatorLoader delete mode 100644 testsuite-junit-platform-engine/src/test/resources/tests/boolean_schema.json delete mode 100644 testsuite-junit-platform-engine/src/test/resources/tests/test_resource.json diff --git a/pom.xml b/pom.xml index 7370627b..f61368ea 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,6 @@ - testsuite-junit-platform-engine api vocabulary-spi core diff --git a/testsuite-junit-platform-engine/pom.xml b/testsuite-junit-platform-engine/pom.xml deleted file mode 100644 index c8de0c64..00000000 --- a/testsuite-junit-platform-engine/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - 4.0.0 - - - io.github.sebastian-toepfer.json-schema - json-schema - 0.1.0-SNAPSHOT - - - json-schema-testsuite-junit-platform-engine - Json Schema :: Testsuite Junit Platform Engine - - - - org.junit.platform - junit-platform-engine - - - org.eclipse.parsson - parsson - - - com.github.spotbugs - spotbugs-annotations - - - com.google.errorprone - error_prone_annotations - - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - org.hamcrest - hamcrest - test - - - com.github.npathai - hamcrest-optional - test - - - - nl.jqno.equalsverifier - equalsverifier - test - - - org.junit.platform - junit-platform-testkit - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - jsonschema - - - - - - - diff --git a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/SchemaTestValidatorLoader.java b/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/SchemaTestValidatorLoader.java deleted file mode 100644 index e1053e09..00000000 --- a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/SchemaTestValidatorLoader.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit; - -public interface SchemaTestValidatorLoader { - SchemaTestValidator loadSchemaTestValidator(final String schema); - - public interface SchemaTestValidator { - boolean validate(String data); - } -} diff --git a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ExecuteableTest.java b/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ExecuteableTest.java deleted file mode 100644 index e6729d31..00000000 --- a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ExecuteableTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import org.junit.platform.engine.ExecutionRequest; - -interface ExecuteableTest { - void run(final ExecutionRequest request); -} diff --git a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ImmutableTestDescription.java b/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ImmutableTestDescription.java deleted file mode 100644 index ad41fe31..00000000 --- a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ImmutableTestDescription.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import org.junit.platform.engine.TestDescriptor; -import org.junit.platform.engine.TestSource; -import org.junit.platform.engine.TestTag; -import org.junit.platform.engine.UniqueId; - -abstract class ImmutableTestDescription implements TestDescriptor { - - private final TestDescriptor parent; - - @SuppressFBWarnings("EI_EXPOSE_REP2") - protected ImmutableTestDescription(final TestDescriptor parent) { - this.parent = Objects.requireNonNull(parent); - } - - @Override - public Set getTags() { - return Set.of(); - } - - @Override - public Optional getSource() { - return Optional.empty(); - } - - @Override - public Optional getParent() { - return Optional.of(parent); - } - - @Override - public void setParent(final TestDescriptor parent) { - throw new UnsupportedOperationException("Not supported!"); - } - - @Override - public void addChild(final TestDescriptor descriptor) { - throw new UnsupportedOperationException("Not supported!"); - } - - @Override - public void removeChild(final TestDescriptor descriptor) { - throw new UnsupportedOperationException("Not supported!"); - } - - @Override - public void removeFromHierarchy() {} - - @Override - public Optional findByUniqueId(final UniqueId uniqueId) { - throw new UnsupportedOperationException("Not supported yet."); - } -} diff --git a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuiteTestDescriptor.java b/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuiteTestDescriptor.java deleted file mode 100644 index 632aa812..00000000 --- a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuiteTestDescriptor.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import static java.util.stream.Collectors.toSet; - -import jakarta.json.JsonObject; -import java.util.Objects; -import java.util.Set; -import org.junit.platform.engine.TestDescriptor; -import org.junit.platform.engine.UniqueId; - -final class JsonSchemaSuiteTestDescriptor extends ImmutableTestDescription { - - private final JsonObject testSuiteDescription; - - JsonSchemaSuiteTestDescriptor(final TestDescriptor parent, final JsonObject testSuiteDescription) { - super(parent); - this.testSuiteDescription = Objects.requireNonNull(testSuiteDescription); - } - - @Override - public UniqueId getUniqueId() { - return getParent().orElseThrow().getUniqueId().append("innersuite", getDisplayName()); - } - - @Override - public String getDisplayName() { - return testSuiteDescription.getString("description"); - } - - @Override - public Set getChildren() { - return testSuiteDescription - .getJsonArray("tests") - .stream() - .map(test -> new JsonSchemaTestDescriptor(this, testSuiteDescription.get("schema"), test.asJsonObject())) - .collect(toSet()); - } - - @Override - public Type getType() { - return Type.CONTAINER; - } - - @Override - public String toString() { - return getUniqueId().toString(); - } - - @Override - public int hashCode() { - int hash = 5; - hash = 53 * hash + Objects.hashCode(this.testSuiteDescription); - return hash; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final JsonSchemaSuiteTestDescriptor other = (JsonSchemaSuiteTestDescriptor) obj; - return Objects.equals(this.testSuiteDescription, other.testSuiteDescription); - } -} diff --git a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuitesTestDescriptor.java b/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuitesTestDescriptor.java deleted file mode 100644 index 24b837bc..00000000 --- a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuitesTestDescriptor.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import static java.util.stream.Collectors.toSet; - -import jakarta.json.Json; -import jakarta.json.JsonReader; -import jakarta.json.JsonStructure; -import jakarta.json.JsonValue; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import org.junit.platform.engine.TestDescriptor; -import org.junit.platform.engine.TestSource; -import org.junit.platform.engine.TestTag; -import org.junit.platform.engine.UniqueId; - -final class JsonSchemaSuitesTestDescriptor implements TestDescriptor { - - private final Resource tests; - private TestDescriptor parent; - - public JsonSchemaSuitesTestDescriptor(final Resource tests) { - this.tests = Objects.requireNonNull(tests); - } - - @Override - public UniqueId getUniqueId() { - return getParent() - .map(TestDescriptor::getUniqueId) - .map(id -> id.append("suite", getDisplayName())) - .orElse(UniqueId.root("suite", getDisplayName())); - } - - @Override - public String getDisplayName() { - return tests.name(); - } - - @Override - public Set getTags() { - return Set.of(); - } - - @Override - public Optional getSource() { - return Optional.empty(); - } - - @Override - public Optional getParent() { - return Optional.ofNullable(parent); - } - - @Override - public void setParent(final TestDescriptor parent) { - this.parent = parent; - } - - @Override - public Set getChildren() { - final Set result; - try (JsonReader reader = Json.createReader(tests.content())) { - final JsonStructure jsonValue = reader.read(); - if (jsonValue.getValueType() == JsonValue.ValueType.ARRAY) { - result = - jsonValue - .asJsonArray() - .stream() - .map(JsonValue::asJsonObject) - .map(object -> new JsonSchemaSuiteTestDescriptor(this, object)) - .collect(toSet()); - } else { - result = Set.of(); - } - return result; - } - } - - @Override - public void addChild(final TestDescriptor descriptor) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void removeChild(final TestDescriptor descriptor) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void removeFromHierarchy() {} - - @Override - public Optional findByUniqueId(final UniqueId uniqueId) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public TestDescriptor.Type getType() { - return TestDescriptor.Type.CONTAINER; - } - - @Override - public String toString() { - return getUniqueId().toString(); - } - - @Override - public int hashCode() { - int hash = 3; - hash = 79 * hash + Objects.hashCode(this.tests); - return hash; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final JsonSchemaSuitesTestDescriptor other = (JsonSchemaSuitesTestDescriptor) obj; - return Objects.equals(this.tests, other.tests); - } -} diff --git a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestDescriptor.java b/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestDescriptor.java deleted file mode 100644 index 2bc65949..00000000 --- a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestDescriptor.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import io.github.sebastiantoepfer.jsonschema.testsuite.junit.SchemaTestValidatorLoader; -import jakarta.json.JsonObject; -import jakarta.json.JsonValue; -import java.util.Objects; -import java.util.Optional; -import java.util.ServiceLoader; -import java.util.Set; -import org.junit.platform.engine.ExecutionRequest; -import org.junit.platform.engine.TestDescriptor; -import org.junit.platform.engine.TestExecutionResult; -import org.junit.platform.engine.UniqueId; - -final class JsonSchemaTestDescriptor extends ImmutableTestDescription implements TestDescriptor, ExecuteableTest { - - private final JsonValue schema; - private final JsonObject testDescription; - - public JsonSchemaTestDescriptor( - final TestDescriptor parent, - final JsonValue schema, - final JsonObject testDescription - ) { - super(parent); - this.schema = Objects.requireNonNull(schema); - this.testDescription = Objects.requireNonNull(testDescription); - } - - @Override - public UniqueId getUniqueId() { - return getParent().orElseThrow().getUniqueId().append("test", getDisplayName()); - } - - @Override - public String getDisplayName() { - return testDescription.getString("description"); - } - - @Override - public Set getChildren() { - return Set.of(); - } - - @Override - public Type getType() { - return Type.TEST; - } - - @Override - public Optional findByUniqueId(final UniqueId uniqueId) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void run(final ExecutionRequest request) { - request.getEngineExecutionListener().executionStarted(this); - TestExecutionResult result; - try { - final boolean isValid = ServiceLoader - .load(SchemaTestValidatorLoader.class) - .findFirst() - .orElseThrow() - .loadSchemaTestValidator(schema.toString()) - .validate(testDescription.get("data").toString()); - if (isValid == testDescription.getBoolean("valid")) { - result = TestExecutionResult.successful(); - } else { - throw new RuntimeException("expected " + testDescription.getBoolean("valid") + " but was " + isValid); - } - } catch (RuntimeException t) { - result = TestExecutionResult.failed(t); - } - request.getEngineExecutionListener().executionFinished(this, result); - } - - @Override - public String toString() { - return getUniqueId().toString(); - } - - @Override - public int hashCode() { - int hash = 7; - hash = 97 * hash + Objects.hashCode(this.schema); - hash = 97 * hash + Objects.hashCode(this.testDescription); - return hash; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final JsonSchemaTestDescriptor other = (JsonSchemaTestDescriptor) obj; - if (!Objects.equals(this.schema, other.schema)) { - return false; - } - return Objects.equals(this.testDescription, other.testDescription); - } -} diff --git a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestSuiteEngine.java b/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestSuiteEngine.java deleted file mode 100644 index d14e28fe..00000000 --- a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestSuiteEngine.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import java.util.stream.Stream; -import org.junit.platform.engine.EngineDiscoveryRequest; -import org.junit.platform.engine.ExecutionRequest; -import org.junit.platform.engine.TestDescriptor; -import org.junit.platform.engine.TestEngine; -import org.junit.platform.engine.UniqueId; -import org.junit.platform.engine.support.descriptor.EngineDescriptor; - -public class JsonSchemaTestSuiteEngine implements TestEngine { - - @Override - public String getId() { - return "jsonschema"; - } - - @Override - public TestDescriptor discover(final EngineDiscoveryRequest discoveryRequest, final UniqueId uniqueId) { - final TestDescriptor result = new EngineDescriptor(uniqueId, "Json Schema Test"); - try (final Stream res = new Resources().all()) { - res - .filter(resource -> resource.hasExtension("json")) - .map(JsonSchemaSuitesTestDescriptor::new) - .forEach(result::addChild); - } - return result; - } - - @Override - public void execute(final ExecutionRequest request) { - new TestFinder(request.getRootTestDescriptor()).findTests().forEach(test -> test.run(request)); - } - - private static class TestFinder { - - private final TestDescriptor desc; - - public TestFinder(final TestDescriptor desc) { - this.desc = desc; - } - - Stream findTests() { - final Stream result; - if (desc instanceof ExecuteableTest test) { - result = Stream.of(test); - } else { - result = desc.getChildren().stream().map(TestFinder::new).flatMap(TestFinder::findTests); - } - return result; - } - } -} diff --git a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/Resource.java b/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/Resource.java deleted file mode 100644 index 61ca0dc6..00000000 --- a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/Resource.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import java.io.InputStream; -import java.util.Objects; - -final record Resource(String name) { - boolean hasName(final String name) { - return Objects.equals(this.name, name); - } - - boolean hasExtension(final String extension) { - return name.endsWith(".".concat(extension)); - } - - InputStream content() { - return Resource.class.getClassLoader().getResourceAsStream(name); - } - - @Override - public String toString() { - return "Resource{" + "name=" + name + '}'; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0); - return hash; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Resource other = (Resource) obj; - return (this.name == null) ? (other.name == null) : this.name.equals(other.name); - } -} diff --git a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/Resources.java b/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/Resources.java deleted file mode 100644 index f98fd551..00000000 --- a/testsuite-junit-platform-engine/src/main/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/Resources.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Objects; -import java.util.Spliterator; -import java.util.Spliterators; -import java.util.regex.Pattern; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; - -final class Resources { - - private final String baseDir; - - public Resources() { - this("."); - } - - public Resources(final String baseDir) { - this.baseDir = baseDir; - } - - @com.google.errorprone.annotations.MustBeClosed - Stream all() { - try { - return StreamSupport - .stream( - Spliterators.spliteratorUnknownSize( - Resource.class.getClassLoader().getResources(baseDir).asIterator(), - Spliterator.ORDERED - ), - false - ) - .map(url -> { - try { - return url.toURI(); - } catch (URISyntaxException e) { - throw new IllegalStateException(e); - } - }) - .filter(uri -> "file".equals(uri.getScheme())) - .map(Paths::get) - .map(PathResources::new) - .flatMap(PathResources::toResources); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - - private static class PathResources { - - private static final Pattern PATH_SEPARATOR = Pattern.compile(File.pathSeparator); - private final Path path; - - public PathResources(final Path path) { - this.path = Objects.requireNonNull(path); - } - - @SuppressWarnings("StreamResourceLeak") - Stream toResources() { - final Stream result; - try { - if (path.toFile().isFile()) { - result = - Stream.of( - new Resource( - path - .toFile() - .getAbsolutePath() - .substring( - PATH_SEPARATOR - .splitAsStream(System.getProperty("java.class.path")) - .map(Path::of) - .filter(path::startsWith) - .map(Path::toFile) - .map(File::getAbsolutePath) - .map(String::length) - .map(i -> i + 1) - .findAny() - .orElse(0) - ) - ) - ); - } else { - result = Files.list(path).map(PathResources::new).flatMap(PathResources::toResources); - } - } catch (IOException e) { - throw new IllegalStateException(e); - } - return result; - } - } -} diff --git a/testsuite-junit-platform-engine/src/main/java/module-info.java b/testsuite-junit-platform-engine/src/main/java/module-info.java deleted file mode 100644 index c7ad8af1..00000000 --- a/testsuite-junit-platform-engine/src/main/java/module-info.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -module io.github.sebastiantoepfer.jsonschema.testsuite.junit { - exports io.github.sebastiantoepfer.jsonschema.testsuite.junit; - - provides org.junit.platform.engine.TestEngine - with io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine.JsonSchemaTestSuiteEngine; - - requires org.junit.platform.engine; - requires org.junit.platform.commons; - requires com.github.spotbugs.annotations; - requires com.google.errorprone.annotations; - requires jakarta.json; -} diff --git a/testsuite-junit-platform-engine/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine b/testsuite-junit-platform-engine/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine deleted file mode 100644 index ae716d90..00000000 --- a/testsuite-junit-platform-engine/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine +++ /dev/null @@ -1 +0,0 @@ -io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine.JsonSchemaTestSuiteEngine diff --git a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/FakeSchemaTestValidatorLoader.java b/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/FakeSchemaTestValidatorLoader.java deleted file mode 100644 index 3ffbdc54..00000000 --- a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/FakeSchemaTestValidatorLoader.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import io.github.sebastiantoepfer.jsonschema.testsuite.junit.SchemaTestValidatorLoader; - -public final class FakeSchemaTestValidatorLoader implements SchemaTestValidatorLoader { - - @Override - public SchemaTestValidator loadSchemaTestValidator(final String schema) { - return data -> true; - } -} diff --git a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuiteTestDescriptorTest.java b/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuiteTestDescriptorTest.java deleted file mode 100644 index e3993d43..00000000 --- a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuiteTestDescriptorTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import static com.github.npathai.hamcrestopt.OptionalMatchers.isPresent; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; - -import io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine.JsonSchemaSuiteTestDescriptor; -import jakarta.json.Json; -import jakarta.json.JsonValue; -import nl.jqno.equalsverifier.EqualsVerifier; -import org.junit.jupiter.api.Test; -import org.junit.platform.engine.UniqueId; -import org.junit.platform.engine.support.descriptor.EngineDescriptor; - -class JsonSchemaSuiteTestDescriptorTest { - - @Test - void should_return_parent() { - final JsonSchemaSuiteTestDescriptor desc = new JsonSchemaSuiteTestDescriptor( - new EngineDescriptor(UniqueId.forEngine("test"), "test"), - JsonValue.EMPTY_JSON_OBJECT - ); - - assertThat(desc.getParent(), isPresent()); - } - - @Test - void equalsContract() { - EqualsVerifier.forClass(JsonSchemaSuiteTestDescriptor.class).withIgnoredFields("parent").verify(); - } - - @Test - void should_return_all_children() { - assertThat( - new JsonSchemaSuiteTestDescriptor( - new EngineDescriptor(UniqueId.forEngine("test"), "test"), - Json - .createObjectBuilder() - .add("description", "boolean schema 'true'") - .add("schema", JsonValue.TRUE) - .add("tests", Json.createArrayBuilder().add(JsonValue.EMPTY_JSON_OBJECT)) - .build() - ) - .getChildren(), - hasSize(1) - ); - } -} diff --git a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuitesTestDescriptorTest.java b/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuitesTestDescriptorTest.java deleted file mode 100644 index d88f690b..00000000 --- a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaSuitesTestDescriptorTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import static com.github.npathai.hamcrestopt.OptionalMatchers.isEmpty; -import static com.github.npathai.hamcrestopt.OptionalMatchers.isPresent; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -import io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine.JsonSchemaSuitesTestDescriptor; -import io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine.Resource; -import nl.jqno.equalsverifier.EqualsVerifier; -import org.junit.jupiter.api.Test; -import org.junit.platform.engine.UniqueId; -import org.junit.platform.engine.support.descriptor.EngineDescriptor; - -class JsonSchemaSuitesTestDescriptorTest { - - @Test - void should_return_id_with_parent() { - final JsonSchemaSuitesTestDescriptor desc = new JsonSchemaSuitesTestDescriptor( - new Resource("tests/boolean_schema.json") - ); - //mutable :( - desc.setParent(new EngineDescriptor(UniqueId.forEngine("test"), "test")); - - assertThat(desc.getUniqueId(), is(UniqueId.parse("[engine:test]/[suite:tests%2Fboolean_schema.json]"))); - } - - @Test - void should_return_id_without_parent() { - final JsonSchemaSuitesTestDescriptor desc = new JsonSchemaSuitesTestDescriptor( - new Resource("tests/boolean_schema.json") - ); - //mutable :( - desc.setParent(null); - - assertThat(desc.getUniqueId(), is(UniqueId.parse("[suite:tests%2Fboolean_schema.json]"))); - } - - @Test - void should_return_parent() { - final JsonSchemaSuitesTestDescriptor desc = new JsonSchemaSuitesTestDescriptor( - new Resource("tests/boolean_schema.json") - ); - //mutable :( - desc.setParent(new EngineDescriptor(UniqueId.forEngine("test"), "test")); - - assertThat(desc.getParent(), isPresent()); - } - - @Test - void should_return_empty_parent() { - final JsonSchemaSuitesTestDescriptor desc = new JsonSchemaSuitesTestDescriptor( - new Resource("tests/boolean_schema.json") - ); - //mutable :( - desc.setParent(null); - - assertThat(desc.getParent(), isEmpty()); - } - - @Test - void equalsContract() { - EqualsVerifier.forClass(JsonSchemaSuitesTestDescriptor.class).withIgnoredFields("parent").verify(); - } -} diff --git a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestDescriptorTest.java b/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestDescriptorTest.java deleted file mode 100644 index 0e22269e..00000000 --- a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestDescriptorTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import static com.github.npathai.hamcrestopt.OptionalMatchers.isPresent; -import static org.hamcrest.MatcherAssert.assertThat; - -import io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine.JsonSchemaTestDescriptor; -import jakarta.json.JsonValue; -import nl.jqno.equalsverifier.EqualsVerifier; -import org.junit.jupiter.api.Test; -import org.junit.platform.engine.UniqueId; -import org.junit.platform.engine.support.descriptor.EngineDescriptor; - -class JsonSchemaTestDescriptorTest { - - @Test - void should_return_parent() { - final JsonSchemaTestDescriptor desc = new JsonSchemaTestDescriptor( - new EngineDescriptor(UniqueId.forEngine("test"), "test"), - JsonValue.EMPTY_JSON_OBJECT, - JsonValue.EMPTY_JSON_OBJECT - ); - - assertThat(desc.getParent(), isPresent()); - } - - @Test - void equalsContract() { - EqualsVerifier.forClass(JsonSchemaTestDescriptor.class).withIgnoredFields("parent").verify(); - } -} diff --git a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestSuiteEngineTest.java b/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestSuiteEngineTest.java deleted file mode 100644 index 3a689678..00000000 --- a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/JsonSchemaTestSuiteEngineTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import static org.junit.platform.testkit.engine.EventConditions.event; -import static org.junit.platform.testkit.engine.EventConditions.finishedSuccessfully; -import static org.junit.platform.testkit.engine.EventConditions.started; - -import org.junit.jupiter.api.Test; -import org.junit.platform.testkit.engine.EngineTestKit; - -class JsonSchemaTestSuiteEngineTest { - - @Test - void should_run_all_tests() { - EngineTestKit - .engine("jsonschema") - .execute() - .testEvents() - .assertThatEvents() - .haveExactly(4, event(started())) - .haveExactly(4, event(finishedSuccessfully())); - } -} diff --git a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ResourceTest.java b/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ResourceTest.java deleted file mode 100644 index e4d2fc4a..00000000 --- a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ResourceTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import nl.jqno.equalsverifier.EqualsVerifier; -import org.junit.jupiter.api.Test; - -class ResourceTest { - - @Test - void should_determine_file_extension() { - assertThat(new Resource("tests/test_resource.json").hasExtension("json"), is(true)); - } - - @Test - void should_determine_name() { - assertThat(new Resource("tests/test_resource.json").hasName("tests/test_resource.json"), is(true)); - assertThat(new Resource("tests/test_resource.json").hasName("tests/pitest"), is(false)); - } - - @Test - void should_return_content() throws Exception { - try (final InputStream content = new Resource("tests/test_resource.json").content()) { - assertThat( - new String(content.readAllBytes(), StandardCharsets.UTF_8), - is( - """ - { - "name": "sebastian" - } - """ - ) - ); - } - } - - @Test - void equalsContract() { - EqualsVerifier.forClass(Resource.class).verify(); - } -} diff --git a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ResourcesTest.java b/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ResourcesTest.java deleted file mode 100644 index 352c1990..00000000 --- a/testsuite-junit-platform-engine/src/test/java/io/github/sebastiantoepfer/jsonschema/testsuite/junit/engine/ResourcesTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * The MIT License - * - * Copyright 2023 sebastian. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasItems; - -import java.util.stream.Stream; -import org.junit.jupiter.api.Test; - -class ResourcesTest { - - @Test - void should_find_resources_from_classpath() { - try (final Stream res = new Resources().all()) { - assertThat(res.toList(), hasItems(new Resource("tests/test_resource.json"))); - } - } - - @Test - void should_find_resources_in_subdir_from_classpath() { - try (final Stream res = new Resources("tests").all()) { - assertThat(res.toList(), hasItems(new Resource("tests/test_resource.json"))); - } - } - - @Test - void should_find_resources_in_metainf() { - try (final Stream res = new Resources("META-INF").all()) { - //to kill all mutants, we need a resource from non-test classpath - assertThat(res.toList(), hasItems(new Resource("META-INF/services/org.junit.platform.engine.TestEngine"))); - } - } -} diff --git a/testsuite-junit-platform-engine/src/test/resources/META-INF/services/io.github.sebastiantoepfer.jsonschema.testsuite.junit.SchemaTestValidatorLoader b/testsuite-junit-platform-engine/src/test/resources/META-INF/services/io.github.sebastiantoepfer.jsonschema.testsuite.junit.SchemaTestValidatorLoader deleted file mode 100644 index f16d4901..00000000 --- a/testsuite-junit-platform-engine/src/test/resources/META-INF/services/io.github.sebastiantoepfer.jsonschema.testsuite.junit.SchemaTestValidatorLoader +++ /dev/null @@ -1 +0,0 @@ -io.github.sebastiantoepfer.jsonschema.testsuite.junit.engine.FakeSchemaTestValidatorLoader diff --git a/testsuite-junit-platform-engine/src/test/resources/tests/boolean_schema.json b/testsuite-junit-platform-engine/src/test/resources/tests/boolean_schema.json deleted file mode 100644 index ca3c4627..00000000 --- a/testsuite-junit-platform-engine/src/test/resources/tests/boolean_schema.json +++ /dev/null @@ -1,34 +0,0 @@ -[ - { - "description": "boolean schema 'true'", - "schema": true, - "tests": [ - { - "description": "number is valid", - "data": 1, - "valid": true - }, - { - "description": "string is valid", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "boolean schema 'false'", - "schema": false, - "tests": [ - { - "description": "number is invalid", - "data": 1, - "valid": true - }, - { - "description": "string is invalid", - "data": "foo", - "valid": true - } - ] - } -] diff --git a/testsuite-junit-platform-engine/src/test/resources/tests/test_resource.json b/testsuite-junit-platform-engine/src/test/resources/tests/test_resource.json deleted file mode 100644 index aa47a748..00000000 --- a/testsuite-junit-platform-engine/src/test/resources/tests/test_resource.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "sebastian" -}