remove the bug that in save testScript result:behavior and page can not

be saved:in testPlanScript the notify is wrong
This commit is contained in:
fanfuxiaoran 2014-03-26 15:40:17 +08:00
parent 99f8789c33
commit 42cf1b02bf
3 changed files with 29 additions and 10 deletions

View File

@ -111,7 +111,7 @@ public class TestPlanScript extends Observable implements
this.testPlan = testPlan; this.testPlan = testPlan;
} }
@OneToMany(mappedBy = "testPlanScript", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) @OneToMany(mappedBy = "testPlanScript", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
public Set<TestPlanScriptResult> getTestPlanScriptResults() { public Set<TestPlanScriptResult> getTestPlanScriptResults() {
return testPlanScriptResults; return testPlanScriptResults;
} }
@ -266,11 +266,11 @@ public class TestPlanScript extends Observable implements
// } // }
private void doPeriodicalBrief() { private void doPeriodicalBrief() {
try { try {
this.setChanged();
ScriptResultModel scriptResultModel = this.getSampler() ScriptResultModel scriptResultModel = this.getSampler()
.getResultModelFromAgent(); .getResultModelFromAgent();
notifyObserver(scriptResultModel.getScriptBriefResultModel());
notifyObserver(scriptResultModel.getScriptPagesBriefModel()); notifyObserver(scriptResultModel.getScriptPagesBriefModel());
notifyObserver(scriptResultModel.getScriptBriefResultModel());
notifyObserver(scriptResultModel.getScriptBehaviorsBriefModel()); notifyObserver(scriptResultModel.getScriptBehaviorsBriefModel());
} catch (Exception e) { } catch (Exception e) {
logger.info(ExceptionLog.getStackTrace(e)); logger.info(ExceptionLog.getStackTrace(e));
@ -279,9 +279,9 @@ public class TestPlanScript extends Observable implements
} }
private void notifyObserver(SampleModel sample) { private void notifyObserver(SampleModel sample) {
this.setChanged();
this.notifyObservers(sample); this.notifyObservers(sample);
} }
public TestPlanScript doForComplete() { public TestPlanScript doForComplete() {

View File

@ -61,6 +61,7 @@ public class TestScriptResultSave implements Observer {
public boolean doSaveResult(UUID testPlanRunId, int scriptId, public boolean doSaveResult(UUID testPlanRunId, int scriptId,
Object resultModel, Date now) { Object resultModel, Date now) {
Session session = this.getSessionHelper().openSession(); Session session = this.getSessionHelper().openSession();
try { try {
TestPlan testPlan = this.getTestPlanRepository().doGetTestPlanBy( TestPlan testPlan = this.getTestPlanRepository().doGetTestPlanBy(

View File

@ -3,12 +3,19 @@ package org.bench4q.mater.test.entity;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import javax.xml.bind.JAXBException;
import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.Monitor; import org.bench4q.master.domain.entity.Monitor;
import org.bench4q.master.domain.entity.TestPlan; import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.entity.TestPlanScript;
import org.bench4q.master.domain.factory.TestPlanFactory; import org.bench4q.master.domain.factory.TestPlanFactory;
import org.bench4q.master.domain.service.TestPlanService; import org.bench4q.master.domain.service.TestPlanService;
import org.bench4q.master.exception.ExceptionLog;
import org.bench4q.master.test.TestBase_MakeUpTestPlan; import org.bench4q.master.test.TestBase_MakeUpTestPlan;
import org.bench4q.share.enums.master.TestPlanStatus; import org.bench4q.share.enums.master.TestPlanStatus;
import org.bench4q.share.helper.MarshalHelper;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -45,7 +52,7 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan {
@Before @Before
public void prepare() { public void prepare() {
this.getHaPool().timerTask(); this.getHaPool().timerTask();
submitATestPlanWithOneScript(); submitATestPlanWithOneScript();
} }
@After @After
@ -54,16 +61,27 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan {
} }
@Test @Test
public void testDoAfterRun() throws InterruptedException { public void testDoAfterRun() throws InterruptedException, JAXBException {
assertNotNull(getTestPlanRunIdUuid()); assertNotNull(getTestPlanRunIdUuid());
try{
TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain( TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain(
this.getTestPlanRepository().getTestPlanBy( this.getTestPlanRepository().getTestPlanBy(
getTestPlanRunIdUuid())); getTestPlanRunIdUuid()));
assertEquals(TestPlanStatus.InRunning, assertEquals(TestPlanStatus.InRunning, testPlanInDomain.run());
testPlanInDomain.run());
Thread.sleep(4000); Thread.sleep(4000);
for (Monitor monitor : getTestPlan().getMonitors()) { for (Monitor monitor : getTestPlan().getMonitors()) {
assertTrue(monitor.getResults().size()>0); assertTrue(monitor.getResults().size() > 0);
}
for (TestPlanScript testPlanScript : getTestPlan().getTestPlanScripts()) {
Logger.getLogger(Test_TestPlan.class)
.info("testPlanScript:"+
testPlanScript.getTestPlanScriptResults().size());
assertTrue(testPlanScript.getTestPlanScriptResults().size() > 1);
}
}catch(Exception e){
Logger.getLogger(Test_TestPlan.class).info(
ExceptionLog.getStackTrace(e));
} }
} }