use of org.springframework.integration.redis.rules.RedisAvailable in project spring-integration by spring-projects.
the class RedisMessageStoreTests method testAddStringMessage.
@Test
@RedisAvailable
public void testAddStringMessage() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Message<String> stringMessage = new GenericMessage<String>("Hello Redis");
Message<String> storedMessage = store.addMessage(stringMessage);
assertNotSame(stringMessage, storedMessage);
assertEquals("Hello Redis", storedMessage.getPayload());
}
use of org.springframework.integration.redis.rules.RedisAvailable in project spring-integration by spring-projects.
the class RedisMessageStoreTests method testAddAndGetWithPrefix.
@SuppressWarnings("unchecked")
@Test
@RedisAvailable
public void testAddAndGetWithPrefix() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf, "foo");
Message<String> stringMessage = new GenericMessage<String>("Hello Redis");
store.addMessage(stringMessage);
Message<String> retrievedMessage = (Message<String>) store.getMessage(stringMessage.getHeaders().getId());
assertNotNull(retrievedMessage);
assertEquals("Hello Redis", retrievedMessage.getPayload());
StringRedisTemplate template = createStringRedisTemplate(getConnectionFactoryForTest());
BoundValueOperations<String, String> ops = template.boundValueOps("foo" + "MESSAGE_" + stringMessage.getHeaders().getId());
assertNotNull(ops.get());
}
use of org.springframework.integration.redis.rules.RedisAvailable in project spring-integration by spring-projects.
the class RedisMessageStoreTests method testAddSerializableObjectMessage.
@Test
@RedisAvailable
public void testAddSerializableObjectMessage() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Address address = new Address();
address.setAddress("1600 Pennsylvania Av, Washington, DC");
Person person = new Person(address, "Barak Obama");
Message<Person> objectMessage = new GenericMessage<Person>(person);
Message<Person> storedMessage = store.addMessage(objectMessage);
assertNotSame(objectMessage, storedMessage);
assertEquals("Barak Obama", storedMessage.getPayload().getName());
}
use of org.springframework.integration.redis.rules.RedisAvailable in project spring-integration by spring-projects.
the class RedisOutboundChannelAdapterParserTests method validateConfiguration.
@Test
@RedisAvailable
public void validateConfiguration() {
EventDrivenConsumer adapter = context.getBean("outboundAdapter", EventDrivenConsumer.class);
Object handler = context.getBean("outboundAdapter.handler");
assertEquals("outboundAdapter", adapter.getComponentName());
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
Object topicExpression = accessor.getPropertyValue("topicExpression");
assertNotNull(topicExpression);
assertEquals("headers['topic'] ?: 'foo'", ((Expression) topicExpression).getExpressionString());
Object converterBean = context.getBean("testConverter");
assertEquals(converterBean, accessor.getPropertyValue("messageConverter"));
assertEquals(context.getBean("serializer"), accessor.getPropertyValue("serializer"));
Object endpointHandler = TestUtils.getPropertyValue(adapter, "handler");
assertTrue(AopUtils.isAopProxy(endpointHandler));
assertThat(TestUtils.getPropertyValue(endpointHandler, "h.advised.advisors.first.item.advice"), Matchers.instanceOf(RequestHandlerRetryAdvice.class));
}
use of org.springframework.integration.redis.rules.RedisAvailable in project spring-integration by spring-projects.
the class RedisStoreInboundChannelAdapterIntegrationTests method testListInboundConfiguration.
@Test
@RedisAvailable
@SuppressWarnings("unchecked")
public void testListInboundConfiguration() throws Exception {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareList(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("list-inbound-adapter.xml", this.getClass());
SourcePollingChannelAdapter spca = context.getBean("listAdapter", SourcePollingChannelAdapter.class);
spca.start();
QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class);
Message<Integer> message = (Message<Integer>) redisChannel.receive(10000);
assertNotNull(message);
assertEquals(Integer.valueOf(13), message.getPayload());
// poll again, should get the same stuff
message = (Message<Integer>) redisChannel.receive(10000);
assertNotNull(message);
assertEquals(Integer.valueOf(13), message.getPayload());
this.deletePresidents(jcf);
context.close();
}
Aggregations