From f2fe714853d28f65fb1a7b76115a45eb9e7c8a64 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 21 Oct 2019 10:57:30 -0400 Subject: [PATCH] Try LocalStack with JUnit 4 --- build.gradle | 2 +- .../aws/kinesis/KinesisIntegrationTests.java | 2 ++ ...amoDbLockRegistryLeaderInitiatorTests.java | 3 ++ .../aws/lock/DynamoDbLockRegistryTests.java | 2 ++ .../metadata/DynamoDbMetadataStoreTests.java | 36 +++++++++---------- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/build.gradle b/build.gradle index 775eb95..dc346c6 100644 --- a/build.gradle +++ b/build.gradle @@ -110,7 +110,7 @@ dependencies { compile("javax.servlet:javax.servlet-api:$servletApiVersion", provided) testCompile ('org.springframework.integration:spring-integration-test') { - exclude group: 'junit' +// exclude group: 'junit' } testCompile "org.assertj:assertj-core:$assertjVersion" diff --git a/src/test/java/org/springframework/integration/aws/kinesis/KinesisIntegrationTests.java b/src/test/java/org/springframework/integration/aws/kinesis/KinesisIntegrationTests.java index e5b2240..a9975d1 100644 --- a/src/test/java/org/springframework/integration/aws/kinesis/KinesisIntegrationTests.java +++ b/src/test/java/org/springframework/integration/aws/kinesis/KinesisIntegrationTests.java @@ -25,6 +25,7 @@ import java.util.Set; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.OS; @@ -66,6 +67,7 @@ import com.amazonaws.services.kinesis.AmazonKinesisAsync; * @author Artem Bilan * @since 1.1 */ +@Disabled @DisabledOnOs(OS.WINDOWS) @SpringJUnitConfig @ExtendWith(LocalstackDockerExtension.class) diff --git a/src/test/java/org/springframework/integration/aws/leader/DynamoDbLockRegistryLeaderInitiatorTests.java b/src/test/java/org/springframework/integration/aws/leader/DynamoDbLockRegistryLeaderInitiatorTests.java index e00506c..f3b010b 100644 --- a/src/test/java/org/springframework/integration/aws/leader/DynamoDbLockRegistryLeaderInitiatorTests.java +++ b/src/test/java/org/springframework/integration/aws/leader/DynamoDbLockRegistryLeaderInitiatorTests.java @@ -24,8 +24,10 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import org.junit.Ignore; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.OS; @@ -54,6 +56,7 @@ import com.amazonaws.waiters.WaiterParameters; * * @since 2.0 */ +@Disabled @DisabledOnOs(OS.WINDOWS) @ExtendWith(LocalstackDockerExtension.class) @LocalstackDockerProperties(randomizePorts = true, services = "dynamodb") diff --git a/src/test/java/org/springframework/integration/aws/lock/DynamoDbLockRegistryTests.java b/src/test/java/org/springframework/integration/aws/lock/DynamoDbLockRegistryTests.java index 2b614aa..6ed23ea 100644 --- a/src/test/java/org/springframework/integration/aws/lock/DynamoDbLockRegistryTests.java +++ b/src/test/java/org/springframework/integration/aws/lock/DynamoDbLockRegistryTests.java @@ -27,6 +27,7 @@ import java.util.concurrent.locks.Lock; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.OS; @@ -57,6 +58,7 @@ import com.amazonaws.waiters.WaiterParameters; * * @since 2.0 */ +@Disabled @DisabledOnOs(OS.WINDOWS) @SpringJUnitConfig @ExtendWith(LocalstackDockerExtension.class) diff --git a/src/test/java/org/springframework/integration/aws/metadata/DynamoDbMetadataStoreTests.java b/src/test/java/org/springframework/integration/aws/metadata/DynamoDbMetadataStoreTests.java index 4512863..3d67508 100644 --- a/src/test/java/org/springframework/integration/aws/metadata/DynamoDbMetadataStoreTests.java +++ b/src/test/java/org/springframework/integration/aws/metadata/DynamoDbMetadataStoreTests.java @@ -21,17 +21,15 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Collections; import java.util.concurrent.CountDownLatch; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.integration.aws.ExtendedDockerTestUtils; import org.springframework.integration.test.util.TestUtils; -import cloud.localstack.docker.LocalstackDockerExtension; +import cloud.localstack.docker.LocalstackDockerTestRunner; import cloud.localstack.docker.annotation.LocalstackDockerProperties; import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsync; import com.amazonaws.services.dynamodbv2.model.AttributeValue; @@ -47,10 +45,10 @@ import com.amazonaws.waiters.WaiterParameters; * * @since 1.1 */ -@DisabledOnOs(OS.WINDOWS) -@ExtendWith(LocalstackDockerExtension.class) +//@DisabledOnOs(OS.WINDOWS) +@RunWith(LocalstackDockerTestRunner.class) @LocalstackDockerProperties(randomizePorts = true, services = "dynamodb") -class DynamoDbMetadataStoreTests { +public class DynamoDbMetadataStoreTests { private static AmazonDynamoDBAsync DYNAMO_DB; @@ -62,8 +60,8 @@ class DynamoDbMetadataStoreTests { private final String file1Id = "12345"; - @BeforeAll - static void setup() { + @BeforeClass + public static void setup() { DYNAMO_DB = ExtendedDockerTestUtils.getClientDynamoDbAsync(); try { @@ -79,12 +77,12 @@ class DynamoDbMetadataStoreTests { } store = new DynamoDbMetadataStore(DYNAMO_DB, TEST_TABLE); - store.setTimeToLive(10); // Dynalite doesn't support TTL + store.setTimeToLive(10); store.afterPropertiesSet(); } - @BeforeEach - void clear() throws InterruptedException { + @Before + public void clear() throws InterruptedException { CountDownLatch createTableLatch = TestUtils.getPropertyValue(store, "createTableLatch", CountDownLatch.class); createTableLatch.await(); @@ -93,7 +91,7 @@ class DynamoDbMetadataStoreTests { } @Test - void testGetFromStore() { + public void testGetFromStore() { String fileID = store.get(this.file1); assertThat(fileID).isNull(); @@ -105,7 +103,7 @@ class DynamoDbMetadataStoreTests { } @Test - void testPutIfAbsent() { + public void testPutIfAbsent() { String fileID = store.get(this.file1); assertThat(fileID).describedAs("Get First time, Value must not exist").isNull(); @@ -120,7 +118,7 @@ class DynamoDbMetadataStoreTests { } @Test - void testRemove() { + public void testRemove() { String fileID = store.remove(this.file1); assertThat(fileID).isNull(); @@ -136,7 +134,7 @@ class DynamoDbMetadataStoreTests { } @Test - void testReplace() { + public void testReplace() { boolean removedValue = store.replace(this.file1, this.file1Id, "4567"); assertThat(removedValue).isFalse();