Skip to content

Commit

Permalink
Revert mantis-control-plane-server to junit4
Browse files Browse the repository at this point in the history
Upgrade mockito in mantis-server-worker
  • Loading branch information
cypherean committed Apr 10, 2023
1 parent 271afb7 commit 456ee55
Show file tree
Hide file tree
Showing 49 changed files with 347 additions and 346 deletions.
12 changes: 11 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ ext.versions = [
flink : "1.14.2",
hadoop : "2.7.7",
jsr305 : "3.0.1",
junit4 : "4.11",
junit5 : "5.4.+",
mockito : "2.0.+",
mockito3 : "3.+",
mockito4 : "4.8.+",
spectator: "1.3.+",
slf4j : "1.7.0",
vavr : "0.9.2",
Expand All @@ -57,6 +59,11 @@ ext.libraries = [
flinkRpcImpl : [
"org.apache.flink:flink-rpc-akka:${versions.flink}",
],
junit4 : [
"junit:junit:${versions.junit4}",
"junit:junit-dep:${versions.junit4}",
"org.junit.vintage:junit-vintage-engine:${versions.junit5}",
],
hadoopCommon : "org.apache.hadoop:hadoop-common:${versions.hadoop}",
hadoopS3 : "org.apache.hadoop:hadoop-aws:${versions.hadoop}",
jsr305 : "com.google.code.findbugs:jsr305:${versions.jsr305}", // For Nonnull annotation
Expand All @@ -69,6 +76,7 @@ ext.libraries = [
mockitoAll : "org.mockito:mockito-all:${versions.mockito}",
mockitoCore : "org.mockito:mockito-core:${versions.mockito}",
mockitoCore3 : "org.mockito:mockito-core:${versions.mockito3}",
mockitoCore4 : "org.mockito:mockito-core:${versions.mockito4}",
mockneat : "net.andreinc:mockneat:0.4.8",
rxJava : "io.reactivex:rxjava:1.3.8",
rxNettyShaded : "com.netflix:mantis-rxnetty:0.4.19.1",
Expand Down Expand Up @@ -158,7 +166,9 @@ subprojects {
}

test {
useJUnitPlatform()
useJUnitPlatform {
includeEngines 'junit-jupiter', 'junit-vintage'
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dependencies {

testImplementation "com.typesafe.akka:akka-testkit_$scalaBinaryVersion:$akkaVersion"
testImplementation "com.typesafe.akka:akka-http-testkit_$scalaBinaryVersion:$akkaHttpVersion"
testImplementation libraries.junitJupiter
testImplementation libraries.junit4
testImplementation libraries.mockitoCore3
testImplementation "org.testng:testng:$testngVersion"
testImplementation testFixtures(project(":mantis-common"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package io.mantisrx.master.api.akka.route;

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

import io.mantisrx.common.Ack;
import io.mantisrx.master.jobcluster.job.MantisJobMetadataView;
Expand All @@ -30,7 +30,7 @@
import java.io.ObjectOutputStream;
import java.util.List;
import java.util.Optional;
import org.junit.jupiter.api.Test;
import org.junit.Test;


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

package io.mantisrx.master.api.akka.route;

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

import akka.http.javadsl.server.AllDirectives;
import akka.http.javadsl.server.Route;
Expand All @@ -27,7 +27,7 @@
import io.mantisrx.server.master.ILeadershipManager;
import io.mantisrx.server.master.LeaderRedirectionFilter;
import io.mantisrx.server.master.LeadershipManagerLocalImpl;
import org.junit.jupiter.api.Test;
import org.junit.Test;

public class LeaderRedirectionFilterTest extends AllDirectives {

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

package io.mantisrx.master.api.akka.route;

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 static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import akka.NotUsed;
import akka.actor.ActorSystem;
Expand Down Expand Up @@ -46,9 +46,9 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -99,7 +99,7 @@ private String getResponseMessage(final String msg, final Throwable t) {
private static final MasterMonitor masterMonitor = new LocalMasterMonitor(fakeMasterDesc);
private static final ILeadershipManager leadershipMgr = new LeadershipManagerLocalImpl(fakeMasterDesc);

@BeforeAll
@BeforeClass
public static void setup() throws Exception {
JobTestHelper.deleteAllFiles();
JobTestHelper.createDirsIfRequired();
Expand Down Expand Up @@ -131,7 +131,7 @@ public static void setup() throws Exception {
latch.await();
}

@AfterAll
@AfterClass
public static void teardown() {
logger.info("MasterDescriptionRouteTest teardown");
binding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,30 @@

package io.mantisrx.master.api.akka.route.pagination;

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

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import scala.Tuple1;

public class ListObjectTests {

private static final Random rnd = new Random(System.currentTimeMillis());

@Test
@Test(expected = RuntimeException.class)
public void testSortingByInvalidFieldName() {
assertThrows(RuntimeException.class, () -> {
try {
ListObject<TestObject> listobject = new ListObject.Builder<TestObject>()
.withObjects(generateList(10), TestObject.class)
.withSortField("invalidValue")
.withSortAscending(true)
.build();
} catch (Exception e) {
assertTrue(e.getMessage().contains("Specified sort field is invalid."));
throw e;
}
});
try {
ListObject<TestObject> listobject = new ListObject.Builder<TestObject>()
.withObjects(generateList(10), TestObject.class)
.withSortField("invalidValue")
.withSortAscending(true)
.build();
} catch (Exception e) {
assertTrue(e.getMessage().contains("Specified sort field is invalid."));
throw e;
}
}

@Test
Expand Down Expand Up @@ -113,20 +110,18 @@ public void testSortingByPublicValueFieldNameDescending() {
}
}

@Test
@Test(expected = RuntimeException.class)
public void testSortingByPrivateValueFieldName() {
assertThrows(RuntimeException.class, () -> {
try {
ListObject<TestObject> listobject = new ListObject.Builder<TestObject>()
.withObjects(generateList(10), TestObject.class)
.withSortField("privateValue")
.withSortAscending(true)
.build();
} catch (Exception e) {
assertTrue(e.getMessage().contains("Cannot access sort field."));
throw e;
}
});
try {
ListObject<TestObject> listobject = new ListObject.Builder<TestObject>()
.withObjects(generateList(10), TestObject.class)
.withSortField("privateValue")
.withSortAscending(true)
.build();
} catch (Exception e) {
assertTrue(e.getMessage().contains("Cannot access sort field."));
throw e;
}
}

@Test
Expand Down Expand Up @@ -179,19 +174,17 @@ public void testPaginationLimit() {
.build().list.size() == 5);
}

@Test
@Test(expected = IllegalStateException.class)
public void testPaginationInvalidLimit() {
assertThrows(IllegalStateException.class, () -> {
try {
int size = new ListObject.Builder<TestObject>()
.withObjects(generateList(10), TestObject.class)
.withLimit(-1)
.build().list.size();
} catch (Exception e) {
assertTrue(e.getMessage().contains("limit needs to be greater than 0"));
throw e;
}
});
try {
int size = new ListObject.Builder<TestObject>()
.withObjects(generateList(10), TestObject.class)
.withLimit(-1)
.build().list.size();
} catch (Exception e) {
assertTrue(e.getMessage().contains("limit needs to be greater than 0"));
throw e;
}
}

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

package io.mantisrx.master.api.akka.route.utils;

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

import io.mantisrx.master.jobcluster.job.JobState;
import io.mantisrx.master.jobcluster.job.worker.WorkerState;
Expand All @@ -26,7 +26,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.junit.jupiter.api.Test;
import org.junit.Test;

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

package io.mantisrx.master.api.akka.route.v0;

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 static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -68,9 +68,9 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rx.Observer;
Expand Down Expand Up @@ -111,7 +111,7 @@ private String getResponseMessage(final String msg, final Throwable t) {
private static CompletionStage<ServerBinding> binding;
private static ActorSystem system = ActorSystem.create("AgentClusterRoutes");

@BeforeAll
@BeforeClass
public static void setup() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
t = new Thread(() -> {
Expand Down Expand Up @@ -156,7 +156,7 @@ public static void setup() throws InterruptedException {
latch.await();
}

@AfterAll
@AfterClass
public static void teardown() {
logger.info("V0AgentClusterRouteTest teardown");
binding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package io.mantisrx.master.api.akka.route.v0;

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 static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -71,9 +71,9 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -112,7 +112,7 @@ private String getResponseMessage(final String msg, final Throwable t) {
private static CompletionStage<ServerBinding> binding;
private static ActorSystem system = ActorSystem.create("JobClusterRoutes");

@BeforeAll
@BeforeClass
public static void setup() throws Exception {
TestHelpers.setupMasterConfig();
final CountDownLatch latch = new CountDownLatch(1);
Expand Down Expand Up @@ -152,7 +152,7 @@ public static void setup() throws Exception {
latch.await();
}

@AfterAll
@AfterClass
public static void teardown() {
logger.info("V0JobClusterRouteTest teardown");
binding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package io.mantisrx.master.api.akka.route.v0;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package io.mantisrx.master.api.akka.route.v0;

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 static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import akka.NotUsed;
import akka.actor.ActorSystem;
Expand Down
Loading

0 comments on commit 456ee55

Please sign in to comment.