Skip to content

Commit

Permalink
Upgrade JUnit4 to Junit5
Browse files Browse the repository at this point in the history
  • Loading branch information
cypherean committed Mar 20, 2023
1 parent 88a727a commit 9a76a2b
Show file tree
Hide file tree
Showing 150 changed files with 1,201 additions and 1,170 deletions.
5 changes: 0 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ buildscript {
ext.versions = [
flink : "1.14.2",
hadoop : "2.7.7",
junit4 : "4.11",
junit5 : "5.4.+",
mockito : "2.0.+",
mockito3 : "3.+",
Expand All @@ -58,10 +57,6 @@ ext.libraries = [
flinkRpcImpl : [
"org.apache.flink:flink-rpc-akka:${versions.flink}",
],
junit4 : [
"junit:junit:${versions.junit4}",
"junit:junit-dep:${versions.junit4}",
],
hadoopCommon : "org.apache.hadoop:hadoop-common:${versions.hadoop}",
hadoopS3 : "org.apache.hadoop:hadoop-aws:${versions.hadoop}",
junitJupiter : [
Expand Down
2 changes: 1 addition & 1 deletion mantis-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {

implementation libraries.slf4jApi
implementation libraries.spectatorApi
testImplementation libraries.junit4
testImplementation libraries.junitJupiter
testImplementation libraries.mockitoCore
}

Expand Down
2 changes: 1 addition & 1 deletion mantis-client/src/test/java/MantisSSEJobTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.fail;

import io.mantisrx.client.MantisClient;
import io.mantisrx.client.MantisSSEJob;
Expand Down
2 changes: 1 addition & 1 deletion mantis-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ dependencies {
testImplementation libraries.spectatorApi
testImplementation libraries.commonsLang3
testImplementation "org.hamcrest:hamcrest-core:1.3"
testImplementation libraries.junit4
testImplementation libraries.junitJupiter
testImplementation libraries.mockitoCore
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

package com.mantisrx.common.utils;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import io.mantisrx.common.Label;
import io.mantisrx.shaded.com.fasterxml.jackson.core.JsonProcessingException;
import io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.junit.jupiter.api.Test;


public class LabelUtilsTest {
Expand Down Expand Up @@ -189,4 +189,4 @@ public void testSerDe() {
}


}
}
4 changes: 2 additions & 2 deletions mantis-common/src/test/java/io/mantisrx/common/AckTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package io.mantisrx.common;

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

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

public class AckTest {
private final JsonSerializer serializer = new JsonSerializer();
Expand Down
31 changes: 19 additions & 12 deletions mantis-common/src/test/java/io/mantisrx/common/WorkerPortsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
*/
package io.mantisrx.common;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class WorkerPortsTest {

Expand All @@ -29,31 +30,37 @@ public class WorkerPortsTest {
* Uses legacy constructor {@link WorkerPorts#WorkerPorts(List)} which expects
* at least 5 ports: metrics, debug, console, custom.
*/
@Test(expected = IllegalArgumentException.class)
@Test
public void shouldNotConstructWorkerPorts() {
// Not enough ports.
new WorkerPorts(Arrays.asList(1, 1, 1, 1));
assertThrows(IllegalArgumentException.class, () -> {
// Not enough ports.
new WorkerPorts(Arrays.asList(1, 1, 1, 1));
});
}

/**
* Uses legacy constructor {@link WorkerPorts#WorkerPorts(List)} which cannot construct
* a WorkerPorts object, because a worker needs a sink to be useful.
* Otherwise, other workers can't connect to it.
*/
@Test(expected = IllegalStateException.class)
@Test
public void shouldNotConstructWorkerPortsWithDuplicatePorts() {
// Enough ports, but has duplicate ports.
new WorkerPorts(Arrays.asList(1, 1, 1, 1, 1));
assertThrows(IllegalStateException.class, () -> {
// Enough ports, but has duplicate ports.
new WorkerPorts(Arrays.asList(1, 1, 1, 1, 1));
});
}

/**
* Uses legacy constructor {@link WorkerPorts#WorkerPorts(List)} but was given a port
* out of range.
*/
@Test(expected = IllegalStateException.class)
@Test
public void shouldNotConstructWorkerPortsWithInvalidPortRange() {
// Enough ports, but given an invalid port range
new WorkerPorts(Arrays.asList(1, 1, 1, 1, 65536));
assertThrows(IllegalStateException.class, () -> {
// Enough ports, but given an invalid port range
new WorkerPorts(Arrays.asList(1, 1, 1, 1, 65536));
});
}

/**
Expand Down Expand Up @@ -82,4 +89,4 @@ public void testWorkerPortsIsSerializableByJava() {
byte[] serialized = SerializationUtils.serialize(workerPorts);
assertEquals(workerPorts, SerializationUtils.deserialize(serialized));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package io.mantisrx.common.compression;

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

import io.mantisrx.common.MantisServerSentEvent;
import java.io.BufferedReader;
Expand All @@ -24,7 +24,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class CompressionUtilsTest {

Expand Down Expand Up @@ -56,7 +56,7 @@ public void shouldTokenizeWithEventsContainingPartialDelimiterMatchesWithCustomD
List<MantisServerSentEvent> result = CompressionUtils.tokenize(reader, delimiter);

List<String> actual = result.stream().map(e -> e.getEventAsString()).collect(Collectors.toList());
assertEquals("Delimiter: '" + delimiter + "'", Arrays.asList(event1,event2,event3), actual);
assertEquals(Arrays.asList(event1,event2,event3), actual, "Delimiter: '" + delimiter + "'");
}

@Test
Expand All @@ -76,7 +76,7 @@ public void testDelimiterWiithPrefixMatchingEndOfMEssage() throws Exception {
List<MantisServerSentEvent> result = CompressionUtils.tokenize(reader, delimiter);

List<String> actual = result.stream().map(e -> e.getEventAsString()).collect(Collectors.toList());
assertEquals("Delimiter: '" + delimiter + "'", Arrays.asList(event1,event2,event3), actual);
assertEquals(Arrays.asList(event1,event2,event3), actual, "Delimiter: '" + delimiter + "'");
}

@Test
Expand All @@ -102,7 +102,7 @@ public void testMultiline() throws Exception {
List<MantisServerSentEvent> result = CompressionUtils.tokenize(reader, delimiter);

List<String> actual = result.stream().map(e -> e.getEventAsString()).collect(Collectors.toList());
assertEquals("Delimiter: '" + delimiter + "'", Arrays.asList(event1,event2,event3), actual);
assertEquals(Arrays.asList(event1,event2,event3), actual, "Delimiter: '" + delimiter + "'");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package io.mantisrx.runtime;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

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

public class MachineDefinitionTest {
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

package io.mantisrx.runtime.descriptor;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import io.mantisrx.common.JsonSerializer;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class DeploymentStrategyTest {
private final JsonSerializer serializer = new JsonSerializer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

import static java.util.Optional.empty;
import static java.util.Optional.of;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import io.mantisrx.common.JsonSerializer;
import io.mantisrx.runtime.MachineDefinition;
import io.mantisrx.runtime.descriptor.SchedulingInfo.Builder;
import io.mantisrx.shaded.com.google.common.collect.ImmutableMap;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class SchedulingInfoTest {
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package io.mantisrx.runtime.descriptor;

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

import io.mantisrx.common.JsonSerializer;
import io.mantisrx.runtime.descriptor.StageScalingPolicy.RollingCount;
Expand All @@ -25,7 +25,7 @@
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class StageScalingPolicyTest {
private final JsonSerializer serializer = new JsonSerializer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package io.mantisrx.runtime.parameter;

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

import io.mantisrx.common.JsonSerializer;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class TestSerialization {
private final JsonSerializer jsonSerializer = new JsonSerializer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
package io.reactivx.common.consistenthashing;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import io.mantisrx.common.network.ConsistentHash;
import io.mantisrx.common.network.Endpoint;
import io.mantisrx.common.network.EndpointConfiguration;
import io.mantisrx.common.network.HashFunctions;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.junit.jupiter.api.Test;


public class ConsistentHashTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package io.reactivx.common.consistenthashing;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import io.mantisrx.common.network.HashFunctions;
import io.mantisrx.common.network.ServerSlotManager;
Expand All @@ -28,7 +28,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;


public class ServerSlotManagerTest {
Expand Down
Loading

0 comments on commit 9a76a2b

Please sign in to comment.