From 4cca684f368d3ff719c62d3fa4cac3cdb7828bff Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Fri, 31 Jul 2015 10:22:18 -0400 Subject: [PATCH] INT-3789: Upgrade to SF 4.2 and other fixes JIRA: https://jira.spring.io/browse/INT-3789 * Hazelcast -> `3.5.1` * ActiveMq -> `5.11.1` * Boon -> `0.33` * Spring Security -> `4.0.2` * Kryo -> `3.0.3` * Fix missed polishing for the `Log4jLevelAdjuster` according required generics: https://build.spring.io/browse/INT-MJATS41-348 * Fix `ImapIdelIntegrationTests` sporadic failure * Fix `Kryo` Codec stuff according to the changes in the latest Kryo version --- build.gradle | 12 +++--- .../integration/codec/kryo/PojoCodec.java | 4 ++ .../codec/{ => kryo}/CompositeCodecTests.java | 23 +++++------ ...sts.java => ImapIdleIntegrationTests.java} | 38 +++++++++++++------ .../imap-idle-mock-integration-config.xml | 3 +- .../test/rule/Log4jLevelAdjuster.java | 2 +- 6 files changed, 52 insertions(+), 30 deletions(-) rename spring-integration-core/src/test/java/org/springframework/integration/codec/{ => kryo}/CompositeCodecTests.java (67%) rename spring-integration-mail/src/test/java/org/springframework/integration/mail/config/{ImapIdelIntegrationTests.java => ImapIdleIntegrationTests.java} (80%) diff --git a/build.gradle b/build.gradle index 4adabb170e..86a36c692f 100644 --- a/build.gradle +++ b/build.gradle @@ -82,10 +82,10 @@ subprojects { subproject -> ext { - activeMqVersion = '5.11.0' + activeMqVersion = '5.11.1' aspectjVersion = '1.8.4' apacheSshdVersion = '0.13.0' - boonVersion = '0.31' + boonVersion = '0.33' chronicleVersion = '3.4.3' commonsDbcpVersion = '1.4' commonsIoVersion = '2.4' @@ -97,7 +97,7 @@ subprojects { subproject -> groovyVersion = '2.4.4' guavaVersion = '18.0' hamcrestVersion = '1.3' - hazelcastVersion = '3.4.2' + hazelcastVersion = '3.5.1' hibernateVersion = '4.3.10.Final' hsqldbVersion = '2.3.2' h2Version = '1.4.180' @@ -113,7 +113,7 @@ subprojects { subproject -> jsonpathVersion = '2.0.0' junitVersion = '4.11' jythonVersion = '2.5.3' - kryoShadedVersion = '3.0.0' + kryoShadedVersion = '3.0.3' log4jVersion = '1.2.17' mockitoVersion = '1.9.5' mysqlVersion = '5.1.34' @@ -136,10 +136,10 @@ subprojects { subproject -> springDataMongoVersion = '1.7.2.RELEASE' springDataRedisVersion = '1.5.2.RELEASE' springGemfireVersion = '1.6.0.RELEASE' - springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '4.0.1.RELEASE' + springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '4.0.2.RELEASE' springSocialTwitterVersion = '1.1.0.RELEASE' springRetryVersion = '1.1.2.RELEASE' - springVersion = project.hasProperty('springVersion') ? project.springVersion : '4.2.0.BUILD-SNAPSHOT' + springVersion = project.hasProperty('springVersion') ? project.springVersion : '4.2.0.RELEASE' springWsVersion = '2.2.1.RELEASE' xmlUnitVersion = '1.5' xstreamVersion = '1.4.7' diff --git a/spring-integration-core/src/main/java/org/springframework/integration/codec/kryo/PojoCodec.java b/spring-integration-core/src/main/java/org/springframework/integration/codec/kryo/PojoCodec.java index ed5f4f766b..969673d5a1 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/codec/kryo/PojoCodec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/codec/kryo/PojoCodec.java @@ -19,6 +19,8 @@ package org.springframework.integration.codec.kryo; import java.util.Collections; import java.util.List; +import org.objenesis.strategy.StdInstantiatorStrategy; + import org.springframework.util.CollectionUtils; import com.esotericsoftware.kryo.Kryo; @@ -31,6 +33,7 @@ import com.esotericsoftware.kryo.io.Output; * {@link KryoRegistrar}s. * * @author David Turanski + * @author Artem Bilan * @since 4.2 */ public class PojoCodec extends AbstractKryoCodec { @@ -96,6 +99,7 @@ public class PojoCodec extends AbstractKryoCodec { @Override protected void configureKryoInstance(Kryo kryo) { + kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); if (this.kryoRegistrar != null) { this.kryoRegistrar.registerTypes(kryo); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/codec/CompositeCodecTests.java b/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/CompositeCodecTests.java similarity index 67% rename from spring-integration-core/src/test/java/org/springframework/integration/codec/CompositeCodecTests.java rename to spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/CompositeCodecTests.java index 75035eac25..c405e6400a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/codec/CompositeCodecTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/CompositeCodecTests.java @@ -1,20 +1,20 @@ /* * Copyright 2015 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. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -package org.springframework.integration.codec; +package org.springframework.integration.codec.kryo; import static org.junit.Assert.assertEquals; @@ -25,7 +25,8 @@ import java.util.Map; import org.junit.Before; import org.junit.Test; -import org.springframework.integration.codec.kryo.PojoCodec; +import org.springframework.integration.codec.Codec; +import org.springframework.integration.codec.CompositeCodec; /** * @author David Turanski diff --git a/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/ImapIdelIntegrationTests.java b/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/ImapIdleIntegrationTests.java similarity index 80% rename from spring-integration-mail/src/test/java/org/springframework/integration/mail/config/ImapIdelIntegrationTests.java rename to spring-integration-mail/src/test/java/org/springframework/integration/mail/config/ImapIdleIntegrationTests.java index 1e97ec86dd..90e2c0e6ae 100644 --- a/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/ImapIdelIntegrationTests.java +++ b/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/ImapIdleIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 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. @@ -16,21 +16,23 @@ package org.springframework.integration.mail.config; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.lang.reflect.Field; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import javax.mail.Folder; import javax.mail.Message; import org.junit.Test; -import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -39,13 +41,15 @@ import org.springframework.integration.mail.ImapIdleChannelAdapter; import org.springframework.integration.mail.ImapMailReceiver; import org.springframework.integration.test.util.TestUtils; import org.springframework.util.ReflectionUtils; + /** * @author Oleg Zhurakousky + * @author Artem Bilan */ -public class ImapIdelIntegrationTests { +public class ImapIdleIntegrationTests { @Test - public void testWithTransactionSynchronization() throws Exception{ + public void testWithTransactionSynchronization() throws Exception { final AtomicBoolean block = new AtomicBoolean(false); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("imap-idle-mock-integration-config.xml", this.getClass()); @@ -61,7 +65,7 @@ public class ImapIdelIntegrationTests { // to emulate the behavior of IDLE public Object answer(InvocationOnMock invocation) throws Throwable { - if (block.get()){ + if (block.get()) { Thread.sleep(5000); } block.set(true); @@ -83,17 +87,29 @@ public class ImapIdelIntegrationTests { mrField.set(adapter, receiver); // end mock setup + final CountDownLatch txProcessorLatch = new CountDownLatch(1); + doAnswer(new Answer() { + + @Override + public Object answer(InvocationOnMock invocation) throws Throwable { + txProcessorLatch.countDown(); + return null; + } + + }).when(processor).process(any(Message.class)); + adapter.start(); - Thread.sleep(1000); - // validating that TXpost processor was invoked + assertTrue(txProcessorLatch.await(10, TimeUnit.SECONDS)); adapter.stop(); context.destroy(); - verify(processor, Mockito.times(1)).process(m1); + } - public static interface PostTransactionProcessor { - public void process(Message mailMessage); + public interface PostTransactionProcessor { + + void process(Message mailMessage); } + } diff --git a/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/imap-idle-mock-integration-config.xml b/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/imap-idle-mock-integration-config.xml index eada95c872..911f18b36f 100644 --- a/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/imap-idle-mock-integration-config.xml +++ b/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/imap-idle-mock-integration-config.xml @@ -20,7 +20,8 @@ - + diff --git a/spring-integration-test/src/main/java/org/springframework/integration/test/rule/Log4jLevelAdjuster.java b/spring-integration-test/src/main/java/org/springframework/integration/test/rule/Log4jLevelAdjuster.java index a03a95dbd2..bb8f7128b0 100755 --- a/spring-integration-test/src/main/java/org/springframework/integration/test/rule/Log4jLevelAdjuster.java +++ b/spring-integration-test/src/main/java/org/springframework/integration/test/rule/Log4jLevelAdjuster.java @@ -56,7 +56,7 @@ public class Log4jLevelAdjuster implements MethodRule { public Log4jLevelAdjuster(Level level, String... categories) { this.level = level; - this.classes = new Class[0]; + this.classes = new Class[0]; this.categories = categories; }