From 789b4669a400a8418eadc7e082c823fe73fcbae5 Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Mon, 16 Dec 2013 22:59:31 +0800 Subject: [PATCH] refacotr and add log --- .../org/bench4q/master/helper/MarshalHelper.java | 9 +++++++-- .../test/service/TestTestPlanScriptService.java | 15 +++++++++++++++ .../master/test/testplan/TestPlanTester.java | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/bench4q/master/helper/MarshalHelper.java b/src/main/java/org/bench4q/master/helper/MarshalHelper.java index f6290df8..36763e39 100644 --- a/src/main/java/org/bench4q/master/helper/MarshalHelper.java +++ b/src/main/java/org/bench4q/master/helper/MarshalHelper.java @@ -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; } } diff --git a/src/test/java/org/bench4q/master/test/service/TestTestPlanScriptService.java b/src/test/java/org/bench4q/master/test/service/TestTestPlanScriptService.java index a6e0af97..7e967a9a 100644 --- a/src/test/java/org/bench4q/master/test/service/TestTestPlanScriptService.java +++ b/src/test/java/org/bench4q/master/test/service/TestTestPlanScriptService.java @@ -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 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); } + } diff --git a/src/test/java/org/bench4q/master/test/testplan/TestPlanTester.java b/src/test/java/org/bench4q/master/test/testplan/TestPlanTester.java index db252c97..20a92ce5 100644 --- a/src/test/java/org/bench4q/master/test/testplan/TestPlanTester.java +++ b/src/test/java/org/bench4q/master/test/testplan/TestPlanTester.java @@ -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;