add ways to submit paramFiles to agent
This commit is contained in:
parent
1576076d75
commit
38b805153c
2076
Upload/ready
2076
Upload/ready
File diff suppressed because it is too large
Load Diff
11
Upload/test
11
Upload/test
|
@ -1,11 +0,0 @@
|
|||
-- Adminer 3.7.1 MySQL dump
|
||||
|
||||
SET NAMES utf8;
|
||||
SET foreign_key_checks = 0;
|
||||
SET time_zone = '+08:00';
|
||||
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||
|
||||
CREATE DATABASE `bench4q-master-yvAxaJI0` /*!40100 DEFAULT CHARACTER SET utf8 */;
|
||||
USE `bench4q-master-yvAxaJI0`;
|
||||
|
||||
-- 2014-01-20 15:37:24
|
|
@ -45,6 +45,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
@Controller
|
||||
@RequestMapping("/test")
|
||||
public class TestController {
|
||||
private static final String FILE_SEPARATOR = System
|
||||
.getProperty("file.separator");
|
||||
private ScenarioEngine scenarioEngine;
|
||||
private Logger logger = Logger.getLogger(TestController.class);
|
||||
|
||||
|
@ -61,16 +63,18 @@ public class TestController {
|
|||
this.scenarioEngine = scenarioEngine;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/prepare/{fileName}", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/submit", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public String prepare(@RequestParam("file") MultipartFile file,
|
||||
@PathVariable String fileName) {
|
||||
public String submitParams(
|
||||
@RequestParam("files[]") List<MultipartFile> files) {
|
||||
RunScenarioResultModel result = new RunScenarioResultModel();
|
||||
try {
|
||||
File receiveFile = new File("Upload"
|
||||
+ System.getProperty("file.separator") + fileName);
|
||||
file.transferTo(receiveFile);
|
||||
result.setRunId(UUID.randomUUID());
|
||||
UUID runId = UUID.randomUUID();
|
||||
for (MultipartFile file : files) {
|
||||
file.transferTo(new File(guardDirExists(runId)
|
||||
+ file.getOriginalFilename()));
|
||||
}
|
||||
result.setRunId(runId);
|
||||
return MarshalHelper.tryMarshal(result);
|
||||
} catch (IOException e) {
|
||||
logger.error("/prepare/fileName", e);
|
||||
|
@ -78,6 +82,16 @@ public class TestController {
|
|||
}
|
||||
}
|
||||
|
||||
private String guardDirExists(UUID runId) {
|
||||
String dirPath = "ScenarioParameters" + FILE_SEPARATOR
|
||||
+ runId.toString() + FILE_SEPARATOR;
|
||||
File dirFile = new File(dirPath);
|
||||
if (!dirFile.exists()) {
|
||||
dirFile.mkdirs();
|
||||
}
|
||||
return dirPath;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/run", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public RunScenarioResultModel run(
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<bean id="multipartResolver"
|
||||
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
||||
<property name="maxUploadSize" value="5000000" />
|
||||
<property name="maxInMemorySize" value="5000000" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
|
|
@ -4,6 +4,8 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
@ -176,11 +178,14 @@ public class TestWithScriptFile {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPrepare() throws IOException {
|
||||
HttpResponse httpResponse = this.getHttpRequester().postMultiFile(
|
||||
url + "/prepare/" + "ready.txt",
|
||||
"Scripts" + System.getProperty("file.separator")
|
||||
+ "forGoodRecord.xml");
|
||||
public void testSubmitParams() throws IOException {
|
||||
List<File> files = new ArrayList<File>();
|
||||
files.add(new File("Scripts" + System.getProperty("file.separator")
|
||||
+ "forGoodRecord.xml"));
|
||||
files.add(new File("Scripts" + System.getProperty("file.separator")
|
||||
+ "testJD.xml"));
|
||||
HttpResponse httpResponse = this.getHttpRequester().postFiles(
|
||||
url + "/submit", "files[]", files);
|
||||
assertNotNull(httpResponse);
|
||||
assertNotNull(httpResponse.getContent());
|
||||
assertEquals(200, httpResponse.getCode());
|
||||
|
|
Loading…
Reference in New Issue