From 0d42c3e97a6b39808a56d9f3f81f9b6ea47537fb Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Thu, 28 Aug 2014 08:56:38 +0800 Subject: [PATCH] refactor the tests refactor the tests --- .../datastatistics/Test_ScriptSample.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/datastatistics/Test_ScriptSample.java b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/datastatistics/Test_ScriptSample.java index 368bb496..566aced1 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/datastatistics/Test_ScriptSample.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/datastatistics/Test_ScriptSample.java @@ -12,8 +12,6 @@ import org.bench4q.master.domain.RunningAgentInterface; import org.bench4q.master.domain.entity.Agent; import org.bench4q.master.domain.factory.RunningAgentFactory; import org.bench4q.master.domain.valueobject.datastatistics.RunningScriptSampler; -import org.bench4q.share.enums.master.AgentStatus; -import org.bench4q.share.models.master.statistics.ScriptResultModel; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -31,8 +29,14 @@ public class Test_ScriptSample { testcase2.add(Agent.createAgentWithoutId("127.0.0.2", 6565, 500)); } + /** + * The destiny is to justify if a runningAgent is stopped, if it will + * decrease the totalSuccessCount + * + * @throws JAXBException + */ @Test - public void test() throws JAXBException { + public void testForStopOneRunningAgentWhenSample() throws JAXBException { ArrayList runningAgents = new ArrayList(); runningAgents.add(this.runningAgentFactory .buildRunningAgentWithOutIdAndRunningScript( @@ -41,18 +45,13 @@ public class Test_ScriptSample { .buildRunningAgentWithOutIdAndRunningScript( this.testcase2.get(1), 20, UUID.randomUUID())); RunningScriptSampler sampler = new RunningScriptSampler(runningAgents); - long totalSuccessCountBeforeKill = sampler.getResultModelFromAgent() + long totalSuccessCountBeforeStop = sampler.getResultModelFromAgent() .getScriptBriefResultModel().getTotalSuccessCountFromBegin(); - kill(this.testcase2.get(0)); + runningAgents.get(0).stop(); - long totalSuccessCountAfterKill = sampler.getResultModelFromAgent() + long totalSuccessCountAfterStop = sampler.getResultModelFromAgent() .getScriptBriefResultModel().getTotalSuccessCountFromBegin(); - assertTrue(totalSuccessCountAfterKill >= totalSuccessCountBeforeKill); - - } - - private void kill(Agent agent) { - agent.setCurrentEnumStatus(AgentStatus.BreakDown); + assertTrue(totalSuccessCountAfterStop >= totalSuccessCountBeforeStop); } }