Skip to content

Commit

Permalink
Upgrade parent to version 2.2.6 and Mockito to version 3.0.0 (assertj…
Browse files Browse the repository at this point in the history
…#1589)

This introduces dependency and plugin management with overridable
versions, a dependency convergence rule for the enforcer and a
GitHub-friendly license configuration.
  • Loading branch information
scordio authored and joel-costigliola committed Sep 9, 2019
1 parent b214bc0 commit 36ec7dc
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 43 deletions.
File renamed without changes.
10 changes: 0 additions & 10 deletions licence-header.txt

This file was deleted.

61 changes: 47 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
<modelVersion>4.0.0</modelVersion>
<artifactId>assertj-core</artifactId>
<version>3.13.3-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>AssertJ fluent assertions</name>
<description>Rich and fluent assertions for testing for Java</description>
<inceptionYear>2014</inceptionYear>
<parent>
<groupId>org.assertj</groupId>
<artifactId>assertj-parent-pom</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
<relativePath />
</parent>
<mailingLists>
Expand All @@ -32,21 +30,40 @@
<system>github</system>
<url>https://github.com/joel-costigliola/assertj-core/issues</url>
</issueManagement>

<properties>
<javadocAdditionalOptions>-html5 --allow-script-in-comments --no-module-directories</javadocAdditionalOptions>
<byte-buddy.version>1.10.1</byte-buddy.version>
<!-- Dependency versions overriding -->
<junit-jupiter.version>5.5.2</junit-jupiter.version>
<mockito.version>3.0.0</mockito.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.5.2</version>
<type>pom</type>
<scope>import</scope>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>${byte-buddy.version}</version>
</dependency>
<dependency> <!-- Included by mockito-core -->
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>${byte-buddy.version}</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.opentest4j</groupId>
<artifactId>opentest4j</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -85,7 +102,6 @@
<dependency>
<groupId>org.opentest4j</groupId>
<artifactId>opentest4j</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
Expand All @@ -100,23 +116,21 @@
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.10.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>2.23.0</version>
<scope>test</scope>
</dependency>
<!-- NEEDED! Unlike File, a Path is not linked to the JRE's filesystem. In order to accurately test assertions, we need
Expand Down Expand Up @@ -145,11 +159,29 @@
<build>
<plugins>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<!-- TODO this header should go to the parent POM -->
<inlineHeader>
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.

Copyright ${inceptionYear}-${currentYear} the original author or authors.
</inlineHeader>
</configuration>
</plugin><plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-banned-dependencies</id>
<id>enforce-dependency-rules</id>
<goals>
<goal>enforce</goal>
</goals>
Expand All @@ -164,6 +196,7 @@
<exclude>*:*:*:jar:compile</exclude>
</excludes>
</bannedDependencies>
<dependencyConvergence/>
</rules>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*
* Copyright 2012-2019 the original author or authors.
*/

package org.assertj.core.api.junit.jupiter;

import static java.lang.String.format;
Expand Down
1 change: 0 additions & 1 deletion src/main/java9/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*
* Copyright 2012-2019 the original author or authors.
*/

module org.assertj.core {
// AssertJ Core's package API
exports org.assertj.core.annotations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*
* Copyright 2012-2019 the original author or authors.
*/

package org.assertj.core.api.junit.jupiter;

import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*
* Copyright 2012-2019 the original author or authors.
*/

package org.assertj.core.api.junit.jupiter;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
* line number information will be removed by the assertj filtering of internal lines.
* {@link org.assertj.core.util.Throwables#removeAssertJRelatedElementsFromStackTrace}
*/
public class AutoClosableSoftAssertionsLineNumberTest {
class AutoClosableSoftAssertionsLineNumberTest {

@Test
public void should_print_line_numbers_of_failed_assertions() {
void should_print_line_numbers_of_failed_assertions() {
AutoCloseableSoftAssertions softly = new AutoCloseableSoftAssertions();
softly.assertThat(1)
.isLessThan(0)
.isLessThan(1);
// WHEN
AssertionError error = catchThrowableOfType(() -> softly.close(), AssertionError.class);
AssertionError error = catchThrowableOfType(softly::close, AssertionError.class);
// THEN
assertThat(error).hasMessageContaining(format("%n"
+ "Expecting:%n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
* line number information will be removed by the assertj filtering of internal lines.
* {@link org.assertj.core.util.Throwables#removeAssertJRelatedElementsFromStackTrace}
*/
public class BDDSoftAssertionsLineNumberTest {
class BDDSoftAssertionsLineNumberTest {

@Test
public void should_print_line_numbers_of_failed_assertions() {
void should_print_line_numbers_of_failed_assertions() {
BDDSoftAssertions softly = new BDDSoftAssertions();
softly.then(1)
.isLessThan(0)
.isLessThan(1);
// WHEN
AssertionError error = catchThrowableOfType(() -> softly.assertAll(), AssertionError.class);
AssertionError error = catchThrowableOfType(softly::assertAll, AssertionError.class);
// THEN
assertThat(error).hasMessageContaining(format("%n"
+ "Expecting:%n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@
* The assertions classes have to be in a package other than org.assertj to test
* the behavior of line numbers for assertions defined outside the assertj package
*/
public class CustomSoftAssertionsLineNumberTest {
class CustomSoftAssertionsLineNumberTest {

// ignore because of failure only happening in Travis CI https://travis-ci.org/joel-costigliola/assertj-core/builds/351639100
@Test
@Disabled
public void should_print_line_numbers_of_failed_assertions_even_if_custom_assertion_in_non_assertj_package() throws Exception {
void should_print_line_numbers_of_failed_assertions_even_if_custom_assertion_in_non_assertj_package() throws Exception {
// GIVEN
MyProjectSoftAssertions softly = new MyProjectSoftAssertions();
softly.assertThat(new MyProjectClass("v1")).hasValue("v2");
// WHEN
AssertionError error = catchThrowableOfType(() -> softly.assertAll(), AssertionError.class);
AssertionError error = catchThrowableOfType(softly::assertAll, AssertionError.class);
// THEN
assertThat(error).hasMessageContaining(format("Expecting value to be <v2> but was <v1>:%n" +
"at CustomSoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions_even_if_custom_assertion_in_non_assertj_package(CustomSoftAssertionsLineNumberTest.java:31)"));
"at CustomSoftAssertionsLineNumberTest.should_print_line_numbers_of_failed_assertions_even_if_custom_assertion_in_non_assertj_package(CustomSoftAssertionsLineNumberTest.java:34)"));
}

}
10 changes: 5 additions & 5 deletions src/test/java/org/example/test/SoftAssertionsLineNumberTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
* line number information will be removed by the assertj filtering of internal lines.
* {@link org.assertj.core.util.Throwables#removeAssertJRelatedElementsFromStackTrace}
*/
public class SoftAssertionsLineNumberTest {
class SoftAssertionsLineNumberTest {

@Test
public void should_print_line_numbers_of_failed_assertions() {
void should_print_line_numbers_of_failed_assertions() {
// GIVEN
SoftAssertions softly = new SoftAssertions();
softly.assertThat(1)
.isLessThan(0)
.isLessThan(1);
// WHEN
AssertionError error = catchThrowableOfType(() -> softly.assertAll(), AssertionError.class);
AssertionError error = catchThrowableOfType(softly::assertAll, AssertionError.class);
// THEN
assertThat(error).hasMessageContaining(format("%n"
+ "Expecting:%n"
Expand All @@ -54,7 +54,7 @@ public void should_print_line_numbers_of_failed_assertions() {
}

@Test
public void should_print_line_numbers_of_failed_assertions_even_if_it_came_from_nested_calls() {
void should_print_line_numbers_of_failed_assertions_even_if_it_came_from_nested_calls() {
// GIVEN
SoftAssertions softly = new SoftAssertions();
softly.assertThat(Optional.empty()).contains("Foo");
Expand All @@ -63,7 +63,7 @@ public void should_print_line_numbers_of_failed_assertions_even_if_it_came_from_
Predicate<String> lowercasePredicate = s -> s.equals(s.toLowerCase());
softly.assertThat(lowercasePredicate).accepts("a", "b", "C");
// WHEN
AssertionError error = catchThrowableOfType(() -> softly.assertAll(), AssertionError.class);
AssertionError error = catchThrowableOfType(softly::assertAll, AssertionError.class);
// THEN
assertThat(error).hasMessageContaining(format("%n"
+ "Expecting Optional to contain:%n"
Expand Down

0 comments on commit 36ec7dc

Please sign in to comment.