add behavior to behavior
This commit is contained in:
parent
0794013636
commit
3b57cc690f
|
@ -36,7 +36,7 @@
|
|||
<behavior name="next">
|
||||
<params />
|
||||
</behavior>
|
||||
<behavior name="reset">
|
||||
<timer name="reset">
|
||||
<params />
|
||||
</behavior>
|
||||
</timer>
|
||||
</ui>
|
||||
|
|
|
@ -31,7 +31,7 @@ public class PluginController extends BaseController {
|
|||
this.pluginService = pluginService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "loadPluginUI", method = { RequestMethod.GET,
|
||||
@RequestMapping(value = "/loadPluginUI", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public PluginResponseModel loadPluginUIModels() throws Bench4QException {
|
||||
|
@ -73,7 +73,7 @@ public class PluginController extends BaseController {
|
|||
return pluginResponseModel;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "loadBehaviors/{pluginName}", method = {
|
||||
@RequestMapping(value = "/loadBehaviors/{pluginName}", method = {
|
||||
RequestMethod.GET, RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public PluginResponseModel getMethods(
|
||||
|
|
|
@ -219,7 +219,7 @@ public class TestPlan implements IAggregate {
|
|||
}
|
||||
|
||||
public List<Object> collectResult() {
|
||||
List<Object> resultList = new LinkedList<>();
|
||||
List<Object> resultList = new LinkedList<Object>();
|
||||
for (TestPlanScript testPlanScript : getTestPlanScripts()) {
|
||||
List<TestPlanScriptResult> testPlanScriptResults = testPlanScript
|
||||
.doAfterRun();
|
||||
|
|
|
@ -19,6 +19,7 @@ import javax.persistence.Table;
|
|||
public class BehaviorInfo {
|
||||
private int id;
|
||||
private String name;
|
||||
private String behavoirType;
|
||||
private Set<BehaviorParamInfo> params;
|
||||
private PluginUI pluginUI;
|
||||
|
||||
|
@ -42,6 +43,15 @@ public class BehaviorInfo {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
@Column(name = "behavoirType")
|
||||
public String getBehavoirType() {
|
||||
return behavoirType;
|
||||
}
|
||||
|
||||
public void setBehavoirType(String behavoirType) {
|
||||
this.behavoirType = behavoirType;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy = "behaviorInfo", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
public Set<BehaviorParamInfo> getParams() {
|
||||
return params;
|
||||
|
|
|
@ -35,37 +35,16 @@ public class PluginEntityFactory {
|
|||
public PluginUI createPluginUIWithOutId(String pluginUIContent) {
|
||||
Element root = getDocument(pluginUIContent).getRootElement();
|
||||
PluginUI pluginUI = new PluginUI();
|
||||
String[] behaviorNames = { "behavior", "timer", "control" };
|
||||
pluginUI.setPluginInfo(createPluginInfoWithOutId(XmlParseHelper
|
||||
.getOneChildElementByName(root, "plugin")));
|
||||
|
||||
pluginUI.setBehaviorInfos(createBehaviorInfosWithOutId(
|
||||
XmlParseHelper.getChildElementsByName(root, "behavior"),
|
||||
pluginUI));
|
||||
XmlParseHelper.getChildElements(root, behaviorNames), pluginUI));
|
||||
pluginUI.setCreateDateTime(new Date());
|
||||
return pluginUI;
|
||||
}
|
||||
|
||||
private Document getDocument(String pluginUI) {
|
||||
try {
|
||||
return DocumentHelper.parseText(pluginUI);
|
||||
|
||||
} catch (DocumentException e) {
|
||||
logger.info(ExceptionLog.getStackTrace(e));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private PluginInfo createPluginInfoWithOutId(Element element) {
|
||||
|
||||
PluginInfo pluginInfo = new PluginInfo();
|
||||
pluginInfo.setName(XmlParseHelper.getAttribute(element, "name"));
|
||||
Element paramsElement = XmlParseHelper.getOneChildElementByName(
|
||||
element, "params");
|
||||
pluginInfo.setPluginParamInfos(createPluginParamInfos(
|
||||
XmlParseHelper.getChildElements(paramsElement), pluginInfo));
|
||||
return pluginInfo;
|
||||
|
||||
}
|
||||
|
||||
private Set<BehaviorInfo> createBehaviorInfosWithOutId(
|
||||
List<Element> elements, PluginUI pluginUI) {
|
||||
Set<BehaviorInfo> behaviorInfos = new HashSet<BehaviorInfo>();
|
||||
|
@ -78,6 +57,7 @@ public class PluginEntityFactory {
|
|||
private BehaviorInfo createBehaviorInfoWithOutId(Element element,
|
||||
PluginUI pluginUI) {
|
||||
BehaviorInfo behaviorInfo = new BehaviorInfo();
|
||||
behaviorInfo.setBehavoirType(element.getName());
|
||||
behaviorInfo.setName(XmlParseHelper.getAttribute(element, "name"));
|
||||
behaviorInfo.setPluginUI(pluginUI);
|
||||
behaviorInfo.setParams(createBehaviorParamInfos(
|
||||
|
@ -99,20 +79,6 @@ public class PluginEntityFactory {
|
|||
return paramInfos;
|
||||
}
|
||||
|
||||
private Set<PluginParamInfo> createPluginParamInfos(List<Element> elements,
|
||||
PluginInfo pluginInfo) {
|
||||
Set<PluginParamInfo> paramInfos = new HashSet<PluginParamInfo>();
|
||||
for (Element element : elements) {
|
||||
PluginParamInfo pluginParamInfo = createPluginParamInfoWithOutId(
|
||||
element, pluginInfo);
|
||||
if (pluginParamInfo != null)
|
||||
paramInfos.add(pluginParamInfo);
|
||||
}
|
||||
if (paramInfos.size() == 0)
|
||||
paramInfos = null;
|
||||
return paramInfos;
|
||||
}
|
||||
|
||||
private BehaviorParamInfo createBehaviorParamInfo(Element element,
|
||||
BehaviorInfo behaviorInfo) {
|
||||
if (XmlParseHelper.getAttribute(element, "name") == null)
|
||||
|
@ -133,6 +99,42 @@ public class PluginEntityFactory {
|
|||
return behaviorParamInfo;
|
||||
}
|
||||
|
||||
private Document getDocument(String pluginUI) {
|
||||
try {
|
||||
return DocumentHelper.parseText(pluginUI);
|
||||
|
||||
} catch (DocumentException e) {
|
||||
logger.info(ExceptionLog.getStackTrace(e));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private PluginInfo createPluginInfoWithOutId(Element element) {
|
||||
|
||||
PluginInfo pluginInfo = new PluginInfo();
|
||||
pluginInfo.setName(XmlParseHelper.getAttribute(element, "name"));
|
||||
Element paramsElement = XmlParseHelper.getOneChildElementByName(
|
||||
element, "params");
|
||||
pluginInfo.setPluginParamInfos(createPluginParamInfos(
|
||||
XmlParseHelper.getChildElements(paramsElement), pluginInfo));
|
||||
return pluginInfo;
|
||||
|
||||
}
|
||||
|
||||
private Set<PluginParamInfo> createPluginParamInfos(List<Element> elements,
|
||||
PluginInfo pluginInfo) {
|
||||
Set<PluginParamInfo> paramInfos = new HashSet<PluginParamInfo>();
|
||||
for (Element element : elements) {
|
||||
PluginParamInfo pluginParamInfo = createPluginParamInfoWithOutId(
|
||||
element, pluginInfo);
|
||||
if (pluginParamInfo != null)
|
||||
paramInfos.add(pluginParamInfo);
|
||||
}
|
||||
if (paramInfos.size() == 0)
|
||||
paramInfos = null;
|
||||
return paramInfos;
|
||||
}
|
||||
|
||||
private PluginParamInfo createPluginParamInfoWithOutId(Element element,
|
||||
PluginInfo pluginInfo) {
|
||||
if (XmlParseHelper.getAttribute(element, "name") == null)
|
||||
|
@ -297,4 +299,14 @@ class XmlParseHelper {
|
|||
return elements;
|
||||
|
||||
}
|
||||
|
||||
public static List<Element> getChildElements(Element element,
|
||||
String[] elementNames) {
|
||||
List<Element> elements = new LinkedList<Element>();
|
||||
for (String elementName : elementNames) {
|
||||
elements.addAll(getChildElementsByName(element, elementName));
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.bench4q.master.domain.repository;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bench4q.master.domain.entity.plugin.BehaviorInfo;
|
||||
import org.bench4q.master.domain.entity.plugin.PluginInfo;
|
||||
import org.bench4q.master.domain.entity.plugin.PluginUI;
|
||||
|
@ -138,4 +139,14 @@ public class PluginRepository extends AbstractRepositoty {
|
|||
.add(Restrictions.eq("name", pluginName)).uniqueResult();
|
||||
}
|
||||
|
||||
public boolean clearPlugins() {
|
||||
|
||||
List<PluginUI> pluginUIs = this.loadPlugins();
|
||||
for (PluginUI pluginUI : pluginUIs) {
|
||||
if (!this.detach(pluginUI.getPluginInfo().getName()))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,8 +8,10 @@ import org.bench4q.master.domain.entity.plugin.PluginUI;
|
|||
import org.bench4q.master.domain.factory.PluginEntityFactory;
|
||||
import org.bench4q.master.domain.repository.PluginRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
public class Test_PluginHelper {
|
||||
@Component
|
||||
public class Test_PluginHelper {
|
||||
|
||||
private PluginRepository pluginRepository;
|
||||
|
||||
|
@ -22,11 +24,17 @@ public class Test_PluginHelper {
|
|||
this.pluginRepository = pluginRepository;
|
||||
}
|
||||
|
||||
public static PluginUI createPluginUI(String fileName) throws IOException {
|
||||
PluginEntityFactory pluginEntityFactory = new PluginEntityFactory();
|
||||
public static String filePath(String fileName) {
|
||||
|
||||
String fileSeparator = System.getProperty("file.separator");
|
||||
String filePath = System.getProperty("user.dir") + fileSeparator
|
||||
+ "pluginUI" + fileSeparator + fileName;
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public PluginUI createPluginUI(String fileName) throws IOException {
|
||||
PluginEntityFactory pluginEntityFactory = new PluginEntityFactory();
|
||||
String filePath = filePath(fileName);
|
||||
File file = new File(filePath);
|
||||
String uiContent = FileUtils.readFileToString(file);
|
||||
PluginUI pluginUI = pluginEntityFactory
|
||||
|
@ -34,11 +42,10 @@ public class Test_PluginHelper {
|
|||
return pluginUI;
|
||||
}
|
||||
|
||||
protected String addPlugin(String fileName,
|
||||
PluginRepository pluginRepository) {
|
||||
public String addPlugin(String fileName) {
|
||||
try {
|
||||
PluginUI pluginUI = createPluginUI(fileName);
|
||||
pluginRepository.attatch(pluginUI);
|
||||
this.pluginRepository.attatch(pluginUI);
|
||||
return pluginUI.getPluginInfo().getName();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -46,4 +53,9 @@ public class Test_PluginHelper {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public void clearPlugin(String pluginName) {
|
||||
this.getPluginRepository().detach(pluginName);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,14 @@ package org.bench4q.master.test.controller;
|
|||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.domain.entity.plugin.PluginUI;
|
||||
import org.bench4q.master.domain.service.PluginService;
|
||||
import org.bench4q.share.communication.HttpRequester.HttpResponse;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.plugin.PluginResponseModel;
|
||||
|
@ -15,34 +17,50 @@ import org.junit.After;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import TestHelper.Test_PluginHelper;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
public class PluginControllerTest extends TestBase {
|
||||
private final String URLSTRING = BASE_URL + "/plugin";
|
||||
|
||||
private PluginService pluginService;
|
||||
private String pluginName;
|
||||
|
||||
public String getURLSTRING() {
|
||||
return URLSTRING;
|
||||
}
|
||||
|
||||
|
||||
public PluginService getPluginService() {
|
||||
return pluginService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
public void setPluginService(PluginService pluginService) {
|
||||
this.pluginService = pluginService;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws IOException, JAXBException {
|
||||
testAddPlugin();
|
||||
this.pluginName="CsvProvider";
|
||||
this.getPluginService().deletePlugin(pluginName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddPlugin() throws JAXBException, IOException {
|
||||
this.setAccessTocken(this.login());
|
||||
String url = URLSTRING + "/addPlugin";
|
||||
PluginUI pluginGUI = Test_PluginHelper.createPluginUI("ui.xml");
|
||||
pluginName = pluginGUI.getPluginInfo().getName();
|
||||
String pluginContentString = MarshalHelper.marshal(PluginUI.class,
|
||||
pluginGUI);
|
||||
File file=new File(Test_PluginHelper.filePath("ui.xml"));
|
||||
String pluginContent=FileUtils.readFileToString(file);
|
||||
HttpResponse httpResponse = this.httpRequester.sendPutXml(url,
|
||||
pluginContentString,
|
||||
pluginContent,
|
||||
makeAccessTockenMap(this.getAccessTocken()));
|
||||
System.out.println(httpResponse.getContent());
|
||||
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
|
||||
.tryUnmarshal(PluginResponseModel.class,
|
||||
httpResponse.getContent());
|
||||
|
@ -54,29 +72,6 @@ public class PluginControllerTest extends TestBase {
|
|||
Assert.assertTrue(pluginResponseModel.isSuccess());
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testGetMethodParamModel() throws IOException, JAXBException {
|
||||
// String url = URLSTRING + "/loadMethodParams";
|
||||
// String urlForLoadMethod = URLSTRING + "/loadMethodList/" + pluginName;
|
||||
// HttpResponse httpResponseMethod = this.httpRequester.sendPost(
|
||||
// urlForLoadMethod, null,
|
||||
// makeAccessTockenMap(this.getAccessTocken()));
|
||||
// PluginResponseModel pluginResponseModelMethod = (PluginResponseModel)
|
||||
// MarshalHelper
|
||||
// .unmarshal(PluginResponseModel.class,
|
||||
// httpResponseMethod.getContent());
|
||||
// assertTrue(pluginResponseModelMethod.isSuccess());
|
||||
// String methodName = pluginResponseModelMethod.getMethodList().get(0);
|
||||
// url += "/" + pluginName + "/" + methodName;
|
||||
// HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
|
||||
// makeAccessTockenMap(this.getAccessTocken()));
|
||||
// PluginResponseModel pluginResponseModel = (PluginResponseModel)
|
||||
// MarshalHelper
|
||||
// .tryUnmarshal(PluginResponseModel.class,
|
||||
// httpResponse.getContent());
|
||||
// Assert.assertTrue(pluginResponseModel.isSuccess());
|
||||
// assertEquals(2, pluginResponseModel.getMethosMethodParamModels().size());
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testLoadPluginList() throws JAXBException, IOException {
|
||||
|
@ -91,20 +86,6 @@ public class PluginControllerTest extends TestBase {
|
|||
Assert.assertTrue(pluginResponseModel.getPluginList().size() > 0);
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testLoadMethodNameList() throws IOException, JAXBException {
|
||||
// String urlForLoadMethod = URLSTRING + "/loadMethodList/" + pluginName;
|
||||
// HttpResponse httpResponse = this.httpRequester.sendPost(
|
||||
// urlForLoadMethod, null,
|
||||
// makeAccessTockenMap(this.getAccessTocken()));
|
||||
// System.out.println(httpResponse.getContent());
|
||||
// PluginResponseModel pluginResponseModel = (PluginResponseModel)
|
||||
// MarshalHelper
|
||||
// .unmarshal(PluginResponseModel.class, httpResponse.getContent());
|
||||
// assertNotNull(pluginResponseModel);
|
||||
// Assert.assertTrue(pluginResponseModel.isSuccess());
|
||||
// assertEquals(2, pluginResponseModel.getMethodList().size());
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testDeletePlugin() throws IOException, JAXBException {
|
||||
|
@ -125,23 +106,6 @@ public class PluginControllerTest extends TestBase {
|
|||
Assert.assertTrue(pluginResponseModel.isSuccess());
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testGetMethodInPlugin() throws IOException {
|
||||
// String url = URLSTRING + "/loadMethods/" + pluginName;
|
||||
// HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
|
||||
// makeAccessTockenMap(this.getAccessTocken()));
|
||||
// Logger.getLogger(PluginControllerTest.class).info(
|
||||
// httpResponse.getContent());
|
||||
// PluginResponseModel pluginResponseModel = (PluginResponseModel)
|
||||
// MarshalHelper
|
||||
// .tryUnmarshal(PluginResponseModel.class,
|
||||
// httpResponse.getContent());
|
||||
//
|
||||
// assertNotNull(pluginResponseModel);
|
||||
// assertTrue(pluginResponseModel.isSuccess());
|
||||
// assertTrue(pluginResponseModel.getMethodModels().size() == 2);
|
||||
//
|
||||
// }
|
||||
|
||||
@After
|
||||
public void clear() throws IOException {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class Test_PluginDomainFactory extends Test_PluginHelper {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.pluginName = addPlugin("ui.xml", this.getPluginRepository());
|
||||
this.pluginName = addPlugin("ui.xml");
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
|
@ -41,6 +41,7 @@ public class Test_PluginEntityFactory {
|
|||
+ "pluginUI" + fileSeparator + "ui.xml";
|
||||
File file = new File(filePath);
|
||||
String uiContent = FileUtils.readFileToString(file);
|
||||
assertNotNull(uiContent);
|
||||
PluginUI pluginUI = pluginEntityFactory
|
||||
.createPluginUIWithOutId(uiContent);
|
||||
assertNotNull(pluginUI);
|
||||
|
@ -57,7 +58,13 @@ public class Test_PluginEntityFactory {
|
|||
fieldType = (FieldType) pluginParamInfo.getType();
|
||||
}
|
||||
assertTrue(fieldType.getSize() == 7);
|
||||
BehaviorInfo behaviorInfo=pluginUI.getBehaviorInfos().iterator().next();
|
||||
assertNull(behaviorInfo.getParams());
|
||||
assertEquals(2, pluginUI.getBehaviorInfos().size());
|
||||
int timerCount=0;
|
||||
for( BehaviorInfo behaviorInfo:pluginUI.getBehaviorInfos()){
|
||||
if(behaviorInfo.getBehavoirType().equals("timer"))
|
||||
timerCount++;
|
||||
}
|
||||
assertEquals(1, timerCount);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class Test_PluginRepository extends Test_PluginHelper {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Bench4QException {
|
||||
this.pluginName = addPlugin("ui.xml", this.getPluginRepository());
|
||||
this.pluginName = addPlugin("ui.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -53,7 +53,7 @@ public class Test_PluginRepository extends Test_PluginHelper {
|
|||
@Test
|
||||
public void testLoadPlugins() throws Bench4QException {
|
||||
int countBeforeInsert = this.getPluginRepository().loadPlugins().size();
|
||||
String name = addPlugin("test.xml", this.getPluginRepository());
|
||||
String name = addPlugin("test.xml");
|
||||
|
||||
assertEquals(countBeforeInsert + 1, this.getPluginRepository()
|
||||
.loadPlugins().size());
|
||||
|
@ -75,7 +75,7 @@ public class Test_PluginRepository extends Test_PluginHelper {
|
|||
|
||||
@Test
|
||||
public void testDeletePlugin() {
|
||||
String name = addPlugin("ui.xml", this.getPluginRepository());
|
||||
String name = addPlugin("ui.xml");
|
||||
assertTrue(this.getPluginRepository().detach(name));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,109 +1,91 @@
|
|||
package org.bench4q.master.test.service;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bench4q.master.domain.service.PluginService;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import TestHelper.Test_PluginHelper;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
public class Test_PluginService {
|
||||
public class Test_PluginService extends Test_PluginHelper {
|
||||
private PluginService pluginService;
|
||||
private String pluginName;
|
||||
|
||||
// private PluginService pluginService;
|
||||
// private String nameForPlugin;
|
||||
//
|
||||
// public PluginService getPluginService() {
|
||||
// return pluginService;
|
||||
// }
|
||||
//
|
||||
// @Autowired
|
||||
// public void setPluginService(PluginService pluginService) {
|
||||
// this.pluginService = pluginService;
|
||||
// }
|
||||
//
|
||||
// @Before
|
||||
// public void setUp() throws Bench4QException {
|
||||
// nameForPlugin = addPlugin();
|
||||
// }
|
||||
public PluginService getPluginService() {
|
||||
return pluginService;
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testPluginModel() throws JAXBException, IOException {
|
||||
// File file = new File(
|
||||
// buildSavePath()
|
||||
// + System.getProperty("file.separator")
|
||||
// + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss")
|
||||
// .format(new Date()) + "plugin.xml");
|
||||
// FileUtils.writeStringToFile(
|
||||
// file,
|
||||
// MarshalHelper.marshal(PluginModel.class,
|
||||
// Test_PlunginHelper.createOnePlugin()));
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testLoadMethodNameList() throws Bench4QException {
|
||||
// assertTrue(this.getPluginService().getPluginNameList().size() > 0);
|
||||
// int methodCount = this.getPluginService()
|
||||
// .getMethodNameInPlugin(nameForPlugin).size();
|
||||
// assertEquals(2, methodCount);
|
||||
// }
|
||||
@Autowired
|
||||
public void setPluginService(PluginService pluginService) {
|
||||
this.pluginService = pluginService;
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testLoadPluginNameList() throws Bench4QException {
|
||||
// int pluginCountBefore = this.getPluginService().getPluginNameList()
|
||||
// .size();
|
||||
// String pluginName = addPlugin();
|
||||
// System.out.println(this.getPluginService().getPluginNameList().size()
|
||||
// - pluginCountBefore);
|
||||
// Assert.assertTrue(this.getPluginService().getPluginNameList().size() == (pluginCountBefore + 1));
|
||||
//
|
||||
// Assert.assertTrue(this.getPluginService().deletePlugin(pluginName));
|
||||
// }
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.pluginName = "CsvProvider";
|
||||
this.getPluginRepository().detach(pluginName);
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void getMethodParam() throws Bench4QException {
|
||||
// String methodName = this.getPluginService()
|
||||
// .getMethodNameInPlugin(nameForPlugin).get(0);
|
||||
// assertTrue(this.getPluginService()
|
||||
// .getMethodParamModelsInPlugin(nameForPlugin, methodName).size() == 2);
|
||||
// }
|
||||
@After
|
||||
public void clear() {
|
||||
|
||||
// @Test
|
||||
// public void testDeletePlugin() throws Bench4QException {
|
||||
// String pluginName = addPlugin();
|
||||
// Assert.assertTrue(this.getPluginService().deletePlugin(pluginName));
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testGetMethodInPlugin() {
|
||||
// assertTrue(this.getPluginService().getMethodsInPlugin(nameForPlugin)
|
||||
// .size() > 0);
|
||||
// }
|
||||
//
|
||||
// private String addPlugin() throws Bench4QException {
|
||||
// PluginModel plugin = Test_PlunginHelper.createOnePlugin();
|
||||
// plugin.setName("test" + UUID.randomUUID());
|
||||
// Assert.assertTrue(this.getPluginService().addPlugin(plugin));
|
||||
// return plugin.getName();
|
||||
// }
|
||||
@Test
|
||||
public void test_addPlugin() {
|
||||
|
||||
// @After
|
||||
// public void clear() throws Bench4QException {
|
||||
// this.getPluginService().deletePlugin(nameForPlugin);
|
||||
// }
|
||||
//
|
||||
// private String buildSavePath() {
|
||||
// String dirString = "GUI" + System.getProperty("file.separator")
|
||||
// + System.getProperty("file.separator");
|
||||
// File dirFile = new File(dirString);
|
||||
// if (!dirFile.exists()) {
|
||||
// dirFile.mkdirs();
|
||||
// }
|
||||
// return dirString;
|
||||
// }
|
||||
File file = new File(filePath("ui.xml"));
|
||||
String pluginContent;
|
||||
try {
|
||||
pluginContent = FileUtils.readFileToString(file);
|
||||
assertTrue(this.getPluginService().addPlugin(pluginContent));
|
||||
assertFalse(this.getPluginService().addPlugin(pluginContent));
|
||||
assertTure(this.getPluginService().deletePlugin(pluginName));
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadPlugins() {
|
||||
int insertBefore = this.getPluginService().loadPluginUIs().size();
|
||||
addPluginByString();
|
||||
assertEquals(insertBefore + 1, this.getPluginService().loadPluginUIs()
|
||||
.size());
|
||||
this.getPluginService().deletePlugin(pluginName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadBehaviors(){
|
||||
addPluginByString();
|
||||
assertEquals(2,this.getPluginService().loadBehaviorInfoModels(pluginName).size());
|
||||
}
|
||||
private void assertTure(boolean deletePlugin) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void addPluginByString() {
|
||||
File file = new File(filePath("ui.xml"));
|
||||
String pluginContent;
|
||||
try {
|
||||
pluginContent = FileUtils.readFileToString(file);
|
||||
this.getPluginService().addPlugin(pluginContent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,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" />
|
||||
base-package="org.bench4q.master.domain,org.bench4q.master.infrastructure,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>
|
||||
|
|
|
@ -13,6 +13,7 @@ public class BehaviorInfoModel {
|
|||
@SuppressWarnings("rawtypes")
|
||||
private List<ParamInfoModel> paramInfoModels;
|
||||
|
||||
private String behaviorType;
|
||||
private String name;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
@ -22,7 +23,8 @@ public class BehaviorInfoModel {
|
|||
return paramInfoModels;
|
||||
}
|
||||
|
||||
public void setParamInfoModels(@SuppressWarnings("rawtypes") List<ParamInfoModel> paramInfoModels) {
|
||||
public void setParamInfoModels(
|
||||
@SuppressWarnings("rawtypes") List<ParamInfoModel> paramInfoModels) {
|
||||
this.paramInfoModels = paramInfoModels;
|
||||
}
|
||||
|
||||
|
@ -35,4 +37,13 @@ public class BehaviorInfoModel {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getBehaviorType() {
|
||||
return behaviorType;
|
||||
}
|
||||
|
||||
public void setBehaviorType(String behaviorType) {
|
||||
this.behaviorType = behaviorType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue