Experimental: Support Gradle --parallel
This should be treated as experimental but with these changes it seems to build ok. BUILD SUCCESSFUL Total time: 5 mins 15.533 secs It turns out that our sporadic Redis problems were fixed in a later version of Jedis. The problem was that the `connection.subscribe()` exited immediately. When I started adding debug logic, the problem went away (because I was using a newer versio of Jedis). spring-data-redis 1.5.2 is updated to work with the 2.7.3 version of Jedis. Polishing
This commit is contained in:
committed by
Artem Bilan
parent
b57018b78b
commit
75a7b63350
@@ -5,8 +5,7 @@ services:
|
||||
- mongodb
|
||||
- rabbitmq
|
||||
- redis-server
|
||||
install:
|
||||
- sudo rabbitmq-plugins enable rabbitmq_mqtt
|
||||
- sudo service rabbitmq-server restart
|
||||
env:
|
||||
- TERM=dumb SI_FATAL_WHEN_NO_BEANFACTORY=true GRADLE_OPTS='-XX:MaxPermSize=512M -Xmx1024M'
|
||||
#script:
|
||||
# - ./gradlew build --parallel
|
||||
|
||||
@@ -103,7 +103,7 @@ subprojects { subproject ->
|
||||
jackson2Version = '2.5.1'
|
||||
javaxActivationVersion = '1.1.1'
|
||||
javaxMailVersion = '1.5.2'
|
||||
jedisVersion = '2.6.2'
|
||||
jedisVersion = '2.7.3'
|
||||
jmsApiVersion = '1.1-rev-1'
|
||||
jpaApiVersion = '2.0.0'
|
||||
jrubyVersion = '1.7.19'
|
||||
@@ -131,7 +131,7 @@ subprojects { subproject ->
|
||||
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '1.5.0.M1'
|
||||
// springCloudClusterVersion = '1.0.0.BUILD-SNAPSHOT'
|
||||
springDataMongoVersion = '1.7.0.RELEASE'
|
||||
springDataRedisVersion = '1.5.0.RELEASE'
|
||||
springDataRedisVersion = '1.5.2.BUILD-SNAPSHOT'
|
||||
springGemfireVersion = '1.6.0.RELEASE'
|
||||
springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '4.0.1.RELEASE'
|
||||
springSocialTwitterVersion = '1.1.0.RELEASE'
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.integration.redis.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
@@ -38,10 +37,10 @@ import org.springframework.integration.redis.inbound.RedisInboundChannelAdapter;
|
||||
import org.springframework.integration.redis.rules.RedisAvailable;
|
||||
import org.springframework.integration.redis.rules.RedisAvailableTests;
|
||||
import org.springframework.integration.support.converter.SimpleMessageConverter;
|
||||
import org.springframework.integration.support.utils.IntegrationUtils;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
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;
|
||||
|
||||
@@ -53,6 +52,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class RedisInboundChannelAdapterParserTests extends RedisAvailableTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -16,13 +16,15 @@
|
||||
|
||||
package org.springframework.integration.redis.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -33,16 +35,15 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
|
||||
import org.springframework.integration.redis.inbound.RedisInboundChannelAdapter;
|
||||
import org.springframework.integration.redis.outbound.RedisPublishingMessageHandler;
|
||||
import org.springframework.integration.redis.rules.RedisAvailable;
|
||||
import org.springframework.integration.redis.rules.RedisAvailableTests;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.support.converter.SimpleMessageConverter;
|
||||
import org.springframework.integration.support.utils.IntegrationUtils;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -55,6 +56,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class RedisOutboundChannelAdapterParserTests extends RedisAvailableTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -37,15 +37,18 @@ import org.springframework.integration.redis.inbound.RedisQueueMessageDrivenEndp
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @since 3.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class RedisQueueInboundChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.integration.redis.inbound.RedisQueueInboundGateway;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class RedisQueueInboundGatewayParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-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,7 +16,11 @@
|
||||
|
||||
package org.springframework.integration.redis.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
@@ -33,15 +37,18 @@ import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
|
||||
import org.springframework.integration.redis.outbound.RedisQueueOutboundChannelAdapter;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @since 3.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class RedisQueueOutboundChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-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.
|
||||
@@ -26,28 +26,25 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.integration.endpoint.PollingConsumer;
|
||||
import org.springframework.integration.redis.outbound.RedisQueueOutboundGateway;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author David Liu
|
||||
* @author Gary Russell
|
||||
* since 4.1
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class RedisQueueOutboundGatewayParserTests {
|
||||
|
||||
@Autowired
|
||||
private RedisConnectionFactory connectionFactory;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("outboundGateway")
|
||||
private PollingConsumer consumer;
|
||||
@@ -67,9 +64,6 @@ public class RedisQueueOutboundGatewayParserTests {
|
||||
@Autowired
|
||||
private RedisSerializer<?> serializer;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testDefaultConfig() throws Exception {
|
||||
assertFalse(TestUtils.getPropertyValue(this.defaultGateway, "extractPayload", Boolean.class));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.data.redis.support.collections.RedisCollectionFactory
|
||||
import org.springframework.expression.spel.standard.SpelExpression;
|
||||
import org.springframework.integration.redis.inbound.RedisStoreMessageSource;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -43,6 +44,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class RedisStoreInboundChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2014 the original author or authors
|
||||
* Copyright 2007-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,7 +16,11 @@
|
||||
|
||||
package org.springframework.integration.redis.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
@@ -34,6 +38,7 @@ import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
|
||||
import org.springframework.integration.redis.outbound.RedisStoreWritingMessageHandler;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
/**
|
||||
@@ -44,6 +49,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class RedisStoreOutboundChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -255,7 +255,7 @@ public class RedisQueueMessageDrivenEndpointTests extends RedisAvailableTests {
|
||||
endpoint.stop();
|
||||
|
||||
executorService.shutdown();
|
||||
assertTrue(executorService.awaitTermination(1, TimeUnit.SECONDS));
|
||||
assertTrue(executorService.awaitTermination(10, TimeUnit.SECONDS));
|
||||
|
||||
Mockito.verify(boundListOperations).rightPush(Mockito.any(byte[].class));
|
||||
}
|
||||
@@ -286,9 +286,9 @@ public class RedisQueueMessageDrivenEndpointTests extends RedisAvailableTests {
|
||||
|
||||
@Override
|
||||
public void publishEvent(Object event) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
endpoint.setOutputChannel(channel);
|
||||
endpoint.setReceiveTimeout(100);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class RedisAvailableTests {
|
||||
RedisConnection connection = null;
|
||||
|
||||
int n = 0;
|
||||
while (n++ < 100 &&
|
||||
while (n++ < 300 &&
|
||||
(connection =
|
||||
TestUtils.getPropertyValue(container, "subscriptionTask.connection", RedisConnection .class)) == null) {
|
||||
Thread.sleep(100);
|
||||
@@ -72,10 +72,10 @@ public class RedisAvailableTests {
|
||||
assertNotNull("RedisMessageListenerContainer Failed to Connect", connection);
|
||||
|
||||
n = 0;
|
||||
while (n++ < 100 && !connection.isSubscribed()) {
|
||||
while (n++ < 300 && !connection.isSubscribed()) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
assertTrue("RedisMessageListenerContainer Failed to Subscribe", n < 100);
|
||||
assertTrue("RedisMessageListenerContainer Failed to Subscribe", n < 300);
|
||||
}
|
||||
|
||||
protected void awaitContainerSubscribedWithPatterns(RedisMessageListenerContainer container) throws Exception {
|
||||
@@ -84,10 +84,10 @@ public class RedisAvailableTests {
|
||||
RedisConnection.class);
|
||||
|
||||
int n = 0;
|
||||
while (n++ < 100 && connection.getSubscription().getPatterns().size() == 0) {
|
||||
while (n++ < 300 && connection.getSubscription().getPatterns().size() == 0) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
assertTrue("RedisMessageListenerContainer Failed to Subscribe with patterns", n < 100);
|
||||
assertTrue("RedisMessageListenerContainer Failed to Subscribe with patterns", n < 300);
|
||||
// wait another second because of race condition
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class RedisAvailableTests {
|
||||
drain(channel);
|
||||
long now = System.currentTimeMillis();
|
||||
Message<?> received = null;
|
||||
while (received == null && System.currentTimeMillis() - now < 10000) {
|
||||
while (received == null && System.currentTimeMillis() - now < 30000) {
|
||||
redisTemplate.convertAndSend(redisChannelName, message);
|
||||
received = channel.receive(1000);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ log4j.rootCategory=WARN, stdout
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %5p %t [%c] - <%m>%n
|
||||
|
||||
log4j.category.org.springframework.data.redis=WARN
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
log4j.category.org.springframework.integration.redis=INFO
|
||||
|
||||
@@ -26,10 +26,13 @@
|
||||
requires-reply="false"
|
||||
host="localhost">
|
||||
<rmi:request-handler-advice-chain>
|
||||
<beans:bean class="org.springframework.integration.rmi.config.RmiOutboundGatewayParserTests$FooAdvice" />
|
||||
<beans:ref bean="advice" />
|
||||
</rmi:request-handler-advice-chain>
|
||||
</rmi:outbound-gateway>
|
||||
|
||||
<beans:bean id="advice"
|
||||
class="org.springframework.integration.rmi.config.RmiOutboundGatewayParserTests$FooAdvice" />
|
||||
|
||||
<chain input-channel="rmiOutboundGatewayInsideChain">
|
||||
<rmi:outbound-gateway remote-channel="testChannel" host="localhost" requires-reply="false"/>
|
||||
</chain>
|
||||
@@ -22,12 +22,13 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.integration.rmi.RmiInboundGateway;
|
||||
@@ -38,20 +39,47 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class RmiOutboundGatewayParserTests {
|
||||
|
||||
private final QueueChannel testChannel = new QueueChannel();
|
||||
private static final QueueChannel testChannel = new QueueChannel();
|
||||
|
||||
private static volatile int adviceCalled;
|
||||
@Autowired
|
||||
public FooAdvice advice;
|
||||
|
||||
@Before
|
||||
public void setupTestInboundGateway() throws Exception {
|
||||
@Autowired
|
||||
private MessageChannel advisedChannel;
|
||||
|
||||
@Autowired
|
||||
private MessageChannel rmiOutboundGatewayInsideChain;
|
||||
|
||||
@Autowired
|
||||
private MessageChannel requestReplyRmiWithChainChannel;
|
||||
|
||||
@Autowired
|
||||
private PollableChannel replyChannel;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("gateway.handler")
|
||||
RmiOutboundGateway gateway;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("advised.handler")
|
||||
RmiOutboundGateway advised;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupTestInboundGateway() throws Exception {
|
||||
testChannel.setBeanName("testChannel");
|
||||
RmiInboundGateway gateway = new RmiInboundGateway();
|
||||
gateway.setRequestChannel(testChannel);
|
||||
@@ -62,57 +90,41 @@ public class RmiOutboundGatewayParserTests {
|
||||
|
||||
@Test
|
||||
public void testOrder() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"rmiOutboundGatewayParserTests.xml", this.getClass());
|
||||
RmiOutboundGateway gateway = context.getBean("gateway.handler", RmiOutboundGateway.class);
|
||||
assertEquals(23, TestUtils.getPropertyValue(gateway, "order"));
|
||||
assertTrue(TestUtils.getPropertyValue(gateway, "requiresReply", Boolean.class));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void directInvocation() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"rmiOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageChannel localChannel = (MessageChannel) context.getBean("advisedChannel");
|
||||
RmiOutboundGateway gateway = context.getBean("advised.handler", RmiOutboundGateway.class);
|
||||
assertFalse(TestUtils.getPropertyValue(gateway, "requiresReply", Boolean.class));
|
||||
assertFalse(TestUtils.getPropertyValue(advised, "requiresReply", Boolean.class));
|
||||
|
||||
localChannel.send(new GenericMessage<String>("test"));
|
||||
advisedChannel.send(new GenericMessage<String>("test"));
|
||||
Message<?> result = testChannel.receive(1000);
|
||||
assertNotNull(result);
|
||||
assertEquals("test", result.getPayload());
|
||||
assertEquals(1, adviceCalled);
|
||||
context.close();
|
||||
assertEquals(1, advice.adviceCalled);
|
||||
}
|
||||
|
||||
@Test //INT-1029
|
||||
public void testRmiOutboundGatewayInsideChain() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"rmiOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageChannel localChannel = context.getBean("rmiOutboundGatewayInsideChain", MessageChannel.class);
|
||||
localChannel.send(MessageBuilder.withPayload("test").build());
|
||||
rmiOutboundGatewayInsideChain.send(MessageBuilder.withPayload("test").build());
|
||||
Message<?> result = testChannel.receive(1000);
|
||||
assertNotNull(result);
|
||||
assertEquals("test", result.getPayload());
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test //INT-1029
|
||||
public void testRmiRequestReplyWithinChain() {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"rmiOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageChannel localChannel = context.getBean("requestReplyRmiWithChainChannel", MessageChannel.class);
|
||||
localChannel.send(MessageBuilder.withPayload("test").build());
|
||||
PollableChannel replyChannel = context.getBean("replyChannel", PollableChannel.class);
|
||||
Message<?> result = replyChannel.receive();
|
||||
requestReplyRmiWithChainChannel.send(MessageBuilder.withPayload("test").build());
|
||||
Message<?> result = replyChannel.receive(1000);
|
||||
assertNotNull(result);
|
||||
assertEquals("TEST", result.getPayload());
|
||||
context.close();
|
||||
}
|
||||
|
||||
public static class FooAdvice extends AbstractRequestHandlerAdvice {
|
||||
|
||||
int adviceCalled;
|
||||
|
||||
@Override
|
||||
protected Object doInvoke(ExecutionCallback callback, Object target, Message<?> message) throws Exception {
|
||||
adviceCalled++;
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.springframework.integration.test.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
import com.sun.management.HotSpotDiagnosticMXBean;
|
||||
|
||||
/**
|
||||
* Use to take a heap dump programmatically. Useful to examine the heap when debugging
|
||||
* sporadic test failures.
|
||||
* <p>
|
||||
* Usage: {@code HeapDumper.dumpHeap("/tmp/foo.hprof");}
|
||||
* <p>
|
||||
* If the file exists already, it will be replaced.
|
||||
* <p>
|
||||
* Courtesy:
|
||||
* https://blogs.oracle.com/sundararajan/entry/programmatically_dumping_heap_from_java
|
||||
* <pre>
|
||||
* See https://docs.oracle.com/javase/8/docs/jre/api/management/extension/com/sun/management/HotSpotDiagnosticMXBean.html#dumpHeap-java.lang.String-boolean-
|
||||
* </pre>
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
public class HeapDumper {
|
||||
|
||||
// This is the name of the HotSpot Diagnostic MBean
|
||||
private static final String HOTSPOT_BEAN_NAME = "com.sun.management:type=HotSpotDiagnostic";
|
||||
|
||||
// field to store the hotspot diagnostic MBean
|
||||
private static volatile HotSpotDiagnosticMXBean hotspotMBean;
|
||||
|
||||
public static void dumpHeap(String fileName) {
|
||||
dumpHeap(fileName, true);
|
||||
}
|
||||
|
||||
public static void dumpHeap(String fileName, boolean live) {
|
||||
File file = new File(fileName);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
// initialize hotspot diagnostic MBean
|
||||
initHotspotMBean();
|
||||
try {
|
||||
hotspotMBean.dumpHeap(fileName, live);
|
||||
}
|
||||
catch (RuntimeException re) {
|
||||
throw re;
|
||||
}
|
||||
catch (Exception exp) {
|
||||
throw new RuntimeException(exp);
|
||||
}
|
||||
}
|
||||
|
||||
// initialize the hotspot diagnostic MBean field
|
||||
private static void initHotspotMBean() {
|
||||
if (hotspotMBean == null) {
|
||||
synchronized (Object.class) {
|
||||
if (hotspotMBean == null) {
|
||||
hotspotMBean = getHotspotMBean();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get the hotspot diagnostic MBean from the
|
||||
// platform MBean server
|
||||
private static HotSpotDiagnosticMXBean getHotspotMBean() {
|
||||
try {
|
||||
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
|
||||
HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy(server, HOTSPOT_BEAN_NAME,
|
||||
HotSpotDiagnosticMXBean.class);
|
||||
return bean;
|
||||
}
|
||||
catch (RuntimeException re) {
|
||||
throw re;
|
||||
}
|
||||
catch (Exception exp) {
|
||||
throw new RuntimeException(exp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,6 +49,8 @@ import org.springframework.web.socket.client.WebSocketClient;
|
||||
*/
|
||||
public final class ClientWebSocketContainer extends IntegrationWebSocketContainer implements SmartLifecycle {
|
||||
|
||||
private static final int DEFAULT_CONNECTION_TIMEOUT = 10;
|
||||
|
||||
private final WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
|
||||
|
||||
private final ConnectionManagerSupport connectionManager;
|
||||
@@ -59,6 +61,8 @@ public final class ClientWebSocketContainer extends IntegrationWebSocketContaine
|
||||
|
||||
private volatile Throwable openConnectionException;
|
||||
|
||||
private volatile int connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
|
||||
|
||||
public ClientWebSocketContainer(WebSocketClient client, String uriTemplate, Object... uriVariables) {
|
||||
Assert.notNull(client, "'client' must not be null");
|
||||
this.connectionManager = new IntegrationWebSocketConnectionManager(client, uriTemplate, uriVariables);
|
||||
@@ -84,6 +88,15 @@ public final class ClientWebSocketContainer extends IntegrationWebSocketContaine
|
||||
this.headers.putAll(headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the connection timeout in seconds; default: 10.
|
||||
* @param connectionTimeout the timeout in seconds.
|
||||
* @since 4.2
|
||||
*/
|
||||
public void setConnectionTimeout(int connectionTimeout) {
|
||||
this.connectionTimeout = connectionTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link #clientSession} {@link WebSocketSession}.
|
||||
* Independently of provided argument, this method always returns only the
|
||||
@@ -95,7 +108,7 @@ public final class ClientWebSocketContainer extends IntegrationWebSocketContaine
|
||||
public WebSocketSession getSession(String sessionId) {
|
||||
if (this.isRunning()) {
|
||||
try {
|
||||
this.connectionLatch.await(10, TimeUnit.SECONDS);
|
||||
this.connectionLatch.await(this.connectionTimeout, TimeUnit.SECONDS);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
logger.error("'clientSession' has not been established during 'openConnection'");
|
||||
|
||||
@@ -66,6 +66,7 @@ public class ClientWebSocketContainerTests {
|
||||
|
||||
TestWebSocketListener messageListener = new TestWebSocketListener();
|
||||
container.setMessageListener(messageListener);
|
||||
container.setConnectionTimeout(30);
|
||||
|
||||
container.start();
|
||||
|
||||
|
||||
@@ -75,20 +75,20 @@ public class ZookeeperLeaderTests extends ZookeeperTestSupport {
|
||||
LeaderInitiator initiator2 = new LeaderInitiator(this.client, candidate2, "/sitest");
|
||||
initiator2.setLeaderEventPublisher(publisher);
|
||||
initiator2.start();
|
||||
AbstractLeaderEvent event = this.events.poll(10, TimeUnit.SECONDS);
|
||||
AbstractLeaderEvent event = this.events.poll(30, TimeUnit.SECONDS);
|
||||
assertNotNull(event);
|
||||
assertThat(event, instanceOf(OnGrantedEvent.class));
|
||||
event.getContext().yield();
|
||||
|
||||
assertTrue(this.adapter.isRunning());
|
||||
|
||||
event = this.events.poll(10, TimeUnit.SECONDS);
|
||||
event = this.events.poll(30, TimeUnit.SECONDS);
|
||||
assertNotNull(event);
|
||||
assertThat(event, instanceOf(OnRevokedEvent.class));
|
||||
|
||||
assertFalse(this.adapter.isRunning());
|
||||
|
||||
event = this.events.poll(10, TimeUnit.SECONDS);
|
||||
event = this.events.poll(30, TimeUnit.SECONDS);
|
||||
assertNotNull(event);
|
||||
assertThat(event, instanceOf(OnGrantedEvent.class));
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ZookeeperLeaderTests extends ZookeeperTestSupport {
|
||||
|
||||
initiator1.stop();
|
||||
initiator2.stop();
|
||||
event = this.events.poll(10, TimeUnit.SECONDS);
|
||||
event = this.events.poll(30, TimeUnit.SECONDS);
|
||||
assertNotNull(event);
|
||||
assertThat(event, instanceOf(OnRevokedEvent.class));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user