change the Serialization of paramTypeModel

This commit is contained in:
fanfuxiaoran 2014-04-18 18:16:31 +08:00
parent 6f31b2a49c
commit 97c4a31855
12 changed files with 278 additions and 142 deletions

View File

@ -4,6 +4,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import javax.xml.bind.JAXBException;
import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.plugin.BehaviorInfo;
import org.bench4q.master.domain.entity.plugin.CheckBoxType;
import org.bench4q.master.domain.entity.plugin.ChoiceType;
@ -16,6 +19,8 @@ import org.bench4q.master.domain.entity.plugin.PluginInfo;
import org.bench4q.master.domain.entity.plugin.PluginUI;
import org.bench4q.master.domain.entity.plugin.RadioButtonType;
import org.bench4q.master.domain.entity.plugin.TableType;
import org.bench4q.master.exception.ExceptionLog;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.master.plugin.BehaviorInfoModel;
import org.bench4q.share.models.master.plugin.CheckBoxModel;
import org.bench4q.share.models.master.plugin.ChoiceModel;
@ -23,16 +28,30 @@ import org.bench4q.share.models.master.plugin.ComboModel;
import org.bench4q.share.models.master.plugin.FieldModel;
import org.bench4q.share.models.master.plugin.NFieldModel;
import org.bench4q.share.models.master.plugin.ParamInfoModel;
import org.bench4q.share.models.master.plugin.ParamTypeModel;
import org.bench4q.share.models.master.plugin.ParamTypeClassAndContnet;
import org.bench4q.share.models.master.plugin.PluginInfoModel;
import org.bench4q.share.models.master.plugin.PluginUIModel;
import org.bench4q.share.models.master.plugin.RadioButtonModel;
import org.bench4q.share.models.master.plugin.TableModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class PluginDomainFactory {
private ParamTypeClassAndContentFactory paramTypeClassAndContentFactory;
private Logger logger = Logger.getLogger(PluginDomainFactory.class);
public ParamTypeClassAndContentFactory getParamTypeClassAndContentFactory() {
return paramTypeClassAndContentFactory;
}
@Autowired
public void setParamTypeClassAndContentFactory(
ParamTypeClassAndContentFactory paramTypeClassAndContentFactory) {
this.paramTypeClassAndContentFactory = paramTypeClassAndContentFactory;
}
public PluginUIModel createPluginUIModelwithOutBehaviors(PluginUI pluginUI) {
PluginUIModel pluginUIModel = new PluginUIModel();
pluginUIModel.setPluginInfoModel(createPluginInfoModel(pluginUI
@ -49,6 +68,46 @@ public class PluginDomainFactory {
return pluginInfoModel;
}
private ParamInfoModel createParamInfoModel(ParamInfo paramInfo) {
ParamInfoModel paramInfoModel = new ParamInfoModel();
paramInfoModel.setLable(paramInfo.getLable());
paramInfoModel.setName(paramInfo.getName());
try {
paramInfoModel
.setParamTypeClassAndContnet(paramTypeClassAndContentFactory
.createParamTypeClassAndContnet(paramInfo));
paramInfoModel.setType(getParamTypeByParamClass(paramInfoModel
.getParamTypeClassAndContnet().getParamTypeClass()
.toString()));
} catch (JAXBException e) {
// TODO Auto-generated catch block
logger.info(ExceptionLog.getStackTrace(e));
return null;
}
return paramInfoModel;
}
private String getParamTypeByParamClass(String paramTypeClass) {
return paramTypeClass = paramTypeClass.substring(
paramTypeClass.lastIndexOf(".") + 1, paramTypeClass.length());
}
private List<ParamInfoModel> createParamInfoModels(
Set<? extends ParamInfo> paramInfos) {
List<ParamInfoModel> paramInfoModels = new LinkedList<ParamInfoModel>();
for (ParamInfo paramInfo : paramInfos) {
ParamInfoModel paramInfoModel = createParamInfoModel(paramInfo);
if (paramInfo == null) {
return null;
}
paramInfoModels.add(paramInfoModel);
}
return paramInfoModels;
}
public List<BehaviorInfoModel> createBehaviorInfoModels(
Set<BehaviorInfo> behaviorInfos) {
List<BehaviorInfoModel> behaviorInfoModels = new LinkedList<BehaviorInfoModel>();
@ -67,112 +126,87 @@ public class PluginDomainFactory {
}
private List<ParamInfoModel<? extends ParamTypeModel>> createParamInfoModels(
Set<? extends ParamInfo> paramInfos) {
List<ParamInfoModel<? extends ParamTypeModel>> paramInfoModels = new LinkedList<ParamInfoModel<? extends ParamTypeModel>>();
ParamInfoFacoty paramInfoFacoty =new ParamInfoFacoty();
for (ParamInfo paramInfo : paramInfos) {
paramInfoModels
.add(paramInfoFacoty.createParamTypeModel(paramInfo));
}
return paramInfoModels;
}
}
class ParamInfoFacoty {
@Component
class ParamTypeClassAndContentFactory {
public ParamInfoModel<? extends ParamTypeModel> createParamTypeModel(
ParamInfo paramInfo) {
public ParamTypeClassAndContnet createParamTypeClassAndContnet(
ParamInfo paramInfo) throws JAXBException {
ParamType paramType = paramInfo.getType();
if (paramType instanceof FieldType)
return createFieldModel((FieldType) paramType, paramInfo);
else if (paramType instanceof NFieldType)
return createNFieldModel((NFieldType) paramType, paramInfo);
else if (paramType instanceof TableType)
return createTableModel((TableType) paramType, paramInfo);
else if (paramType instanceof CheckBoxType)
return createCheckBoxModel((CheckBoxType) paramType, paramInfo);
else if (paramType instanceof ComboType)
return createComboModel((ComboType) paramType, paramInfo);
else if (paramType instanceof RadioButtonType)
return createRadioButton((RadioButtonType) paramType, paramInfo);
else
if (paramType instanceof FieldType) {
String content = MarshalHelper.marshal(FieldModel.class,
createFieldModel((FieldType) paramType));
return new ParamTypeClassAndContnet(FieldModel.class, content);
}
else if (paramType instanceof NFieldType) {
String content = MarshalHelper.marshal(NFieldModel.class,
createNFieldModel((NFieldType) paramType));
return new ParamTypeClassAndContnet(NFieldModel.class, content);
} else if (paramType instanceof TableType) {
String content = MarshalHelper.marshal(TableModel.class,
createTableModel((TableType) paramType));
return new ParamTypeClassAndContnet(TableModel.class, content);
} else if (paramType instanceof CheckBoxType) {
String content = MarshalHelper.marshal(CheckBoxModel.class,
createCheckBoxModel((CheckBoxType) paramType));
return new ParamTypeClassAndContnet(CheckBoxModel.class, content);
} else if (paramType instanceof ComboType) {
String content = MarshalHelper.marshal(ComboModel.class,
createComboModel((ComboType) paramType));
return new ParamTypeClassAndContnet(ComboModel.class, content);
} else if (paramType instanceof RadioButtonType) {
String content = MarshalHelper.marshal(RadioButtonModel.class,
createRadioButton((RadioButtonType) paramType));
return new ParamTypeClassAndContnet(RadioButtonModel.class, content);
} else
return null;
}
private ParamInfoModel<FieldModel> createFieldModel(FieldType fieldType,
ParamInfo paramInfo) {
ParamInfoModel<FieldModel> paramInfoModel = new ParamInfoModel<>();
private FieldModel createFieldModel(FieldType fieldType) {
FieldModel fieldModel = new FieldModel();
fieldModel.setSize(fieldType.getSize());
fieldModel.setText(fieldType.getText());
paramInfoModel.setLable(paramInfo.getLable());
paramInfo.setName(paramInfo.getName());
return paramInfoModel;
return fieldModel;
}
private ParamInfoModel<NFieldModel> createNFieldModel(
NFieldType nFieldType, ParamInfo paramInfo) {
ParamInfoModel<NFieldModel> paramInfoModel = new ParamInfoModel<NFieldModel>();
paramInfoModel.setName(paramInfo.getName());
paramInfoModel.setLable(paramInfo.getLable());
private NFieldModel createNFieldModel(NFieldType nFieldType) {
NFieldModel nFieldModel = new NFieldModel();
nFieldModel.setSize(nFieldType.getSize());
nFieldModel.setText(nFieldType.getText());
paramInfoModel.setParamTypeModel(nFieldModel);
return paramInfoModel;
return nFieldModel;
}
private ParamInfoModel<TableModel> createTableModel(TableType tableType,
ParamInfo paramInfo) {
ParamInfoModel<TableModel> paramInfoModel = new ParamInfoModel<TableModel>();
paramInfoModel.setName(paramInfo.getName());
paramInfoModel.setLable(paramInfo.getLable());
private TableModel createTableModel(TableType tableType) {
TableModel tableModel = new TableModel();
tableModel.setCols(tableType.getCols());
paramInfoModel.setParamTypeModel(tableModel);
return paramInfoModel;
return tableModel;
}
private ParamInfoModel<CheckBoxModel> createCheckBoxModel(
CheckBoxType checkBoxType, ParamInfo paramInfo) {
ParamInfoModel<CheckBoxModel> paramInfoModel = new ParamInfoModel<CheckBoxModel>();
paramInfoModel.setName(paramInfo.getName());
paramInfoModel.setLable(paramInfo.getLable());
private CheckBoxModel createCheckBoxModel(CheckBoxType checkBoxType) {
CheckBoxModel checkBoxModel = new CheckBoxModel();
checkBoxModel.setChoiceModels(createChoiceModels(checkBoxType
.getChoiceList()));
paramInfo.setType(checkBoxType);
return paramInfoModel;
return checkBoxModel;
}
private ParamInfoModel<ComboModel> createComboModel(ComboType comboType,
ParamInfo paramInfo) {
ParamInfoModel<ComboModel> paramInfoModel = new ParamInfoModel<ComboModel>();
paramInfoModel.setName(paramInfo.getName());
paramInfoModel.setLable(paramInfo.getLable());
private ComboModel createComboModel(ComboType comboType) {
ComboModel comboModel = new ComboModel();
comboModel
.setChoiceModels(createChoiceModels(comboType.getChoiceList()));
paramInfoModel.setParamTypeModel(comboModel);
return paramInfoModel;
return comboModel;
}
private ParamInfoModel<RadioButtonModel> createRadioButton(
RadioButtonType radioButtonType, ParamInfo paramInfo) {
ParamInfoModel<RadioButtonModel> paramInfoModel = new ParamInfoModel<RadioButtonModel>();
paramInfoModel.setLable(paramInfo.getLable());
paramInfoModel.setName(paramInfo.getName());
private RadioButtonModel createRadioButton(RadioButtonType radioButtonType) {
RadioButtonModel radioButtonModel = new RadioButtonModel();
radioButtonModel.setChoiceModels(createChoiceModels(radioButtonType
.getChoices()));
paramInfoModel.setParamTypeModel(radioButtonModel);
return paramInfoModel;
return radioButtonModel;
}

View File

@ -141,7 +141,7 @@ public class PluginEntityFactory {
if (XmlParseHelper.getAttribute(element, "name") == null)
return null;
PluginParamInfo pluginParamInfo = new PluginParamInfo();
pluginParamInfo.setLable(XmlParseHelper.getAttribute(element, "lable"));
pluginParamInfo.setLable(XmlParseHelper.getAttribute(element, "label"));
pluginParamInfo.setName(XmlParseHelper.getAttribute(element, "name"));
ParamTypeFactory paramTypeFactory = new ParamTypeFactory();
pluginParamInfo.setType(paramTypeFactory

View File

@ -23,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
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 PluginControllerTest extends TestBase {
@ -69,7 +68,7 @@ public class PluginControllerTest extends TestBase {
@Test
public void testAddPlugin() throws JAXBException, IOException {
this.test_PluginHelper.clearPlugin(pluginName);
this.getPluginService().deletePlugin(pluginName);
this.setAccessTocken(this.login());
String url = URLSTRING + "/addPlugin";
File file = new File(Test_PluginHelper.filePath(fileName));
@ -81,16 +80,15 @@ public class PluginControllerTest extends TestBase {
httpResponse.getContent());
Assert.assertNotNull(pluginResponseModel);
Assert.assertTrue(pluginResponseModel.isSuccess());
this.test_PluginHelper.clearPlugin(pluginName);
this.getPluginService().deletePlugin(pluginName);
}
@Test
public void testLoadPluginNameList() throws JAXBException, IOException {
this.test_PluginHelper.clearPlugin(pluginName);
this.getPluginService().deletePlugin(pluginName);
String url = URLSTRING + "/loadPluginNameList";
int insertBefore = test_PluginHelper.getPluginRepository()
.loadPlugins().size();
test_PluginHelper.addPlugin(fileName);
int insertBefore = this.getPluginService().loadPluginUIs().size();
this.test_PluginHelper.addPlugin("ui.xml", pluginService, pluginName);
HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken()));
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
@ -101,15 +99,15 @@ public class PluginControllerTest extends TestBase {
Assert.assertTrue(pluginResponseModel.getPluginList().size() > 0);
assertEquals(insertBefore + 1, pluginResponseModel.getPluginList()
.size());
test_PluginHelper.clearPlugin(pluginName);
this.getPluginService().deletePlugin(pluginName);
}
@Test
public void testLoadPluginList() throws IOException, JAXBException {
this.getTest_PluginHelper().clearPlugin(pluginName);
int insertBefore = test_PluginHelper.getPluginRepository()
.loadPlugins().size();
this.getTest_PluginHelper().addPlugin(fileName);
this.getPluginService().deletePlugin(pluginName);
int insertBefore = this.getPluginService().loadPluginUIs().size();
this.getTest_PluginHelper().addPlugin(fileName,
this.getPluginService(), pluginName);
String url = URLSTRING + "/loadPluginList";
HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken()));
@ -119,13 +117,14 @@ public class PluginControllerTest extends TestBase {
assertNotNull(pluginResponseModel);
assertEquals(insertBefore + 1, pluginResponseModel.getPluginUIModels()
.size());
this.getTest_PluginHelper().clearPlugin(pluginName);
this.getPluginService().deletePlugin(pluginName);
}
@Test
public void testDeletePlugin() throws IOException {
this.getTest_PluginHelper().clearPlugin(pluginName);
this.getTest_PluginHelper().addPlugin(fileName);
this.getPluginService().deletePlugin(pluginName);
this.getTest_PluginHelper().addPlugin(fileName,
this.getPluginService(), pluginName);
String url = URLSTRING + "/deletePlugin" + "/" + this.pluginName;
HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken()));
@ -139,7 +138,8 @@ public class PluginControllerTest extends TestBase {
@Test
public void testGetBehaviors() throws IOException {
this.getTest_PluginHelper().addPlugin(fileName);
this.getTest_PluginHelper().addPlugin(fileName,
this.getPluginService(), pluginName);
String url = URLSTRING + "/loadBehaviors/" + this.pluginName;
HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
makeAccessTockenMap(this.getAccessTocken()));
@ -153,7 +153,8 @@ public class PluginControllerTest extends TestBase {
@Test
public void testGetParamType() throws IOException, JAXBException {
this.getTest_PluginHelper().addPlugin(fileName);
this.getTest_PluginHelper().addPlugin(fileName,
this.getPluginService(), pluginName);
String url = URLSTRING + "/loadPluginList";
Map<String, String> properties = makeAccessTockenMap(this
.getAccessTocken());
@ -161,19 +162,20 @@ public class PluginControllerTest extends TestBase {
HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
properties);
System.out.println(httpResponse.getContent());
// Gson gson = new Gson();
// PluginResponseModel pluginResponseModel = gson.fromJson(
// httpResponse.getContent(), PluginResponseModel.class);
// assertNotNull(pluginResponseModel);
// PluginInfoModel pluginInfoModel = pluginResponseModel
// .getPluginUIModels().get(0).getPluginInfoModel();
// int count = 0;
// for (@SuppressWarnings("rawtypes")
// ParamInfoModel paramInfoModel : pluginInfoModel.getParamInfoModels()) {
// if (paramInfoModel.getParamTypeModel() instanceof FieldModel)
// count++;
// }
// assertEquals(this.fieldParamCount, count);
// Gson gson = new Gson();
// PluginResponseModel pluginResponseModel = gson.fromJson(
// httpResponse.getContent(), PluginResponseModel.class);
// assertNotNull(pluginResponseModel);
// PluginInfoModel pluginInfoModel = pluginResponseModel
// .getPluginUIModels().get(0).getPluginInfoModel();
// int count = 0;
// for (@SuppressWarnings("rawtypes")
// ParamInfoModel paramInfoModel : pluginInfoModel.getParamInfoModels())
// {
// if (paramInfoModel.getParamTypeModel() instanceof FieldModel)
// count++;
// }
// assertEquals(this.fieldParamCount, count);
}

View File

@ -2,13 +2,17 @@ package org.bench4q.master.test.factory;
import static org.junit.Assert.*;
import java.util.List;
import java.util.Set;
import javax.xml.bind.JAXBException;
import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.plugin.BehaviorInfo;
import org.bench4q.master.domain.entity.plugin.PluginUI;
import org.bench4q.master.domain.factory.PluginDomainFactory;
import org.bench4q.master.domain.repository.PluginRepository;
import org.bench4q.master.test.testHelper.Test_PluginHelper;
import org.bench4q.share.models.master.plugin.ParamInfoModel;
import org.bench4q.share.models.master.plugin.PluginUIModel;
import org.junit.After;
import org.junit.Before;
@ -18,12 +22,14 @@ import org.springframework.beans.factory.annotation.Autowired;
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_PluginDomainFactory extends Test_PluginHelper {
private PluginDomainFactory pluginDomainFactory;
private PluginRepository pluginRepository;
private String pluginName;
private Logger logger = Logger.getLogger(Test_PluginDomainFactory.class);
public PluginDomainFactory getPluginDomainFactory() {
return pluginDomainFactory;
@ -45,7 +51,7 @@ public class Test_PluginDomainFactory extends Test_PluginHelper {
@Before
public void setUp() {
this.pluginName = addPlugin("ui.xml");
this.pluginName = addPlugin("ui.xml", pluginRepository);
}
@After
@ -57,6 +63,7 @@ public class Test_PluginDomainFactory extends Test_PluginHelper {
public void test_createPluginUIModel() {
assertNotNull(pluginName);
PluginUI pluginUI = this.getPluginRepository().getPluginUI(pluginName);
PluginUIModel pluginUIModel = this.getPluginDomainFactory()
.createPluginUIModelwithOutBehaviors(pluginUI);
assertNotNull(pluginUIModel);
@ -66,6 +73,29 @@ public class Test_PluginDomainFactory extends Test_PluginHelper {
}
@Test
public void test_createParamInfoModel() throws JAXBException {
assertNotNull(pluginName);
PluginUI pluginUI = this.getPluginRepository().getPluginUI(pluginName);
PluginUIModel pluginUIModel = this.getPluginDomainFactory()
.createPluginUIModelwithOutBehaviors(pluginUI);
assertNotNull(pluginUIModel);
List<ParamInfoModel> paramInfoModels = pluginUIModel
.getPluginInfoModel().getParamInfoModels();
int count = 0;
for (ParamInfoModel paramInfoModel : paramInfoModels) {
if (paramInfoModel.getParamTypeClassAndContnet()
.getParamTypeClass().toString().contains("CheckBoxModel")) {
logger.info( paramInfoModel
.getParamTypeClassAndContnet().getParamTypeClass());
count++;
}
}
System.out.println(count);
}
@Test
public void test_CreateBehaviorModels() {
assertNotNull(pluginName);

View File

@ -2,6 +2,8 @@ package org.bench4q.master.test.repository;
import static org.junit.Assert.*;
import javax.xml.bind.JAXBException;
import org.bench4q.master.domain.factory.PluginEntityFactory;
import org.bench4q.master.domain.repository.PluginRepository;
import org.bench4q.master.exception.Bench4QException;
@ -14,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
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_PluginRepository extends Test_PluginHelper {
@ -41,7 +44,7 @@ public class Test_PluginRepository extends Test_PluginHelper {
@Before
public void setUp() throws Bench4QException {
this.pluginName = addPlugin("ui.xml");
this.pluginName = addPlugin("ui.xml", this.pluginRepository);
}
@Test
@ -51,10 +54,11 @@ public class Test_PluginRepository extends Test_PluginHelper {
}
@Test
public void testLoadPlugins() throws Bench4QException {
public void testLoadPlugins() throws Bench4QException, JAXBException {
this.clearPlugin(pluginName, this.pluginRepository);
int countBeforeInsert = this.getPluginRepository().loadPlugins().size();
String name = addPlugin("test.xml");
System.out.println(countBeforeInsert);
String name = addPlugin("ui.xml", this.pluginRepository);
assertEquals(countBeforeInsert + 1, this.getPluginRepository()
.loadPlugins().size());
assertTrue(this.getPluginRepository().detach(name));
@ -75,7 +79,7 @@ public class Test_PluginRepository extends Test_PluginHelper {
@Test
public void testDeletePlugin() {
String name = addPlugin("ui.xml");
String name = addPlugin("ui.xml", this.pluginRepository);
assertTrue(this.getPluginRepository().detach(name));
}

View File

@ -6,6 +6,7 @@ import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.bench4q.master.domain.repository.PluginRepository;
import org.bench4q.master.domain.service.PluginService;
import org.bench4q.master.test.testHelper.Test_PluginHelper;
import org.junit.After;
@ -22,6 +23,8 @@ public class Test_PluginService extends Test_PluginHelper {
private PluginService pluginService;
private String pluginName;
private PluginRepository pluginRepository;
public PluginService getPluginService() {
return pluginService;
}
@ -31,6 +34,15 @@ public class Test_PluginService extends Test_PluginHelper {
this.pluginService = pluginService;
}
public PluginRepository getPluginRepository() {
return pluginRepository;
}
@Autowired
public void setPluginRepository(PluginRepository pluginRepository) {
this.pluginRepository = pluginRepository;
}
@Before
public void setUp() {
this.pluginName = "CsvProvider";

View File

@ -7,24 +7,11 @@ import org.apache.commons.io.FileUtils;
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;
import org.bench4q.master.domain.service.PluginService;
@Component
public class Test_PluginHelper {
public class Test_PluginHelper {
private PluginRepository pluginRepository;
public PluginRepository getPluginRepository() {
return pluginRepository;
}
@Autowired
public void setPluginRepository(PluginRepository pluginRepository) {
this.pluginRepository = pluginRepository;
}
public static String filePath(String fileName) {
public static String filePath(String fileName) {
String fileSeparator = System.getProperty("file.separator");
String filePath = System.getProperty("user.dir") + fileSeparator
@ -32,7 +19,7 @@ public class Test_PluginHelper {
return filePath;
}
public PluginUI createPluginUI(String fileName) throws IOException {
public PluginUI createPluginUI(String fileName) throws IOException {
PluginEntityFactory pluginEntityFactory = new PluginEntityFactory();
String filePath = filePath(fileName);
File file = new File(filePath);
@ -42,10 +29,10 @@ public class Test_PluginHelper {
return pluginUI;
}
public String addPlugin(String fileName) {
public String addPlugin(String fileName, PluginRepository pluginRepository) {
try {
PluginUI pluginUI = createPluginUI(fileName);
this.pluginRepository.attatch(pluginUI);
pluginRepository.attatch(pluginUI);
return pluginUI.getPluginInfo().getName();
} catch (Exception e) {
e.printStackTrace();
@ -54,8 +41,22 @@ public class Test_PluginHelper {
}
public void clearPlugin(String pluginName) {
this.getPluginRepository().detach(pluginName);
public String addPlugin(String fileName, PluginService pluginService,
String pluginName) {
try {
String pluginUI = FileUtils.readFileToString(new File(
filePath(fileName)));
pluginService.addPlugin(pluginUI);
return pluginName;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public void clearPlugin(String pluginName, PluginRepository pluginRepository) {
pluginRepository.detach(pluginName);
}
}

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.test.testHelper,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" />
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>

View File

@ -10,19 +10,19 @@ import com.sun.xml.internal.txw2.annotation.XmlElement;
@XmlRootElement
public class BehaviorInfoModel {
private List<ParamInfoModel<? extends ParamTypeModel>> paramInfoModels;
private List<ParamInfoModel> paramInfoModels;
private String behaviorType;
private String name;
@XmlElementWrapper
@XmlElement
public List<ParamInfoModel<? extends ParamTypeModel>> getParamInfoModels() {
public List<ParamInfoModel> getParamInfoModels() {
return paramInfoModels;
}
public void setParamInfoModels(
List<ParamInfoModel<? extends ParamTypeModel>> paramInfoModels) {
List<ParamInfoModel> paramInfoModels) {
this.paramInfoModels = paramInfoModels;
}

View File

@ -1,16 +1,17 @@
package org.bench4q.share.models.master.plugin;
import javax.xml.bind.annotation.XmlRootElement;
import com.sun.xml.internal.txw2.annotation.XmlElement;
@XmlRootElement
public class ParamInfoModel<T extends ParamTypeModel> {
public class ParamInfoModel {
private String name;
private String lable;
private T paramTypeModel;
private String type;
private ParamTypeClassAndContnet paramTypeClassAndContnet;
@XmlElement
public String getName() {
@ -31,12 +32,23 @@ public class ParamInfoModel<T extends ParamTypeModel> {
}
@XmlElement
public T getParamTypeModel() {
return paramTypeModel;
public ParamTypeClassAndContnet getParamTypeClassAndContnet() {
return paramTypeClassAndContnet;
}
public void setParamTypeModel(T paramTypeModel) {
this.paramTypeModel = paramTypeModel;
public void setParamTypeClassAndContnet(
ParamTypeClassAndContnet paramTypeClassAndContnet) {
this.paramTypeClassAndContnet = paramTypeClassAndContnet;
}
@XmlElement
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@ -0,0 +1,40 @@
package org.bench4q.share.models.master.plugin;
import javax.xml.bind.annotation.XmlRootElement;
import com.sun.xml.internal.txw2.annotation.XmlElement;
@XmlRootElement
public class ParamTypeClassAndContnet {
private Class<?> paramTypeClass;
private String content;
public ParamTypeClassAndContnet() {
}
public ParamTypeClassAndContnet(Class<?> paramTyClass, String content) {
this.paramTypeClass = paramTyClass;
this.content = content;
}
@XmlElement
public Class<?> getParamTypeClass() {
return paramTypeClass;
}
public void setParamTypeClass(Class<?> paramTypeClass) {
this.paramTypeClass = paramTypeClass;
}
@XmlElement
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}

View File

@ -11,7 +11,7 @@ import com.sun.xml.internal.txw2.annotation.XmlElement;
public class PluginInfoModel {
private String name;
private List<ParamInfoModel<? extends ParamTypeModel>> paramInfoModels;
private List<ParamInfoModel> paramInfoModels;
@XmlElement
public String getName() {
@ -24,13 +24,14 @@ public class PluginInfoModel {
@XmlElementWrapper
@XmlElement
public List<ParamInfoModel<? extends ParamTypeModel>> getParamInfoModels() {
public List<ParamInfoModel> getParamInfoModels() {
return paramInfoModels;
}
public void setParamInfoModels(
List<ParamInfoModel<? extends ParamTypeModel>> paramInfoModels) {
List<ParamInfoModel> paramInfoModels) {
this.paramInfoModels = paramInfoModels;
}
}