Skip to content

Commit

Permalink
Checking empty upload location
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedmohiduet authored and Buzzardo committed Oct 10, 2023
1 parent d344e84 commit c128ccf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public class FileSystemStorageService implements StorageService {

@Autowired
public FileSystemStorageService(StorageProperties properties) {

if(properties.getLocation().trim().length() == 0){
throw new StorageException("File upload location can not be Empty.");
}

this.rootLocation = Paths.get(properties.getLocation());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ public void init() {
service.init();
}

@Test
public void emptyUploadLocation() {
service = null;
properties.setLocation("");
assertThrows(StorageException.class, () -> {
service = new FileSystemStorageService(properties);
});
}

@Test
public void loadNonExistent() {
assertThat(service.load("foo.txt")).doesNotExist();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public class FileSystemStorageService implements StorageService {

@Autowired
public FileSystemStorageService(StorageProperties properties) {

if(properties.getLocation().trim().length() == 0){
throw new StorageException("File upload location can not be Empty.");
}

this.rootLocation = Paths.get(properties.getLocation());
}

Expand Down

0 comments on commit c128ccf

Please sign in to comment.