refacotr and add log

This commit is contained in:
coderfengyun 2013-12-16 22:59:31 +08:00
parent 0829d5caef
commit 789b4669a4
3 changed files with 23 additions and 3 deletions

View File

@ -8,8 +8,13 @@ import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import org.apache.log4j.Logger;
import org.bench4q.master.exception.ExceptionLog;
public class MarshalHelper {
private static Logger logger = Logger.getLogger(MarshalHelper.class);
public static String marshal(Class<?> classToMarshal, Object input) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
Marshaller marshaller;
@ -18,7 +23,7 @@ public class MarshalHelper {
.createMarshaller();
marshaller.marshal(input, os);
} catch (JAXBException e) {
e.printStackTrace();
logger.error(ExceptionLog.getExceptionStackTrace(e));
}
return os.toString();
}
@ -31,7 +36,7 @@ public class MarshalHelper {
return unmarshaller.unmarshal(new ByteArrayInputStream(input
.getBytes()));
} catch (JAXBException e) {
e.printStackTrace();
logger.error(ExceptionLog.getExceptionStackTrace(e));
return null;
}
}

View File

@ -20,6 +20,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
public class TestTestPlanScriptService {
private static final int WRONG_SCRIPT_ID = 99999;
private static final String WRONG_TEST_PLAN_RUN_ID = "0cdca8da-5b61-4bff-be48-8075e5d2fa64";
private static final int PROPER_SCRIPT_ID = 17;
private static final String TEST_PLAN_RUN_ID = "4e7d6b05-ab25-4d8f-a54d-2b2a60ae4934";
private TestPlanScriptService testPlanScriptService;
private TestPlanScriptService getTestPlanScriptService() {
@ -43,6 +46,17 @@ public class TestTestPlanScriptService {
assertTrue(scriptBriefResultModels.size() == 0);
}
@Test
public void testLoadScriptResultRightly() {
TestPlanScript testPlanScript = this.getTestPlanScriptService()
.getTestPlanScript(PROPER_SCRIPT_ID,
UUID.fromString(TEST_PLAN_RUN_ID));
List<TestPlanScriptResult> scriptBriefList = this
.getTestPlanScriptService().queryTestPlanScriptResult(
testPlanScript);
assertTrue(scriptBriefList.size() > 0);
}
@Test
public void testSaveScriptBriefResultWithWrongScriptIdOrRunId() {
ScriptBriefResultModel briefResultModel = new ScriptBriefResultModel();
@ -60,4 +74,5 @@ public class TestTestPlanScriptService {
assertTrue(this.getTestPlanScriptService()
.queryTestPlanScriptResult(testPlanScript).size() == 0);
}
}

View File

@ -29,7 +29,7 @@ public class TestPlanTester extends TestBase {
private TestPlanBusinessModel testPlanBusinessModel = new TestPlanBusinessModel();
private String _url = TestBase.BASE_URL + "/testPlan";
private int scriptSumNum;
private static int SCRIPTID1 = 11;
private static int SCRIPTID1 = 32;
private static int SCRIPTID2 = 2;
// private static int EACH_SCRIPT_LOAD_LargeSCALE = 12000;
private static int EACH_SCRIPT_LOAD_SMALLSCALE = 40;