diff --git a/pom.xml b/pom.xml index 20380fbe..b08d984e 100644 --- a/pom.xml +++ b/pom.xml @@ -67,11 +67,18 @@ spring-test 3.2.5.RELEASE + commons-fileupload commons-fileupload 1.2 + + + commons-io + commons-io + 2.4 + diff --git a/src/main/java/org/bench4q/agent/api/TestController.java b/src/main/java/org/bench4q/agent/api/TestController.java index 7a859126..3eaae374 100644 --- a/src/main/java/org/bench4q/agent/api/TestController.java +++ b/src/main/java/org/bench4q/agent/api/TestController.java @@ -20,6 +20,7 @@ import org.bench4q.agent.scenario.Scenario; import org.bench4q.agent.scenario.ScenarioContext; import org.bench4q.agent.scenario.ScenarioEngine; import org.bench4q.agent.scenario.behavior.Behavior; +import org.bench4q.share.helper.MarshalHelper; import org.bench4q.share.models.agent.BehaviorBriefModel; import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel; import org.bench4q.share.models.agent.CleanTestResultModel; @@ -62,7 +63,7 @@ public class TestController { @RequestMapping(value = "/prepare/{fileName}", method = RequestMethod.POST) @ResponseBody - public String prepare(@RequestParam MultipartFile file, + public String prepare(@RequestParam("file") MultipartFile file, @PathVariable String fileName) { RunScenarioResultModel result = new RunScenarioResultModel(); try { @@ -70,7 +71,7 @@ public class TestController { + System.getProperty("file.separator") + fileName); file.transferTo(receiveFile); result.setRunId(UUID.randomUUID()); - return "It's ok!"; + return MarshalHelper.tryMarshal(result); } catch (IOException e) { logger.error("/prepare/fileName", e); return null; diff --git a/src/test/java/org/bench4q/agent/test/TestWithScriptFile.java b/src/test/java/org/bench4q/agent/test/TestWithScriptFile.java index b570f85e..e4043e9e 100644 --- a/src/test/java/org/bench4q/agent/test/TestWithScriptFile.java +++ b/src/test/java/org/bench4q/agent/test/TestWithScriptFile.java @@ -31,27 +31,27 @@ public class TestWithScriptFile { private UUID testId; private static int load = 10; - public String getFilePath() { + private String getFilePath() { return filePath; } - public void setFilePath(String filePath) { + private void setFilePath(String filePath) { this.filePath = filePath; } - public HttpRequester getHttpRequester() { + private HttpRequester getHttpRequester() { return httpRequester; } - public void setHttpRequester(HttpRequester httpRequester) { + private void setHttpRequester(HttpRequester httpRequester) { this.httpRequester = httpRequester; } - public UUID getTestId() { + private UUID getTestId() { return testId; } - public void setTestId(UUID testId) { + private void setTestId(UUID testId) { this.testId = testId; } @@ -61,7 +61,7 @@ public class TestWithScriptFile { this.setHttpRequester(new HttpRequester()); } - public void startTest() throws JAXBException { + private void startTest() throws JAXBException { File file = new File(this.getFilePath()); if (!file.exists()) { System.out.println("this script not exists!");