refactor port test

This commit is contained in:
fanfuxiaoran 2014-05-14 13:35:26 +08:00
parent bf8f1693ee
commit 67a90d69f3
2 changed files with 14 additions and 3 deletions

View File

@ -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<PortModel> ports = new LinkedList<PortModel>();
organizeRecordPortResponseModel.setPortModels(ports);
}
return organizeRecordPortResponseModel;
}
}

View File

@ -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);