diff --git a/spring-content-autoconfigure/src/test/java/org/springframework/content/s3/boot/defaultstorage/S3AutoConfigurationTest.java b/spring-content-autoconfigure/src/test/java/org/springframework/content/s3/boot/defaultstorage/S3AutoConfigurationTest.java index be95d2c32..c0fd4aa3f 100644 --- a/spring-content-autoconfigure/src/test/java/org/springframework/content/s3/boot/defaultstorage/S3AutoConfigurationTest.java +++ b/spring-content-autoconfigure/src/test/java/org/springframework/content/s3/boot/defaultstorage/S3AutoConfigurationTest.java @@ -31,8 +31,12 @@ public class S3AutoConfigurationTest { { Describe("S3 auto configuration with default storage", () -> { BeforeEach(() -> { + System.setProperty("aws.region", "us-east-1"); contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(S3ContentAutoConfiguration.class)); + .withConfiguration(AutoConfigurations.of(S3ContentAutoConfiguration.class)) + .withPropertyValues( + "spring.content.s3.bucket=test-bucket" + ); }); Context("given a default storage type of s3", () -> { BeforeEach(() -> { @@ -68,6 +72,9 @@ public class S3AutoConfigurationTest { Assertions.assertThat(context).hasSingleBean(S3Client.class); }); }); + }); + AfterEach(() -> { + System.clearProperty("aws.region"); }); }); } diff --git a/spring-content-autoconfigure/src/test/java/org/springframework/content/solr/boot/SolrAutoConfigurationTest.java b/spring-content-autoconfigure/src/test/java/org/springframework/content/solr/boot/SolrAutoConfigurationTest.java index ea00ff8f7..327970f0d 100644 --- a/spring-content-autoconfigure/src/test/java/org/springframework/content/solr/boot/SolrAutoConfigurationTest.java +++ b/spring-content-autoconfigure/src/test/java/org/springframework/content/solr/boot/SolrAutoConfigurationTest.java @@ -3,6 +3,7 @@ import com.github.paulcwarren.ginkgo4j.Ginkgo4jConfiguration; import com.github.paulcwarren.ginkgo4j.Ginkgo4jSpringRunner; import internal.org.springframework.content.elasticsearch.boot.autoconfigure.ElasticsearchAutoConfiguration; +import internal.org.springframework.content.s3.boot.autoconfigure.S3ContentAutoConfiguration; import internal.org.springframework.content.solr.SolrFulltextIndexServiceImpl; import internal.org.springframework.content.solr.boot.autoconfigure.SolrAutoConfiguration; import org.apache.solr.client.solrj.SolrClient; @@ -18,9 +19,6 @@ import org.springframework.content.solr.SolrIndexerStoreEventHandler; import org.springframework.content.solr.SolrProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.convert.ConversionService; import static com.github.paulcwarren.ginkgo4j.Ginkgo4jDSL.*; @@ -50,7 +48,7 @@ public class SolrAutoConfigurationTest { public void test() { } - @SpringBootApplication(exclude= ElasticsearchAutoConfiguration.class) + @SpringBootApplication(exclude = {ElasticsearchAutoConfiguration.class, S3ContentAutoConfiguration.class}) public static class TestConfig { @Autowired diff --git a/spring-content-fs/src/test/java/org/springframework/content/fs/io/FileSystemResourceLoaderTest.java b/spring-content-fs/src/test/java/org/springframework/content/fs/io/FileSystemResourceLoaderTest.java index 8cc421ef3..eb072eaac 100644 --- a/spring-content-fs/src/test/java/org/springframework/content/fs/io/FileSystemResourceLoaderTest.java +++ b/spring-content-fs/src/test/java/org/springframework/content/fs/io/FileSystemResourceLoaderTest.java @@ -49,28 +49,30 @@ public class FileSystemResourceLoaderTest { } }); Context("given well formed path (has a trailing slash)", () -> { - BeforeEach(() -> { - path = "/some/well-formed/path/"; - }); + BeforeEach(() -> path = Paths.get("some", "well-formed", "path") + File.separator); It("succeeds", () -> { assertThat(ex, is(nullValue())); - assertThat(loader.getResource("/something").getFile().getPath(), - is("/some/well-formed/path/something")); + + File expected = Paths.get(path, "something").toFile(); + File actual = loader.getResource("/something").getFile(); + + assertThat(actual.getAbsolutePath(), is(expected.getAbsolutePath())); assertThat(loader.getResource("/something"), - instanceOf(DeletableResource.class)); + instanceOf(DeletableResource.class)); }); }); Context("given malformed path without a trailing slash)", () -> { - BeforeEach(() -> { - path = "/some/malformed/path"; - }); + BeforeEach(() -> path = Paths.get("some", "malformed", "path").toString()); It("succeeds", () -> { assertThat(ex, is(nullValue())); - assertThat(loader.getResource("/something").getFile().getPath(), - is("/some/malformed/path/something")); + + File expected = Paths.get(path, "something").toFile(); + File actual = loader.getResource("/something").getFile(); + + assertThat(actual.getAbsolutePath(), is(expected.getAbsolutePath())); assertThat(loader.getResource("/something"), - instanceOf(DeletableResource.class)); + instanceOf(DeletableResource.class)); }); }); }); @@ -85,7 +87,7 @@ public class FileSystemResourceLoaderTest { .toAbsolutePath().toString()); }); JustBeforeEach(() -> { - loader = new FileSystemResourceLoader(parent.getPath() + "/"); + loader = new FileSystemResourceLoader(parent.getPath() + File.separator); Resource resource = loader.getResource(location); assertThat(resource, instanceOf(DeletableResource.class)); ((DeletableResource) resource).delete(); diff --git a/spring-content-s3/src/test/java/internal/org/springframework/content/s3/config/EnableS3StoresTest.java b/spring-content-s3/src/test/java/internal/org/springframework/content/s3/config/EnableS3StoresTest.java index b1104d5e5..500dee770 100644 --- a/spring-content-s3/src/test/java/internal/org/springframework/content/s3/config/EnableS3StoresTest.java +++ b/spring-content-s3/src/test/java/internal/org/springframework/content/s3/config/EnableS3StoresTest.java @@ -41,10 +41,6 @@ import internal.org.springframework.content.s3.io.S3StoreResource; import lombok.Data; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.AwsCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3.S3Client; @RunWith(Ginkgo4jRunner.class) @@ -54,6 +50,7 @@ public class EnableS3StoresTest { static { System.setProperty("spring.content.s3.bucket", BUCKET); + System.setProperty("aws.region", "us-east-1"); } private AnnotationConfigApplicationContext context; diff --git a/spring-content-s3/src/test/java/internal/org/springframework/content/s3/it/LocalStack.java b/spring-content-s3/src/test/java/internal/org/springframework/content/s3/it/LocalStack.java index 3ed418aa1..de82614a1 100644 --- a/spring-content-s3/src/test/java/internal/org/springframework/content/s3/it/LocalStack.java +++ b/spring-content-s3/src/test/java/internal/org/springframework/content/s3/it/LocalStack.java @@ -17,7 +17,7 @@ public class LocalStack extends LocalStackContainer implements Serializable { - private static final DockerImageName IMAGE_NAME = DockerImageName.parse("localstack/localstack"); + private static final DockerImageName IMAGE_NAME = DockerImageName.parse("localstack/localstack:4.9.0"); private LocalStack() { super(IMAGE_NAME);