diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/core/RedisTemplate.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/core/RedisTemplate.java index d3565d996..eb9c1d398 100644 --- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/core/RedisTemplate.java +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/core/RedisTemplate.java @@ -538,14 +538,14 @@ public class RedisTemplate extends RedisAccessor implements RedisOperation public Set keys(K pattern) { final byte[] rawKey = rawKey(pattern); - Collection rawKeys = execute(new RedisCallback>() { + Set rawKeys = execute(new RedisCallback>() { @Override - public Collection doInRedis(RedisConnection connection) { + public Set doInRedis(RedisConnection connection) { return connection.keys(rawKey); } }, true); - return (Set) SerializationUtils.deserialize(rawKeys, keySerializer); + return SerializationUtils.deserialize(rawKeys, keySerializer); } @Override diff --git a/spring-data-redis/src/test/java/org/springframework/data/keyvalue/redis/core/TemplateTest.java b/spring-data-redis/src/test/java/org/springframework/data/keyvalue/redis/core/TemplateTest.java new file mode 100644 index 000000000..96cf1d05c --- /dev/null +++ b/spring-data-redis/src/test/java/org/springframework/data/keyvalue/redis/core/TemplateTest.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 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.data.keyvalue.redis.core; + +import static org.junit.Assert.*; + +import java.util.Collection; + +import org.junit.AfterClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.springframework.data.keyvalue.redis.ConnectionFactoryTracker; +import org.springframework.data.keyvalue.redis.support.collections.CollectionTestParams; +import org.springframework.data.keyvalue.redis.support.collections.ObjectFactory; + +/** + * @author Costin Leau + */ +@RunWith(Parameterized.class) +public class TemplateTest { + private ObjectFactory objFactory; + private RedisTemplate template; + + public TemplateTest(ObjectFactory objFactory, RedisTemplate template) { + this.objFactory = objFactory; + this.template = template; + ConnectionFactoryTracker.add(template.getConnectionFactory()); + } + + @AfterClass + public static void cleanUp() { + ConnectionFactoryTracker.cleanUp(); + } + + @Parameters + public static Collection testParams() { + return CollectionTestParams.testParams(); + } + + @Test + public void testKeys() throws Exception { + assertTrue(template.keys("*") != null); + } +}