|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -21,6 +21,7 @@ import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.lang.NonNull; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.FileCopyUtils; |
|
|
|
import org.springframework.util.FileCopyUtils; |
|
|
|
@ -42,10 +43,10 @@ public class MockMultipartFile implements MultipartFile { |
|
|
|
|
|
|
|
|
|
|
|
private final String name; |
|
|
|
private final String name; |
|
|
|
|
|
|
|
|
|
|
|
private String originalFilename; |
|
|
|
private final String originalFilename; |
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
private String contentType; |
|
|
|
private final String contentType; |
|
|
|
|
|
|
|
|
|
|
|
private final byte[] content; |
|
|
|
private final byte[] content; |
|
|
|
|
|
|
|
|
|
|
|
@ -79,7 +80,7 @@ public class MockMultipartFile implements MultipartFile { |
|
|
|
public MockMultipartFile( |
|
|
|
public MockMultipartFile( |
|
|
|
String name, @Nullable String originalFilename, @Nullable String contentType, @Nullable byte[] content) { |
|
|
|
String name, @Nullable String originalFilename, @Nullable String contentType, @Nullable byte[] content) { |
|
|
|
|
|
|
|
|
|
|
|
Assert.hasLength(name, "Name must not be null"); |
|
|
|
Assert.hasLength(name, "Name must not be empty"); |
|
|
|
this.name = name; |
|
|
|
this.name = name; |
|
|
|
this.originalFilename = (originalFilename != null ? originalFilename : ""); |
|
|
|
this.originalFilename = (originalFilename != null ? originalFilename : ""); |
|
|
|
this.contentType = contentType; |
|
|
|
this.contentType = contentType; |
|
|
|
@ -108,6 +109,7 @@ public class MockMultipartFile implements MultipartFile { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
|
|
|
|
@NonNull |
|
|
|
public String getOriginalFilename() { |
|
|
|
public String getOriginalFilename() { |
|
|
|
return this.originalFilename; |
|
|
|
return this.originalFilename; |
|
|
|
} |
|
|
|
} |
|
|
|
|