little refa

This commit is contained in:
coderfengyun 2014-02-21 16:23:10 +08:00
parent d6fc35085c
commit fe7067b4b0
15 changed files with 98 additions and 99 deletions

View File

@ -3,8 +3,8 @@ package org.bench4q.master.api;
import java.util.ArrayList;
import java.util.List;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.entity.Agent;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.domain.service.AgentService;
import org.bench4q.master.domain.service.UserService;
import org.bench4q.master.infrastructure.communication.AgentStateMessenger;

View File

@ -3,8 +3,8 @@ package org.bench4q.master.api;
import java.util.ArrayList;
import java.util.List;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.entity.Port;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.domain.service.PortPoolService;
import org.bench4q.master.domain.service.UserService;
import org.bench4q.share.models.master.OrganizeRecordPortResponseModel;

View File

@ -13,9 +13,9 @@ import javax.xml.bind.JAXBException;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.entity.Port;
import org.bench4q.master.domain.entity.Script;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.domain.service.PortPoolService;
import org.bench4q.master.domain.service.ScriptService;
import org.bench4q.master.domain.service.UserService;

View File

@ -9,12 +9,12 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.RunningScript;
import org.bench4q.master.domain.TestPlanContext;
import org.bench4q.master.domain.TestPlanInBusiness;
import org.bench4q.master.domain.entity.Monitor;
import org.bench4q.master.domain.entity.TestPlanDB;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.domain.service.TestPlanEngine;
import org.bench4q.master.domain.service.TestPlanScriptResultService;
import org.bench4q.master.domain.service.TestPlanService;

View File

@ -1,4 +1,4 @@
package org.bench4q.master.api.modelfactory;
package org.bench4q.master.domain.factory;
import java.util.ArrayList;
import java.util.List;

View File

@ -5,7 +5,6 @@ import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.entity.Monitor;
import org.bench4q.master.domain.entity.PlanedConfig;
import org.bench4q.master.domain.entity.TestPlanDB;

View File

@ -3,10 +3,10 @@ package org.bench4q.master.domain.service;
import java.util.List;
import java.util.UUID;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.TestPlanInBusiness;
import org.bench4q.master.domain.entity.TestPlanDB;
import org.bench4q.master.domain.entity.User;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.domain.factory.TestPlanFactory;
import org.bench4q.master.domain.repository.TestPlanRepository;
import org.bench4q.share.enums.master.TestPlanStatus;

View File

@ -4,9 +4,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.TestPlanInBusiness;
import org.bench4q.master.domain.entity.User;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.domain.repository.TestPlanRepository;
import org.bench4q.master.domain.repository.UserRepository;
import org.bench4q.master.domain.service.ScriptService;

View File

@ -7,9 +7,9 @@ import java.util.UUID;
import javax.xml.bind.JAXBException;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.TestPlanInBusiness;
import org.bench4q.master.domain.entity.User;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
import org.bench4q.share.communication.HttpRequester.HttpResponse;
import org.bench4q.share.helper.MarshalHelper;

View File

@ -5,10 +5,10 @@ import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.RunningAgent;
import org.bench4q.master.domain.RunningScript;
import org.bench4q.master.domain.entity.Agent;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
import org.bench4q.master.testplan.datastatistics.PagesBriefStatistics;
import org.junit.BeforeClass;

View File

@ -2,8 +2,8 @@ package org.bench4q.master.test.domain;
import java.util.UUID;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.TestPlanContext;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
import org.junit.BeforeClass;
import org.junit.Test;

View File

@ -5,9 +5,9 @@ import static org.junit.Assert.*;
import java.util.List;
import java.util.UUID;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.TestPlanInBusiness;
import org.bench4q.master.domain.entity.User;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.domain.service.TestPlanScriptResultService;
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
import org.bench4q.share.helper.TestHelper;

View File

@ -5,11 +5,11 @@ import static org.junit.Assert.*;
import java.util.Set;
import java.util.UUID;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.TestPlanInBusiness;
import org.bench4q.master.domain.entity.TestPlanDB;
import org.bench4q.master.domain.entity.TestPlanScript;
import org.bench4q.master.domain.entity.User;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
import org.bench4q.share.enums.master.TestPlanStatus;
import org.junit.After;

View File

