/** * Sets the expression used as the key for Map and Properties entries. * Default is 'headers.{@link RedisHeaders#MAP_KEY}' * @param mapKeyExpression The map key expression. * @since 5.0 */ public void setMapKeyExpressionString(String mapKeyExpression) { Assert.hasText(mapKeyExpression, "'mapKeyExpression' must not be empty"); setMapKeyExpression(EXPRESSION_PARSER.parseExpression(mapKeyExpression)); }
@Test(expected = IllegalStateException.class) @RedisAvailable public void testListWithMapKeyExpression() { RedisConnectionFactory jcf = this.getConnectionFactoryForTest(); String key = "foo"; RedisStoreWritingMessageHandler handler = new RedisStoreWritingMessageHandler(jcf); handler.setKey(key); handler.setMapKeyExpression(new LiteralExpression(key)); handler.setBeanFactory(mock(BeanFactory.class)); handler.afterPropertiesSet(); }
@Test(expected = IllegalStateException.class) @RedisAvailable public void testSetWithMapKeyExpression() { RedisConnectionFactory jcf = this.getConnectionFactoryForTest(); String key = "foo"; RedisStoreWritingMessageHandler handler = new RedisStoreWritingMessageHandler(jcf); handler.setKey(key); handler.setCollectionType(CollectionType.SET); handler.setMapKeyExpression(new LiteralExpression(key)); handler.setBeanFactory(mock(BeanFactory.class)); handler.afterPropertiesSet(); }
@Test(expected = IllegalStateException.class) @RedisAvailable public void testZsetWithMapKeyExpression() { RedisConnectionFactory jcf = this.getConnectionFactoryForTest(); String key = "foo"; RedisStoreWritingMessageHandler handler = new RedisStoreWritingMessageHandler(jcf); handler.setKey(key); handler.setCollectionType(CollectionType.ZSET); handler.setMapKeyExpression(new LiteralExpression(key)); handler.setBeanFactory(mock(BeanFactory.class)); handler.afterPropertiesSet(); }
/** * Sets the expression used as the key for Map and Properties entries. * Default is 'headers.{@link RedisHeaders#MAP_KEY}' * @param mapKeyExpression The map key expression. * @since 5.0 */ public void setMapKeyExpressionString(String mapKeyExpression) { Assert.hasText(mapKeyExpression, "'mapKeyExpression' must not be empty"); setMapKeyExpression(EXPRESSION_PARSER.parseExpression(mapKeyExpression)); }
@Test @RedisAvailable public void testMapWithMapKeyExpression() { RedisConnectionFactory jcf = this.getConnectionFactoryForTest(); this.deleteKey(jcf, "foo"); String key = "foo"; RedisStoreWritingMessageHandler handler = new RedisStoreWritingMessageHandler(jcf); handler.setKey(key); handler.setCollectionType(CollectionType.MAP); handler.setMapKeyExpression(new LiteralExpression(key)); handler.setBeanFactory(mock(BeanFactory.class)); try { handler.afterPropertiesSet(); } catch (Exception e) { fail("No exception expected:" + e.getMessage()); } this.deleteKey(jcf, "foo"); }
@Test @RedisAvailable public void testPropertiesWithMapKeyExpression() { RedisConnectionFactory jcf = this.getConnectionFactoryForTest(); this.deleteKey(jcf, "foo"); String key = "foo"; RedisStoreWritingMessageHandler handler = new RedisStoreWritingMessageHandler(jcf); handler.setKey(key); handler.setCollectionType(CollectionType.PROPERTIES); handler.setMapKeyExpression(new LiteralExpression(key)); handler.setBeanFactory(mock(BeanFactory.class)); try { handler.afterPropertiesSet(); } catch (Exception e) { fail("No exception expected:" + e.getMessage()); } this.deleteKey(jcf, "foo"); }