From 0bf162cdacee5578f7e3502b77b69032a7759883 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Mon, 26 Feb 2018 16:19:04 +0800 Subject: [PATCH 1/2] Fix time unit problem related with FutureAdapter in UT --- .../dubbo/rpc/protocol/dubbo/ImplicitCallBackTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/ImplicitCallBackTest.java b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/ImplicitCallBackTest.java index b4c0f6bcd1d..6006be84934 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/ImplicitCallBackTest.java +++ b/dubbo-rpc/dubbo-rpc-default/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/ImplicitCallBackTest.java @@ -242,7 +242,7 @@ public void test_Async_Future() throws Exception { Person ret = demoProxy.get(requestId); Assert.assertEquals(null, ret); Future pFuture = RpcContext.getContext().getFuture(); - ret = pFuture.get(1000, TimeUnit.MICROSECONDS); + ret = pFuture.get(1000 * 1000, TimeUnit.MICROSECONDS); Assert.assertEquals(requestId, ret.getId()); destroyService(); } @@ -264,8 +264,8 @@ public void test_Async_Future_Multi() throws Exception { Assert.assertEquals(null, ret2); Future p2Future = RpcContext.getContext().getFuture(); - ret = p1Future.get(1000, TimeUnit.MICROSECONDS); - ret2 = p2Future.get(1000, TimeUnit.MICROSECONDS); + ret = p1Future.get(1000 * 1000, TimeUnit.MICROSECONDS); + ret2 = p2Future.get(1000 * 1000, TimeUnit.MICROSECONDS); Assert.assertEquals(requestId1, ret.getId()); Assert.assertEquals(requestId2, ret.getId()); destroyService(); @@ -283,7 +283,7 @@ public void test_Async_Future_Ex() throws Exception { Person ret = demoProxy.get(requestId); Assert.assertEquals(null, ret); Future pFuture = RpcContext.getContext().getFuture(); - ret = pFuture.get(1000, TimeUnit.MICROSECONDS); + ret = pFuture.get(1000 * 1000, TimeUnit.MICROSECONDS); Assert.assertEquals(requestId, ret.getId()); } finally { destroyService(); From 08da4520747da3fcec9340a10a36507d9bae2c5c Mon Sep 17 00:00:00 2001 From: WangXin Date: Mon, 26 Feb 2018 17:52:23 +0800 Subject: [PATCH 2/2] fix hessian lite test case fail bug (#1394) * fix hessian lite test case fail bug * update test * remove ignore * Fix time unit problem related with FutureAdapter in UT * revert file --- .../hessian/io/Hessian2StringShortTest.java | 32 ++++++------------- .../{ => beans}/Hessian2StringShortType.java | 8 ++--- .../hessian/io/{ => beans}/PersonType.java | 3 +- 3 files changed, 14 insertions(+), 29 deletions(-) rename hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/{ => beans}/Hessian2StringShortType.java (55%) rename hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/{ => beans}/PersonType.java (95%) diff --git a/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/Hessian2StringShortTest.java b/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/Hessian2StringShortTest.java index e6619d4f7cb..f079ee5b885 100644 --- a/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/Hessian2StringShortTest.java +++ b/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/Hessian2StringShortTest.java @@ -1,5 +1,9 @@ package com.alibaba.com.caucho.hessian.io; +import com.alibaba.com.caucho.hessian.io.base.SerializeTestBase; +import com.alibaba.com.caucho.hessian.io.beans.Hessian2StringShortType; +import com.alibaba.com.caucho.hessian.io.beans.PersonType; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.ArrayList; @@ -7,6 +11,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import org.junit.Test; import static junit.framework.TestCase.assertEquals; @@ -15,7 +20,7 @@ /** * @author jason.shang@hotmail.com */ -public class Hessian2StringShortTest { +public class Hessian2StringShortTest extends SerializeTestBase { @Test public void serialize_string_short_map_then_deserialize() throws Exception { @@ -26,16 +31,7 @@ public void serialize_string_short_map_then_deserialize() throws Exception { stringShortMap.put("last", (short)60); stringShort.stringShortMap = stringShortMap; - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - Hessian2Output out = new Hessian2Output(bout); - - out.writeObject(stringShort); - out.flush(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - Hessian2Input input = new Hessian2Input(bin); - - Hessian2StringShortType deserialize = (Hessian2StringShortType) input.readObject(); + Hessian2StringShortType deserialize = baseHession2Serialize(stringShort); assertTrue(deserialize.stringShortMap != null); assertTrue(deserialize.stringShortMap.size() == 2); assertTrue(deserialize.stringShortMap.get("last") instanceof Short); @@ -52,16 +48,7 @@ public void serialize_string_byte_map_then_deserialize() throws Exception { stringByteMap.put("last", (byte)60); stringShort.stringByteMap = stringByteMap; - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - Hessian2Output out = new Hessian2Output(bout); - - out.writeObject(stringShort); - out.flush(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - Hessian2Input input = new Hessian2Input(bin); - - Hessian2StringShortType deserialize = (Hessian2StringShortType) input.readObject(); + Hessian2StringShortType deserialize = baseHession2Serialize(stringShort); assertTrue(deserialize.stringByteMap != null); assertTrue(deserialize.stringByteMap.size() == 2); assertTrue(deserialize.stringByteMap.get("last") instanceof Byte); @@ -145,8 +132,7 @@ public void serialize_list_then_deserialize() throws Exception { ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); Hessian2Input input = new Hessian2Input(bin); - List deserialize = (List) input.readObject(ArrayList.class, Short.class); -// List deserialize = (List) input.readObject(); + List deserialize = (List) input.readObject(ArrayList.class, Short.class); assertTrue(deserialize != null); assertTrue(deserialize.size() == 2); assertTrue(deserialize.get(1) instanceof Short); diff --git a/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/Hessian2StringShortType.java b/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/beans/Hessian2StringShortType.java similarity index 55% rename from hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/Hessian2StringShortType.java rename to hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/beans/Hessian2StringShortType.java index 4346f05ffc6..66a1ae22de1 100644 --- a/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/Hessian2StringShortType.java +++ b/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/beans/Hessian2StringShortType.java @@ -1,4 +1,4 @@ -package com.alibaba.com.caucho.hessian.io; +package com.alibaba.com.caucho.hessian.io.beans; import java.io.Serializable; import java.util.Map; @@ -11,11 +11,11 @@ */ public class Hessian2StringShortType implements Serializable { - Map stringShortMap; + public Map stringShortMap; - Map stringByteMap; + public Map stringByteMap; - Map stringPersonTypeMap; + public Map stringPersonTypeMap; public Hessian2StringShortType(){ diff --git a/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/PersonType.java b/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/beans/PersonType.java similarity index 95% rename from hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/PersonType.java rename to hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/beans/PersonType.java index e31bf31fbe8..942dec547cf 100644 --- a/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/PersonType.java +++ b/hessian-lite/src/test/java/com/alibaba/com/caucho/hessian/io/beans/PersonType.java @@ -1,7 +1,6 @@ -package com.alibaba.com.caucho.hessian.io; +package com.alibaba.com.caucho.hessian.io.beans; import java.io.Serializable; -import java.util.Arrays; import java.util.List; /**