From be9d735c1c843ab78cb706447c34c45aa6fde3db Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 7 Jan 2020 11:56:36 -0500 Subject: [PATCH] Fix Gemfire tests for the latest Spring Data * Upgrade to SF-5.2.3.BUILD-SNAPSHOT to confirm that there is no regression in HTTP module --- build.gradle | 4 +-- .../inbound/CqInboundChannelAdapterTests.java | 31 +++++++++---------- .../GemfireInboundChannelAdapterTests.java | 25 ++++++++------- .../GemfireOutboundChannelAdapterTests.java | 31 ++++++++++--------- 4 files changed, 47 insertions(+), 44 deletions(-) diff --git a/build.gradle b/build.gradle index d9d5287437..dc15899b96 100644 --- a/build.gradle +++ b/build.gradle @@ -95,7 +95,7 @@ ext { springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : 'Neumann-BUILD-SNAPSHOT' springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '5.3.0.BUILD-SNAPSHOT' springRetryVersion = '1.2.5.RELEASE' - springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.2.2.RELEASE' + springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.2.3.BUILD-SNAPSHOT' springWsVersion = '3.0.8.RELEASE' tomcatVersion = "9.0.30" xstreamVersion = '1.4.11.1' @@ -473,7 +473,7 @@ project('spring-integration-gemfire') { api "commons-io:commons-io:$commonsIoVersion" testImplementation project(':spring-integration-stream') - + testRuntimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl' } } diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests.java index 68f10cf4ee..b34c831b11 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,22 +21,21 @@ import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; import java.io.OutputStream; +import org.apache.geode.cache.Region; import org.apache.geode.cache.query.CqEvent; -import org.apache.geode.internal.cache.LocalRegion; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.integration.gemfire.fork.ForkUtil; import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.Message; import org.springframework.messaging.PollableChannel; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * @author David Turanski @@ -44,13 +43,13 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Artem Bilan * */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration +@SpringJUnitConfig @DirtiesContext public class CqInboundChannelAdapterTests { @Autowired - LocalRegion region; + @Qualifier("test") + Region region; @Autowired ConfigurableApplicationContext applicationContext; @@ -66,13 +65,13 @@ public class CqInboundChannelAdapterTests { static OutputStream os; - @BeforeClass - public static void startUp() throws Exception { + @BeforeAll + public static void startUp() { os = ForkUtil.cacheServer(); } @Test - public void testCqEvent() throws InterruptedException { + public void testCqEvent() { assertThat(TestUtils.getPropertyValue(withDurable, "durable", Boolean.class)).isTrue(); region.put("one", 1); Message msg = outputChannel1.receive(10000); @@ -81,14 +80,14 @@ public class CqInboundChannelAdapterTests { } @Test - public void testPayloadExpression() throws InterruptedException { + public void testPayloadExpression() { region.put("one", 1); Message msg = outputChannel2.receive(10000); assertThat(msg).isNotNull(); assertThat(msg.getPayload()).isEqualTo(1); } - @AfterClass + @AfterAll public static void cleanUp() { sendSignal(); } diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests.java index 0ad180a344..299a237109 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,26 +19,26 @@ package org.springframework.integration.gemfire.inbound; import static org.assertj.core.api.Assertions.assertThat; import org.apache.geode.cache.EntryEvent; -import org.apache.geode.internal.cache.LocalRegion; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.apache.geode.cache.Region; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandler; import org.springframework.messaging.MessagingException; import org.springframework.messaging.SubscribableChannel; import org.springframework.messaging.support.ErrorMessage; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * @author David Turanski + * @author Artem Bilan + * * @since 2.1 */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration +@SpringJUnitConfig @DirtiesContext public class GemfireInboundChannelAdapterTests { @@ -55,13 +55,16 @@ public class GemfireInboundChannelAdapterTests { SubscribableChannel errorChannel; @Autowired - LocalRegion region1; + @Qualifier("region1") + Region region1; @Autowired - LocalRegion region2; + @Qualifier("region2") + Region region2; @Autowired - LocalRegion region3; + @Qualifier("region3") + Region region3; @Test public void testGemfireInboundChannelAdapterWithExpression() { diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests.java index f54f4b08cc..82a2ba4ca4 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,27 +21,26 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.HashMap; import java.util.Map; -import org.apache.geode.internal.cache.DistributedRegion; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.apache.geode.cache.Region; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * @author David Turanski * @author Artem Bilan + * * @since 2.1 */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration +@SpringJUnitConfig @DirtiesContext public class GemfireOutboundChannelAdapterTests { @@ -49,19 +48,21 @@ public class GemfireOutboundChannelAdapterTests { MessageChannel cacheChannel1; @Autowired - DistributedRegion region1; + @Qualifier("region1") + Region region1; @Autowired MessageChannel cacheChannel2; @Autowired - DistributedRegion region2; + @Qualifier("region2") + Region region2; @Autowired MessageChannel cacheChainChannel; - @Before + @BeforeEach public void setUp() { region1.clear(); region2.clear(); @@ -69,7 +70,7 @@ public class GemfireOutboundChannelAdapterTests { @Test public void testWriteMapPayload() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("foo", "bar"); Message message = MessageBuilder.withPayload(map).build(); @@ -87,9 +88,9 @@ public class GemfireOutboundChannelAdapterTests { assertThat(region2.get("foo")).isEqualTo("bar"); } - @Test //INT-2275 + @Test public void testWriteWithinChain() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("foo", "bar"); Message message = MessageBuilder.withPayload(map).build();