Last active
February 6, 2017 11:41
-
-
Save smlc/568a1953f2877573635a1c9938dadcd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package services | |
import org.springframework.beans.factory.annotation.Autowired | |
import org.springframework.boot.test.context.SpringBootTest | |
import org.springframework.boot.test.web.client.TestRestTemplate | |
import org.springframework.mock.web.MockMultipartFile | |
import org.springframework.test.context.ContextConfiguration | |
import spock.lang.Specification | |
@ContextConfiguration | |
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | |
class FileUploadControllerTest extends Specification { | |
@Autowired | |
private TestRestTemplate restTemplate | |
def "test loading a empyt file"(){ | |
when: "give a empyt file to load" | |
MockMultipartFile multipartFile = new MockMultipartFile("file", "test.txt", "text/plain", "Please select a file to upload".getBytes()) | |
String requestResult = restTemplate.postForObject("/uploadFile",multipartFile,String.class) | |
then: "return a error message" | |
requestResult.contains("Please select a file to upload") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment