1 16 17 package org.springframework.mock.web.portlet; 18 19 import java.util.Collections ; 20 import java.util.Iterator ; 21 import java.util.Map ; 22 23 import org.springframework.core.CollectionFactory; 24 import org.springframework.util.Assert; 25 import org.springframework.web.multipart.MultipartFile; 26 import org.springframework.web.portlet.multipart.MultipartActionRequest; 27 28 40 public class MockMultipartActionRequest extends MockActionRequest implements MultipartActionRequest { 41 42 private final Map multipartFiles = CollectionFactory.createLinkedMapIfPossible(4); 43 44 45 50 public void addFile(MultipartFile file) { 51 Assert.notNull(file, "MultipartFile must not be null"); 52 this.multipartFiles.put(file.getName(), file); 53 } 54 55 public Iterator getFileNames() { 56 return getFileMap().keySet().iterator(); 57 } 58 59 public MultipartFile getFile(String name) { 60 return (MultipartFile) this.multipartFiles.get(name); 61 } 62 63 public Map getFileMap() { 64 return Collections.unmodifiableMap(this.multipartFiles); 65 } 66 67 } 68 | Popular Tags |