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;
}
@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() {
return testPlanScriptResults;
}
@ -266,11 +266,11 @@ public class TestPlanScript extends Observable implements
// }
private void doPeriodicalBrief() {
try {
this.setChanged();
ScriptResultModel scriptResultModel = this.getSampler()
.getResultModelFromAgent();
notifyObserver(scriptResultModel.getScriptBriefResultModel());
notifyObserver(scriptResultModel.getScriptPagesBriefModel());
notifyObserver(scriptResultModel.getScriptBriefResultModel());
notifyObserver(scriptResultModel.getScriptBehaviorsBriefModel());
} catch (Exception e) {
logger.info(ExceptionLog.getStackTrace(e));
@ -279,9 +279,9 @@ public class TestPlanScript extends Observable implements
}
private void notifyObserver(SampleModel sample) {
this.setChanged();
this.notifyObservers(sample);
}
public TestPlanScript doForComplete() {

View File

@ -61,6 +61,7 @@ public class TestScriptResultSave implements Observer {
public boolean doSaveResult(UUID testPlanRunId, int scriptId,
Object resultModel, Date now) {
Session session = this.getSessionHelper().openSession();
try {
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.assertNotNull;
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.TestPlan;
import org.bench4q.master.domain.entity.TestPlanScript;
import org.bench4q.master.domain.factory.TestPlanFactory;
import org.bench4q.master.domain.service.TestPlanService;
import org.bench4q.master.exception.ExceptionLog;
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
import org.bench4q.share.enums.master.TestPlanStatus;
import org.bench4q.share.helper.MarshalHelper;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -45,7 +52,7 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan {
@Before
public void prepare() {
this.getHaPool().timerTask();
submitATestPlanWithOneScript();
submitATestPlanWithOneScript();
}
@After
@ -54,16 +61,27 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan {
}
@Test
public void testDoAfterRun() throws InterruptedException {
public void testDoAfterRun() throws InterruptedException, JAXBException {
assertNotNull(getTestPlanRunIdUuid());
try{
TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain(
this.getTestPlanRepository().getTestPlanBy(
getTestPlanRunIdUuid()));
assertEquals(TestPlanStatus.InRunning,
testPlanInDomain.run());
assertEquals(TestPlanStatus.InRunning, testPlanInDomain.run());
Thread.sleep(4000);
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));
}
}