Skip to content

Commit 395d9e8

Browse files
committed
spring-cloudGH-368: Update AWS code to the latest deps
Fixes spring-cloud#368 * Upgrade to `spring-cloud-aws-2.4.2`; fix respective package changes * Remove `AutoConfigurationExclusionEnvironmentPostProcessor` since classes in the SC-AWS are not considered as auto-configuration anymore. Instead, add an explicit `@Import` into `AmazonS3Configuration`. Not sure, though, why it was excluded before at all * Fix `MetadataStoreAutoConfigurationTests` with the current state of code. Looks like before it was designed for auto-configuration based on classpath content * Re-enable other AWS S3 tests This fix has helped to spot a bug in Spring Integration Testing framework: spring-projects/spring-integration@e2d8eeb
1 parent 735d420 commit 395d9e8

File tree

20 files changed

+74
-178
lines changed

20 files changed

+74
-178
lines changed

Diff for: applications/sink/s3-sink/src/test/java/org/springframework/cloud/stream/app/s3/sink/AwsS3SinkTests.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 the original author or authors.
2+
* Copyright 2016-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,7 +37,6 @@
3737
import com.amazonaws.services.s3.transfer.internal.S3ProgressPublisher;
3838
import com.amazonaws.util.Md5Utils;
3939
import org.junit.jupiter.api.BeforeEach;
40-
import org.junit.jupiter.api.Disabled;
4140
import org.junit.jupiter.api.Test;
4241
import org.junit.jupiter.api.io.TempDir;
4342
import org.mockito.ArgumentCaptor;
@@ -65,7 +64,6 @@
6564
import static org.mockito.Mockito.spy;
6665
import static org.mockito.Mockito.verify;
6766

