opentest4j-r1.2.0/ 0000775 0000000 0000000 00000000000 13476264065 0014010 5 ustar 00root root 0000000 0000000 opentest4j-r1.2.0/.gitattributes 0000664 0000000 0000000 00000000035 13476264065 0016701 0 ustar 00root root 0000000 0000000 * text eol=lf *.bat eol=crlf opentest4j-r1.2.0/.github/ 0000775 0000000 0000000 00000000000 13476264065 0015350 5 ustar 00root root 0000000 0000000 opentest4j-r1.2.0/.github/PULL_REQUEST_TEMPLATE.md 0000664 0000000 0000000 00000000151 13476264065 0021146 0 ustar 00root root 0000000 0000000 ## Overview - --- I hereby agree to the terms of the Open Test Alliance Contributor License Agreement. opentest4j-r1.2.0/.gitignore 0000664 0000000 0000000 00000000264 13476264065 0016002 0 ustar 00root root 0000000 0000000 # Gradle .gradle build/ # Ignore Gradle GUI config gradle-app.setting # Eclipse .classpath .settings/ .project bin/ # IntelliJ *.iml *.ipr *.iws *.uml .idea/ out/ # Misc *.log opentest4j-r1.2.0/.travis.yml 0000664 0000000 0000000 00000005607 13476264065 0016131 0 ustar 00root root 0000000 0000000 language: java # Specify which branches/tags that we do not want to be built: r5.0.0-M5 branches: except: - /^r\d.*$/ before_install: - unset _JAVA_OPTIONS # https://github.com/travis-ci/travis-ci/issues/8408 install: - ./gradlew --version # Display Gradle, Groovy, JVM and other versions jdk: - openjdk11 stages: - test - name: deploy if: (branch = master) AND (NOT type IN (pull_request)) jobs: include: - script: ./gradlew --stacktrace build - stage: deploy name: "Publish snapshot artifacts" env: # ORG_GRADLE_PROJECT_ossrhUsername - secure: K3oEnLQ2ai8lmTHrfQsktkb8vc/W5ghP6NurUmb4E+SHWw/zqv2naxupbpVZqovhhTqYm1/I0rqHKrGrBIUDSFMhyTKYmqw4+Nck3BAnjXovotGuKyMrg6yqoBjaWhT8rJe/fR2hZgUi96vSjEKC/UDSGRRHhoEyX73qAwbA7CGJ3SMVRZpkBvs2GUubKZgXuJCpGSk2FWOtJpWK4sC87/yV8Arg1DgrCHUm7uc1we+CedjierPxfo6QX9Laohyn60D3BtojYw1xxsiX9Rv0KCxCqmZn5Qd6PLV4+0PzFXjO0xvrHecQ+NhyWfmMkfV5dO/zaF0OoxrHj/cFmvoGSHN4r1SIV2TwbtIuUCxypWqUTVrfejQyJ2Dhk2GbOa941EtXXX8i2zEDTBq56Tby4d44QvhK1v8QNmmev/o6j1YCBMKN+X59bSqUHF4PX8ap9m2iWYNCbvwET5YJAKnWLEj2QGBXn34GWZksyU/Fe+mvVJ0eRwZjUWKfOcS5xzrvRrNayyMIzUSUGKuTDeS+KR9eF7215hBDu6t8z+s+jSyoLD8+tttnHrgBkkUvwzctT8MeQP0JdpYhYyITuWYJ1OB9w2GKHE5ch9JYYOKUliJga42P6Hbx4NwTeCSNJ96mzQAKcDwwJZujzN2PDSr86uBlHwLdn+9cy0vndYUSYtY= # ORG_GRADLE_PROJECT_ossrhPassword - secure: NewZka3bmiDgrSP8+yfPQNf85K/sT4CQiIbrf9SWOTgI7Z6kq6kKXU94cEQue6Ugli0USreMZYhl5b6XvcCUzRF9kOh/mRk9VIaOOaOIloatmaF581mGiYNBn8AoBoQ/JURQ59dBxHxyyf4Wm5o63FW0RdZoBOb8FA+esLGdY8ZlpsSc3WdYmguJf6Ga2auT1FIGujDLjBYCaPBqx1xM8JckFWBU0QHhDGFo6CjGUUd62KTf72RVtsLmcMnEvoJ18s7txmWYY4H/BwONekTnmXw80+y6EVXP3K7kkD/9KL9xq/fDibcmP9UfbpCnEysu7hygMhPfMPB3KmPhFSP7GGlEZsLeGNhLBLXidpJmyNvcSHOdS+vaF8xbW/+DBJ3stNntS1TaPGPcIjAyKN67q4yayZBdJKzkIWzVkJy3akRwO7D0Lj1irs7mcLL0DSkP3YrgShIhcq34D+Iknblz4AykG1/ehv4eAipljrh66SGB41QlN6U0AZVpqi869sPfu55q8Piucnrps+3jo26q25mtPpurEIIQIX6SCwUyK4A+4Jvk4r8KUykkBS7HildiflKGwiLTRHgskGkAslm0ARZo4B50FQgqcJbytkSqe76y4WeVLZ648zNNTlX7oysKeizGjj6CxnXN3KLKmmXqKaht5UX6gCSbw2+O9/OlAgw= script: ./gradlew --stacktrace uploadArchives -x check - name: "Update snapshot documentation" env: # ORG_GRADLE_PROJECT_githubToken - secure: AW4jpuuv5MTIxUw1dlfIKyRgp5G9aj9/wsJx+XBVdZ6/+0Tj8BzBldUe9b4JeNEnDGIRIL83lPHMR0a/DbfF5Cg0Cpi0oLQE+JkKh/ucRZucrXXMjIg+3IEtpdUG/I4vqjwd1xUAYZ/URPP75NVr7b3RVY9+MTaSaZ2b+VtG/aMNJ5kih4PHfJ2wR0OobHrTSxOkyGwZTdG6ZvFplHcPtuZ/v6KJGaUrCFYRnXOZIE73dPDQjxqy90FQrNlscvkZ3cerqVeeQ1nK7eU60neNBrSP9PJsN6zqSyPfMfyfzGBiS7v2dlVktSjeOmdEn+NCSmR59a0wbVObhzisOgODqBMk3KLWOWwWHfA2M5URuQaNr/AsKQTr2FlVkwY/cHO52q58tKNE1m/3nPs5ZMEhlh6jtbBafUe8NA9JQ0LKppA/kMqd1vT97hCeMGR0B5rTZEYXK9pCKWmWg98YEAR9RA9gnNuRod07uI/T9dSvHVvg3T7K1jdFtnSs8TOYamxn3wo1I8jud34mUTv7v4Wdk7ujXZJIcIkHFWKon/OpRwiBHNh9w5w0d7qZVvH7dYFhxRYjbUP4d+QzYlUQUVcy1QvixHBr4eYRZ1q7v40OWBKb9lOXdD1I6x7XLtcNcZ08c3xKpiBFjwTPIMot87vw90PTPFigBAfRj1wDocdd9Sg= script: ./gradlew --stacktrace publishGhPages opentest4j-r1.2.0/CONTRIBUTING.md 0000664 0000000 0000000 00000004303 13476264065 0016241 0 ustar 00root root 0000000 0000000 # Contributing ## Open Test Alliance Contributor License Agreement **Project License:** [Apache License Version 2.0](LICENSE) - You will only Submit Contributions where You have authored 100% of the content. - You will only Submit Contributions to which You have the necessary rights. This means that if You are employed You have received the necessary permissions from Your employer to make the Contributions. - Whatever content You Contribute will be provided under the Project License(s). ## Pull Requests Please add the following lines to your pull request description: ```markdown --- I hereby agree to the terms of the Open Test Alliance Contributor License Agreement. ``` ## Coding Conventions ### Formatting Code formatting is enforced using the [Spotless](https://github.com/diffplug/spotless) Gradle plugin. You can use `gradle spotlessApply` to format new code and add missing license headers to source files. Formatter settings for Eclipse are available [in the repository](https://github.com/ota4j-team/opentest4j/blob/master/etc/eclipse/eclipse-formatter-settings.xml). For IntelliJ IDEA there's a [plugin](https://plugins.jetbrains.com/plugin/6546) you can use. ### Javadoc - Javadoc comments should be wrapped after 80 characters whenever possible. - This first paragraph must be a single, concise sentence that ends with a period ("."). - Place `
` on the same line as the first line in a new paragraph and precede `
` with a blank line.
- Insert a blank line before at-clauses/tags.
- Favor `{@code foo}` over `foo
`.
- Favor literals (e.g., `{@literal @}`) over HTML entities.
- Use `@since 1.0` instead of `@since 1.0.0`.
- Use `@author` tags with full, real names (no nicknames or aliases) at the type level. Do not include email addresses or URLs in `@author` tags.
### Tests
#### Naming
- Tests are written using JUnit 4.
- All test classes must end with a `Tests` suffix.
- Example test classes that should not be picked up by the build must end with a `TestCase` suffix.
#### Assertions
- Use `org.junit.Assert` wherever possible.
- Do not use `junit.framework.Assert`.
- Use AssertJ when richer assertions are needed.
#### Mocking
- Use either Mockito or hand-written test doubles.
opentest4j-r1.2.0/LICENSE 0000664 0000000 0000000 00000026136 13476264065 0015025 0 ustar 00root root 0000000 0000000 Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
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.
opentest4j-r1.2.0/README.md 0000664 0000000 0000000 00000010040 13476264065 0015262 0 ustar 00root root 0000000 0000000 # Open Test Alliance for the JVM
[](https://travis-ci.org/ota4j-team/opentest4j)
## History
This project is the result of an initiative by the [JUnit 5 team](https://github.com/junit-team/junit5/issues/12).
## Status Quo
There is no standard for testing on the JVM: the only common building block we have is `java.lang.AssertionError`.
`AssertionError` is great for signaling that a test has failed, but it doesn't go far enough. Each testing framework is therefore forced to fill the gap with custom subclasses of `AssertionError` or `RuntimeException` to provide a richer feature set to end users. The downside is that each framework has its **own** set of custom errors and exceptions, and this makes it a challenge for frameworks to interoperate.
For example, JUnit has long supported the notion of a _failed assumption_ via its `AssumptionViolatedException`, but assertion frameworks like AssertJ cannot integrate that feature without a direct dependency on JUnit. Furthermore, the status quo makes the work of IDEs and build tools more difficult than it should be.
## Proposal
The only real solution to this problem is to create a foundation that we can all build on!
Based on discussions with IDE and build tool developers from Eclipse, Gradle, and IntelliJ, the JUnit 5 team is working on a proposal for an open source project to provide a minimal common foundation for testing libraries on the JVM. The primary goal of the project is to enable testing frameworks like JUnit, TestNG, Spock, etc. and third-party assertion libraries like Hamcrest, AssertJ, etc. to use a common set of exceptions that IDEs and build tools can support in a consistent manner across all testing scenarios -- for example, for consistent handling of failed assertions and failed assumptions as well as visualization of test execution in IDEs and reports.
## Initial Implementation
We have begun with a small set of errors and exceptions that we consider to be common for all testing and assertion frameworks. In fact, these errors and exceptions are already used in [JUnit 5]. Please take a look at the project and let us know what you think.
## Javadocs
- [Latest release](http://ota4j-team.github.io/opentest4j/docs/current/api/)
- [Latest snapshot](http://ota4j-team.github.io/opentest4j/docs/snapshot/api/)
## Contributing
Contributions to the Open Test Alliance are both welcomed and appreciated. For specific
guidelines regarding contributions, please see [CONTRIBUTING.md] in the root directory of
the project. Those willing to use milestone or SNAPSHOT releases are encouraged to file
feature requests and bug reports using the project's
[issue tracker](https://github.com/ota4j-team/opentest4j/issues).
### Feedback is welcome!
What types of _errors_ and _exceptions_ should the OTA support?
What types of properties should such errors and exceptions have?
What additional functionality (e.g., interfaces, utility methods, etc.) should the OTA provide?
## Projects already contacted
We've already reached out to and asked for feedback from the maintainers of the following projects.
- Test NG
- Hamcrest
- AssertJ
- Spock
- Google Truth
- ScalaTest
- Eclipse
- IntelliJ
- Gradle
- Maven Surefire Plugin
- Allure Framework
# Installation
Release artifacts are deployed to [Maven Central].
Snapshot artifacts are deployed to Sonatype's [snapshots repository].
## Dependency Metadata
### Latest Release
- **Group ID**: `org.opentest4j`
- **Artifact ID**: `opentest4j`
- **Version**: `1.2.0`
See also:
In addition to a message and a cause, this class stores the expected * and actual values of an assertion using the {@link ValueWrapper} type. * * @author Sam Brannen * @author Marc Philipp * @since 1.0 */ public class AssertionFailedError extends AssertionError { private static final long serialVersionUID = 1L; private final ValueWrapper expected; private final ValueWrapper actual; /** * Constructs an {@code AssertionFailedError} with an empty message, no * cause, and no expected/actual values. */ public AssertionFailedError() { this(null); } /** * Constructs an {@code AssertionFailedError} with a message, no cause, * and no expected/actual values. * * @param message the detail message; {@code null} or blank will be * converted to the empty {@code String} */ public AssertionFailedError(String message) { this(message, null); } /** * Constructs an {@code AssertionFailedError} with a message and * expected/actual values but without a cause. * * @param message the detail message; {@code null} or blank will be * converted to the empty {@code String} * @param expected the expected value; may be {@code null} * @param actual the actual value; may be {@code null} */ public AssertionFailedError(String message, Object expected, Object actual) { this(message, expected, actual, null); } /** * Constructs an {@code AssertionFailedError} with a message and a cause * but without expected/actual values. * * @param message the detail message; {@code null} or blank will be * converted to the empty {@code String} * @param cause the cause of the failure */ public AssertionFailedError(String message, Throwable cause) { this(message, null, null, cause); } /** * Constructs an {@code AssertionFailedError} with a message, * expected/actual values, and a cause. * * @param message the detail message; {@code null} or blank will be * converted to the empty {@code String} * @param expected the expected value; may be {@code null} * @param actual the actual value; may be {@code null} * @param cause the cause of the failure */ public AssertionFailedError(String message, Object expected, Object actual, Throwable cause) { this(message, ValueWrapper.create(expected), ValueWrapper.create(actual), cause); } private AssertionFailedError(String message, ValueWrapper expected, ValueWrapper actual, Throwable cause) { super((message == null || message.trim().length() == 0) ? "" : message); this.expected = expected; this.actual = actual; initCause(cause); } /** * Returns {@code true} if an expected value was supplied via an * appropriate constructor. * * @see #getExpected() */ public boolean isExpectedDefined() { return this.expected != null; } /** * Returns {@code true} if an actual value was supplied via an * appropriate constructor. * * @see #getActual() */ public boolean isActualDefined() { return this.actual != null; } /** * Returns the wrapped expected value if it is defined; otherwise {@code null}. * * @see #isExpectedDefined() */ public ValueWrapper getExpected() { return this.expected; } /** * Returns the wrapped actual value if it is defined; otherwise {@code null}. * * @see #isActualDefined() */ public ValueWrapper getActual() { return this.actual; } /** * Returns a short description of this assertion error using the same format * as {@link Throwable#toString()}. * *
Since the constructors of this class convert supplied {@code null} or * blank messages to the empty {@code String}, this method only includes * non-empty messages in its return value. * * @return a string representation of this {@code AssertionFailedError} * @since 1.1.1 */ @Override public String toString() { String className = getClass().getName(); String message = getLocalizedMessage(); return ("".equals(message) ? className : (className + ": " + message)); } } opentest4j-r1.2.0/src/main/java/org/opentest4j/IncompleteExecutionException.java 0000664 0000000 0000000 00000002577 13476264065 0030052 0 ustar 00root root 0000000 0000000 /* * Copyright 2015-2018 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.opentest4j; /** * {@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.
*
* @author Johannes Link
* @author Sam Brannen
* @since 1.0
*/
public class IncompleteExecutionException extends RuntimeException {
private static final long serialVersionUID = 1L;
public IncompleteExecutionException() {
}
public IncompleteExecutionException(String message) {
super(message);
}
public IncompleteExecutionException(String message, Throwable cause) {
super(message, cause);
}
}
opentest4j-r1.2.0/src/main/java/org/opentest4j/MultipleFailuresError.java 0000664 0000000 0000000 00000006663 13476264065 0026510 0 ustar 00root root 0000000 0000000 /*
* Copyright 2015-2018 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.opentest4j;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* {@link MultipleFailuresError} is an {@link AssertionError} that aggregates
* multiple failures thrown in a given context (i.e., typically within the
* invocation of a single test).
*
* @author Johannes Link
* @author Sam Brannen
* @author Marc Philipp
* @since 1.0
*/
public class MultipleFailuresError extends AssertionError {
private static final long serialVersionUID = 1L;
private static final String EOL = System.getProperty("line.separator");
private final String heading;
private final List This class only stores the value if it implements {@link Serializable}.
* In any case, it stores its {@linkplain #getType() runtime type}, {@linkplain
* #getIdentityHashCode() identity hash code}, and {@linkplain
* #getStringRepresentation() string representation} determined via {@link
* String#valueOf(Object)}. If the invocation of {@code String.valueOf(Object)}
* throws an {@link Exception}, the string representation will take the form of
* {@code " The {@link #toString()} method returns the string representation of the
* value along with its type and identity hash code.
*
* @author Marc Philipp
* @author Sam Brannen
* @since 1.0
* @see System#identityHashCode
*/
public final class ValueWrapper implements Serializable {
private static final long serialVersionUID = 1L;
private static final ValueWrapper nullValueWrapper = new ValueWrapper(null);
/**
* Factory for creating a new {@code ValueWrapper} for the supplied {@code value}.
*
* If the supplied {@code value} is {@code null}, this method will return a
* cached {@code ValueWrapper} suitable for all {@code null} values.
* If the supplied {@code value} is already an instance of {@link ValueWrapper},
* it will be returned as is.
*
* @param value the value to wrap; may be {@code null}
* @return a wrapper for the supplied value; never {@code null}
*/
public static ValueWrapper create(Object value) {
if (value instanceof ValueWrapper)
return (ValueWrapper) value;
return (value == null) ? nullValueWrapper : new ValueWrapper(value);
}
/**
* Factory for creating a new {@code ValueWrapper} for the supplied {@code value}
* using the supplied custom {@code stringRepresentation}.
*
* You should use this method when you don't want to rely on the result of the
* value's {@link Object#toString() toString()} method.
*
* If the supplied {@code value} is {@code null}, this method will return a
* cached {@code ValueWrapper} suitable for all {@code null} values.
* If the supplied {@code value} is already an instance of {@link ValueWrapper},
* it will be returned as is if the {@code stringRepresentation} match, otherwise
* the original value will be unwrapped and a new {@code ValueWrapper} with the
* new {@code stringRepresentation} will be created.
*
* @param value the value to wrap; may be {@code null}
* @param stringRepresentation a custom rendering of the value; will fallback to
* the default behavior if {@code null}
* @return a wrapper for the supplied value; never {@code null}
* @since 1.2
*/
public static ValueWrapper create(Object value, String stringRepresentation) {
if (value instanceof ValueWrapper) {
ValueWrapper wrapper = (ValueWrapper) value;
return wrapper.stringRepresentation.equals(stringRepresentation) ? wrapper
: create(wrapper.value, stringRepresentation);
}
return (value == null ? nullValueWrapper : new ValueWrapper(value, stringRepresentation));
}
private final Serializable value;
private final Class> type;
private final String stringRepresentation;
private final int identityHashCode;
private final transient Object ephemeralValue;
/**
* Reads and stores the supplied value's runtime type, string representation, and
* identity hash code.
*/
private ValueWrapper(Object value, String stringRepresentation) {
this.value = value instanceof Serializable ? (Serializable) value : null;
this.type = value != null ? value.getClass() : null;
this.stringRepresentation = stringRepresentation == null ? safeValueToString(value) : stringRepresentation;
this.identityHashCode = System.identityHashCode(value);
this.ephemeralValue = value;
}
private ValueWrapper(Object value) {
this(value, safeValueToString(value));
}
private static String safeValueToString(Object value) {
try {
return String.valueOf(value);
}
catch (Exception e) {
return " The string representation is generated by invoking
* {@link String#valueOf(Object) String.valueOf(value)} for the value
* supplied to {@link #create(Object)}.
*
* @see #getValue()
*/
public String getStringRepresentation() {
return this.stringRepresentation;
}
/**
* Returns the value's identity hash code.
*
* The identity hash code is generated by invoking
* {@link System#identityHashCode(Object) System.identityHashCode(value)}
* for the value supplied to {@link #create(Object)}.
*
* @see #getValue()
*/
public int getIdentityHashCode() {
return this.identityHashCode;
}
/**
* Returns the original value supplied to {@link #create(Object) create()}.
*
* If this {@code ValueWrapper} was created by deserialization this method
* returns {@code null}.
*
* @see #getValue()
* @since 1.2
*/
public Object getEphemeralValue() {
return this.ephemeralValue;
}
/**
* Returns the value's string representation along with its type and
* identity hash code.
*/
@Override
public String toString() {
if (this.type == null) {
return "null";
}
return this.stringRepresentation + //
" (" + this.type.getName() + "@" + Integer.toHexString(this.identityHashCode) + ")";
}
}
opentest4j-r1.2.0/src/main/java/org/opentest4j/package-info.java 0000664 0000000 0000000 00000000276 13476264065 0024526 0 ustar 00root root 0000000 0000000 /**
* Common {@link java.lang.AssertionError AssertionErrors} and
* {@link java.lang.RuntimeException RuntimeExceptions} for testing
* frameworks on the JVM.
*/
package org.opentest4j;
opentest4j-r1.2.0/src/module/ 0000775 0000000 0000000 00000000000 13476264065 0016064 5 ustar 00root root 0000000 0000000 opentest4j-r1.2.0/src/module/java/ 0000775 0000000 0000000 00000000000 13476264065 0017005 5 ustar 00root root 0000000 0000000 opentest4j-r1.2.0/src/module/java/org.opentest4j/ 0000775 0000000 0000000 00000000000 13476264065 0021672 5 ustar 00root root 0000000 0000000 opentest4j-r1.2.0/src/module/java/org.opentest4j/module-info.java 0000664 0000000 0000000 00000000063 13476264065 0024752 0 ustar 00root root 0000000 0000000 module org.opentest4j {
exports org.opentest4j;
}
opentest4j-r1.2.0/src/test/ 0000775 0000000 0000000 00000000000 13476264065 0015556 5 ustar 00root root 0000000 0000000 opentest4j-r1.2.0/src/test/java/ 0000775 0000000 0000000 00000000000 13476264065 0016477 5 ustar 00root root 0000000 0000000 opentest4j-r1.2.0/src/test/java/org/ 0000775 0000000 0000000 00000000000 13476264065 0017266 5 ustar 00root root 0000000 0000000 opentest4j-r1.2.0/src/test/java/org/opentest4j/ 0000775 0000000 0000000 00000000000 13476264065 0021365 5 ustar 00root root 0000000 0000000 opentest4j-r1.2.0/src/test/java/org/opentest4j/AssertionFailedErrorTests.java 0000664 0000000 0000000 00000020445 13476264065 0027346 0 ustar 00root root 0000000 0000000 /*
* Copyright 2015-2018 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.opentest4j;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import org.junit.Test;
/**
* Unit tests for {@link AssertionFailedError}.
*
* @author Marc Philipp
* @author Sam Brannen
* @since 1.0
*/
public class AssertionFailedErrorTests {
private static final String EMPTY = "";
private static final String BLANK = " ";
@Test
public void defaultConstructorUsesEmptyMessage() {
assertEquals(EMPTY, new AssertionFailedError().getMessage());
}
@Test
public void nullMessageIsConvertedToEmptyMessage() {
assertEquals(EMPTY, new AssertionFailedError(null).getMessage());
assertEquals(EMPTY, new AssertionFailedError(null, null).getMessage());
assertEquals(EMPTY, new AssertionFailedError(null, "foo", "bar").getMessage());
assertEquals(EMPTY, new AssertionFailedError(null, "foo", "bar", null).getMessage());
}
@Test
public void blankMessageIsConvertedToEmptyMessage() {
assertEquals(EMPTY, new AssertionFailedError(BLANK).getMessage());
assertEquals(EMPTY, new AssertionFailedError(BLANK, null).getMessage());
assertEquals(EMPTY, new AssertionFailedError(BLANK, "foo", "bar").getMessage());
assertEquals(EMPTY, new AssertionFailedError(BLANK, "foo", "bar", null).getMessage());
}
@Test
public void toStringChecks() {
String className = AssertionFailedError.class.getName();
assertEquals(className, new AssertionFailedError().toString());
assertEquals(className, new AssertionFailedError(null).toString());
assertEquals(className, new AssertionFailedError(null, "foo", "bar").toString());
assertEquals(className, new AssertionFailedError(null, new RuntimeException()).toString());
assertEquals(className, new AssertionFailedError(null, "foo", "bar", new RuntimeException()).toString());
assertEquals(className, new AssertionFailedError(EMPTY).toString());
assertEquals(className, new AssertionFailedError(EMPTY, "foo", "bar").toString());
assertEquals(className, new AssertionFailedError(EMPTY, new RuntimeException()).toString());
assertEquals(className, new AssertionFailedError(EMPTY, "foo", "bar", new RuntimeException()).toString());
assertEquals(className, new AssertionFailedError(BLANK).toString());
assertEquals(className, new AssertionFailedError(BLANK, "foo", "bar").toString());
assertEquals(className, new AssertionFailedError(BLANK, new RuntimeException()).toString());
assertEquals(className, new AssertionFailedError(BLANK, "foo", "bar", new RuntimeException()).toString());
assertEquals(className + ": message", new AssertionFailedError("message").toString());
assertEquals(className + ": message", new AssertionFailedError("message", "foo", "bar").toString());
assertEquals(className + ": message", new AssertionFailedError("message", new RuntimeException()).toString());
assertEquals(className + ": message",
new AssertionFailedError("message", "foo", "bar", new RuntimeException()).toString());
}
@Test
public void messageAndCauseAreStored() {
RuntimeException cause = new RuntimeException("cause");
AssertionFailedError error = new AssertionFailedError("my message", cause);
assertEquals("my message", error.getMessage());
assertEquals(cause, error.getCause());
assertFalse(error.isExpectedDefined());
assertFalse(error.isActualDefined());
}
@Test
public void expectedAndActualValuesAreStored() {
AssertionFailedError errorWithExpectedAndActual = new AssertionFailedError(null, "foo", "bar");
assertTrue(errorWithExpectedAndActual.isExpectedDefined());
assertEquals("foo", errorWithExpectedAndActual.getExpected().getValue());
assertTrue(errorWithExpectedAndActual.isActualDefined());
assertEquals("bar", errorWithExpectedAndActual.getActual().getValue());
}
@Test
public void returnsNullForExpectedAndActualWhenNotPassedToConstructor() {
AssertionFailedError errorWithoutExpectedAndActual = new AssertionFailedError();
assertFalse(errorWithoutExpectedAndActual.isExpectedDefined());
assertNull(errorWithoutExpectedAndActual.getExpected());
assertFalse(errorWithoutExpectedAndActual.isActualDefined());
assertNull(errorWithoutExpectedAndActual.getActual());
}
@Test
public void serializationWorksForAssertionFailedErrorWithMessageAndExpectedAndActualValues() throws Exception {
AssertionFailedError error = serializeAndDeserialize(new AssertionFailedError("a message", "foo", "bar"));
assertEquals("a message", error.getMessage());
assertTrue(error.isExpectedDefined());
assertEquals("foo", error.getExpected().getValue());
assertTrue(error.isActualDefined());
assertEquals("bar", error.getActual().getValue());
}
@Test
public void serializationWorksForAssertionFailedErrorWithoutAnyValues() throws Exception {
AssertionFailedError error = serializeAndDeserialize(new AssertionFailedError());
assertEquals(EMPTY, error.getMessage());
assertFalse(error.isExpectedDefined());
assertNull(error.getExpected());
assertFalse(error.isActualDefined());
assertNull(error.getActual());
}
@Test
public void deserializationOfAssertionFailedErrorWorksForVersion_1_0_0() throws Exception {
// Generated using:
// FileOutputStream outputStream = new FileOutputStream("src/test/resources/AssertionFailedError_serializedVersion_1_0_0.out");
// serialize(new AssertionFailedError("message", "foo", "bar"), outputStream);
// outputStream.close();
AssertionFailedError error = (AssertionFailedError) deserializeClasspathResource(
"/AssertionFailedError_serializedVersion_1_0_0.out");
assertEquals("message", error.getMessage());
assertTrue(error.isExpectedDefined());
assertEquals("foo", error.getExpected().getValue());
assertTrue(error.isActualDefined());
assertEquals("bar", error.getActual().getValue());
}
@Test
public void ephemeralValueIsOmittedFromSerialization() throws Exception {
class NonSerializable {
public final String guid = "8675309";
}
AssertionFailedError error = serializeAndDeserialize(
new AssertionFailedError("a message", new NonSerializable(), new NonSerializable()));
assertEquals("a message", error.getMessage());
assertTrue(error.isExpectedDefined());
assertNull(error.getExpected().getValue());
assertNull(error.getExpected().getEphemeralValue());
assertTrue(error.isActualDefined());
assertNull(error.getActual().getValue());
assertNull(error.getActual().getEphemeralValue());
}
private Object deserializeClasspathResource(String name) throws Exception {
InputStream inputStream = getClass().getResourceAsStream(name);
try {
return deserialize(inputStream);
}
finally {
inputStream.close();
}
}
private AssertionFailedError serializeAndDeserialize(AssertionFailedError originalError) throws Exception {
byte[] bytes = serialize(originalError);
Object deserializedObject = deserialize(new ByteArrayInputStream(bytes));
assertEquals(AssertionFailedError.class, deserializedObject.getClass());
return (AssertionFailedError) deserializedObject;
}
private Object deserialize(InputStream inputStream) throws Exception {
ObjectInputStream in = new ObjectInputStream(inputStream);
return in.readObject();
}
private byte[] serialize(Object object) throws Exception {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
serialize(object, byteArrayOutputStream);
return byteArrayOutputStream.toByteArray();
}
private void serialize(Object object, OutputStream outputStream) throws Exception {
ObjectOutputStream out = new ObjectOutputStream(outputStream);
out.writeObject(object);
out.flush();
}
}
opentest4j-r1.2.0/src/test/java/org/opentest4j/MultipleFailuresErrorTests.java 0000664 0000000 0000000 00000010542 13476264065 0027555 0 ustar 00root root 0000000 0000000 /*
* Copyright 2015-2018 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.opentest4j;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
/**
* Unit tests for {@link MultipleFailuresError}.
*
* @author Marc Philipp
* @author Sam Brannen
* @since 1.0
*/
public class MultipleFailuresErrorTests {
private static final String DEFAULT_HEADING = "Multiple Failures";
private static final String HEADING = "Custom Heading";
@Test
public void mfeWithNoFailuresWithNullHeading() {
assertExceptionWithNoFailures(null, DEFAULT_HEADING);
}
@Test
public void mfeWithNoFailuresWithEmptyHeading() {
assertExceptionWithNoFailures(" ", DEFAULT_HEADING);
}
@Test
public void mfeWithNoFailuresWithCustomHeading() {
assertExceptionWithNoFailures(HEADING, HEADING);
}
@Test
public void mfeWithSingleFailureWithNullHeading() {
assertExceptionWithSingleFailure(null, DEFAULT_HEADING);
}
@Test
public void mfeWithSingleFailureWithEmptyHeading() {
assertExceptionWithSingleFailure(" ", DEFAULT_HEADING);
}
@Test
public void mfeWithSingleFailureWithCustomHeading() {
assertExceptionWithSingleFailure(HEADING, HEADING);
}
@Test
public void mfeWithFailuresWithNullHeading() {
assertExceptionWithFailures(null, DEFAULT_HEADING);
}
@Test
public void mfeWithFailuresWithEmptyHeading() {
assertExceptionWithFailures(" ", DEFAULT_HEADING);
}
@Test
public void mfeWithFailuresWithCustomHeading() {
assertExceptionWithFailures(HEADING, HEADING);
}
@Test
public void mfeWithNullMessageFailures() throws Exception {
List