[Java] Replace junit with testNG (#3768)

This commit is contained in:
Wang Qing 2019-01-14 17:49:17 +08:00 committed by Hao Chen
parent 19908c01b8
commit 3cf59855af
25 changed files with 52 additions and 55 deletions

View file

@ -111,9 +111,9 @@
<version>1.10.19</version> <version>1.10.19</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.testng</groupId>
<artifactId>junit</artifactId> <artifactId>testng</artifactId>
<version>4.11</version> <version>6.9.9</version>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>

View file

@ -72,8 +72,8 @@
<!-- test dependencies --> <!-- test dependencies -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.testng</groupId>
<artifactId>junit</artifactId> <artifactId>testng</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View file

@ -7,15 +7,14 @@ import java.nio.file.StandardCopyOption;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.ray.api.function.RayFunc0; import org.ray.api.function.RayFunc0;
import org.ray.api.function.RayFunc1; import org.ray.api.function.RayFunc1;
import org.ray.api.id.UniqueId; import org.ray.api.id.UniqueId;
import org.ray.runtime.functionmanager.FunctionManager.DriverFunctionTable; import org.ray.runtime.functionmanager.FunctionManager.DriverFunctionTable;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/** /**
* Tests for {@link FunctionManager} * Tests for {@link FunctionManager}

View file

@ -30,8 +30,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.testng</groupId>
<artifactId>junit</artifactId> <artifactId>testng</artifactId>
</dependency> </dependency>
<dependency> <dependency>

View file

@ -1,10 +1,10 @@
package org.ray.api.benchmark; package org.ray.api.benchmark;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayActor; import org.ray.api.RayActor;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.testng.annotations.Test;
public class ActorPressTest extends RayBenchmarkTest { public class ActorPressTest extends RayBenchmarkTest {

View file

@ -1,10 +1,10 @@
package org.ray.api.benchmark; package org.ray.api.benchmark;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayActor; import org.ray.api.RayActor;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.testng.annotations.Test;
public class MaxPressureTest extends RayBenchmarkTest { public class MaxPressureTest extends RayBenchmarkTest {

View file

@ -1,10 +1,10 @@
package org.ray.api.benchmark; package org.ray.api.benchmark;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayActor; import org.ray.api.RayActor;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.testng.annotations.Test;
public class RateLimiterPressureTest extends RayBenchmarkTest { public class RateLimiterPressureTest extends RayBenchmarkTest {

View file

@ -6,7 +6,6 @@ import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.junit.Assert;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayActor; import org.ray.api.RayActor;
import org.ray.api.RayObject; import org.ray.api.RayObject;
@ -14,6 +13,7 @@ import org.ray.api.annotation.RayRemote;
import org.ray.api.test.BaseTest; import org.ray.api.test.BaseTest;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.testng.Assert;
public abstract class RayBenchmarkTest<T> extends BaseTest implements Serializable { public abstract class RayBenchmarkTest<T> extends BaseTest implements Serializable {

View file

@ -1,10 +1,10 @@
package org.ray.api.benchmark; package org.ray.api.benchmark;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayActor; import org.ray.api.RayActor;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.testng.annotations.Test;
public class SingleLatencyTest extends RayBenchmarkTest { public class SingleLatencyTest extends RayBenchmarkTest {

View file

@ -5,12 +5,12 @@ import static org.ray.runtime.util.SystemUtil.pid;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayActor; import org.ray.api.RayActor;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.ray.api.options.ActorCreationOptions; import org.ray.api.options.ActorCreationOptions;
import org.testng.Assert;
import org.testng.annotations.Test;
public class ActorReconstructionTest extends BaseTest { public class ActorReconstructionTest extends BaseTest {

View file

@ -1,7 +1,5 @@
package org.ray.api.test; package org.ray.api.test;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayActor; import org.ray.api.RayActor;
import org.ray.api.RayObject; import org.ray.api.RayObject;
@ -9,6 +7,8 @@ import org.ray.api.annotation.RayRemote;
import org.ray.api.function.RayFunc2; import org.ray.api.function.RayFunc2;
import org.ray.api.id.UniqueId; import org.ray.api.id.UniqueId;
import org.ray.runtime.RayActorImpl; import org.ray.runtime.RayActorImpl;
import org.testng.Assert;
import org.testng.annotations.Test;
public class ActorTest extends BaseTest { public class ActorTest extends BaseTest {

View file

@ -1,20 +1,22 @@
package org.ray.api.test; package org.ray.api.test;
import java.io.File; import java.io.File;
import org.junit.After;
import org.junit.Before;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
public class BaseTest { public class BaseTest {
@Before @BeforeMethod
public void setUp() { public void setUp() {
System.setProperty("ray.home", "../.."); System.setProperty("ray.home", "../..");
System.setProperty("ray.resources", "CPU:4,RES-A:4"); System.setProperty("ray.resources", "CPU:4,RES-A:4");
Ray.init(); Ray.init();
} }
@After @AfterMethod
public void tearDown() { public void tearDown() {
// TODO(qwang): This is double check to check that the socket file is removed actually. // TODO(qwang): This is double check to check that the socket file is removed actually.
// We could not enable this until `systemInfo` enabled. // We could not enable this until `systemInfo` enabled.

View file

@ -1,11 +1,11 @@
package org.ray.api.test; package org.ray.api.test;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayActor; import org.ray.api.RayActor;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.exception.RayException; import org.ray.api.exception.RayException;
import org.testng.Assert;
import org.testng.annotations.Test;
public class FailureTest extends BaseTest { public class FailureTest extends BaseTest {

View file

@ -1,10 +1,10 @@
package org.ray.api.test; package org.ray.api.test;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.testng.Assert;
import org.testng.annotations.Test;
/** /**
* Hello world. * Hello world.

View file

@ -9,13 +9,13 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayActor; import org.ray.api.RayActor;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.WaitResult; import org.ray.api.WaitResult;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.testng.Assert;
import org.testng.annotations.Test;
public class MultiThreadingTest extends BaseTest { public class MultiThreadingTest extends BaseTest {

View file

@ -3,12 +3,11 @@ package org.ray.api.test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.id.UniqueId; import org.ray.api.id.UniqueId;
import org.testng.Assert;
import org.testng.annotations.Test;
/** /**
* Test putting and getting objects. * Test putting and getting objects.

View file

@ -3,14 +3,13 @@ package org.ray.api.test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.WaitResult; import org.ray.api.WaitResult;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.ray.api.id.UniqueId; import org.ray.api.id.UniqueId;
import org.testng.Assert;
import org.testng.annotations.Test;
public class PlasmaFreeTest extends BaseTest { public class PlasmaFreeTest extends BaseTest {

View file

@ -2,15 +2,13 @@ package org.ray.api.test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.testng.Assert;
import org.testng.annotations.Test;
/** /**
* Test Ray.call API * Test Ray.call API
@ -87,7 +85,7 @@ public class RayCallTest extends BaseTest {
Assert.assertEquals(1, (long) Ray.call(RayCallTest::testLong, 1L).get()); Assert.assertEquals(1, (long) Ray.call(RayCallTest::testLong, 1L).get());
Assert.assertEquals(1.0, Ray.call(RayCallTest::testDouble, 1.0).get(), 0.0); Assert.assertEquals(1.0, Ray.call(RayCallTest::testDouble, 1.0).get(), 0.0);
Assert.assertEquals(1.0f, Ray.call(RayCallTest::testFloat, 1.0f).get(), 0.0); Assert.assertEquals(1.0f, Ray.call(RayCallTest::testFloat, 1.0f).get(), 0.0);
Assert.assertEquals(true, Ray.call(RayCallTest::testBool, true).get()); Assert.assertTrue(Ray.call(RayCallTest::testBool, true).get());
Assert.assertEquals("foo", Ray.call(RayCallTest::testString, "foo").get()); Assert.assertEquals("foo", Ray.call(RayCallTest::testString, "foo").get());
List<Integer> list = ImmutableList.of(1, 2, 3); List<Integer> list = ImmutableList.of(1, 2, 3);
Assert.assertEquals(list, Ray.call(RayCallTest::testList, list).get()); Assert.assertEquals(list, Ray.call(RayCallTest::testList, list).get());

View file

@ -1,10 +1,10 @@
package org.ray.api.test; package org.ray.api.test;
import org.junit.Assert;
import org.junit.Test;
import org.ray.runtime.config.RayConfig; import org.ray.runtime.config.RayConfig;
import org.ray.runtime.config.RunMode; import org.ray.runtime.config.RunMode;
import org.ray.runtime.config.WorkerMode; import org.ray.runtime.config.WorkerMode;
import org.testng.Assert;
import org.testng.annotations.Test;
public class RayConfigTest { public class RayConfigTest {

View file

@ -3,11 +3,11 @@ package org.ray.api.test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.WaitResult; import org.ray.api.WaitResult;
import org.testng.Assert;
import org.testng.annotations.Test;
/** /**
* Integration test for Ray.* * Integration test for Ray.*

View file

@ -2,8 +2,6 @@ package org.ray.api.test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayActor; import org.ray.api.RayActor;
import org.ray.api.RayObject; import org.ray.api.RayObject;
@ -11,6 +9,8 @@ import org.ray.api.WaitResult;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.ray.api.options.ActorCreationOptions; import org.ray.api.options.ActorCreationOptions;
import org.ray.api.options.CallOptions; import org.ray.api.options.CallOptions;
import org.testng.Assert;
import org.testng.annotations.Test;
/** /**
* Resources Management Test. * Resources Management Test.

View file

@ -3,12 +3,12 @@ package org.ray.api.test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayActor; import org.ray.api.RayActor;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.id.UniqueId; import org.ray.api.id.UniqueId;
import org.testng.Assert;
import org.testng.annotations.Test;
public class StressTest extends BaseTest { public class StressTest extends BaseTest {

View file

@ -2,12 +2,11 @@ package org.ray.api.test;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import javax.xml.bind.DatatypeConverter; import javax.xml.bind.DatatypeConverter;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.id.UniqueId; import org.ray.api.id.UniqueId;
import org.ray.runtime.util.UniqueIdUtil; import org.ray.runtime.util.UniqueIdUtil;
import org.testng.Assert;
import org.testng.annotations.Test;
public class UniqueIdTest { public class UniqueIdTest {

View file

@ -3,12 +3,12 @@ package org.ray.api.test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.WaitResult; import org.ray.api.WaitResult;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.testng.Assert;
import org.testng.annotations.Test;
public class WaitTest extends BaseTest { public class WaitTest extends BaseTest {

View file

@ -3,11 +3,12 @@ package org.ray.api.test;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.Assert;
import org.ray.api.Ray; import org.ray.api.Ray;
import org.ray.api.RayObject; import org.ray.api.RayObject;
import org.ray.api.annotation.RayRemote; import org.ray.api.annotation.RayRemote;
import org.ray.runtime.util.FileUtil; import org.ray.runtime.util.FileUtil;
import org.testng.Assert;
import org.testng.annotations.Test;
/** /**
* given a directory of document files on each "machine", we would like to count the appearance of * given a directory of document files on each "machine", we would like to count the appearance of