Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to JUnit 5 with OpenRewrite #281

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,26 @@ limitations under the License.
</distributionManagement>

<properties>
<jmhVersion>1.36</jmhVersion>
<project.build.outputTimestamp>2023-03-02T01:23:19Z</project.build.outputTimestamp>
</properties>

<dependencies>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.36</version>
<version>${jmhVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.36</version>
<version>${jmhVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -97,8 +97,7 @@ limitations under the License.
<goal>compile</goal>
</goals>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>8</release>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -131,16 +130,6 @@ limitations under the License.
<exclude>org/codehaus/plexus/util/FileBasedTestCase.java</exclude>
<exclude>**/Test*.java</exclude>
</excludes>
<systemProperties>
<property>
<name>JAVA_HOME</name>
<value>${JAVA_HOME}</value>
</property>
<property>
<name>M2_HOME</name>
<value>${M2_HOME}</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
Expand Down
48 changes: 24 additions & 24 deletions src/test/java/org/codehaus/plexus/util/CollectionUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
import java.util.Map;
import java.util.Properties;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

/**
* <p>CollectionUtilsTest class.</p>
Expand All @@ -35,21 +35,21 @@
* @version $Id: $Id
* @since 3.4.0
*/
public class CollectionUtilsTest {
class CollectionUtilsTest {
/**
* <p>testMergeMaps.</p>
*/
@Test
public void testMergeMaps() {
Map<String, String> dominantMap = new HashMap<String, String>();
void mergeMaps() {
Map<String, String> dominantMap = new HashMap<>();
dominantMap.put("a", "a");
dominantMap.put("b", "b");
dominantMap.put("c", "c");
dominantMap.put("d", "d");
dominantMap.put("e", "e");
dominantMap.put("f", "f");

Map<String, String> recessiveMap = new HashMap<String, String>();
Map<String, String> recessiveMap = new HashMap<>();
recessiveMap.put("a", "invalid");
recessiveMap.put("b", "invalid");
recessiveMap.put("c", "invalid");
Expand All @@ -60,7 +60,7 @@ public void testMergeMaps() {
Map<String, String> result = CollectionUtils.mergeMaps(dominantMap, recessiveMap);

// We should have 9 elements
assertEquals(9, result.keySet().size());
assertEquals(9, result.size());

// Check the elements.
assertEquals("a", result.get("a"));
Expand All @@ -79,22 +79,22 @@ public void testMergeMaps() {
*/
@SuppressWarnings("unchecked")
@Test
public void testMergeMapArray() {
void mergeMapArray() {
// Test empty array of Maps
Map<String, String> result0 = CollectionUtils.mergeMaps(new Map[] {});

assertNull(result0);

// Test with an array with a single element.
Map<String, String> map1 = new HashMap<String, String>();
Map<String, String> map1 = new HashMap<>();
map1.put("a", "a");

Map<String, String> result1 = CollectionUtils.mergeMaps(new Map[] {map1});

assertEquals("a", result1.get("a"));

// Test with an array with two elements.
Map<String, String> map2 = new HashMap<String, String>();
Map<String, String> map2 = new HashMap<>();
map2.put("a", "aa");
map2.put("b", "bb");

Expand All @@ -110,7 +110,7 @@ public void testMergeMapArray() {
assertEquals("bb", result3.get("b"));

// Test with an array with three elements.
Map<String, String> map3 = new HashMap<String, String>();
Map<String, String> map3 = new HashMap<>();
map3.put("a", "aaa");
map3.put("b", "bbb");
map3.put("c", "ccc");
Expand All @@ -133,7 +133,7 @@ public void testMergeMapArray() {
* <p>testMavenPropertiesLoading.</p>
*/
@Test
public void testMavenPropertiesLoading() {
void mavenPropertiesLoading() {
// Mimic MavenSession properties loading. Properties listed
// in dominant order.
Properties systemProperties = new Properties();
Expand Down Expand Up @@ -175,26 +175,26 @@ public void testMavenPropertiesLoading() {
});

// Values that should be taken from systemProperties.
assertEquals("/projects/maven", (String) result.get("maven.home"));
assertEquals("/projects/maven", result.get("maven.home"));

// Values that should be taken from userBuildProperties.
assertEquals("/opt/maven/artifact", (String) result.get("maven.repo.local"));
assertEquals("false", (String) result.get("maven.repo.remote.enabled"));
assertEquals("jvanzyl", (String) result.get("maven.username"));
assertEquals("/opt/maven/artifact", result.get("maven.repo.local"));
assertEquals("false", result.get("maven.repo.remote.enabled"));
assertEquals("jvanzyl", result.get("maven.username"));

// Values take from projectBuildProperties.
assertEquals("maven", (String) result.get("maven.final.name"));
assertEquals("maven", result.get("maven.final.name"));

// Values take from projectProperties.
assertEquals(mavenRepoRemote, (String) result.get("maven.repo.remote"));
assertEquals(mavenRepoRemote, result.get("maven.repo.remote"));
}

/**
* <p>testIteratorToListWithAPopulatedList.</p>
*/
@Test
public void testIteratorToListWithAPopulatedList() {
List<String> original = new ArrayList<String>();
void iteratorToListWithAPopulatedList() {
List<String> original = new ArrayList<>();

original.add("en");
original.add("to");
Expand All @@ -215,8 +215,8 @@ public void testIteratorToListWithAPopulatedList() {
* <p>testIteratorToListWithAEmptyList.</p>
*/
@Test
public void testIteratorToListWithAEmptyList() {
List<String> original = new ArrayList<String>();
void iteratorToListWithAEmptyList() {
List<String> original = new ArrayList<>();

List<String> copy = CollectionUtils.iteratorToList(original.iterator());

Expand Down
Loading
Loading