add validate about the plugin is null

This commit is contained in:
fanfuxiaoran 2014-03-24 10:45:51 +08:00
parent 268f751220
commit 23f5642b3b
5 changed files with 29 additions and 12 deletions

View File

@ -29,8 +29,7 @@ public class PluginController extends BaseController {
public void setPluginService(PluginService pluginService) {
this.pluginService = pluginService;
}
@RequestMapping("/loadPluginList")
@ResponseBody
public PluginResponseModel loadPluginList() throws Bench4QException {
@ -92,8 +91,12 @@ public class PluginController extends BaseController {
throws Bench4QException {
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
throw new Bench4QException(400 + "", "not permitted",
"loadMethodParams/{pluginName}/{methodName}");
"addPlugin/{pluginName}/{methodName}");
}
if (pluginGUI.getPlugin() == null) {
throw new Bench4QException(400 + "", "plugin is null", "addPlugin");
}
PluginResponseModel pluginResponseModel = new PluginResponseModel();
pluginResponseModel.setSuccess(this.getPluginService().addPlugin(
pluginGUI.getPlugin()));

View File

@ -41,10 +41,10 @@ public class PluginFactory {
plugin.getPluginMethods().add(
createMethodEntity(methodModel, plugin));
}
}
plugin.setName(pluginModel.getName());
return plugin;
plugin.setName(pluginModel.getName());
return plugin;
} else
throw new Bench4QException("", "no method in plugin", "");
}
@ -56,7 +56,8 @@ public class PluginFactory {
if (methodModel.getMethodParams() != null) {
for (MethodParamModel methodParamModel : methodModel
.getMethodParams()) {
Logger.getLogger(PluginFactory.class).info("method model:" + methodModel.getName());
Logger.getLogger(PluginFactory.class).info(
"method model:" + methodModel.getName());
method.getMethodParams().add(
createMethodParamEntity(methodParamModel, method));
}

View File

@ -55,8 +55,17 @@ public class PluginService {
}
public boolean addPlugin(PluginModel pluginModel) throws Bench4QException {
return this.getPluginRepository().attatch(
this.getPluginFactory().createPluginEntity(pluginModel));
if (validatePlugin(pluginModel))
return this.getPluginRepository().attatch(
this.getPluginFactory().createPluginEntity(pluginModel));
else {
throw new Bench4QException("", "invalidate plugin file", "");
}
}
private boolean validatePlugin(PluginModel pluginModel) {
return true;
}
public boolean deletePlugin(String pluginName) throws Bench4QException {

View File

@ -81,7 +81,6 @@ public class TestPlanEngine implements TaskCompleteCallback,
this.getScheduleExecutor().scheduleAtFixedRate(new Runnable() {
public void run() {
TestPlan testPlan = pickATestPlan();
if (testPlan == null) {
logger.info("testPlan by pick is null");
return;

View File

@ -23,7 +23,8 @@ public class Test_TestPlanEngine extends TestBase_MakeUpTestPlan {
@Before
public void prepare() {
prepareForTestPlanRunning();
submitATestPlanWithOneScript();
}
@After
@ -42,6 +43,10 @@ public class Test_TestPlanEngine extends TestBase_MakeUpTestPlan {
testForStatus(TestPlanStatus.InRunning);
}
@Test
public void testPickTestPlan(){
}
@Test
public void testRunTestPlanRightly() throws InterruptedException {
assertNotNull(this.getAgentMessenger().askLiving(Test_AGENT_HOSTNAME,