use of com.thoughtworks.go.helper.StubMultipartHttpServletRequest in project gocd by gocd.
the class ArtifactsControllerIntegrationTest method shouldSaveChecksumFileInTheCruiseOutputFolder.
@Test
public void shouldSaveChecksumFileInTheCruiseOutputFolder() throws Exception {
File fooFile = createFile(artifactsRoot, "/tmp/foobar.html");
FileUtils.writeStringToFile(fooFile, "FooBarBaz...");
File checksumFile = createFile(artifactsRoot, "/tmp/foobar.html.checksum");
FileUtils.writeStringToFile(checksumFile, "baz/foobar.html:FooMD5\n");
MockMultipartFile artifactMultipart = new MockMultipartFile("file", new FileInputStream(fooFile));
MockMultipartFile checksumMultipart = new MockMultipartFile("file_checksum", new FileInputStream(checksumFile));
request.addHeader("Confirm", "true");
StubMultipartHttpServletRequest multipartRequest = new StubMultipartHttpServletRequest(request, artifactMultipart, checksumMultipart);
postFileWithChecksum("baz/foobar.html", multipartRequest);
assertThat(file(artifactsRoot, "baz/foobar.html"), exists());
File uploadedChecksumFile = file(artifactsRoot, "cruise-output/md5.checksum");
assertThat(uploadedChecksumFile, exists());
assertThat(FileUtils.readLines(uploadedChecksumFile).get(0).toString(), is("baz/foobar.html:FooMD5"));
}
use of com.thoughtworks.go.helper.StubMultipartHttpServletRequest in project gocd by gocd.
the class ArtifactsControllerIntegrationTest method shouldAppendChecksumInTheCruiseOutputFolder.
@Test
public void shouldAppendChecksumInTheCruiseOutputFolder() throws Exception {
File fooFile = createFileWithContent(artifactsRoot, "/tmp/foobar.html", "FooBarBaz...");
createFileWithContent(artifactsRoot, "cruise-output/md5.checksum", "oldbaz/foobar.html:BazMD5\n");
File checksumFile = createFileWithContent(artifactsRoot, "/tmp/foobar.html.checksum", "baz/foobar.html:FooMD5\n");
MockMultipartFile artifactMultipart = new MockMultipartFile("file", new FileInputStream(fooFile));
MockMultipartFile checksumMultipart = new MockMultipartFile("file_checksum", new FileInputStream(checksumFile));
request.addHeader("Confirm", "true");
StubMultipartHttpServletRequest multipartRequest = new StubMultipartHttpServletRequest(request, artifactMultipart, checksumMultipart);
postFileWithChecksum("baz/foobar.html", multipartRequest);
assertThat(file(artifactsRoot, "baz/foobar.html"), exists());
File uploadedChecksumFile = file(artifactsRoot, "cruise-output/md5.checksum");
assertThat(uploadedChecksumFile, exists());
List list = FileUtils.readLines(uploadedChecksumFile);
assertThat(list.size(), is(2));
assertThat(list.get(0).toString(), is("oldbaz/foobar.html:BazMD5"));
assertThat(list.get(1).toString(), is("baz/foobar.html:FooMD5"));
}
use of com.thoughtworks.go.helper.StubMultipartHttpServletRequest in project gocd by gocd.
the class ArtifactsControllerIntegrationTest method shouldReturn404WhenNoLatestBuildForPost.
@Test
public void shouldReturn404WhenNoLatestBuildForPost() throws Exception {
request.addHeader("Confirm", "true");
StubMultipartHttpServletRequest multipartRequest = new StubMultipartHttpServletRequest(request);
ModelAndView mav = artifactsController.postArtifact(pipelineName, "latest", "stage", "1", "build2", null, "/foo.xml", 1, multipartRequest);
assertValidContentAndStatus(mav, SC_NOT_FOUND, "Job " + pipelineName + "/latest/stage/1/build2 not found.");
}
use of com.thoughtworks.go.helper.StubMultipartHttpServletRequest in project gocd by gocd.
the class ArtifactsControllerIntegrationTest method postFile.
private ModelAndView postFile(String requestFilename, String multipartFilename, InputStream stream, MockHttpServletResponse response) throws Exception {
MockMultipartFile multipartFile = new MockMultipartFile(multipartFilename, stream);
request.addHeader("Confirm", "true");
StubMultipartHttpServletRequest multipartRequest = new StubMultipartHttpServletRequest(request, multipartFile);
return artifactsController.postArtifact(pipelineName, pipeline.getLabel(), "stage", "LATEST", "build", buildId, requestFilename, null, multipartRequest);
}
Aggregations