diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_Monitor.java b/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_Monitor.java deleted file mode 100644 index 273e134d..00000000 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_Monitor.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.bench4q.master.integrated; - -import static org.junit.Assert.*; - -import org.bench4q.master.domain.entity.Monitor; -import org.bench4q.master.domain.entity.TestPlan; -import org.bench4q.master.unitTest.TestBase_MakeUpTestPlan; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:service-test-context.xml" }) -public class Test_Monitor extends TestBase_MakeUpTestPlan { - - @Before - public void prepare() { - prepareForTestPlanRunning(); - submitATestPlanWithOneScript(); - } - - @Test - public void testDoAfterRun() { - TestPlan testPlan = this.getTestPlanRepository().getTestPlanInDomainBy( - getTestPlanRunIdUuid()); - assertEquals(1, testPlan.getMonitors().size()); - for (Monitor monitor : testPlan.getMonitors()) { - monitor.doAfterRun(); - } - } - -} diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_TestMonitorSampler.java b/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_TestMonitorSampler.java index 4b971674..75deb6cf 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_TestMonitorSampler.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_TestMonitorSampler.java @@ -4,7 +4,6 @@ import static org.junit.Assert.assertTrue; import org.bench4q.master.domain.entity.Monitor; import org.bench4q.master.domain.valueobject.datastatistics.TestMonitorSampler; -import org.bench4q.master.unitTest.TestBase_MakeUpTestPlan; import org.bench4q.share.models.monitor.MonitorMain; import org.junit.After; import org.junit.Assert; @@ -17,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:service-test-context.xml" }) -public class Test_TestMonitorSampler extends TestBase_MakeUpTestPlan { +public class Test_TestMonitorSampler { private TestMonitorSampler testMonitorSampler; private Monitor monitor; diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_TestPlan.java b/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_TestPlan.java index f098e85c..e37daba3 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_TestPlan.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_TestPlan.java @@ -53,6 +53,7 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan { TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain( testPlanFromRepo); testPlanInDomain.run(); + this.getTestPlanRepository().attachRunningTestPlan(testPlanInDomain); assertEquals(TestPlanStatus.InRunning.name(), testPlanInDomain.getCurrentStatus()); @@ -72,8 +73,7 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan { testPlanScript.getRequireLoad()); assertNotNull(testPlanScript.getRunningAgentsDB()); assertEquals(1, testPlanScript.getRunningAgentsDB().size()); - RunningAgentDB runningAgentDB = extractRunningAgent(testPlanScript, - Test_AGENT_HOSTNAME); + RunningAgentDB runningAgentDB = extractTheFirstRunningAgent(testPlanScript); assertNotNull(runningAgentDB); assertEquals(EACH_SCRIPT_LOAD_SMALLSCALE, runningAgentDB.getLoadInUse()); Thread.sleep(10000); diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/TestBase_MakeUpTestPlan.java b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/TestBase_MakeUpTestPlan.java index c9ccf804..faa72e44 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/TestBase_MakeUpTestPlan.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/TestBase_MakeUpTestPlan.java @@ -218,9 +218,8 @@ public class TestBase_MakeUpTestPlan extends TestBase { return; } testPlan.setCurrentStatus(TestPlanStatus.Complete.name()); - RunningAgentDB runningAgent = extractRunningAgent( - testPlan.extracSpecifiedScript(getScriptId()), - Test_AGENT_HOSTNAME); + RunningAgentDB runningAgent = extractTheFirstRunningAgent(testPlan + .extracSpecifiedScript(getScriptId())); RunningScriptInterface runningScript = testPlan .extracSpecifiedScript(getScriptId()); runningScript.doForComplete(); @@ -234,13 +233,11 @@ public class TestBase_MakeUpTestPlan extends TestBase { this.getTestPlanRepository().detach(testPlan.getId()); } - protected RunningAgentDB extractRunningAgent(TestPlanScript testPlanScript, - String hostName) { + protected RunningAgentDB extractTheFirstRunningAgent( + TestPlanScript testPlanScript) { for (RunningAgentDB runningAgentDB : testPlanScript .getRunningAgentsDB()) { - if (runningAgentDB.getAgent().getHostName().equals(hostName)) { - return runningAgentDB; - } + return runningAgentDB; } return null; } diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/entity/Test_Monitor.java b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/entity/Test_Monitor.java deleted file mode 100644 index 607ba740..00000000 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/entity/Test_Monitor.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.bench4q.master.unitTest.entity; - -import static org.junit.Assert.*; - -import org.bench4q.master.domain.entity.Monitor; -import org.bench4q.master.domain.entity.TestPlan; -import org.bench4q.master.unitTest.TestBase_MakeUpTestPlan; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:service-test-context.xml" }) -public class Test_Monitor extends TestBase_MakeUpTestPlan { - - @Before - public void prepare() { - prepareForTestPlanRunning(); - submitATestPlanWithOneScript(); - } - - @Test - public void testDoAfterRun() { - TestPlan testPlan = this.getTestPlanRepository().getTestPlanInDomainBy( - getTestPlanRunIdUuid()); - assertEquals(1, testPlan.getMonitors().size()); - for (Monitor monitor : testPlan.getMonitors()) { - monitor.doAfterRun(); - } - for (Monitor monitor : getTestPlanRepository().getTestPlanInDomainBy( - getTestPlanRunIdUuid()).getMonitors()) { - assertEquals(5, monitor.getResults().size()); - } - } - - @After - public void clear() { - cleanUpForTestPlanRunning(); - } - -} diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/entity/Test_TestPlan.java b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/entity/Test_TestPlan.java index 7f442b02..67c8173a 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/entity/Test_TestPlan.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/entity/Test_TestPlan.java @@ -90,8 +90,8 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan { } private TestPlan getTestPlan() { - TestPlan testPlanFromRepo = this.getTestPlanRepository().getTestPlanInDomainBy( - getTestPlanRunIdUuid()); + TestPlan testPlanFromRepo = this.getTestPlanRepository() + .getTestPlanInDomainBy(getTestPlanRunIdUuid()); TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain( testPlanFromRepo); return testPlanInDomain; @@ -115,4 +115,5 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan { this.getHaPool().checkAllHeartBeat(); assertEquals(500, this.getHaPool().getCurrentAvailableLoad()); } + } diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/infrastructure/ha/Test_highAvailableWithMockMessenger.java b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/infrastructure/ha/Test_highAvailableWithMockMessenger.java index ec3d50b7..35295d29 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/infrastructure/ha/Test_highAvailableWithMockMessenger.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/infrastructure/ha/Test_highAvailableWithMockMessenger.java @@ -20,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import stubs.Mock_AgentMessenger; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { HighAvailablePoolImpl.class, AgentRepository.class, Mock_AgentMessenger.class, HttpRequester.class, diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/repository/Test_AgentRepository.java b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/repository/Test_AgentRepository.java index b0a97d3d..291df99b 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/repository/Test_AgentRepository.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/repository/Test_AgentRepository.java @@ -4,6 +4,7 @@ import static org.junit.Assert.*; import org.bench4q.master.domain.entity.Agent; import org.bench4q.master.domain.repository.AgentRepository; +import org.bench4q.master.helper.SessionHelper; import org.bench4q.share.enums.master.AgentStatus; import org.junit.Test; import org.junit.runner.RunWith; @@ -12,7 +13,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:service-test-context.xml" }) +@ContextConfiguration(classes = { AgentRepository.class, SessionHelper.class }) public class Test_AgentRepository { private AgentRepository agentRepoitory; diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/infrastructure/ha/Mock_AgentMessenger.java b/Bench4Q-Master/src/test/java/stubs/Mock_AgentMessenger.java similarity index 97% rename from Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/infrastructure/ha/Mock_AgentMessenger.java rename to Bench4Q-Master/src/test/java/stubs/Mock_AgentMessenger.java index 3b2257bf..c61d29bd 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/infrastructure/ha/Mock_AgentMessenger.java +++ b/Bench4Q-Master/src/test/java/stubs/Mock_AgentMessenger.java @@ -1,4 +1,4 @@ -package org.bench4q.master.unitTest.infrastructure.ha; +package stubs; import java.io.File; import java.util.List;