diff --git a/build.gradle b/build.gradle index 4d6746310fa8..5db2509619dc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,6 @@ buildscript { repositories { - maven { - url 'https://plugins.gradle.org/m2/' - } + maven { url 'https://plugins.gradle.org/m2/' } } dependencies { classpath 'com.diffplug.gradle.spotless:spotless:1.3.1' @@ -22,6 +20,7 @@ subprojects { repositories { mavenCentral() + maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } } compileJava { @@ -86,13 +85,18 @@ subprojects { spotless { java { - if (project.name == 'open-test-alliance') { - licenseHeaderFile rootProject.file('src/spotless/apache-license-2.0.java') - } else { - licenseHeaderFile rootProject.file('src/spotless/eclipse-public-license-1.0.java') + target project.fileTree(project.rootDir) { + include '**/*.java' + exclude '**/package-info.java' + exclude '**/eclipse-public-license-1.0.java' + exclude '.gradle/**/*.java' } + + licenseHeaderFile rootProject.file('src/spotless/eclipse-public-license-1.0.java') importOrder(['java', 'javax', 'com', 'org']) eclipseFormatFile rootProject.file('src/eclipse/junit-lambda-eclipse-formatter-settings.xml') + // trimTrailingWhitespace() + // endWithNewline() custom 'Lambda fix', { it.replace('} )', '})').replace('} ,', '},') } } @@ -146,16 +150,9 @@ subprojects { } licenses { - if (project.name == 'open-test-alliance') { - license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } else { - license { - name 'Eclipse Public License v1.0' - url 'http://www.eclipse.org/legal/epl-v10.html' - } + license { + name 'Eclipse Public License v1.0' + url 'http://www.eclipse.org/legal/epl-v10.html' } } diff --git a/gradle.properties b/gradle.properties index f023e98a6d57..aecd432319be 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,3 +5,4 @@ assertJVersion = 3.2.0 junit4Version = 4.12 log4JVersion = 2.4.1 mockitoVersion = 1.10.19 +ota4jVersion = 1.0.0-SNAPSHOT diff --git a/junit-tests/build.gradle b/junit-tests/build.gradle index 4eb630caa645..4615cc8d9197 100644 --- a/junit-tests/build.gradle +++ b/junit-tests/build.gradle @@ -10,12 +10,10 @@ dependencies { compile(project(':junit5-api')) compile(project(':junit5-engine')) - testCompile("org.assertj:assertj-core:${assertJVersion}") testCompile("junit:junit:${junit4Version}") testCompile("org.mockito:mockito-core:${mockitoVersion}") testRuntime("org.apache.logging.log4j:log4j-core:${log4JVersion}") testRuntime("org.apache.logging.log4j:log4j-jul:${log4JVersion}") - } diff --git a/junit5-api/build.gradle b/junit5-api/build.gradle index 096b8054fbaf..70f19b543fc5 100644 --- a/junit5-api/build.gradle +++ b/junit5-api/build.gradle @@ -1,4 +1,4 @@ dependencies { - compile(project(':open-test-alliance')) + compile("org.opentest4j:opentest4j:${ota4jVersion}") compile(project(':junit-commons')) } diff --git a/junit5-api/src/main/java/org/junit/gen5/api/Assertions.java b/junit5-api/src/main/java/org/junit/gen5/api/Assertions.java index d33d2a3afea6..12a268fbf170 100644 --- a/junit5-api/src/main/java/org/junit/gen5/api/Assertions.java +++ b/junit5-api/src/main/java/org/junit/gen5/api/Assertions.java @@ -15,8 +15,8 @@ import java.util.function.Supplier; import org.junit.gen5.commons.util.StringUtils; -import org.opentestalliance.AssertionFailedError; -import org.opentestalliance.MultipleFailuresException; +import org.opentest4j.AssertionFailedError; +import org.opentest4j.MultipleFailuresError; /** * @since 5.0 @@ -200,13 +200,13 @@ public static void assertAll(Executable... asserts) { } public static void assertAll(String heading, Executable... asserts) { - MultipleFailuresException multipleFailuresException = new MultipleFailuresException(heading); + MultipleFailuresError multipleFailuresError = new MultipleFailuresError(heading); for (Executable executable : asserts) { try { executable.execute(); } catch (AssertionError failure) { - multipleFailuresException.addFailure(failure); + multipleFailuresError.addFailure(failure); } catch (Error | RuntimeException ex) { throw ex; @@ -215,8 +215,8 @@ public static void assertAll(String heading, Executable... asserts) { throw new RuntimeException(throwable); } } - if (multipleFailuresException.hasFailures()) { - throw multipleFailuresException; + if (multipleFailuresError.hasFailures()) { + throw multipleFailuresError; } } diff --git a/junit5-api/src/main/java/org/junit/gen5/api/Assumptions.java b/junit5-api/src/main/java/org/junit/gen5/api/Assumptions.java index 85b816b44f1a..76874e9537a8 100644 --- a/junit5-api/src/main/java/org/junit/gen5/api/Assumptions.java +++ b/junit5-api/src/main/java/org/junit/gen5/api/Assumptions.java @@ -13,7 +13,7 @@ import java.util.function.Supplier; import org.junit.gen5.commons.util.StringUtils; -import org.opentestalliance.TestAbortedException; +import org.opentest4j.TestAbortedException; /** * Collection of utility methods for conditional test execution based on diff --git a/open-test-alliance/build.gradle b/open-test-alliance/build.gradle deleted file mode 100644 index 6fcdd48cb548..000000000000 --- a/open-test-alliance/build.gradle +++ /dev/null @@ -1,13 +0,0 @@ -version = '1.0.0-SNAPSHOT' - -compileJava { - sourceCompatibility = 1.6 - targetCompatibility = 1.6 -} - - -dependencies { - testCompile("junit:junit:4.12") - testRuntime("org.apache.logging.log4j:log4j-core:${log4JVersion}") - testRuntime("org.apache.logging.log4j:log4j-jul:${log4JVersion}") -} diff --git a/open-test-alliance/src/main/java/org/opentestalliance/AssertionFailedError.java b/open-test-alliance/src/main/java/org/opentestalliance/AssertionFailedError.java deleted file mode 100644 index faacfdf9ca27..000000000000 --- a/open-test-alliance/src/main/java/org/opentestalliance/AssertionFailedError.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.opentestalliance; - -/** - * @since 1.0 - */ -public class AssertionFailedError extends AssertionError { - - private static final long serialVersionUID = 3170879295749989795L; - - /** - * Undefined object, used to differentiate between a {@code null} - * default value and a user-supplied {@code null} value. - */ - private static final Object UNDEFINED = new Object(); - - private final Object expected; - - private final Object actual; - - public AssertionFailedError() { - this((String) null); - } - - public AssertionFailedError(String message) { - this(message, UNDEFINED, UNDEFINED); - } - - public AssertionFailedError(String message, Object expected, Object actual) { - this(message, expected, actual, null); - } - - public AssertionFailedError(String message, Throwable cause) { - this(message, UNDEFINED, UNDEFINED, cause); - } - - public AssertionFailedError(String message, Object expected, Object actual, Throwable cause) { - super(message, cause); - this.expected = expected; - this.actual = actual; - } - - public boolean isExpectedDefined() { - return (this.expected != UNDEFINED); - } - - public boolean isActualDefined() { - return (this.actual != UNDEFINED); - } - - public Object getExpected() { - return (this.expected == UNDEFINED ? null : this.expected); - } - - public Object getActual() { - return (this.actual == UNDEFINED ? null : this.actual); - } - -} diff --git a/open-test-alliance/src/main/java/org/opentestalliance/IncompleteExecutionException.java b/open-test-alliance/src/main/java/org/opentestalliance/IncompleteExecutionException.java deleted file mode 100644 index de07300e0cb9..000000000000 --- a/open-test-alliance/src/main/java/org/opentestalliance/IncompleteExecutionException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.opentestalliance; - -/** - * {@link RuntimeException} used to indicate that the execution of a test - * was incomplete — for example, that the execution was entirely - * skipped or aborted mid-stream. See subclasses for concrete use cases. - * - *

An {@code IncompleteExecutionException} is not used - * to indicate that a test execution failed. - * - * @since 1.0 - */ -public class IncompleteExecutionException extends RuntimeException { - - private static final long serialVersionUID = -747115119423872864L; - - public IncompleteExecutionException() { - } - - public IncompleteExecutionException(String message) { - super(message); - } - - public IncompleteExecutionException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/open-test-alliance/src/main/java/org/opentestalliance/MultipleFailuresException.java b/open-test-alliance/src/main/java/org/opentestalliance/MultipleFailuresException.java deleted file mode 100644 index 64ed902f5336..000000000000 --- a/open-test-alliance/src/main/java/org/opentestalliance/MultipleFailuresException.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.opentestalliance; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * @since 1.0 - */ -public class MultipleFailuresException extends AssertionError { - - private static final long serialVersionUID = 110777277591630805L; - - private final String heading; - - private final List failures = new ArrayList(); - - public MultipleFailuresException(String heading) { - this.heading = isBlank(heading) ? "Multiple Failures" : heading.trim(); - } - - public void addFailure(AssertionError failure) { - this.failures.add(failure); - } - - @Override - public String getMessage() { - int failureCount = this.failures.size(); - - if (failureCount == 0) { - return this.heading; - } - - String formattedHeading = String.format("%s (%d %s)%n", this.heading, failureCount, - pluralize(failureCount, "failure", "failures")); - - StringBuilder builder = new StringBuilder(formattedHeading); - - int lastIndex = failureCount - 1; - for (AssertionError failure : this.failures.subList(0, lastIndex)) { - builder.append(String.format("\t%s%n", nullSafeMessage(failure))); - } - builder.append('\t').append(nullSafeMessage(this.failures.get(lastIndex))); - - return builder.toString(); - } - - public List getFailures() { - return Collections.unmodifiableList(this.failures); - } - - public boolean hasFailures() { - return !this.failures.isEmpty(); - } - - private static boolean isBlank(String str) { - return (str == null || str.trim().length() == 0); - } - - private static String pluralize(int count, String singular, String plural) { - return count == 1 ? singular : plural; - } - - private static String nullSafeMessage(AssertionError failure) { - if (failure.getMessage() == null) { - return String.format(" in %s", failure.getClass().getName()); - } - return failure.getMessage(); - } - -} diff --git a/open-test-alliance/src/main/java/org/opentestalliance/TestAbortedException.java b/open-test-alliance/src/main/java/org/opentestalliance/TestAbortedException.java deleted file mode 100644 index 4c23e42405ce..000000000000 --- a/open-test-alliance/src/main/java/org/opentestalliance/TestAbortedException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.opentestalliance; - -/** - * Specialization of {@link IncompleteExecutionException} used to indicate - * that a test was aborted during execution. - * - * @since 1.0 - * @see TestSkippedException - */ -public class TestAbortedException extends IncompleteExecutionException { - - private static final long serialVersionUID = -5277362515874754471L; - - public TestAbortedException() { - } - - public TestAbortedException(String message) { - super(message); - } - - public TestAbortedException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/open-test-alliance/src/main/java/org/opentestalliance/TestSkippedException.java b/open-test-alliance/src/main/java/org/opentestalliance/TestSkippedException.java deleted file mode 100644 index b28cf35598fc..000000000000 --- a/open-test-alliance/src/main/java/org/opentestalliance/TestSkippedException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.opentestalliance; - -/** - * Specialization of {@link IncompleteExecutionException} used to indicate - * that a test was skipped prior to execution (e.g., disabled - * or ignored). - * - * @since 1.0 - */ -public class TestSkippedException extends IncompleteExecutionException { - - private static final long serialVersionUID = -2632738154006239247L; - - public TestSkippedException() { - } - - public TestSkippedException(String message) { - super(message); - } - - public TestSkippedException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/open-test-alliance/src/test/java/org/opentestalliance/AssertionFailedErrorTest.java b/open-test-alliance/src/test/java/org/opentestalliance/AssertionFailedErrorTest.java deleted file mode 100644 index 2883c3540975..000000000000 --- a/open-test-alliance/src/test/java/org/opentestalliance/AssertionFailedErrorTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.opentestalliance; - -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class AssertionFailedErrorTest { - - @Test - public void nullMessageIsNotConvertedToStringContainingNull() { - assertNull(new AssertionFailedError().getMessage()); - assertNull(new AssertionFailedError(null).getMessage()); - assertNull(new AssertionFailedError(null, null).getMessage()); - assertNull(new AssertionFailedError(null, "foo", "bar").getMessage()); - assertNull(new AssertionFailedError(null, "foo", "bar", null).getMessage()); - } -} diff --git a/open-test-alliance/src/test/java/org/opentestalliance/MultipleFailuresExceptionTest.java b/open-test-alliance/src/test/java/org/opentestalliance/MultipleFailuresExceptionTest.java deleted file mode 100644 index 5ec5ff6ff995..000000000000 --- a/open-test-alliance/src/test/java/org/opentestalliance/MultipleFailuresExceptionTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.opentestalliance; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class MultipleFailuresExceptionTest { - - private static final String DEFAULT_HEADING = "Multiple Failures"; - private static final String HEADING = "Custom Heading"; - - @Test - public void exceptionWithNoFailuresWithNullHeading() { - assertExceptionWithNoFailures(null, DEFAULT_HEADING); - } - - @Test - public void exceptionWithNoFailuresWithEmptyHeading() { - assertExceptionWithNoFailures(" ", DEFAULT_HEADING); - } - - @Test - public void exceptionWithNoFailuresWithCustomHeading() { - assertExceptionWithNoFailures(HEADING, HEADING); - } - - @Test - public void exceptionWithSingleFailureWithNullHeading() { - assertExceptionWithSingleFailure(null, DEFAULT_HEADING); - } - - @Test - public void exceptionWithSingleFailureWithEmptyHeading() { - assertExceptionWithSingleFailure(" ", DEFAULT_HEADING); - } - - @Test - public void exceptionWithSingleFailureWithCustomHeading() { - assertExceptionWithSingleFailure(HEADING, HEADING); - } - - @Test - public void exceptionWithFailuresWithNullHeading() { - assertExceptionWithFailures(null, DEFAULT_HEADING); - } - - @Test - public void exceptionWithFailuresWithEmptyHeading() { - assertExceptionWithFailures(" ", DEFAULT_HEADING); - } - - @Test - public void exceptionWithFailuresWithCustomHeading() { - assertExceptionWithFailures(HEADING, HEADING); - } - - @Test - public void exceptionWithNullMessageFailures() throws Exception { - MultipleFailuresException exception = new MultipleFailuresException(HEADING); - exception.addFailure(new AssertionError()); - exception.addFailure(new AssertionFailedError()); - - assertEquals( - String.format("%s %s%n\t%s%n\t%s", HEADING, "(2 failures)", // - " in java.lang.AssertionError", // - " in org.opentestalliance.AssertionFailedError"), // - exception.getMessage()); - } - - private void assertExceptionWithNoFailures(String inputHeading, String outputHeading) { - MultipleFailuresException exception = new MultipleFailuresException(inputHeading); - - assertTrue(exception.getFailures().isEmpty()); - assertFalse(exception.hasFailures()); - assertEquals(outputHeading, exception.getMessage()); - } - - private void assertExceptionWithSingleFailure(String inputHeading, String outputHeading) { - MultipleFailuresException exception = new MultipleFailuresException(inputHeading); - exception.addFailure(new AssertionError("failure 1")); - - assertEquals(1, exception.getFailures().size()); - assertTrue(exception.hasFailures()); - assertEquals(String.format("%s %s%n\t%s", outputHeading, "(1 failure)", "failure 1"), exception.getMessage()); - } - - private void assertExceptionWithFailures(String inputHeading, String outputHeading) { - MultipleFailuresException exception = new MultipleFailuresException(inputHeading); - exception.addFailure(new AssertionError("failure 1")); - exception.addFailure(new AssertionError("failure 2")); - - assertEquals(2, exception.getFailures().size()); - assertTrue(exception.hasFailures()); - assertEquals(String.format("%s %s%n\t%s%n\t%s", outputHeading, "(2 failures)", "failure 1", "failure 2"), - exception.getMessage()); - } - -} diff --git a/sample-project/src/test/java/com/example/SampleTestCase.java b/sample-project/src/test/java/com/example/SampleTestCase.java index 8d7082d10f6f..79ae52707f77 100644 --- a/sample-project/src/test/java/com/example/SampleTestCase.java +++ b/sample-project/src/test/java/com/example/SampleTestCase.java @@ -27,7 +27,7 @@ import org.junit.gen5.api.Test; import org.junit.gen5.api.TestName; import org.junit.gen5.api.extension.ExtendWith; -import org.opentestalliance.TestSkippedException; +import org.opentest4j.TestSkippedException; /** * Named *TestCase so Gradle will not try to run it. diff --git a/settings.gradle b/settings.gradle index 71ce4d720cff..3aec313d8bca 100644 --- a/settings.gradle +++ b/settings.gradle @@ -12,8 +12,6 @@ include "junit5-engine" include "junit-gradle" include "junit-tests" -include "open-test-alliance" - include "sample-extension" include "sample-project" diff --git a/src/spotless/apache-license-2.0.java b/src/spotless/apache-license-2.0.java deleted file mode 100644 index 82ca41cb9d5e..000000000000 --- a/src/spotless/apache-license-2.0.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */