From 05291888fbfac03d4b4305186bb93f280f31e940 Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Thu, 2 Dec 2010 19:16:22 +0200 Subject: [PATCH] + add Readme in Markdown + minor improvements --- README.md | 73 +++++++++++++++++++ .../serializer/SimpleRedisSerializer.java | 3 - .../AbstractConnectionIntegrationTests.java | 25 ++++++- .../core/RedisTemplateIntegrationTests.java | 39 ---------- 4 files changed, 94 insertions(+), 46 deletions(-) create mode 100644 README.md delete mode 100644 spring-data-redis/src/test/java/org/springframework/data/keyvalue/redis/core/RedisTemplateIntegrationTests.java diff --git a/README.md b/README.md new file mode 100644 index 000000000..f957a8c4d --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +Spring Data - Key Value +======================= + +The primary goal of the [Spring Data](http://www.springsource.org/spring-data) project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services. +As the name implies, the **Key Value** modules provides integration with key value stores such as [Redis](http://code.google.com/p/redis/) and [Riak](http://www.basho.com/Riak.html). + +Getting Help +------------ + +Read the main project [website](http://www.springsource.org/spring-data)) and the [User Guide](http://static.springsource.org/spring-data/datastore-keyvalue/snapshot-site/reference/html/). Look at the source code and the [JavaDocs](). For more detailed questions, use the [forum](http://forum.springsource.org/forumdisplay.php?f=80). If you are new to Spring as well as to Spring Data, look for information about [Spring projects](http://www.springsource.org/projects). + +Quick Start +----------- + +# Redis + +For those in a hurry: + + +* Download the jar through Maven: + + + org.springframework.data + spring-data-keyvalue + 1.0.0-BUILD-SNAPSHOT + + + + spring-maven-snapshot + true + Springframework Maven SNAPSHOT Repository + http://maven.springframework.org/snapshot + + +* Configure the Redis connector to use (here [jedis](https://github.com/xetorthio/jedis) ): + + + + + + + + +* Use RedisTemplate to interact with the Redis store + + String random = template.randomKey(); + template.set(random, new Person("John", "Smith")); + +* Use Redis 'views' to execute specific operations based on the underlying Redis type + + ListOperations listOps = template.listOps(); + listOps.rightPush(random, new Person("Jane", "Smith")); + List peopleOnSecondFloor = listOps.range("users:floor:2", 0, -1); + + +# Riak + + +Contributing to Spring Data +--------------------------- + +Here are some ways for you to get involved in the community: + +* Get involved with the Spring community on the Spring Community Forums. Please help out on the [forum](http://forum.springsource.org/forumdisplay.php?f=80) by responding to questions and joining the debate. +* Create [JIRA](https://jira.springframework.org/browse/DATAKV) tickets for bugs and new features and comment and vote on the ones that you are interested in. +* Github is for social coding: if you want to write code, we encourage contributions through pull requests from [forks of this repository](http://help.github.com/forking/). If you want to contribute code this way, please reference a JIRA ticket as well covering the specific issue you are addressing. +* Watch for upcoming articles on Spring by [subscribing](http://www.springsource.org/node/feed) to springframework.org + +Before we accept a non-trivial patch or pull request we will need you to sign the [contributor's agreement](https://support.springsource.com/spring_committer_signup). Signing the contributor's agreement does not grant anyone commit rights to the main repository, but it does mean that we can accept your contributions, and you will get an author credit if we do. Active contributors might be asked to join the core team, and given the ability to merge pull requests. diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/serializer/SimpleRedisSerializer.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/serializer/SimpleRedisSerializer.java index a9edfc0aa..902878015 100644 --- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/serializer/SimpleRedisSerializer.java +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/serializer/SimpleRedisSerializer.java @@ -31,9 +31,6 @@ public class SimpleRedisSerializer implements RedisSerializer { private Converter serializer = new SerializingConverter(); private Converter deserializer = new DeserializingConverter(); - // private sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder(); - // private sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder(); - @SuppressWarnings("unchecked") @Override public Object deserialize(byte[] bytes) { diff --git a/spring-data-redis/src/test/java/org/springframework/data/keyvalue/redis/connection/AbstractConnectionIntegrationTests.java b/spring-data-redis/src/test/java/org/springframework/data/keyvalue/redis/connection/AbstractConnectionIntegrationTests.java index c290db065..4e031cffa 100644 --- a/spring-data-redis/src/test/java/org/springframework/data/keyvalue/redis/connection/AbstractConnectionIntegrationTests.java +++ b/spring-data-redis/src/test/java/org/springframework/data/keyvalue/redis/connection/AbstractConnectionIntegrationTests.java @@ -19,14 +19,23 @@ package org.springframework.data.keyvalue.redis.connection; import static org.junit.Assert.*; import static org.junit.Assume.*; +import java.util.UUID; + import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.springframework.data.keyvalue.redis.Address; import org.springframework.data.keyvalue.redis.Person; +import org.springframework.data.keyvalue.redis.serializer.RedisSerializer; +import org.springframework.data.keyvalue.redis.serializer.SimpleRedisSerializer; +import org.springframework.data.keyvalue.redis.serializer.StringRedisSerializer; public abstract class AbstractConnectionIntegrationTests { protected RedisConnection connection; + protected RedisSerializer serializer = new SimpleRedisSerializer(); + protected RedisSerializer stringSerializer = new StringRedisSerializer(); + private static final String listName = "test-list"; @Before @@ -57,12 +66,20 @@ public abstract class AbstractConnectionIntegrationTests { assertEquals("blahblah", new String(connection.get("foo".getBytes()))); } - private boolean isJredis() { return connection.getClass().getSimpleName().startsWith("Jredis"); } - public void conversions() { - Person p = new Person("Joe", "Trader", 33); + @Test + public void testByteValue() { + String value = UUID.randomUUID().toString(); + Person person = new Person(value, value, 1, new Address(value, 2)); + String key = getClass() + ":byteValue"; + byte[] rawKey = stringSerializer.serialize(key); + + connection.set(rawKey, serializer.serialize(person)); + byte[] rawValue = connection.get(rawKey); + assertNotNull(rawValue); + assertEquals(person, serializer.deserialize(rawValue)); } -} \ No newline at end of file +} diff --git a/spring-data-redis/src/test/java/org/springframework/data/keyvalue/redis/core/RedisTemplateIntegrationTests.java b/spring-data-redis/src/test/java/org/springframework/data/keyvalue/redis/core/RedisTemplateIntegrationTests.java deleted file mode 100644 index 64a0b2218..000000000 --- a/spring-data-redis/src/test/java/org/springframework/data/keyvalue/redis/core/RedisTemplateIntegrationTests.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2010 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 org.junit.Before; -import org.junit.Test; -import org.springframework.data.keyvalue.redis.Person; -import org.springframework.data.keyvalue.redis.core.RedisTemplate; - -public class RedisTemplateIntegrationTests { - - RedisTemplate template; - @Before - public void setUp() { - // template = new RedisTemplate(new JRedisClientFactory()); - } - - @Test - public void conversions() { - Person p = new Person("Joe", "Trader", 33); - // template.convertAndSet("trader:1", p); - // Person samePerson = template.getAndConvert("trader:1", Person.class); - // Assert.assertEquals(p, samePerson); - } -}