@ -1,85 +1,85 @@
package org.bench4q.master.test.testplan;
import static org.junit.Assert.*;
import java.util.UUID;
import org.bench4q.master.api.modelfactory.BusinessModelMapFactory;
import org.bench4q.master.domain.TestPlanContext;
import org.bench4q.master.helper.ApplicationContextHelper;
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
import org.bench4q.master.testplan.TestPlanContainer;
import org.bench4q.share.models.master.TestPlanBusinessModel;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
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_TestPlanContainer extends TestBase_MakeUpTestPlan {
private TestPlanContainer testPlanContainer;
private TestPlanContainer getTestPlanContainer() {
return testPlanContainer;
}
@Autowired
private void setTestPlanContainer(TestPlanContainer testPlanContainer) {
this.testPlanContainer = testPlanContainer;
}
@SuppressWarnings("resource")
@BeforeClass
public static void beforeClass() {
new ClassPathXmlApplicationContext("classpath:service-test-context.xml");
}
public Test_TestPlanContainer() {
this.setTestPlanContainer(ApplicationContextHelper.getContext()
.getBean(TestPlanContainer.class));
}
private void addTaskToContainer() {
this.setTestPlanRunIdUuid(UUID.randomUUID());
TestPlanBusinessModel testPlanBusinessModel = new TestPlanBusinessModel();
testPlanBusinessModel.setName("Test");
testPlanBusinessModel
.setRunningScriptModels(createOneScriptList(USE_SCRIPT));
testPlanBusinessModel.setMonitorModels(createOneMonitorList());
this.getTestPlanContainer().addATask(
this.getTestPlanRunIdUuid(),
new TestPlanContext(BusinessModelMapFactory
.toBusiness(testPlanBusinessModel), this
.getTestPlanRunIdUuid()));
}
@Test
public void testAddATask() {
assertEquals(0, this.getTestPlanContainer().queryTaskCount());
addTaskToContainer();
assertEquals(1, this.getTestPlanContainer().queryTaskCount());
assertNotNull(this.getTestPlanContainer().queryTestPlanContext(
this.getTestPlanRunIdUuid()));
}
@After
public void removeThatTask() {
this.getTestPlanContainer().reset();
}
@Test
public void testDoForTestPlanComplete() {
testAddATask();
this.getTestPlanContainer().doForTestPlanComplete(
this.getTestPlanRunIdUuid());
assertEquals(0, this.getTestPlanContainer().queryTaskCount());
assertNull(this.getTestPlanContainer().queryTestPlanContext(
this.getTestPlanRunIdUuid()));
}
}
package org.bench4q.master.test.testplan;
import static org.junit.Assert.*;
import java.util.UUID;
import org.bench4q.master.domain.TestPlanContext;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.helper.ApplicationContextHelper;
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
import org.bench4q.master.testplan.TestPlanContainer;
import org.bench4q.share.models.master.TestPlanBusinessModel;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
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_TestPlanContainer extends TestBase_MakeUpTestPlan {
private TestPlanContainer testPlanContainer;
private TestPlanContainer getTestPlanContainer() {
return testPlanContainer;
}
@Autowired
private void setTestPlanContainer(TestPlanContainer testPlanContainer) {
this.testPlanContainer = testPlanContainer;
}
@SuppressWarnings("resource")
@BeforeClass
public static void beforeClass() {
new ClassPathXmlApplicationContext("classpath:service-test-context.xml");
}
public Test_TestPlanContainer() {
this.setTestPlanContainer(ApplicationContextHelper.getContext()
.getBean(TestPlanContainer.class));
}
private void addTaskToContainer() {
this.setTestPlanRunIdUuid(UUID.randomUUID());
TestPlanBusinessModel testPlanBusinessModel = new TestPlanBusinessModel();
testPlanBusinessModel.setName("Test");
testPlanBusinessModel
.setRunningScriptModels(createOneScriptList(USE_SCRIPT));
testPlanBusinessModel.setMonitorModels(createOneMonitorList());
this.getTestPlanContainer().addATask(
this.getTestPlanRunIdUuid(),
new TestPlanContext(BusinessModelMapFactory
.toBusiness(testPlanBusinessModel), this
.getTestPlanRunIdUuid()));
}
@Test
public void testAddATask() {
assertEquals(0, this.getTestPlanContainer().queryTaskCount());
addTaskToContainer();
assertEquals(1, this.getTestPlanContainer().queryTaskCount());
assertNotNull(this.getTestPlanContainer().queryTestPlanContext(
this.getTestPlanRunIdUuid()));
}
@After
public void removeThatTask() {
this.getTestPlanContainer().reset();
}
@Test
public void testDoForTestPlanComplete() {
testAddATask();
this.getTestPlanContainer().doForTestPlanComplete(
this.getTestPlanRunIdUuid());
assertEquals(0, this.getTestPlanContainer().queryTaskCount());
assertNull(this.getTestPlanContainer().queryTestPlanContext(
this.getTestPlanRunIdUuid()));
}
}

View File

@ -8,7 +8,7 @@
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<context:component-scan
base-package="org.bench4q.master.domain.service,org.bench4q.master.infrastructure.communication,org.bench4q.master.report, org.bench4q.master.helper, org.bench4q.master.testplan, org.bench4q.share, org.bench4q.master.api.modelfactory, org.bench4q.master.domain.factory, org.bench4q.master.domain.repository" />
base-package="org.bench4q.master.domain.service,org.bench4q.master.infrastructure.communication,org.bench4q.master.report, org.bench4q.master.helper, org.bench4q.master.testplan, org.bench4q.share, org.bench4q.master.domain.factory, org.bench4q.master.domain.repository" />
<mvc:annotation-driven />
<task:annotation-driven />
</beans>