add ways to get configuration files and upload files
add ways to get configuration files and upload files, and add tests
This commit is contained in:
commit
0cdc7eb0df
7
pom.xml
7
pom.xml
|
@ -67,11 +67,18 @@
|
||||||
<artifactId>spring-test</artifactId>
|
<artifactId>spring-test</artifactId>
|
||||||
<version>3.2.5.RELEASE</version>
|
<version>3.2.5.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--Start: for upload file -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-fileupload</groupId>
|
<groupId>commons-fileupload</groupId>
|
||||||
<artifactId>commons-fileupload</artifactId>
|
<artifactId>commons-fileupload</artifactId>
|
||||||
<version>1.2</version>
|
<version>1.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--End : for upload file -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.bench4q.agent.scenario.Scenario;
|
||||||
import org.bench4q.agent.scenario.ScenarioContext;
|
import org.bench4q.agent.scenario.ScenarioContext;
|
||||||
import org.bench4q.agent.scenario.ScenarioEngine;
|
import org.bench4q.agent.scenario.ScenarioEngine;
|
||||||
import org.bench4q.agent.scenario.behavior.Behavior;
|
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.BehaviorBriefModel;
|
||||||
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
|
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
|
||||||
import org.bench4q.share.models.agent.CleanTestResultModel;
|
import org.bench4q.share.models.agent.CleanTestResultModel;
|
||||||
|
@ -62,7 +63,7 @@ public class TestController {
|
||||||
|
|
||||||
@RequestMapping(value = "/prepare/{fileName}", method = RequestMethod.POST)
|
@RequestMapping(value = "/prepare/{fileName}", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String prepare(@RequestParam MultipartFile file,
|
public String prepare(@RequestParam("file") MultipartFile file,
|
||||||
@PathVariable String fileName) {
|
@PathVariable String fileName) {
|
||||||
RunScenarioResultModel result = new RunScenarioResultModel();
|
RunScenarioResultModel result = new RunScenarioResultModel();
|
||||||
try {
|
try {
|
||||||
|
@ -70,7 +71,7 @@ public class TestController {
|
||||||
+ System.getProperty("file.separator") + fileName);
|
+ System.getProperty("file.separator") + fileName);
|
||||||
file.transferTo(receiveFile);
|
file.transferTo(receiveFile);
|
||||||
result.setRunId(UUID.randomUUID());
|
result.setRunId(UUID.randomUUID());
|
||||||
return "It's ok!";
|
return MarshalHelper.tryMarshal(result);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("/prepare/fileName", e);
|
logger.error("/prepare/fileName", e);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -31,27 +31,27 @@ public class TestWithScriptFile {
|
||||||
private UUID testId;
|
private UUID testId;
|
||||||
private static int load = 10;
|
private static int load = 10;
|
||||||
|
|
||||||
public String getFilePath() {
|
private String getFilePath() {
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFilePath(String filePath) {
|
private void setFilePath(String filePath) {
|
||||||
this.filePath = filePath;
|
this.filePath = filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpRequester getHttpRequester() {
|
private HttpRequester getHttpRequester() {
|
||||||
return httpRequester;
|
return httpRequester;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHttpRequester(HttpRequester httpRequester) {
|
private void setHttpRequester(HttpRequester httpRequester) {
|
||||||
this.httpRequester = httpRequester;
|
this.httpRequester = httpRequester;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getTestId() {
|
private UUID getTestId() {
|
||||||
return testId;
|
return testId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTestId(UUID testId) {
|
private void setTestId(UUID testId) {
|
||||||
this.testId = testId;
|
this.testId = testId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class TestWithScriptFile {
|
||||||
this.setHttpRequester(new HttpRequester());
|
this.setHttpRequester(new HttpRequester());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startTest() throws JAXBException {
|
private void startTest() throws JAXBException {
|
||||||
File file = new File(this.getFilePath());
|
File file = new File(this.getFilePath());
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
System.out.println("this script not exists!");
|
System.out.println("this script not exists!");
|
||||||
|
|
Loading…
Reference in New Issue