Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
黄志磊
committed
Jan 5, 2016
1 parent
c9a6f95
commit f9a9597
Showing
5 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
mpush-tools/src/test/java/com/shinemo/mpush/tools/redis/RedisClusterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,45 @@ | |||
package com.shinemo.mpush.tools.redis; | |||
|
|||
import java.util.Date; | |||
import java.util.HashSet; | |||
import java.util.Set; | |||
|
|||
import org.apache.commons.lang3.builder.ToStringBuilder; | |||
import org.apache.commons.lang3.builder.ToStringStyle; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
|
|||
import com.shinemo.mpush.tools.Jsons; | |||
|
|||
import redis.clients.jedis.HostAndPort; | |||
import redis.clients.jedis.JedisCluster; | |||
|
|||
public class RedisClusterTest { | |||
|
|||
Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>(); | |||
|
|||
JedisCluster cluster = null; | |||
|
|||
@Before | |||
public void init() { | |||
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7000)); | |||
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7001)); | |||
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7002)); | |||
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7003)); | |||
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7004)); | |||
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7005)); | |||
cluster = new JedisCluster(jedisClusterNodes,RedisPoolConfig.config); | |||
} | |||
|
|||
@Test | |||
public void test() { | |||
|
|||
User user = new User("huang", 18, new Date()); | |||
cluster.set("huang", Jsons.toJson(user)); | |||
String ret = cluster.get("huang"); | |||
User newUser = Jsons.fromJson(ret, User.class); | |||
System.out.println(ToStringBuilder.reflectionToString(newUser, ToStringStyle.JSON_STYLE)); | |||
|
|||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters