Skip to content

Commit

Permalink
Remove test that requires call to S3 API not just client. (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
markjschreiber authored Nov 3, 2023
1 parent fc10e5d commit 003182d
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions src/test/java/software/amazon/nio/spi/s3/S3FileSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,30 @@

package software.amazon.nio.spi.s3;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import software.amazon.awssdk.services.s3.S3AsyncClient;
import software.amazon.awssdk.services.s3.model.HeadObjectResponse;

import java.io.IOException;
import java.net.URI;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Iterator;
import java.util.concurrent.CompletableFuture;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.BDDAssertions.then;
import org.junit.jupiter.api.AfterEach;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import static org.mockito.Mockito.lenient;
import static software.amazon.nio.spi.s3.Constants.PATH_SEPARATOR;
import static software.amazon.nio.spi.s3.S3Matchers.anyConsumer;

import org.mockito.junit.jupiter.MockitoExtension;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.services.s3.S3AsyncClient;
import software.amazon.awssdk.services.s3.model.HeadObjectResponse;

@ExtendWith(MockitoExtension.class)
public class S3FileSystemTest {
S3FileSystemProvider provider;
Expand Down Expand Up @@ -135,16 +131,4 @@ public void testGetOpenChannelsIsNotModifiable() {
//
assertThrows(UnsupportedOperationException.class, () -> s3FileSystem.getOpenChannels().add(null));
}

@Test
public void plainInitializationWithError() {
//
// Was want to try a plain initialization (i.e. without any mocks).
// We expect standard client to throw an exception due to missing credentials
final Path path = Paths.get(URI.create("s3://does-not-exists-" + System.currentTimeMillis() + "/dir"));
then(path).isInstanceOf(S3Path.class);
assertThatThrownBy(() -> Files.exists(path))
.isInstanceOf(SdkClientException.class)
.hasMessageStartingWith("Unable to load credentials");
}
}

0 comments on commit 003182d

Please sign in to comment.