From 67a90d69f30b22bed7b8daa45d2e7dd99f16a84f Mon Sep 17 00:00:00 2001 From: fanfuxiaoran <495538672@qq.com> Date: Wed, 14 May 2014 13:35:26 +0800 Subject: [PATCH] refactor port test --- .../web/masterMessager/RecordPortMessager.java | 15 ++++++++++++--- .../web/test/masterMessager/PortMessageTest.java | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/masterMessager/RecordPortMessager.java b/Bench4Q-Web/src/main/java/org/bench4q/web/masterMessager/RecordPortMessager.java index 05782c5f..83be66ca 100644 --- a/Bench4Q-Web/src/main/java/org/bench4q/web/masterMessager/RecordPortMessager.java +++ b/Bench4Q-Web/src/main/java/org/bench4q/web/masterMessager/RecordPortMessager.java @@ -2,6 +2,8 @@ package org.bench4q.web.masterMessager; import java.io.IOException; import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; import javax.xml.bind.JAXBException; @@ -9,6 +11,7 @@ import javax.xml.bind.JAXBException; import org.bench4q.share.communication.HttpRequester.HttpResponse; import org.bench4q.share.helper.MarshalHelper; import org.bench4q.share.models.master.OrganizeRecordPortResponseModel; +import org.bench4q.share.models.master.PortModel; import org.springframework.stereotype.Component; @Component @@ -66,8 +69,14 @@ public class RecordPortMessager extends MasterMessager { private OrganizeRecordPortResponseModel extractOrganizeRecordPortResponseModel( HttpResponse httpResponse) throws JAXBException { - return (OrganizeRecordPortResponseModel) MarshalHelper.unmarshal( - OrganizeRecordPortResponseModel.class, - httpResponse.getContent()); + OrganizeRecordPortResponseModel organizeRecordPortResponseModel = (OrganizeRecordPortResponseModel) MarshalHelper + .unmarshal(OrganizeRecordPortResponseModel.class, + httpResponse.getContent()); + if (organizeRecordPortResponseModel.getPortModels() == null) { + List ports = new LinkedList(); + organizeRecordPortResponseModel.setPortModels(ports); + + } + return organizeRecordPortResponseModel; } } diff --git a/Bench4Q-Web/src/test/java/org/bench4q/web/test/masterMessager/PortMessageTest.java b/Bench4Q-Web/src/test/java/org/bench4q/web/test/masterMessager/PortMessageTest.java index 2d5fecf6..8d612d63 100644 --- a/Bench4Q-Web/src/test/java/org/bench4q/web/test/masterMessager/PortMessageTest.java +++ b/Bench4Q-Web/src/test/java/org/bench4q/web/test/masterMessager/PortMessageTest.java @@ -79,11 +79,13 @@ public class PortMessageTest extends MessagerTestBase { .loadPorts(null); assertNotNull(responseModel); assertTrue(responseModel.isSuccess()); + assertNotNull(responseModel.getPortModels()); } private String createResponse() throws JAXBException { OrganizeRecordPortResponseModel organizeRecordPortResponseModel = new OrganizeRecordPortResponseModel(); organizeRecordPortResponseModel.setSuccess(true); + String response = MarshalHelper.marshal( OrganizeRecordPortResponseModel.class, organizeRecordPortResponseModel);