Skip to content

Commit

Permalink
feat: Implement S3FileSystemProvider.getFileStore (#757)
Browse files Browse the repository at this point in the history
* feat(fsprovider): Tests for getFileStore should return the FileStore
* feat(fsprovider): getFileStore should return the FileStore
  • Loading branch information
guicamest authored Sep 28, 2023
1 parent f6668ba commit 8e9b332
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ public boolean isHidden(Path path)
@Override
public FileStore getFileStore(Path path)
{
throw new UnsupportedOperationException();
return toS3Path(path).getFileStore();
}

@Override
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/org/carlspring/cloud/storage/s3fs/FilesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ private static FileSystem createNewFileSystem()
return FileSystems.newFileSystem(uriGlobal, env);
}

@Test
void fileStore()
throws IOException
{
Path dir = fileSystemAmazon.getPath(bucket);

FileStore fileStore = Files.getFileStore(dir);

assertInstanceOf(S3FileStore.class, fileStore);
}

@Test
void notExistsDir()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package org.carlspring.cloud.storage.s3fs.fileSystemProvider;

import org.carlspring.cloud.storage.s3fs.S3FileStore;
import org.carlspring.cloud.storage.s3fs.S3FileSystem;
import org.carlspring.cloud.storage.s3fs.S3UnitTestBase;
import org.carlspring.cloud.storage.s3fs.util.S3ClientMock;
import org.carlspring.cloud.storage.s3fs.util.S3EndpointConstant;
import org.carlspring.cloud.storage.s3fs.util.S3MockFactory;

import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems;
import java.nio.file.Path;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

import static org.junit.jupiter.api.Assertions.assertInstanceOf;

class GetFileStoreTest
extends S3UnitTestBase
Expand All @@ -30,7 +32,7 @@ public void setup()
}

@Test
void getFileStore()
void shouldReturnS3FileStore()
throws IOException
{
// fixtures
Expand All @@ -40,10 +42,8 @@ void getFileStore()
// act
Path file1 = createNewS3FileSystem().getPath("/bucketA/dir/file1");

// We're expecting an exception here to be thrown
Exception exception = assertThrows(UnsupportedOperationException.class, () -> s3fsProvider.getFileStore(file1));

assertNotNull(exception);
FileStore fileStore = s3fsProvider.getFileStore(file1);
assertInstanceOf(S3FileStore.class, fileStore);
}

/**
Expand Down

0 comments on commit 8e9b332

Please sign in to comment.