Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(() -> {
Expand Down Expand Up @@ -68,6 +72,9 @@ public class S3AutoConfigurationTest {
Assertions.assertThat(context).hasSingleBean(S3Client.class);
});
});
});
AfterEach(() -> {
System.clearProperty("aws.region");
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.*;

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
});
});
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down