DUBBO-71 Graceful shutdown-半关闭状态

codec 测试调整 (heartbeat data不能为非空)
增加event 测试

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@341 1a56cb94-b969-4eaa-88fa-be21384802f2
This commit is contained in:
chao.liuc 2011-11-16 08:24:07 +00:00
parent 2fdc57d58b
commit 216ff95e1f
3 changed files with 34 additions and 5 deletions

View File

@ -97,7 +97,7 @@ public class Request {
}
public boolean isHeartbeat() {
return mEvent && HEARTBEAT_EVENT.equals(mData);
return mEvent && HEARTBEAT_EVENT == mData;
}
@Deprecated

View File

@ -124,7 +124,7 @@ public class Response {
}
public boolean isHeartbeat() {
return mEvent && HEARTBEAT_EVENT.equals(mResult);
return mEvent && HEARTBEAT_EVENT == mResult;
}
@Deprecated

View File

@ -203,7 +203,7 @@ public class ExchangeCodecTest extends TelnetCodecTest{
Assert.assertEquals(errorString, obj.getErrorMessage());
}
@Test
public void test_Decode_Return_Request_Heartbeat_Object() throws IOException{
public void test_Decode_Return_Request_Event_Object() throws IOException{
//|10011111|20-stats=ok|id=0|length=0
byte[] header = new byte[] { MAGIC_HIGH, MAGIC_LOW, (byte) 0xff, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
Person person = new Person();
@ -212,10 +212,39 @@ public class ExchangeCodecTest extends TelnetCodecTest{
Request obj = (Request)decode(request);
Assert.assertEquals(person, obj.getData());
Assert.assertEquals(true, obj.isTwoWay());
Assert.assertEquals(true, obj.isHeartbeat());
Assert.assertEquals(true, obj.isEvent());
Assert.assertEquals("2.0.0", obj.getVersion());
System.out.println(obj);
}
}
@Test
public void test_Decode_Return_Request_Event_String() throws IOException{
//|10011111|20-stats=ok|id=0|length=0
byte[] header = new byte[] { MAGIC_HIGH, MAGIC_LOW, (byte) 0xff, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
String event = Request.READONLY_EVENT;
byte[] request = getRequestBytes(event, header);
Request obj = (Request)decode(request);
Assert.assertEquals(event, obj.getData());
Assert.assertEquals(true, obj.isTwoWay());
Assert.assertEquals(true, obj.isEvent());
Assert.assertEquals("2.0.0", obj.getVersion());
System.out.println(obj);
}
@Test
public void test_Decode_Return_Request_Heartbeat_Object() throws IOException{
//|10011111|20-stats=ok|id=0|length=0
byte[] header = new byte[] { MAGIC_HIGH, MAGIC_LOW, (byte) 0xff, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
byte[] request = getRequestBytes(null, header);
Request obj = (Request)decode(request);
Assert.assertEquals(null, obj.getData());
Assert.assertEquals(true, obj.isTwoWay());
Assert.assertEquals(true, obj.isHeartbeat());
Assert.assertEquals("2.0.0", obj.getVersion());
System.out.println(obj);
}
@Test
public void test_Decode_Return_Request_Object() throws IOException{
//|10011111|20-stats=ok|id=0|length=0