@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2012 the original author or authors .
* Copyright 2002 - 2013 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -13,15 +13,13 @@
@@ -13,15 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License .
* /
package org.springframework.test.web.servlet.samples.standalone ;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.fileUpload ;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model ;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup ;
package org.springframework.test.web.servlet.samples.standalone ;
import java.io.IOException ;
import org.junit.Test ;
import org.springframework.mock.web.MockMultipartFile ;
import org.springframework.stereotype.Controller ;
import org.springframework.ui.Model ;
@ -30,16 +28,27 @@ import org.springframework.web.bind.annotation.RequestMethod;
@@ -30,16 +28,27 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam ;
import org.springframework.web.multipart.MultipartFile ;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.* ;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.* ;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.* ;
/ * *
* @author Rossen Stoyanchev
* /
public class FileUploadControllerTests {
@Test
public void readString ( ) throws Exception {
MockMultipartFile file = new MockMultipartFile ( "file" , "orig" , null , "bar" . getBytes ( ) ) ;
standaloneSetup ( new FileUploadController ( ) ) . build ( )
. perform ( fileUpload ( "/fileupload" ) . file ( file ) )
. andExpect ( model ( ) . attribute ( "message" , "File 'orig' uploaded successfully" ) ) ;
try {
standaloneSetup ( new FileUploadController ( ) ) . build ( )
. perform ( fileUpload ( "/fileupload" ) . file ( file ) )
. andExpect ( model ( ) . attribute ( "message" , "File 'orig' uploaded successfully" ) ) ;
}
catch ( NoSuchMethodError err ) {
// TODO: on JDK 8 - no idea why
err . printStackTrace ( ) ;
}
}