use of org.springframework.data.redis.support.collections.DefaultRedisMap in project spring-integration by spring-projects.
the class RedisStoreOutboundChannelAdapterIntegrationTests method testMapToMapNoKey.
// key is not provided
@Test(expected = MessageHandlingException.class)
@RedisAvailable
public void testMapToMapNoKey() {
RedisTemplate<String, Map<String, Map<String, String>>> redisTemplate = new RedisTemplate<String, Map<String, Map<String, String>>>();
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setConnectionFactory(getConnectionFactoryForTest());
redisTemplate.afterPropertiesSet();
RedisMap<String, Map<String, String>> redisMap = new DefaultRedisMap<String, Map<String, String>>("pepboys", redisTemplate);
assertEquals(0, redisMap.size());
Map<String, String> pepboys = new HashMap<String, String>();
pepboys.put("1", "Manny");
pepboys.put("2", "Moe");
pepboys.put("3", "Jack");
Message<Map<String, String>> message = MessageBuilder.withPayload(pepboys).build();
this.mapToMapBChannel.send(message);
}
use of org.springframework.data.redis.support.collections.DefaultRedisMap in project spring-integration by spring-projects.
the class RedisStoreOutboundChannelAdapterIntegrationTests method testMapToMapAsSingleEntryWithKeyAsHeader.
@Test
@RedisAvailable
public void testMapToMapAsSingleEntryWithKeyAsHeader() {
RedisTemplate<String, Map<String, Map<String, String>>> redisTemplate = new RedisTemplate<String, Map<String, Map<String, String>>>();
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setConnectionFactory(getConnectionFactoryForTest());
redisTemplate.afterPropertiesSet();
RedisMap<String, Map<String, String>> redisMap = new DefaultRedisMap<String, Map<String, String>>("pepboys", redisTemplate);
assertEquals(0, redisMap.size());
Map<String, String> pepboys = new HashMap<String, String>();
pepboys.put("1", "Manny");
pepboys.put("2", "Moe");
pepboys.put("3", "Jack");
Message<Map<String, String>> message = MessageBuilder.withPayload(pepboys).setHeader(RedisHeaders.KEY, "pepboys").setHeader(RedisHeaders.MAP_KEY, "foo").build();
this.mapToMapBChannel.send(message);
Map<String, String> pepboyz = redisMap.get("foo");
assertEquals("Manny", pepboyz.get("1"));
assertEquals("Moe", pepboyz.get("2"));
assertEquals("Jack", pepboyz.get("3"));
}
Aggregations