68-
@Disabled
6967
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
7068
properties = {
7169
"cloud.aws.stack.auto=false",

Diff for: applications/source/s3-source/src/test/java/org/springframework/cloud/stream/app/source/s3/AwsS3SourceTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 the original author or authors.
2+
* Copyright 2016-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,7 +56,6 @@
5656
import static org.mockito.BDDMockito.willReturn;
5757
import static org.mockito.Mockito.mock;
5858

59-
@Disabled
6059
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
6160
properties = {
6261
"cloud.aws.stack.auto=false",

Diff for: functions/common/aws-s3-common/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<properties>
1717
<spring-integration-aws.version>2.5.2</spring-integration-aws.version>
18-
<spring-cloud-aws.version>2.2.6.RELEASE</spring-cloud-aws.version>
18+
<spring-cloud-aws.version>2.4.2</spring-cloud-aws.version>
1919
</properties>
2020

2121
<dependencies>
@@ -25,7 +25,7 @@
2525
<version>${spring-integration-aws.version}</version>
2626
</dependency>
2727
<dependency>
28-
<groupId>org.springframework.cloud</groupId>
28+
<groupId>io.awspring.cloud</groupId>
2929
<artifactId>spring-cloud-starter-aws</artifactId>
3030
<version>${spring-cloud-aws.version}</version>
3131
</dependency>

Diff for: functions/common/aws-s3-common/src/main/java/org/springframework/cloud/fn/common/aws/s3/AmazonS3Configuration.java

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 the original author or authors.
2+
* Copyright 2016-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,15 +22,25 @@
2222

2323
import org.springframework.boot.autoconfigure.AutoConfiguration;
2424
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
25-
import org.springframework.cloud.aws.context.annotation.ConditionalOnMissingAmazonClient;
26-
import org.springframework.cloud.aws.core.region.RegionProvider;
25+
26+
import io.awspring.cloud.autoconfigure.context.ContextCredentialsAutoConfiguration;
27+
import io.awspring.cloud.autoconfigure.context.ContextRegionProviderAutoConfiguration;
28+
import io.awspring.cloud.context.annotation.ConditionalOnMissingAmazonClient;
29+
import io.awspring.cloud.context.config.annotation.ContextDefaultConfigurationRegistrar;
30+
import io.awspring.cloud.core.region.RegionProvider;
2731
import org.springframework.context.annotation.Bean;
32+
import org.springframework.context.annotation.Import;
2833

2934
/**
3035
* @author Artem Bilan
3136
*/
3237
@AutoConfiguration
3338
@ConditionalOnMissingAmazonClient(AmazonS3.class)
39+
@Import({
40+
ContextCredentialsAutoConfiguration.class,
41+
ContextDefaultConfigurationRegistrar.class,
42+
ContextRegionProviderAutoConfiguration.class
43+
})
3444
public class AmazonS3Configuration {
3545

3646
@Bean

Diff for: functions/common/aws-s3-common/src/main/java/org/springframework/cloud/fn/common/aws/s3/AutoConfigurationExclusionEnvironmentPostProcessor.java

-56
This file was deleted.

Diff for: functions/common/aws-s3-common/src/main/java/org/springframework/cloud/fn/common/aws/s3/CompatibleStorageAmazonS3Configuration.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2020 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@
3030
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
3131
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
3232
import org.springframework.boot.context.properties.EnableConfigurationProperties;
33-
import org.springframework.cloud.aws.core.region.RegionProvider;
33+
import io.awspring.cloud.core.region.RegionProvider;
3434
import org.springframework.context.annotation.Bean;
3535
import org.springframework.integration.aws.support.S3SessionFactory;
3636
import org.springframework.lang.Nullable;
@@ -39,6 +39,7 @@
3939
/**
4040
* @author Timo Salm
4141
* @author David Turanski
42+
* @author Artem Bilan
4243
*/
4344
@AutoConfiguration
4445
@EnableConfigurationProperties(AmazonS3Properties.class)

Diff for: functions/common/aws-s3-common/src/main/resources/META-INF/spring.factories

-2
This file was deleted.

Diff for: functions/common/aws-s3-common/src/test/java/org/springframework/cloud/fn/common/aws/s3/AmazonS3ConfigurationTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2020 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,8 +26,8 @@
2626

2727
import org.springframework.boot.context.annotation.UserConfigurations;
2828
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
29-
import org.springframework.cloud.aws.core.region.RegionProvider;
30-
import org.springframework.cloud.aws.core.region.StaticRegionProvider;
29+
import io.awspring.cloud.core.region.RegionProvider;
30+
import io.awspring.cloud.core.region.StaticRegionProvider;
3131
import org.springframework.context.annotation.Bean;
3232

3333
/**

Diff for: functions/common/aws-s3-common/src/test/java/org/springframework/cloud/fn/common/aws/s3/AutoConfigurationExclusionEnvironmentPostProcessorTests.java

-48
This file was deleted.

Diff for: functions/common/metadata-store-common/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<description>metadata-store common</description>
1515

1616
<properties>
17-
<aws-java-sdk.version>1.11.951</aws-java-sdk.version>
18-
<spring-integration-aws.version>2.5.0</spring-integration-aws.version>
17+
<aws-java-sdk.version>1.12.322</aws-java-sdk.version>
18+
<spring-integration-aws.version>2.5.2</spring-integration-aws.version>
1919
<spring-integration-hazelcast.version>3.0.0</spring-integration-hazelcast.version>
2020
<curator.version>4.0.1</curator.version>
2121
</properties>

Diff for: functions/common/metadata-store-common/src/test/java/org/springframework/cloud/fn/common/metadata/store/MetadataStoreAutoConfigurationTests.java

+24-29
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.beans.Introspector;
2020
import java.nio.charset.StandardCharsets;
21-
import java.util.Arrays;
2221
import java.util.List;
2322
import java.util.function.Predicate;
2423

@@ -28,10 +27,8 @@
2827
import com.amazonaws.services.dynamodbv2.model.DescribeTableResult;
2928
import io.awspring.cloud.core.region.RegionProvider;
3029
import org.apache.curator.test.TestingServer;
31-
import org.junit.Ignore;
32-
import org.junit.Test;
33-
import org.junit.runner.RunWith;
34-
import org.junit.runners.Parameterized;
30+
import org.junit.jupiter.params.ParameterizedTest;
31+
import org.junit.jupiter.params.provider.MethodSource;
3532

3633
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
3734
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -57,14 +54,13 @@
5754
/**
5855
* @author Artem Bilan
5956
* @author Corneil du Plessis
57+
*
6058
* @since 2.0.2
6159
*/
62-
@RunWith(Parameterized.class)
63-
@Ignore
6460
public class MetadataStoreAutoConfigurationTests {
6561

6662
private final static List<Class<? extends ConcurrentMetadataStore>> METADATA_STORE_CLASSES =
67-
Arrays.asList(
63+
List.of(
6864
RedisMetadataStore.class,
6965
MongoDbMetadataStore.class,
7066
JdbcMetadataStore.class,
@@ -73,15 +69,30 @@ public class MetadataStoreAutoConfigurationTests {
7369
DynamoDbMetadataStore.class,
7470
SimpleMetadataStore.class
7571
);
76-
private final ApplicationContextRunner contextRunner;
77-
private final Class<? extends ConcurrentMetadataStore> classToInclude;
7872

79-
public MetadataStoreAutoConfigurationTests(Class<? extends ConcurrentMetadataStore> classToInclude) {
80-
this.classToInclude = classToInclude;
81-
this.contextRunner =
73+
@ParameterizedTest
74+
@MethodSource
75+
public void testMetadataStore(Class<? extends ConcurrentMetadataStore> classToInclude) {
76+
ApplicationContextRunner contextRunner =
8277
new ApplicationContextRunner()
8378
.withUserConfiguration(TestConfiguration.class)
79+
.withPropertyValues("metadata.store.type=" +
80+
classToInclude.getSimpleName()
81+
.replaceFirst("MetadataStore", "")
82+
.toLowerCase()
83+
.replaceFirst("simple", "memory"))
8484
.withClassLoader(filteredClassLoaderBut(classToInclude));
85+
contextRunner
86+
.run(context -> {
87+
assertThat(context.getBeansOfType(MetadataStore.class)).hasSize(1);
88+
89+
assertThat(context.getBeanNamesForType(classToInclude))
90+
.containsOnlyOnce(Introspector.decapitalize(classToInclude.getSimpleName()));
91+
});
92+
}
93+
94+
static List<Class<? extends ConcurrentMetadataStore>> testMetadataStore() {
95+
return METADATA_STORE_CLASSES;
8596
}
8697

8798
private static FilteredClassLoader filteredClassLoaderBut(Class<? extends ConcurrentMetadataStore> classToInclude) {
@@ -91,22 +102,6 @@ private static FilteredClassLoader filteredClassLoaderBut(Class<? extends Concur
91102
.toArray(Class<?>[]::new));
92103
}
93104

94-
@Parameterized.Parameters
95-
public static Iterable<?> parameters() {
96-
return METADATA_STORE_CLASSES;
97-
}
98-
99-
@Test
100-
public void testMetadataStore() {
101-
this.contextRunner
102-
.run(context -> {
103-
assertThat(context.getBeansOfType(MetadataStore.class)).hasSize(1);
104-
105-
assertThat(context.getBeanNamesForType(this.classToInclude))
106-
.containsOnlyOnce(Introspector.decapitalize(this.classToInclude.getSimpleName()));
107-
});
108-
}
109-
110105
@Configuration
111106
@EnableAutoConfiguration
112107
public static class TestConfiguration {

Diff for: functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AbstractAwsS3ConsumerMockTests.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 the original author or authors.
2+
* Copyright 2016-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
3030
import com.amazonaws.services.s3.model.SetObjectAclRequest;
3131
import com.amazonaws.services.s3.transfer.PersistableTransfer;
3232
import com.amazonaws.services.s3.transfer.internal.S3ProgressListener;
33+
3334
import org.junit.jupiter.api.BeforeEach;
3435
import org.junit.jupiter.api.io.TempDir;
3536

@@ -144,5 +145,7 @@ public S3MessageHandler.UploadMetadataProvider uploadMetadataProvider() {
144145
}
145146
};
146147
}
148+
147149
}
150+
148151
}

Diff for: functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AmazonS3UploadFileTests.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 the original author or authors.
2+
* Copyright 2016-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@
2828
import com.amazonaws.services.s3.model.SetObjectAclRequest;
2929
import com.amazonaws.services.s3.transfer.internal.S3ProgressPublisher;
3030
import com.amazonaws.util.Md5Utils;
31-
import org.junit.jupiter.api.Disabled;
3231
import org.junit.jupiter.api.Test;
3332
import org.mockito.ArgumentCaptor;
3433

@@ -41,7 +40,6 @@
4140
import static org.mockito.Mockito.atLeastOnce;
4241
import static org.mockito.Mockito.verify;
4342

44-
@Disabled
4543
@TestPropertySource(properties = "s3.consumer.acl=PublicReadWrite")
4644
public class AmazonS3UploadFileTests extends AbstractAwsS3ConsumerMockTests {
4745

0 commit comments

Comments
 (0)