(dic);
Result ret = invoker.invoke(invocation);
- Assert.assertSame(result, ret);
+ Assertions.assertSame(result, ret);
}
@Test()
diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailbackClusterInvokerTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailbackClusterInvokerTest.java
index 581d52ee9df..ad96a66830d 100644
--- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailbackClusterInvokerTest.java
+++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailbackClusterInvokerTest.java
@@ -1,3 +1,4 @@
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -27,27 +28,30 @@
import org.apache.dubbo.rpc.cluster.Directory;
import org.apache.log4j.Level;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
- /**
- * FailbackClusterInvokerTest
- *
- * add annotation @FixMethodOrder, the testARetryFailed Method must to first execution
+/**
+ * FailbackClusterInvokerTest
+ *
+ * add annotation @TestMethodOrder, the testARetryFailed Method must to first execution
*/
-@SuppressWarnings("unchecked")
-@FixMethodOrder(org.junit.runners.MethodSorters.NAME_ASCENDING)
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class FailbackClusterInvokerTest {
List> invokers = new ArrayList>();
@@ -61,7 +65,7 @@ public class FailbackClusterInvokerTest {
* @throws java.lang.Exception
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
dic = mock(Directory.class);
@@ -74,6 +78,15 @@ public void setUp() throws Exception {
invokers.add(invoker);
}
+ @AfterEach
+ public void tearDown() {
+
+ dic = null;
+ invocation = new RpcInvocation();
+ invokers.clear();
+ }
+
+
private void resetInvokerToException() {
given(invoker.invoke(invocation)).willThrow(new RuntimeException());
given(invoker.getUrl()).willReturn(url);
@@ -87,16 +100,18 @@ private void resetInvokerToNoException() {
}
@Test
+ @Order(1)
public void testInvokeException() {
resetInvokerToException();
FailbackClusterInvoker invoker = new FailbackClusterInvoker(
dic);
invoker.invoke(invocation);
- Assert.assertNull(RpcContext.getContext().getInvoker());
+ Assertions.assertNull(RpcContext.getContext().getInvoker());
DubboAppender.clear();
}
- @Test()
+ @Test
+ @Order(2)
public void testInvokeNoException() {
resetInvokerToNoException();
@@ -104,10 +119,11 @@ public void testInvokeNoException() {
FailbackClusterInvoker invoker = new FailbackClusterInvoker(
dic);
Result ret = invoker.invoke(invocation);
- Assert.assertSame(result, ret);
+ Assertions.assertSame(result, ret);
}
- @Test()
+ @Test
+ @Order(3)
public void testNoInvoke() {
dic = mock(Directory.class);
@@ -130,7 +146,9 @@ public void testNoInvoke() {
LogUtil.stop();
}
- @Test()
+ @Disabled
+ @Test
+ @Order(4)
public void testARetryFailed() throws Exception {
//Test retries and
@@ -143,15 +161,15 @@ public void testARetryFailed() throws Exception {
invoker.invoke(invocation);
invoker.invoke(invocation);
invoker.invoke(invocation);
- Assert.assertNull(RpcContext.getContext().getInvoker());
+ Assertions.assertNull(RpcContext.getContext().getInvoker());
// invoker.retryFailed();// when retry the invoker which get from failed map already is not the mocked invoker,so
//Ensure that the main thread is online
CountDownLatch countDown = new CountDownLatch(1);
countDown.await(15000L, TimeUnit.MILLISECONDS);
LogUtil.stop();
- Assert.assertEquals("must have four error message ", 4, LogUtil.findMessage(Level.ERROR, "Failed retry to invoke method"));
- Assert.assertEquals("must have two error message ", 2, LogUtil.findMessage(Level.ERROR, "Failed retry times exceed threshold"));
- Assert.assertEquals("must have one error message ", 1, LogUtil.findMessage(Level.ERROR, "Failback background works error"));
+ Assertions.assertEquals(4, LogUtil.findMessage(Level.ERROR, "Failed retry to invoke method"), "must have four error message ");
+ Assertions.assertEquals(2, LogUtil.findMessage(Level.ERROR, "Failed retry times exceed threshold"), "must have two error message ");
+ Assertions.assertEquals(1, LogUtil.findMessage(Level.ERROR, "Failback background works error"), "must have one error message ");
// it can be invoke successfully
}
}
\ No newline at end of file
diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailfastClusterInvokerTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailfastClusterInvokerTest.java
index 41dc79ca2ee..d8dd653f34e 100644
--- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailfastClusterInvokerTest.java
+++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailfastClusterInvokerTest.java
@@ -25,22 +25,20 @@
import org.apache.dubbo.rpc.RpcResult;
import org.apache.dubbo.rpc.cluster.Directory;
-import org.junit.Assert;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
/**
* FailfastClusterInvokerTest
- *
*/
@SuppressWarnings("unchecked")
public class FailfastClusterInvokerTest {
@@ -55,7 +53,7 @@ public class FailfastClusterInvokerTest {
* @throws java.lang.Exception
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
dic = mock(Directory.class);
@@ -81,12 +79,14 @@ private void resetInvoker1ToNoException() {
given(invoker1.getInterface()).willReturn(FailfastClusterInvokerTest.class);
}
- @Test(expected = RpcException.class)
+ @Test
public void testInvokeExceptoin() {
- resetInvoker1ToException();
- FailfastClusterInvoker invoker = new FailfastClusterInvoker(dic);
- invoker.invoke(invocation);
- Assert.assertSame(invoker1, RpcContext.getContext().getInvoker());
+ Assertions.assertThrows(RpcException.class, () -> {
+ resetInvoker1ToException();
+ FailfastClusterInvoker invoker = new FailfastClusterInvoker(dic);
+ invoker.invoke(invocation);
+ Assertions.assertSame(invoker1, RpcContext.getContext().getInvoker());
+ });
}
@Test()
@@ -96,7 +96,7 @@ public void testInvokeNoExceptoin() {
FailfastClusterInvoker invoker = new FailfastClusterInvoker(dic);
Result ret = invoker.invoke(invocation);
- Assert.assertSame(result, ret);
+ Assertions.assertSame(result, ret);
}
@Test()
diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailoverClusterInvokerTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailoverClusterInvokerTest.java
index 136ba2a349c..ff29a6183a9 100644
--- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailoverClusterInvokerTest.java
+++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailoverClusterInvokerTest.java
@@ -27,18 +27,18 @@
import org.apache.dubbo.rpc.cluster.directory.StaticDirectory;
import org.apache.dubbo.rpc.protocol.AbstractInvoker;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
@@ -61,7 +61,7 @@ public class FailoverClusterInvokerTest {
* @throws java.lang.Exception
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
dic = mock(Directory.class);
diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/ForkingClusterInvokerTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/ForkingClusterInvokerTest.java
index 5b44c838c1b..b3d343a3bbe 100644
--- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/ForkingClusterInvokerTest.java
+++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/ForkingClusterInvokerTest.java
@@ -25,15 +25,15 @@
import org.apache.dubbo.rpc.RpcContext;
import org.apache.dubbo.rpc.cluster.Directory;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
@@ -52,7 +52,7 @@ public class ForkingClusterInvokerTest {
private Directory dic;
private Result result = new RpcResult();
- @Before
+ @BeforeEach
public void setUp() throws Exception {
dic = mock(Directory.class);
@@ -111,9 +111,9 @@ public void testInvokeException() {
try {
invoker.invoke(invocation);
- Assert.fail();
+ Assertions.fail();
} catch (RpcException expected) {
- Assert.assertTrue(expected.getMessage().contains("Failed to forking invoke provider"));
+ Assertions.assertTrue(expected.getMessage().contains("Failed to forking invoke provider"));
assertFalse(expected.getCause() instanceof RpcException);
}
}
@@ -130,16 +130,16 @@ public void testClearRpcContext() {
RpcContext.getContext().setAttachment(attachKey, attachValue);
Map attachments = RpcContext.getContext().getAttachments();
- Assert.assertTrue("set attachment failed!", attachments != null && attachments.size() == 1);
+ Assertions.assertTrue(attachments != null && attachments.size() == 1, "set attachment failed!");
try {
invoker.invoke(invocation);
- Assert.fail();
+ Assertions.fail();
} catch (RpcException expected) {
- Assert.assertTrue("Succeeded to forking invoke provider !", expected.getMessage().contains("Failed to forking invoke provider"));
+ Assertions.assertTrue(expected.getMessage().contains("Failed to forking invoke provider"), "Succeeded to forking invoke provider !");
assertFalse(expected.getCause() instanceof RpcException);
}
Map afterInvoke = RpcContext.getContext().getAttachments();
- Assert.assertTrue("clear attachment failed!", afterInvoke != null && afterInvoke.size() == 0);
+ Assertions.assertTrue(afterInvoke != null && afterInvoke.size() == 0, "clear attachment failed!");
}
@Test()
@@ -150,7 +150,7 @@ public void testInvokeNoException() {
ForkingClusterInvoker invoker = new ForkingClusterInvoker(
dic);
Result ret = invoker.invoke(invocation);
- Assert.assertSame(result, ret);
+ Assertions.assertSame(result, ret);
}
}
\ No newline at end of file
diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/MergeableClusterInvokerTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/MergeableClusterInvokerTest.java
index ba0b617b88c..8a4089c9049 100644
--- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/MergeableClusterInvokerTest.java
+++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/MergeableClusterInvokerTest.java
@@ -24,9 +24,9 @@
import org.apache.dubbo.rpc.RpcResult;
import org.apache.dubbo.rpc.cluster.Directory;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
@@ -38,7 +38,7 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
@@ -86,7 +86,7 @@ static void merge(Map> first, Map> sec
}
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
directory = mock(Directory.class);
@@ -155,7 +155,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
// invoke
Result result = mergeableClusterInvoker.invoke(invocation);
- Assert.assertTrue(result.getValue() instanceof Menu);
+ Assertions.assertTrue(result.getValue() instanceof Menu);
Menu menu = (Menu) result.getValue();
Map> expected = new HashMap>();
merge(expected, firstMenuMap);
@@ -219,7 +219,7 @@ public void testAddMenu() throws Exception {
mergeableClusterInvoker = new MergeableClusterInvoker(directory);
Result result = mergeableClusterInvoker.invoke(invocation);
- Assert.assertNull(result.getValue());
+ Assertions.assertNull(result.getValue());
}
diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvokerTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvokerTest.java
index f305f919933..618e9705d65 100644
--- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvokerTest.java
+++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvokerTest.java
@@ -31,9 +31,9 @@
import org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker;
import org.apache.dubbo.rpc.support.MockProtocol;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
@@ -43,7 +43,7 @@ public class MockClusterInvokerTest {
List> invokers = new ArrayList>();
- @Before
+ @BeforeEach
public void beforeMethod() {
invokers.clear();
}
@@ -67,13 +67,13 @@ public void testMockInvokerInvoke_normal() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("something", ret.getValue());
+ Assertions.assertEquals("something", ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("sayHello");
ret = cluster.invoke(invocation);
- Assert.assertEquals(null, ret.getValue());
+ Assertions.assertEquals(null, ret.getValue());
}
/**
@@ -95,19 +95,19 @@ public void testMockInvokerInvoke_failmock() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("aa", ret.getValue());
+ Assertions.assertEquals("aa", ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething2");
ret = cluster.invoke(invocation);
- Assert.assertEquals(null, ret.getValue());
+ Assertions.assertEquals(null, ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("sayHello");
ret = cluster.invoke(invocation);
- Assert.assertEquals(null, ret.getValue());
+ Assertions.assertEquals(null, ret.getValue());
}
@@ -131,19 +131,19 @@ public void testMockInvokerInvoke_forcemock() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("aa", ret.getValue());
+ Assertions.assertEquals("aa", ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething2");
ret = cluster.invoke(invocation);
- Assert.assertEquals(null, ret.getValue());
+ Assertions.assertEquals(null, ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("sayHello");
ret = cluster.invoke(invocation);
- Assert.assertEquals(null, ret.getValue());
+ Assertions.assertEquals(null, ret.getValue());
}
@Test
@@ -162,7 +162,7 @@ public void testMockInvokerInvoke_forcemock_defaultreturn() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("sayHello");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals(null, ret.getValue());
+ Assertions.assertEquals(null, ret.getValue());
}
/**
@@ -178,25 +178,25 @@ public void testMockInvokerFromOverride_Invoke_Fock_someMethods() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("something", ret.getValue());
+ Assertions.assertEquals("something", ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething2");
ret = cluster.invoke(invocation);
- Assert.assertEquals("y", ret.getValue());
+ Assertions.assertEquals("y", ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething3");
ret = cluster.invoke(invocation);
- Assert.assertEquals("something3", ret.getValue());
+ Assertions.assertEquals("something3", ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("sayHello");
ret = cluster.invoke(invocation);
- Assert.assertEquals(null, ret.getValue());
+ Assertions.assertEquals(null, ret.getValue());
}
/**
@@ -213,20 +213,20 @@ public void testMockInvokerFromOverride_Invoke_Fock_WithOutDefault() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("x", ret.getValue());
+ Assertions.assertEquals("x", ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething2");
ret = cluster.invoke(invocation);
- Assert.assertEquals("y", ret.getValue());
+ Assertions.assertEquals("y", ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething3");
try {
ret = cluster.invoke(invocation);
- Assert.fail();
+ Assertions.fail();
} catch (RpcException e) {
}
@@ -247,25 +247,25 @@ public void testMockInvokerFromOverride_Invoke_Fock_WithDefault() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("x", ret.getValue());
+ Assertions.assertEquals("x", ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething2");
ret = cluster.invoke(invocation);
- Assert.assertEquals("y", ret.getValue());
+ Assertions.assertEquals("y", ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething3");
ret = cluster.invoke(invocation);
- Assert.assertEquals(null, ret.getValue());
+ Assertions.assertEquals(null, ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("sayHello");
ret = cluster.invoke(invocation);
- Assert.assertEquals(null, ret.getValue());
+ Assertions.assertEquals(null, ret.getValue());
}
/**
@@ -283,25 +283,25 @@ public void testMockInvokerFromOverride_Invoke_Fock_WithFailDefault() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("x", ret.getValue());
+ Assertions.assertEquals("x", ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething2");
ret = cluster.invoke(invocation);
- Assert.assertEquals("y", ret.getValue());
+ Assertions.assertEquals("y", ret.getValue());
// If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething3");
ret = cluster.invoke(invocation);
- Assert.assertEquals("z", ret.getValue());
+ Assertions.assertEquals("z", ret.getValue());
//If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("sayHello");
ret = cluster.invoke(invocation);
- Assert.assertEquals("z", ret.getValue());
+ Assertions.assertEquals("z", ret.getValue());
}
/**
@@ -319,25 +319,25 @@ public void testMockInvokerFromOverride_Invoke_Fock_WithForceDefault() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("x", ret.getValue());
+ Assertions.assertEquals("x", ret.getValue());
//If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething2");
ret = cluster.invoke(invocation);
- Assert.assertEquals("y", ret.getValue());
+ Assertions.assertEquals("y", ret.getValue());
//If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething3");
ret = cluster.invoke(invocation);
- Assert.assertEquals("z", ret.getValue());
+ Assertions.assertEquals("z", ret.getValue());
//If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("sayHello");
ret = cluster.invoke(invocation);
- Assert.assertEquals("z", ret.getValue());
+ Assertions.assertEquals("z", ret.getValue());
}
/**
@@ -353,19 +353,19 @@ public void testMockInvokerFromOverride_Invoke_Fock_Default() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("x", ret.getValue());
+ Assertions.assertEquals("x", ret.getValue());
//If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething2");
ret = cluster.invoke(invocation);
- Assert.assertEquals("x", ret.getValue());
+ Assertions.assertEquals("x", ret.getValue());
//If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("sayHello");
ret = cluster.invoke(invocation);
- Assert.assertEquals("x", ret.getValue());
+ Assertions.assertEquals("x", ret.getValue());
}
/**
@@ -381,14 +381,14 @@ public void testMockInvokerFromOverride_Invoke_checkCompatible_return() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("x", ret.getValue());
+ Assertions.assertEquals("x", ret.getValue());
//If no mock was configured, return null directly
invocation = new RpcInvocation();
invocation.setMethodName("getSomething3");
try {
ret = cluster.invoke(invocation);
- Assert.fail("fail invoke");
+ Assertions.fail("fail invoke");
} catch (RpcException e) {
}
@@ -407,7 +407,7 @@ public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("somethingmock", ret.getValue());
+ Assertions.assertEquals("somethingmock", ret.getValue());
}
/**
@@ -423,7 +423,7 @@ public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock2() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("somethingmock", ret.getValue());
+ Assertions.assertEquals("somethingmock", ret.getValue());
}
/**
@@ -438,7 +438,7 @@ public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock3() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals("somethingmock", ret.getValue());
+ Assertions.assertEquals("somethingmock", ret.getValue());
}
@Test
@@ -451,8 +451,8 @@ public void testMockInvokerFromOverride_Invoke_check_String() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getSomething");
Result ret = cluster.invoke(invocation);
- Assert.assertTrue("result type must be String but was : " + ret.getValue().getClass(), ret.getValue() instanceof String);
- Assert.assertEquals("1688", (String) ret.getValue());
+ Assertions.assertTrue(ret.getValue() instanceof String, "result type must be String but was : " + ret.getValue().getClass());
+ Assertions.assertEquals("1688", (String) ret.getValue());
}
@Test
@@ -465,8 +465,8 @@ public void testMockInvokerFromOverride_Invoke_check_int() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getInt1");
Result ret = cluster.invoke(invocation);
- Assert.assertTrue("result type must be integer but was : " + ret.getValue().getClass(), ret.getValue() instanceof Integer);
- Assert.assertEquals(new Integer(1688), (Integer) ret.getValue());
+ Assertions.assertTrue(ret.getValue() instanceof Integer, "result type must be integer but was : " + ret.getValue().getClass());
+ Assertions.assertEquals(new Integer(1688), (Integer) ret.getValue());
}
@Test
@@ -479,8 +479,8 @@ public void testMockInvokerFromOverride_Invoke_check_boolean() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getBoolean1");
Result ret = cluster.invoke(invocation);
- Assert.assertTrue("result type must be Boolean but was : " + ret.getValue().getClass(), ret.getValue() instanceof Boolean);
- Assert.assertEquals(true, Boolean.parseBoolean(ret.getValue().toString()));
+ Assertions.assertTrue(ret.getValue() instanceof Boolean, "result type must be Boolean but was : " + ret.getValue().getClass());
+ Assertions.assertEquals(true, Boolean.parseBoolean(ret.getValue().toString()));
}
@Test
@@ -493,7 +493,7 @@ public void testMockInvokerFromOverride_Invoke_check_Boolean() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getBoolean2");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals(true, Boolean.parseBoolean(ret.getValue().toString()));
+ Assertions.assertEquals(true, Boolean.parseBoolean(ret.getValue().toString()));
}
@SuppressWarnings("unchecked")
@@ -507,7 +507,7 @@ public void testMockInvokerFromOverride_Invoke_check_ListString_empty() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getListString");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals(0, ((List) ret.getValue()).size());
+ Assertions.assertEquals(0, ((List) ret.getValue()).size());
}
@SuppressWarnings("unchecked")
@@ -522,8 +522,8 @@ public void testMockInvokerFromOverride_Invoke_check_ListString() {
invocation.setMethodName("getListString");
Result ret = cluster.invoke(invocation);
List rl = (List) ret.getValue();
- Assert.assertEquals(2, rl.size());
- Assert.assertEquals("hi", rl.get(0));
+ Assertions.assertEquals(2, rl.size());
+ Assertions.assertEquals("hi", rl.get(0));
}
@SuppressWarnings("unchecked")
@@ -537,7 +537,7 @@ public void testMockInvokerFromOverride_Invoke_check_ListPojo_empty() {
RpcInvocation invocation = new RpcInvocation();
invocation.setMethodName("getUsers");
Result ret = cluster.invoke(invocation);
- Assert.assertEquals(0, ((List) ret.getValue()).size());
+ Assertions.assertEquals(0, ((List) ret.getValue()).size());
}
@SuppressWarnings("unchecked")
@@ -553,8 +553,8 @@ public void testMockInvokerFromOverride_Invoke_check_ListPojo() {
Result ret = cluster.invoke(invocation);
List rl = (List) ret.getValue();
System.out.println(rl);
- Assert.assertEquals(2, rl.size());
- Assert.assertEquals("hi1", ((User) rl.get(0)).getName());
+ Assertions.assertEquals(2, rl.size());
+ Assertions.assertEquals("hi1", ((User) rl.get(0)).getName());
}
@Test
@@ -583,9 +583,9 @@ public void testMockInvokerFromOverride_Invoke_force_throw() {
invocation.setMethodName("getBoolean2");
try {
cluster.invoke(invocation);
- Assert.fail();
+ Assertions.fail();
} catch (RpcException e) {
- Assert.assertFalse("not custem exception", e.isBiz());
+ Assertions.assertFalse(e.isBiz(), "not custem exception");
}
}
@@ -600,7 +600,7 @@ public void testMockInvokerFromOverride_Invoke_force_throwCustemException() thro
invocation.setMethodName("getBoolean2");
try {
cluster.invoke(invocation).recreate();
- Assert.fail();
+ Assertions.fail();
} catch (MyMockException e) {
}
@@ -617,9 +617,9 @@ public void testMockInvokerFromOverride_Invoke_force_throwCustemExceptionNotFoun
invocation.setMethodName("getBoolean2");
try {
cluster.invoke(invocation);
- Assert.fail();
+ Assertions.fail();
} catch (Exception e) {
- Assert.assertTrue(e.getCause() instanceof IllegalStateException);
+ Assertions.assertTrue(e.getCause() instanceof IllegalStateException);
}
}
@@ -634,9 +634,9 @@ public void testMockInvokerFromOverride_Invoke_mock_false() {
invocation.setMethodName("getBoolean2");
try {
cluster.invoke(invocation);
- Assert.fail();
+ Assertions.fail();
} catch (RpcException e) {
- Assert.assertTrue(e.isTimeout());
+ Assertions.assertTrue(e.isTimeout());
}
}
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/Resetable.java b/dubbo-common/src/main/java/org/apache/dubbo/common/Resetable.java
index f2eb8da4ed3..021cfbf257a 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/Resetable.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/Resetable.java
@@ -1,31 +1,31 @@
-/*
- * 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.
- */
-package org.apache.dubbo.common;
-
-/**
- * Resetable.
- */
-public interface Resetable {
-
- /**
- * reset.
- *
- * @param url
- */
- void reset(URL url);
-
+/*
+ * 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.
+ */
+package org.apache.dubbo.common;
+
+/**
+ * Resetable.
+ */
+public interface Resetable {
+
+ /**
+ * reset.
+ *
+ * @param url
+ */
+ void reset(URL url);
+
}
\ No newline at end of file
diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java
index 37696e63acf..b4f547ce12b 100644
--- a/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java
+++ b/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java
@@ -18,7 +18,7 @@
import org.apache.dubbo.common.utils.CollectionUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.Arrays;
@@ -27,12 +27,12 @@
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
public class URLTest {
diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanAccessorTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanAccessorTest.java
index 4c4e1523501..55bbc598ec5 100644
--- a/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanAccessorTest.java
+++ b/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanAccessorTest.java
@@ -16,22 +16,22 @@
*/
package org.apache.dubbo.common.beanutil;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class JavaBeanAccessorTest {
@Test
public void testIsAccessByMethod(){
- Assert.assertTrue(JavaBeanAccessor.isAccessByMethod(JavaBeanAccessor.METHOD));
- Assert.assertTrue(JavaBeanAccessor.isAccessByMethod(JavaBeanAccessor.ALL));
- Assert.assertFalse(JavaBeanAccessor.isAccessByMethod(JavaBeanAccessor.FIELD));
+ Assertions.assertTrue(JavaBeanAccessor.isAccessByMethod(JavaBeanAccessor.METHOD));
+ Assertions.assertTrue(JavaBeanAccessor.isAccessByMethod(JavaBeanAccessor.ALL));
+ Assertions.assertFalse(JavaBeanAccessor.isAccessByMethod(JavaBeanAccessor.FIELD));
}
@Test
public void testIsAccessByField(){
- Assert.assertTrue(JavaBeanAccessor.isAccessByField(JavaBeanAccessor.FIELD));
- Assert.assertTrue(JavaBeanAccessor.isAccessByField(JavaBeanAccessor.ALL));
- Assert.assertFalse(JavaBeanAccessor.isAccessByField(JavaBeanAccessor.METHOD));
+ Assertions.assertTrue(JavaBeanAccessor.isAccessByField(JavaBeanAccessor.FIELD));
+ Assertions.assertTrue(JavaBeanAccessor.isAccessByField(JavaBeanAccessor.ALL));
+ Assertions.assertFalse(JavaBeanAccessor.isAccessByField(JavaBeanAccessor.METHOD));
}
}
diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtilTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtilTest.java
index 3cf314cd949..5c72a14d3d0 100644
--- a/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtilTest.java
+++ b/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtilTest.java
@@ -22,8 +22,9 @@
import org.apache.dubbo.common.model.person.PersonStatus;
import org.apache.dubbo.common.model.person.Phone;
import org.apache.dubbo.common.utils.PojoUtilsTest;
-import org.junit.Assert;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.lang.reflect.Array;
import java.math.BigDecimal;
@@ -37,142 +38,160 @@
public class JavaBeanSerializeUtilTest {
@Test
- public void testSerialize_Primitive() throws Exception {
+ public void testSerialize_Primitive() {
JavaBeanDescriptor descriptor;
descriptor = JavaBeanSerializeUtil.serialize(Integer.MAX_VALUE);
- Assert.assertTrue(descriptor.isPrimitiveType());
- Assert.assertEquals(Integer.MAX_VALUE, descriptor.getPrimitiveProperty());
+ Assertions.assertTrue(descriptor.isPrimitiveType());
+ Assertions.assertEquals(Integer.MAX_VALUE, descriptor.getPrimitiveProperty());
Date now = new Date();
descriptor = JavaBeanSerializeUtil.serialize(now);
- Assert.assertTrue(descriptor.isPrimitiveType());
- Assert.assertEquals(now, descriptor.getPrimitiveProperty());
+ Assertions.assertTrue(descriptor.isPrimitiveType());
+ Assertions.assertEquals(now, descriptor.getPrimitiveProperty());
}
@Test
- public void testSerialize_Primitive_NUll() throws Exception {
+ public void testSerialize_Primitive_NUll() {
JavaBeanDescriptor descriptor;
descriptor = JavaBeanSerializeUtil.serialize(null);
- Assert.assertTrue(descriptor == null);
+ Assertions.assertTrue(descriptor == null);
}
@Test
- public void testDeserialize_Primitive() throws Exception {
+ public void testDeserialize_Primitive() {
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
descriptor.setPrimitiveProperty(Long.MAX_VALUE);
- Assert.assertEquals(Long.MAX_VALUE, JavaBeanSerializeUtil.deserialize(descriptor));
+ Assertions.assertEquals(Long.MAX_VALUE, JavaBeanSerializeUtil.deserialize(descriptor));
BigDecimal decimal = BigDecimal.TEN;
- Assert.assertEquals(Long.MAX_VALUE, descriptor.setPrimitiveProperty(decimal));
- Assert.assertEquals(decimal, JavaBeanSerializeUtil.deserialize(descriptor));
+ Assertions.assertEquals(Long.MAX_VALUE, descriptor.setPrimitiveProperty(decimal));
+ Assertions.assertEquals(decimal, JavaBeanSerializeUtil.deserialize(descriptor));
String string = UUID.randomUUID().toString();
- Assert.assertEquals(decimal, descriptor.setPrimitiveProperty(string));
- Assert.assertEquals(string, JavaBeanSerializeUtil.deserialize(descriptor));
+ Assertions.assertEquals(decimal, descriptor.setPrimitiveProperty(string));
+ Assertions.assertEquals(string, JavaBeanSerializeUtil.deserialize(descriptor));
}
- @Test(expected = IllegalArgumentException.class)
- public void testDeserialize_Primitive0() throws Exception {
- JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_BEAN + 1);
+ @Test
+ public void testDeserialize_Primitive0() {
+ Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_BEAN + 1);
+ });
}
- @Test(expected = IllegalArgumentException.class)
- public void testDeserialize_Null() throws Exception {
- JavaBeanDescriptor descriptor = new JavaBeanDescriptor(null, JavaBeanDescriptor.TYPE_BEAN);
+ @Test
+ public void testDeserialize_Null() {
+ Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ JavaBeanDescriptor descriptor = new JavaBeanDescriptor(null, JavaBeanDescriptor.TYPE_BEAN);
+ });
}
- @Test(expected = IllegalArgumentException.class)
- public void testDeserialize_containsProperty() throws Exception {
- JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
- descriptor.containsProperty(null);
+ @Test
+ public void testDeserialize_containsProperty() {
+ Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
+ descriptor.containsProperty(null);
+ });
}
- @Test(expected = IllegalStateException.class)
- public void testSetEnumNameProperty() throws Exception {
- JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
- descriptor.setEnumNameProperty(JavaBeanDescriptor.class.getName());
+ @Test
+ public void testSetEnumNameProperty() {
+ Assertions.assertThrows(IllegalStateException.class, () -> {
+ JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
+ descriptor.setEnumNameProperty(JavaBeanDescriptor.class.getName());
+ });
}
- @Test(expected = IllegalStateException.class)
- public void testGetEnumNameProperty() throws Exception {
- JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
- descriptor.getEnumPropertyName();
+ @Test
+ public void testGetEnumNameProperty() {
+ Assertions.assertThrows(IllegalStateException.class, () -> {
+ JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
+ descriptor.getEnumPropertyName();
+ });
}
- @Test(expected = IllegalStateException.class)
- public void testSetClassNameProperty() throws Exception {
- JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
- descriptor.setClassNameProperty(JavaBeanDescriptor.class.getName());
+ @Test
+ public void testSetClassNameProperty() {
+ Assertions.assertThrows(IllegalStateException.class, () -> {
+ JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
+ descriptor.setClassNameProperty(JavaBeanDescriptor.class.getName());
+ });
}
- @Test(expected = IllegalStateException.class)
- public void testGetClassNameProperty() throws Exception {
- JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
- descriptor.getClassNameProperty();
+ @Test
+ public void testGetClassNameProperty() {
+ Assertions.assertThrows(IllegalStateException.class, () -> {
+ JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
+ descriptor.getClassNameProperty();
+ });
}
- @Test(expected = IllegalStateException.class)
- public void testSetPrimitiveProperty() throws Exception {
- JavaBeanDescriptor descriptor = new JavaBeanDescriptor(JavaBeanDescriptor.class.getName(), JavaBeanDescriptor.TYPE_BEAN);
- descriptor.setPrimitiveProperty(JavaBeanDescriptor.class.getName());
+ @Test
+ public void testSetPrimitiveProperty() {
+ Assertions.assertThrows(IllegalStateException.class, () -> {
+ JavaBeanDescriptor descriptor = new JavaBeanDescriptor(JavaBeanDescriptor.class.getName(), JavaBeanDescriptor.TYPE_BEAN);
+ descriptor.setPrimitiveProperty(JavaBeanDescriptor.class.getName());
+ });
}
- @Test(expected = IllegalStateException.class)
- public void testGetPrimitiveProperty() throws Exception {
- JavaBeanDescriptor descriptor = new JavaBeanDescriptor(JavaBeanDescriptor.class.getName(), JavaBeanDescriptor.TYPE_BEAN);
- descriptor.getPrimitiveProperty();
+ @Test
+ public void testGetPrimitiveProperty() {
+ Assertions.assertThrows(IllegalStateException.class, () -> {
+ JavaBeanDescriptor descriptor = new JavaBeanDescriptor(JavaBeanDescriptor.class.getName(), JavaBeanDescriptor.TYPE_BEAN);
+ descriptor.getPrimitiveProperty();
+ });
}
@Test
- public void testDeserialize_get_and_set() throws Exception {
+ public void testDeserialize_get_and_set() {
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_BEAN);
descriptor.setType(JavaBeanDescriptor.TYPE_PRIMITIVE);
- Assert.assertTrue(descriptor.getType() == JavaBeanDescriptor.TYPE_PRIMITIVE);
+ Assertions.assertTrue(descriptor.getType() == JavaBeanDescriptor.TYPE_PRIMITIVE);
descriptor.setClassName(JavaBeanDescriptor.class.getName());
- Assert.assertEquals(JavaBeanDescriptor.class.getName(), descriptor.getClassName());
+ Assertions.assertEquals(JavaBeanDescriptor.class.getName(), descriptor.getClassName());
}
@Test
- public void testSerialize_Array() throws Exception {
+ public void testSerialize_Array() {
int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9};
JavaBeanDescriptor descriptor = JavaBeanSerializeUtil.serialize(array, JavaBeanAccessor.METHOD);
- Assert.assertTrue(descriptor.isArrayType());
- Assert.assertEquals(int.class.getName(), descriptor.getClassName());
+ Assertions.assertTrue(descriptor.isArrayType());
+ Assertions.assertEquals(int.class.getName(), descriptor.getClassName());
for (int i = 0; i < array.length; i++) {
- Assert.assertEquals(array[i],
+ Assertions.assertEquals(array[i],
((JavaBeanDescriptor) descriptor.getProperty(i)).getPrimitiveProperty());
}
Integer[] integers = new Integer[]{1, 2, 3, 4, null, null, null};
descriptor = JavaBeanSerializeUtil.serialize(integers, JavaBeanAccessor.METHOD);
- Assert.assertTrue(descriptor.isArrayType());
- Assert.assertEquals(Integer.class.getName(), descriptor.getClassName());
- Assert.assertEquals(integers.length, descriptor.propertySize());
+ Assertions.assertTrue(descriptor.isArrayType());
+ Assertions.assertEquals(Integer.class.getName(), descriptor.getClassName());
+ Assertions.assertEquals(integers.length, descriptor.propertySize());
for (int i = 0; i < integers.length; i++) {
if (integers[i] == null) {
- Assert.assertTrue(integers[i] == descriptor.getProperty(i));
+ Assertions.assertTrue(integers[i] == descriptor.getProperty(i));
} else {
- Assert.assertEquals(integers[i], ((JavaBeanDescriptor) descriptor.getProperty(i)).getPrimitiveProperty());
+ Assertions.assertEquals(integers[i], ((JavaBeanDescriptor) descriptor.getProperty(i)).getPrimitiveProperty());
}
}
int[][] second = {{1, 2}, {3, 4}};
descriptor = JavaBeanSerializeUtil.serialize(second, JavaBeanAccessor.METHOD);
- Assert.assertTrue(descriptor.isArrayType());
- Assert.assertEquals(int[].class.getName(), descriptor.getClassName());
+ Assertions.assertTrue(descriptor.isArrayType());
+ Assertions.assertEquals(int[].class.getName(), descriptor.getClassName());
for (int i = 0; i < second.length; i++) {
for (int j = 0; j < second[i].length; j++) {
JavaBeanDescriptor item = (((JavaBeanDescriptor) descriptor.getProperty(i)));
- Assert.assertTrue(item.isArrayType());
- Assert.assertEquals(int.class.getName(), item.getClassName());
- Assert.assertEquals(second[i][j], ((JavaBeanDescriptor) item.getProperty(j)).getPrimitiveProperty());
+ Assertions.assertTrue(item.isArrayType());
+ Assertions.assertEquals(int.class.getName(), item.getClassName());
+ Assertions.assertEquals(second[i][j], ((JavaBeanDescriptor) item.getProperty(j)).getPrimitiveProperty());
}
}
BigPerson[] persons = new BigPerson[]{createBigPerson(), createBigPerson()};
descriptor = JavaBeanSerializeUtil.serialize(persons);
- Assert.assertTrue(descriptor.isArrayType());
- Assert.assertEquals(BigPerson.class.getName(), descriptor.getClassName());
+ Assertions.assertTrue(descriptor.isArrayType());
+ Assertions.assertEquals(BigPerson.class.getName(), descriptor.getClassName());
for (int i = 0; i < persons.length; i++) {
assertEqualsBigPerson(persons[i], descriptor.getProperty(i));
}
@@ -180,27 +199,27 @@ public void testSerialize_Array() throws Exception {
@Test
public void testConstructorArg() {
- Assert.assertFalse((boolean) JavaBeanSerializeUtil.getConstructorArg(boolean.class));
- Assert.assertFalse((boolean) JavaBeanSerializeUtil.getConstructorArg(Boolean.class));
- Assert.assertEquals((byte)0, JavaBeanSerializeUtil.getConstructorArg(byte.class));
- Assert.assertEquals((byte)0, JavaBeanSerializeUtil.getConstructorArg(Byte.class));
- Assert.assertEquals((short)0, JavaBeanSerializeUtil.getConstructorArg(short.class));
- Assert.assertEquals((short)0, JavaBeanSerializeUtil.getConstructorArg(Short.class));
- Assert.assertEquals(0, JavaBeanSerializeUtil.getConstructorArg(int.class));
- Assert.assertEquals(0, JavaBeanSerializeUtil.getConstructorArg(Integer.class));
- Assert.assertEquals((long)0, JavaBeanSerializeUtil.getConstructorArg(long.class));
- Assert.assertEquals((long)0, JavaBeanSerializeUtil.getConstructorArg(Long.class));
- Assert.assertEquals((float) 0, JavaBeanSerializeUtil.getConstructorArg(float.class));
- Assert.assertEquals((float) 0, JavaBeanSerializeUtil.getConstructorArg(Float.class));
- Assert.assertEquals((double) 0, JavaBeanSerializeUtil.getConstructorArg(double.class));
- Assert.assertEquals((double) 0, JavaBeanSerializeUtil.getConstructorArg(Double.class));
- Assert.assertEquals((char)0, JavaBeanSerializeUtil.getConstructorArg(char.class));
- Assert.assertEquals(new Character((char)0), JavaBeanSerializeUtil.getConstructorArg(Character.class));
- Assert.assertEquals(null, JavaBeanSerializeUtil.getConstructorArg(JavaBeanSerializeUtil.class));
+ Assertions.assertFalse((boolean) JavaBeanSerializeUtil.getConstructorArg(boolean.class));
+ Assertions.assertFalse((boolean) JavaBeanSerializeUtil.getConstructorArg(Boolean.class));
+ Assertions.assertEquals((byte) 0, JavaBeanSerializeUtil.getConstructorArg(byte.class));
+ Assertions.assertEquals((byte) 0, JavaBeanSerializeUtil.getConstructorArg(Byte.class));
+ Assertions.assertEquals((short) 0, JavaBeanSerializeUtil.getConstructorArg(short.class));
+ Assertions.assertEquals((short) 0, JavaBeanSerializeUtil.getConstructorArg(Short.class));
+ Assertions.assertEquals(0, JavaBeanSerializeUtil.getConstructorArg(int.class));
+ Assertions.assertEquals(0, JavaBeanSerializeUtil.getConstructorArg(Integer.class));
+ Assertions.assertEquals((long) 0, JavaBeanSerializeUtil.getConstructorArg(long.class));
+ Assertions.assertEquals((long) 0, JavaBeanSerializeUtil.getConstructorArg(Long.class));
+ Assertions.assertEquals((float) 0, JavaBeanSerializeUtil.getConstructorArg(float.class));
+ Assertions.assertEquals((float) 0, JavaBeanSerializeUtil.getConstructorArg(Float.class));
+ Assertions.assertEquals((double) 0, JavaBeanSerializeUtil.getConstructorArg(double.class));
+ Assertions.assertEquals((double) 0, JavaBeanSerializeUtil.getConstructorArg(Double.class));
+ Assertions.assertEquals((char) 0, JavaBeanSerializeUtil.getConstructorArg(char.class));
+ Assertions.assertEquals(new Character((char) 0), JavaBeanSerializeUtil.getConstructorArg(Character.class));
+ Assertions.assertEquals(null, JavaBeanSerializeUtil.getConstructorArg(JavaBeanSerializeUtil.class));
}
@Test
- public void testDeserialize_Array() throws Exception {
+ public void testDeserialize_Array() {
final int len = 10;
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(int.class.getName(), JavaBeanDescriptor.TYPE_ARRAY);
for (int i = 0; i < len; i++) {
@@ -208,10 +227,10 @@ public void testDeserialize_Array() throws Exception {
}
Object obj = JavaBeanSerializeUtil.deserialize(descriptor);
- Assert.assertTrue(obj.getClass().isArray());
- Assert.assertTrue(int.class == obj.getClass().getComponentType());
+ Assertions.assertTrue(obj.getClass().isArray());
+ Assertions.assertTrue(int.class == obj.getClass().getComponentType());
for (int i = 0; i < len; i++) {
- Assert.assertEquals(i, Array.get(obj, i));
+ Assertions.assertEquals(i, Array.get(obj, i));
}
descriptor = new JavaBeanDescriptor(int[].class.getName(), JavaBeanDescriptor.TYPE_ARRAY);
@@ -223,14 +242,14 @@ public void testDeserialize_Array() throws Exception {
descriptor.setProperty(i, innerItem);
}
obj = JavaBeanSerializeUtil.deserialize(descriptor);
- Assert.assertTrue(obj.getClass().isArray());
- Assert.assertEquals(int[].class, obj.getClass().getComponentType());
+ Assertions.assertTrue(obj.getClass().isArray());
+ Assertions.assertEquals(int[].class, obj.getClass().getComponentType());
for (int i = 0; i < len; i++) {
Object innerItem = Array.get(obj, i);
- Assert.assertTrue(innerItem.getClass().isArray());
- Assert.assertEquals(int.class, innerItem.getClass().getComponentType());
+ Assertions.assertTrue(innerItem.getClass().isArray());
+ Assertions.assertEquals(int.class, innerItem.getClass().getComponentType());
for (int j = 0; j < len; j++) {
- Assert.assertEquals(j, Array.get(innerItem, j));
+ Assertions.assertEquals(j, Array.get(innerItem, j));
}
}
@@ -240,18 +259,18 @@ public void testDeserialize_Array() throws Exception {
descriptor.setProperty(0, innerDescriptor);
obj = JavaBeanSerializeUtil.deserialize(descriptor);
- Assert.assertTrue(obj.getClass().isArray());
- Assert.assertEquals(BigPerson[].class, obj.getClass().getComponentType());
- Assert.assertEquals(1, Array.getLength(obj));
+ Assertions.assertTrue(obj.getClass().isArray());
+ Assertions.assertEquals(BigPerson[].class, obj.getClass().getComponentType());
+ Assertions.assertEquals(1, Array.getLength(obj));
obj = Array.get(obj, 0);
- Assert.assertTrue(obj.getClass().isArray());
- Assert.assertEquals(BigPerson.class, obj.getClass().getComponentType());
- Assert.assertEquals(1, Array.getLength(obj));
- Assert.assertEquals(createBigPerson(), Array.get(obj, 0));
+ Assertions.assertTrue(obj.getClass().isArray());
+ Assertions.assertEquals(BigPerson.class, obj.getClass().getComponentType());
+ Assertions.assertEquals(1, Array.getLength(obj));
+ Assertions.assertEquals(createBigPerson(), Array.get(obj, 0));
}
@Test
- public void test_Circular_Reference() throws Exception {
+ public void test_Circular_Reference() {
PojoUtilsTest.Parent parent = new PojoUtilsTest.Parent();
parent.setAge(Integer.MAX_VALUE);
parent.setEmail("a@b");
@@ -265,19 +284,19 @@ public void test_Circular_Reference() throws Exception {
parent.setChild(child);
JavaBeanDescriptor descriptor = JavaBeanSerializeUtil.serialize(parent, JavaBeanAccessor.METHOD);
- Assert.assertTrue(descriptor.isBeanType());
+ Assertions.assertTrue(descriptor.isBeanType());
assertEqualsPrimitive(parent.getAge(), descriptor.getProperty("age"));
assertEqualsPrimitive(parent.getName(), descriptor.getProperty("name"));
assertEqualsPrimitive(parent.getEmail(), descriptor.getProperty("email"));
JavaBeanDescriptor childDescriptor = (JavaBeanDescriptor) descriptor.getProperty("child");
- Assert.assertTrue(descriptor == childDescriptor.getProperty("parent"));
+ Assertions.assertTrue(descriptor == childDescriptor.getProperty("parent"));
assertEqualsPrimitive(child.getName(), childDescriptor.getProperty("name"));
assertEqualsPrimitive(child.getAge(), childDescriptor.getProperty("age"));
}
@Test
- public void testBeanSerialize() throws Exception {
+ public void testBeanSerialize() {
Bean bean = new Bean();
bean.setDate(new Date());
bean.setStatus(PersonStatus.ENABLED);
@@ -295,39 +314,39 @@ public void testBeanSerialize() throws Exception {
bean.setAddresses(map);
JavaBeanDescriptor descriptor = JavaBeanSerializeUtil.serialize(bean, JavaBeanAccessor.METHOD);
- Assert.assertTrue(descriptor.isBeanType());
+ Assertions.assertTrue(descriptor.isBeanType());
assertEqualsPrimitive(bean.getDate(), descriptor.getProperty("date"));
assertEqualsEnum(bean.getStatus(), descriptor.getProperty("status"));
- Assert.assertTrue(((JavaBeanDescriptor) descriptor.getProperty("type")).isClassType());
- Assert.assertEquals(Bean.class.getName(), ((JavaBeanDescriptor) descriptor.getProperty("type")).getClassNameProperty());
- Assert.assertTrue(((JavaBeanDescriptor) descriptor.getProperty("array")).isArrayType());
- Assert.assertEquals(0, ((JavaBeanDescriptor) descriptor.getProperty("array")).propertySize());
+ Assertions.assertTrue(((JavaBeanDescriptor) descriptor.getProperty("type")).isClassType());
+ Assertions.assertEquals(Bean.class.getName(), ((JavaBeanDescriptor) descriptor.getProperty("type")).getClassNameProperty());
+ Assertions.assertTrue(((JavaBeanDescriptor) descriptor.getProperty("array")).isArrayType());
+ Assertions.assertEquals(0, ((JavaBeanDescriptor) descriptor.getProperty("array")).propertySize());
JavaBeanDescriptor property = (JavaBeanDescriptor) descriptor.getProperty("collection");
- Assert.assertTrue(property.isCollectionType());
- Assert.assertEquals(1, property.propertySize());
+ Assertions.assertTrue(property.isCollectionType());
+ Assertions.assertEquals(1, property.propertySize());
property = (JavaBeanDescriptor) property.getProperty(0);
- Assert.assertTrue(property.isBeanType());
- Assert.assertEquals(Phone.class.getName(), property.getClassName());
- Assert.assertEquals(0, property.propertySize());
+ Assertions.assertTrue(property.isBeanType());
+ Assertions.assertEquals(Phone.class.getName(), property.getClassName());
+ Assertions.assertEquals(0, property.propertySize());
property = (JavaBeanDescriptor) descriptor.getProperty("addresses");
- Assert.assertTrue(property.isMapType());
- Assert.assertEquals(bean.getAddresses().getClass().getName(), property.getClassName());
- Assert.assertEquals(1, property.propertySize());
+ Assertions.assertTrue(property.isMapType());
+ Assertions.assertEquals(bean.getAddresses().getClass().getName(), property.getClassName());
+ Assertions.assertEquals(1, property.propertySize());
Map.Entry