This is an automated email from the ASF dual-hosted git repository. khmarbaise pushed a commit to branch MODELTESTS_IMPROVEMENT in repository https://gitbox.apache.org/repos/asf/maven.git
commit af669d3873618416ed209dc5dbcad0762b94f8e7 Author: Karl Heinz Marbaise <khmarba...@apache.org> AuthorDate: Fri Nov 29 00:25:33 2019 +0100 Removing code redundancy Using assertj, JUnit Jupiter --- maven-artifact/pom.xml | 5 ++ maven-model/pom.xml | 22 +++++++- .../org/apache/maven/model/ActivationFileTest.java | 31 ++--------- .../org/apache/maven/model/ActivationOSTest.java | 29 +--------- .../apache/maven/model/ActivationPropertyTest.java | 31 ++--------- .../org/apache/maven/model/ActivationTest.java | 31 ++--------- .../java/org/apache/maven/model/BuildTest.java | 31 ++--------- .../org/apache/maven/model/CiManagementTest.java | 31 ++--------- .../org/apache/maven/model/ContributorTest.java | 30 +--------- .../maven/model/DependencyManagementTest.java | 29 +--------- .../org/apache/maven/model/DependencyTest.java | 29 +--------- .../maven/model/DeploymentRepositoryTest.java | 29 +--------- .../java/org/apache/maven/model/DeveloperTest.java | 29 +--------- .../maven/model/DistributionManagementTest.java | 29 +--------- .../java/org/apache/maven/model/ExclusionTest.java | 29 +--------- .../java/org/apache/maven/model/ExtensionTest.java | 29 +--------- .../apache/maven/model/IssueManagementTest.java | 29 +--------- .../java/org/apache/maven/model/LicenseTest.java | 29 +--------- .../org/apache/maven/model/MailingListTest.java | 29 +--------- .../java/org/apache/maven/model/ModelTest.java | 29 +--------- .../org/apache/maven/model/ModelTestInterface.java | 65 ++++++++++++++++++++++ .../java/org/apache/maven/model/NotifierTest.java | 30 +--------- .../org/apache/maven/model/OrganizationTest.java | 30 +--------- .../java/org/apache/maven/model/ParentTest.java | 30 +--------- .../maven/model/PluginConfigurationTest.java | 29 +--------- .../apache/maven/model/PluginContainerTest.java | 29 +--------- .../apache/maven/model/PluginExecutionTest.java | 29 +--------- .../apache/maven/model/PluginManagementTest.java | 30 +--------- .../java/org/apache/maven/model/PluginTest.java | 30 +--------- .../org/apache/maven/model/PrerequisitesTest.java | 30 +--------- .../java/org/apache/maven/model/ProfileTest.java | 29 +--------- .../org/apache/maven/model/RelocationTest.java | 30 +--------- .../org/apache/maven/model/ReportPluginTest.java | 30 +--------- .../java/org/apache/maven/model/ReportSetTest.java | 29 +--------- .../java/org/apache/maven/model/ReportingTest.java | 30 +--------- .../apache/maven/model/RepositoryPolicyTest.java | 29 +--------- .../org/apache/maven/model/RepositoryTest.java | 31 ++--------- .../java/org/apache/maven/model/ResourceTest.java | 31 ++--------- .../test/java/org/apache/maven/model/ScmTest.java | 29 ++-------- .../test/java/org/apache/maven/model/SiteTest.java | 30 +--------- pom.xml | 13 +++++ 41 files changed, 223 insertions(+), 980 deletions(-) diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml index 336505b..5e7b339 100644 --- a/maven-artifact/pom.xml +++ b/maven-artifact/pom.xml @@ -41,6 +41,11 @@ under the License. <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/maven-model/pom.xml b/maven-model/pom.xml index 023855e..22918fc 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -19,7 +19,8 @@ specific language governing permissions and limitations under the License. --> -<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 https://maven.apache.org/xsd/maven-4.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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> @@ -47,11 +48,30 @@ under the License. <artifactId>hamcrest-core</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> <plugins> <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <compilerArgs> + <arg>-Xlint:deprecation</arg> + <arg>-Xlint:unchecked</arg> + </compilerArgs> + </configuration> + </plugin> + <plugin> <groupId>org.codehaus.modello</groupId> <artifactId>modello-maven-plugin</artifactId> <configuration> diff --git a/maven-model/src/test/java/org/apache/maven/model/ActivationFileTest.java b/maven-model/src/test/java/org/apache/maven/model/ActivationFileTest.java index f88da58..d86651d 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ActivationFileTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ActivationFileTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code ActivationFile}. * * @author Benjamin Bentmann */ -public class ActivationFileTest - extends TestCase +@DisplayName( "ActivationFile" ) +class ActivationFileTest implements ModelTestInterface< ActivationFile > { - - public void testHashCodeNullSafe() - { - new ActivationFile().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new ActivationFile().equals( null ) ); - - new ActivationFile().equals( new ActivationFile() ); - } - - public void testEqualsIdentity() - { - ActivationFile thing = new ActivationFile(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new ActivationFile().toString() ); - } - } + diff --git a/maven-model/src/test/java/org/apache/maven/model/ActivationOSTest.java b/maven-model/src/test/java/org/apache/maven/model/ActivationOSTest.java index f0d3045..5820aed 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ActivationOSTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ActivationOSTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code ActivationOS}. * * @author Benjamin Bentmann */ -public class ActivationOSTest - extends TestCase +@DisplayName( "ActivationOS" ) +class ActivationOSTest implements ModelTestInterface< ActivationOS > { - public void testHashCodeNullSafe() - { - new ActivationOS().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new ActivationOS().equals( null ) ); - - new ActivationOS().equals( new ActivationOS() ); - } - - public void testEqualsIdentity() - { - ActivationOS thing = new ActivationOS(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new ActivationOS().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/ActivationPropertyTest.java b/maven-model/src/test/java/org/apache/maven/model/ActivationPropertyTest.java index 5f5e048..1727d29 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ActivationPropertyTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ActivationPropertyTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code ActivationProperty}. * * @author Benjamin Bentmann */ -public class ActivationPropertyTest - extends TestCase +@DisplayName( "ActivationProperty" ) +class ActivationPropertyTest implements ModelTestInterface< ActivationProperty > { - - public void testHashCodeNullSafe() - { - new ActivationProperty().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new ActivationProperty().equals( null ) ); - - new ActivationProperty().equals( new ActivationProperty() ); - } - - public void testEqualsIdentity() - { - ActivationProperty thing = new ActivationProperty(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new ActivationProperty().toString() ); - } - } + diff --git a/maven-model/src/test/java/org/apache/maven/model/ActivationTest.java b/maven-model/src/test/java/org/apache/maven/model/ActivationTest.java index f6d0f91..34d82e1 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ActivationTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ActivationTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Activation}. * * @author Benjamin Bentmann */ -public class ActivationTest - extends TestCase +@DisplayName( "Activation" ) +class ActivationTest implements ModelTestInterface< Activation > { - - public void testHashCodeNullSafe() - { - new Activation().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Activation().equals( null ) ); - - new Activation().equals( new Activation() ); - } - - public void testEqualsIdentity() - { - Activation thing = new Activation(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Activation().toString() ); - } - } + diff --git a/maven-model/src/test/java/org/apache/maven/model/BuildTest.java b/maven-model/src/test/java/org/apache/maven/model/BuildTest.java index 80a60d5..e1488ad 100644 --- a/maven-model/src/test/java/org/apache/maven/model/BuildTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/BuildTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Build}. * * @author Benjamin Bentmann */ -public class BuildTest - extends TestCase +@DisplayName( "Build" ) +class BuildTest implements ModelTestInterface< Build > { - - public void testHashCodeNullSafe() - { - new Build().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Build().equals( null ) ); - - new Build().equals( new Build() ); - } - - public void testEqualsIdentity() - { - Build thing = new Build(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Build().toString() ); - } - } + diff --git a/maven-model/src/test/java/org/apache/maven/model/CiManagementTest.java b/maven-model/src/test/java/org/apache/maven/model/CiManagementTest.java index 7194c84..5dacbfd 100644 --- a/maven-model/src/test/java/org/apache/maven/model/CiManagementTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/CiManagementTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code CiManagement}. * * @author Benjamin Bentmann */ -public class CiManagementTest - extends TestCase +@DisplayName( "CiManagement" ) +class CiManagementTest implements ModelTestInterface< CiManagement > { - - public void testHashCodeNullSafe() - { - new CiManagement().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new CiManagement().equals( null ) ); - - new CiManagement().equals( new CiManagement() ); - } - - public void testEqualsIdentity() - { - CiManagement thing = new CiManagement(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new CiManagement().toString() ); - } - } + diff --git a/maven-model/src/test/java/org/apache/maven/model/ContributorTest.java b/maven-model/src/test/java/org/apache/maven/model/ContributorTest.java index 491b99a..3853cd1 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ContributorTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ContributorTest.java @@ -19,38 +19,14 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Contributor}. * * @author Benjamin Bentmann */ -public class ContributorTest - extends TestCase +@DisplayName( "Contributore" ) +class ContributorTest implements ModelTestInterface< Contributor > { - - public void testHashCodeNullSafe() - { - new Contributor().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Contributor().equals( null ) ); - - new Contributor().equals( new Contributor() ); - } - - public void testEqualsIdentity() - { - Contributor thing = new Contributor(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Contributor().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/DependencyManagementTest.java b/maven-model/src/test/java/org/apache/maven/model/DependencyManagementTest.java index 7702c62..d4fd03a 100644 --- a/maven-model/src/test/java/org/apache/maven/model/DependencyManagementTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/DependencyManagementTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code DependencyManagement}. * * @author Benjamin Bentmann */ -public class DependencyManagementTest - extends TestCase +@DisplayName( "DependencyManagement" ) +class DependencyManagementTest implements ModelTestInterface< DependencyManagement > { - public void testHashCodeNullSafe() - { - new DependencyManagement().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new DependencyManagement().equals( null ) ); - - new DependencyManagement().equals( new DependencyManagement() ); - } - - public void testEqualsIdentity() - { - DependencyManagement thing = new DependencyManagement(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new DependencyManagement().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java b/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java index ec0a833..9438b97 100644 --- a/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Dependency}. * * @author Benjamin Bentmann */ -public class DependencyTest - extends TestCase +@DisplayName( "Dependency" ) +class DependencyTest implements ModelTestInterface< Dependency > { - public void testHashCodeNullSafe() - { - new Dependency().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Dependency().equals( null ) ); - - new Dependency().equals( new Dependency() ); - } - - public void testEqualsIdentity() - { - Dependency thing = new Dependency(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Dependency().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/DeploymentRepositoryTest.java b/maven-model/src/test/java/org/apache/maven/model/DeploymentRepositoryTest.java index 169ec65..d598f6d 100644 --- a/maven-model/src/test/java/org/apache/maven/model/DeploymentRepositoryTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/DeploymentRepositoryTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code DeploymentRepository}. * * @author Benjamin Bentmann */ -public class DeploymentRepositoryTest - extends TestCase +@DisplayName( "DeploymentRepository" ) +class DeploymentRepositoryTest implements ModelTestInterface< DeploymentRepository > { - public void testHashCodeNullSafe() - { - new DeploymentRepository().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new DeploymentRepository().equals( null ) ); - - new DeploymentRepository().equals( new DeploymentRepository() ); - } - - public void testEqualsIdentity() - { - DeploymentRepository thing = new DeploymentRepository(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new DeploymentRepository().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/DeveloperTest.java b/maven-model/src/test/java/org/apache/maven/model/DeveloperTest.java index c0dfe56..daa0e68 100644 --- a/maven-model/src/test/java/org/apache/maven/model/DeveloperTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/DeveloperTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Developer}. * * @author Benjamin Bentmann */ -public class DeveloperTest - extends TestCase +@DisplayName( "Developer" ) +class DeveloperTest implements ModelTestInterface< Developer > { - public void testHashCodeNullSafe() - { - new Developer().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Developer().equals( null ) ); - - new Developer().equals( new Developer() ); - } - - public void testEqualsIdentity() - { - Developer thing = new Developer(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Developer().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/DistributionManagementTest.java b/maven-model/src/test/java/org/apache/maven/model/DistributionManagementTest.java index 0314d61..c514ca0 100644 --- a/maven-model/src/test/java/org/apache/maven/model/DistributionManagementTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/DistributionManagementTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code DistributionManagement}. * * @author Benjamin Bentmann */ -public class DistributionManagementTest - extends TestCase +@DisplayName( "DistributionManagement" ) +class DistributionManagementTest implements ModelTestInterface< DistributionManagement > { - public void testHashCodeNullSafe() - { - new DistributionManagement().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new DistributionManagement().equals( null ) ); - - new DistributionManagement().equals( new DistributionManagement() ); - } - - public void testEqualsIdentity() - { - DistributionManagement thing = new DistributionManagement(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new DistributionManagement().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/ExclusionTest.java b/maven-model/src/test/java/org/apache/maven/model/ExclusionTest.java index 6febace..7595866 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ExclusionTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ExclusionTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Exclusion}. * * @author Benjamin Bentmann */ -public class ExclusionTest - extends TestCase +@DisplayName( "Exclusion" ) +class ExclusionTest implements ModelTestInterface< Exclusion > { - public void testHashCodeNullSafe() - { - new Exclusion().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Exclusion().equals( null ) ); - - new Exclusion().equals( new Exclusion() ); - } - - public void testEqualsIdentity() - { - Exclusion thing = new Exclusion(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Exclusion().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/ExtensionTest.java b/maven-model/src/test/java/org/apache/maven/model/ExtensionTest.java index 4b8cd8a..ed39bb5 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ExtensionTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ExtensionTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Extension}. * * @author Benjamin Bentmann */ -public class ExtensionTest - extends TestCase +@DisplayName( "Extension" ) +class ExtensionTest implements ModelTestInterface< Extension > { - public void testHashCodeNullSafe() - { - new Extension().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Extension().equals( null ) ); - - new Extension().equals( new Extension() ); - } - - public void testEqualsIdentity() - { - Extension thing = new Extension(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Extension().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/IssueManagementTest.java b/maven-model/src/test/java/org/apache/maven/model/IssueManagementTest.java index 5e50c15..bdd0b9f 100644 --- a/maven-model/src/test/java/org/apache/maven/model/IssueManagementTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/IssueManagementTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code IssueManagement}. * * @author Benjamin Bentmann */ -public class IssueManagementTest - extends TestCase +@DisplayName( "IssueManagement" ) +class IssueManagementTest implements ModelTestInterface< IssueManagement > { - public void testHashCodeNullSafe() - { - new IssueManagement().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new IssueManagement().equals( null ) ); - - new IssueManagement().equals( new IssueManagement() ); - } - - public void testEqualsIdentity() - { - IssueManagement thing = new IssueManagement(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new IssueManagement().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/LicenseTest.java b/maven-model/src/test/java/org/apache/maven/model/LicenseTest.java index 179921b..5fef64a 100644 --- a/maven-model/src/test/java/org/apache/maven/model/LicenseTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/LicenseTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code License}. * * @author Benjamin Bentmann */ -public class LicenseTest - extends TestCase +@DisplayName( "License" ) +class LicenseTest implements ModelTestInterface< License > { - public void testHashCodeNullSafe() - { - new License().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new License().equals( null ) ); - - new License().equals( new License() ); - } - - public void testEqualsIdentity() - { - License thing = new License(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new License().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/MailingListTest.java b/maven-model/src/test/java/org/apache/maven/model/MailingListTest.java index 6129695..b2f3ebe 100644 --- a/maven-model/src/test/java/org/apache/maven/model/MailingListTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/MailingListTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code MailingList}. * * @author Benjamin Bentmann */ -public class MailingListTest - extends TestCase +@DisplayName( "MailingList" ) +class MailingListTest implements ModelTestInterface< MailingList > { - public void testHashCodeNullSafe() - { - new MailingList().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new MailingList().equals( null ) ); - - new MailingList().equals( new MailingList() ); - } - - public void testEqualsIdentity() - { - MailingList thing = new MailingList(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new MailingList().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/ModelTest.java b/maven-model/src/test/java/org/apache/maven/model/ModelTest.java index c9ec4da..2a16ba5 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ModelTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ModelTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Model}. * * @author Benjamin Bentmann */ -public class ModelTest - extends TestCase +@DisplayName( "Model" ) +class ModelTest implements ModelTestInterface< Model > { - public void testHashCodeNullSafe() - { - new Model().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Model().equals( null ) ); - - new Model().equals( new Model() ); - } - - public void testEqualsIdentity() - { - Model thing = new Model(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Model().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/ModelTestInterface.java b/maven-model/src/test/java/org/apache/maven/model/ModelTestInterface.java new file mode 100644 index 0000000..d8108de --- /dev/null +++ b/maven-model/src/test/java/org/apache/maven/model/ModelTestInterface.java @@ -0,0 +1,65 @@ +package org.apache.maven.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; + +interface ModelTestInterface< T > +{ + @SuppressWarnings( "unchecked" ) + default T createNewInstance(Class< ? > x) throws ReflectiveOperationException + { + return ( T ) x.getDeclaredConstructor().newInstance(); + } + + @Test + @DisplayName( "hashCode should not fail with null." ) + default void hashCodeNullSafe() + { + assertThatCode( () -> createNewInstance( this.getClass() ).hashCode() ).doesNotThrowAnyException(); + } + + @Test + @DisplayName( "equals should not fail with null." ) + default void equalsNullSafe() throws ReflectiveOperationException + { + assertThat( createNewInstance( this.getClass() ).equals( null ) ).isFalse(); + } + + @Test + @DisplayName( "equals should result in false for two different instances." ) + default void equalsSameToBeFalse() throws ReflectiveOperationException + { + T firstInstance = createNewInstance( this.getClass() ); + T secondInstance = createNewInstance( this.getClass() ); + assertThat( firstInstance.equals( secondInstance ) ).isFalse(); + } + + @Test + @DisplayName( "toString should not be null." ) + default void toStringNullSafe() throws ReflectiveOperationException + { + assertThat( createNewInstance( this.getClass() ).toString() ).isNotNull(); + } +} diff --git a/maven-model/src/test/java/org/apache/maven/model/NotifierTest.java b/maven-model/src/test/java/org/apache/maven/model/NotifierTest.java index 4e5d068..ab4defb 100644 --- a/maven-model/src/test/java/org/apache/maven/model/NotifierTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/NotifierTest.java @@ -19,38 +19,14 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Notifier}. * * @author Benjamin Bentmann */ -public class NotifierTest - extends TestCase +@DisplayName( "Notifier" ) +class NotifierTest implements ModelTestInterface< Notifier > { - - public void testHashCodeNullSafe() - { - new Notifier().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Notifier().equals( null ) ); - - new Notifier().equals( new Notifier() ); - } - - public void testEqualsIdentity() - { - Notifier thing = new Notifier(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Notifier().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/OrganizationTest.java b/maven-model/src/test/java/org/apache/maven/model/OrganizationTest.java index 48abe77..ef5eb4f 100644 --- a/maven-model/src/test/java/org/apache/maven/model/OrganizationTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/OrganizationTest.java @@ -19,38 +19,14 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Organization}. * * @author Benjamin Bentmann */ -public class OrganizationTest - extends TestCase +@DisplayName( "Organization" ) +class OrganizationTest implements ModelTestInterface< Organization > { - - public void testHashCodeNullSafe() - { - new Organization().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Organization().equals( null ) ); - - new Organization().equals( new Organization() ); - } - - public void testEqualsIdentity() - { - Organization thing = new Organization(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Organization().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/ParentTest.java b/maven-model/src/test/java/org/apache/maven/model/ParentTest.java index 78d4567..3419438 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ParentTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ParentTest.java @@ -19,38 +19,14 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Parent}. * * @author Benjamin Bentmann */ -public class ParentTest - extends TestCase +@DisplayName( "Parent" ) +class ParentTest implements ModelTestInterface< Parent > { - - public void testHashCodeNullSafe() - { - new Parent().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Parent().equals( null ) ); - - new Parent().equals( new Parent() ); - } - - public void testEqualsIdentity() - { - Parent thing = new Parent(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Parent().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/PluginConfigurationTest.java b/maven-model/src/test/java/org/apache/maven/model/PluginConfigurationTest.java index cbb123d..39642ba 100644 --- a/maven-model/src/test/java/org/apache/maven/model/PluginConfigurationTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/PluginConfigurationTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code PluginConfiguration}. * * @author Benjamin Bentmann */ -public class PluginConfigurationTest - extends TestCase +@DisplayName( "PluginConfiguration" ) +class PluginConfigurationTest implements ModelTestInterface< PluginConfiguration > { - public void testHashCodeNullSafe() - { - new PluginConfiguration().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new PluginConfiguration().equals( null ) ); - - new PluginConfiguration().equals( new PluginConfiguration() ); - } - - public void testEqualsIdentity() - { - PluginConfiguration thing = new PluginConfiguration(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new PluginConfiguration().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/PluginContainerTest.java b/maven-model/src/test/java/org/apache/maven/model/PluginContainerTest.java index 878298c..9aab597 100644 --- a/maven-model/src/test/java/org/apache/maven/model/PluginContainerTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/PluginContainerTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code PluginContainer}. * * @author Benjamin Bentmann */ -public class PluginContainerTest - extends TestCase +@DisplayName( "PluginContainer" ) +class PluginContainerTest implements ModelTestInterface< PluginContainer > { - public void testHashCodeNullSafe() - { - new PluginContainer().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new PluginContainer().equals( null ) ); - - new PluginContainer().equals( new PluginContainer() ); - } - - public void testEqualsIdentity() - { - PluginContainer thing = new PluginContainer(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new PluginContainer().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/PluginExecutionTest.java b/maven-model/src/test/java/org/apache/maven/model/PluginExecutionTest.java index e8fff51..8bd1241 100644 --- a/maven-model/src/test/java/org/apache/maven/model/PluginExecutionTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/PluginExecutionTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code PluginExecution}. * * @author Benjamin Bentmann */ -public class PluginExecutionTest - extends TestCase +@DisplayName( "PluginExecution" ) +class PluginExecutionTest implements ModelTestInterface< PluginExecution > { - public void testHashCodeNullSafe() - { - new PluginExecution().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new PluginExecution().equals( null ) ); - - new PluginExecution().equals( new PluginExecution() ); - } - - public void testEqualsIdentity() - { - PluginExecution thing = new PluginExecution(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new PluginExecution().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/PluginManagementTest.java b/maven-model/src/test/java/org/apache/maven/model/PluginManagementTest.java index 571399f..d53450a 100644 --- a/maven-model/src/test/java/org/apache/maven/model/PluginManagementTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/PluginManagementTest.java @@ -19,38 +19,14 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code PluginManagement}. * * @author Benjamin Bentmann */ -public class PluginManagementTest - extends TestCase +@DisplayName( "PluginManagement" ) +class PluginManagementTest implements ModelTestInterface< PluginManagement > { - - public void testHashCodeNullSafe() - { - new PluginManagement().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new PluginManagement().equals( null ) ); - - new PluginManagement().equals( new PluginManagement() ); - } - - public void testEqualsIdentity() - { - PluginManagement thing = new PluginManagement(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new PluginManagement().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/PluginTest.java b/maven-model/src/test/java/org/apache/maven/model/PluginTest.java index 582145e..f75a9f1 100644 --- a/maven-model/src/test/java/org/apache/maven/model/PluginTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/PluginTest.java @@ -19,38 +19,14 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Plugin}. * * @author Benjamin Bentmann */ -public class PluginTest - extends TestCase +@DisplayName( "Plugin" ) +class PluginTest implements ModelTestInterface< Plugin > { - - public void testHashCodeNullSafe() - { - new Plugin().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Plugin().equals( null ) ); - - new Plugin().equals( new Plugin() ); - } - - public void testEqualsIdentity() - { - Plugin thing = new Plugin(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Plugin().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/PrerequisitesTest.java b/maven-model/src/test/java/org/apache/maven/model/PrerequisitesTest.java index 727f2c3..c3b3150 100644 --- a/maven-model/src/test/java/org/apache/maven/model/PrerequisitesTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/PrerequisitesTest.java @@ -19,38 +19,14 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Prerequisites}. * * @author Benjamin Bentmann */ -public class PrerequisitesTest - extends TestCase +@DisplayName( "Prerequisites" ) +class PrerequisitesTest implements ModelTestInterface< Prerequisites > { - - public void testHashCodeNullSafe() - { - new Prerequisites().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Prerequisites().equals( null ) ); - - new Prerequisites().equals( new Prerequisites() ); - } - - public void testEqualsIdentity() - { - Prerequisites thing = new Prerequisites(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Prerequisites().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/ProfileTest.java b/maven-model/src/test/java/org/apache/maven/model/ProfileTest.java index 512e2a8..921fca3 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ProfileTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ProfileTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Profile}. * * @author Benjamin Bentmann */ -public class ProfileTest - extends TestCase +@DisplayName( "Profile" ) +class ProfileTest implements ModelTestInterface< Profile > { - public void testHashCodeNullSafe() - { - new Profile().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Profile().equals( null ) ); - - new Profile().equals( new Profile() ); - } - - public void testEqualsIdentity() - { - Profile thing = new Profile(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Profile().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/RelocationTest.java b/maven-model/src/test/java/org/apache/maven/model/RelocationTest.java index 265304d..92dd309 100644 --- a/maven-model/src/test/java/org/apache/maven/model/RelocationTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/RelocationTest.java @@ -19,38 +19,14 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Relocation}. * * @author Benjamin Bentmann */ -public class RelocationTest - extends TestCase +@DisplayName( "Relocation" ) +class RelocationTest implements ModelTestInterface< Relocation > { - - public void testHashCodeNullSafe() - { - new Relocation().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Relocation().equals( null ) ); - - new Relocation().equals( new Relocation() ); - } - - public void testEqualsIdentity() - { - Relocation thing = new Relocation(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Relocation().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/ReportPluginTest.java b/maven-model/src/test/java/org/apache/maven/model/ReportPluginTest.java index d10cb79..15c6586 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ReportPluginTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ReportPluginTest.java @@ -19,38 +19,14 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code ReportPlugin}. * * @author Benjamin Bentmann */ -public class ReportPluginTest - extends TestCase +@DisplayName( "ReportPlugin" ) +class ReportPluginTest implements ModelTestInterface< ReportPlugin > { - - public void testHashCodeNullSafe() - { - new ReportPlugin().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new ReportPlugin().equals( null ) ); - - new ReportPlugin().equals( new ReportPlugin() ); - } - - public void testEqualsIdentity() - { - ReportPlugin thing = new ReportPlugin(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new ReportPlugin().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/ReportSetTest.java b/maven-model/src/test/java/org/apache/maven/model/ReportSetTest.java index 2f51415..864c9c9 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ReportSetTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ReportSetTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code ReportSet}. * * @author Benjamin Bentmann */ -public class ReportSetTest - extends TestCase +@DisplayName( "ReportSet" ) +class ReportSetTest implements ModelTestInterface< ReportSet > { - public void testHashCodeNullSafe() - { - new ReportSet().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new ReportSet().equals( null ) ); - - new ReportSet().equals( new ReportSet() ); - } - - public void testEqualsIdentity() - { - ReportSet thing = new ReportSet(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new ReportSet().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/ReportingTest.java b/maven-model/src/test/java/org/apache/maven/model/ReportingTest.java index dbc0fa2..063b1e5 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ReportingTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ReportingTest.java @@ -19,38 +19,14 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Reporting}. * * @author Benjamin Bentmann */ -public class ReportingTest - extends TestCase +@DisplayName( "Reporting" ) +class ReportingTest implements ModelTestInterface< Reporting > { - - public void testHashCodeNullSafe() - { - new Reporting().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Reporting().equals( null ) ); - - new Reporting().equals( new Reporting() ); - } - - public void testEqualsIdentity() - { - Reporting thing = new Reporting(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Reporting().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/RepositoryPolicyTest.java b/maven-model/src/test/java/org/apache/maven/model/RepositoryPolicyTest.java index 3ae3435..71c2b71 100644 --- a/maven-model/src/test/java/org/apache/maven/model/RepositoryPolicyTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/RepositoryPolicyTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code RepositoryPolicy}. * * @author Benjamin Bentmann */ -public class RepositoryPolicyTest - extends TestCase +@DisplayName( "RepositoryPolicy" ) +class RepositoryPolicyTest implements ModelTestInterface< RepositoryPolicy > { - public void testHashCodeNullSafe() - { - new RepositoryPolicy().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new RepositoryPolicy().equals( null ) ); - - new RepositoryPolicy().equals( new RepositoryPolicy() ); - } - - public void testEqualsIdentity() - { - RepositoryPolicy thing = new RepositoryPolicy(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new RepositoryPolicy().toString() ); - } - } diff --git a/maven-model/src/test/java/org/apache/maven/model/RepositoryTest.java b/maven-model/src/test/java/org/apache/maven/model/RepositoryTest.java index b68b70a..713fa4a 100644 --- a/maven-model/src/test/java/org/apache/maven/model/RepositoryTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/RepositoryTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Repository}. * * @author Benjamin Bentmann */ -public class RepositoryTest - extends TestCase +@DisplayName( "Repository" ) +class RepositoryTest implements ModelTestInterface< Repository > { - - public void testHashCodeNullSafe() - { - new Repository().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Repository().equals( null ) ); - - new Repository().equals( new Repository() ); - } - - public void testEqualsIdentity() - { - Repository thing = new Repository(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Repository().toString() ); - } - } + diff --git a/maven-model/src/test/java/org/apache/maven/model/ResourceTest.java b/maven-model/src/test/java/org/apache/maven/model/ResourceTest.java index fa40ab4..d09a3c6 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ResourceTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ResourceTest.java @@ -19,38 +19,15 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Resource}. * * @author Benjamin Bentmann */ -public class ResourceTest - extends TestCase +@DisplayName( "Resource" ) +class ResourceTest implements ModelTestInterface< Resource > { - - public void testHashCodeNullSafe() - { - new Resource().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Resource().equals( null ) ); - - new Resource().equals( new Resource() ); - } - - public void testEqualsIdentity() - { - Resource thing = new Resource(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Resource().toString() ); - } - } + diff --git a/maven-model/src/test/java/org/apache/maven/model/ScmTest.java b/maven-model/src/test/java/org/apache/maven/model/ScmTest.java index 4d76993..b244fb5 100644 --- a/maven-model/src/test/java/org/apache/maven/model/ScmTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/ScmTest.java @@ -19,38 +19,17 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Scm}. * * @author Benjamin Bentmann */ -public class ScmTest - extends TestCase +@DisplayName( "Scm" ) +class ScmTest implements ModelTestInterface< Scm > { - public void testHashCodeNullSafe() - { - new Scm().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Scm().equals( null ) ); - - new Scm().equals( new Scm() ); - } - - public void testEqualsIdentity() - { - Scm thing = new Scm(); - assertTrue( thing.equals( thing ) ); - } +} - public void testToStringNullSafe() - { - assertNotNull( new Scm().toString() ); - } -} diff --git a/maven-model/src/test/java/org/apache/maven/model/SiteTest.java b/maven-model/src/test/java/org/apache/maven/model/SiteTest.java index 84896bb..1d96718 100644 --- a/maven-model/src/test/java/org/apache/maven/model/SiteTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/SiteTest.java @@ -19,38 +19,14 @@ package org.apache.maven.model; * under the License. */ -import junit.framework.TestCase; +import org.junit.jupiter.api.DisplayName; /** * Tests {@code Site}. * * @author Benjamin Bentmann */ -public class SiteTest - extends TestCase +@DisplayName( "Site" ) +class SiteTest implements ModelTestInterface< Site > { - - public void testHashCodeNullSafe() - { - new Site().hashCode(); - } - - public void testEqualsNullSafe() - { - assertFalse( new Site().equals( null ) ); - - new Site().equals( new Site() ); - } - - public void testEqualsIdentity() - { - Site thing = new Site(); - assertTrue( thing.equals( thing ) ); - } - - public void testToStringNullSafe() - { - assertNotNull( new Site().toString() ); - } - } diff --git a/pom.xml b/pom.xml index 7e72940..ae5c677 100644 --- a/pom.xml +++ b/pom.xml @@ -443,6 +443,19 @@ under the License. <version>2.2</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <version>3.14.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit</groupId> + <artifactId>junit-bom</artifactId> + <version>5.5.2</version> + <type>pom</type> + <scope>import</scope> + </dependency> </dependencies> <!--bootstrap-start-comment--> </dependencyManagement>