-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedisTest.java
More file actions
95 lines (90 loc) · 2.23 KB
/
RedisTest.java
File metadata and controls
95 lines (90 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.matrix;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import com.matrix.beans.IUserDao;
import com.matrix.beans.User;
@ContextConfiguration(locations = {"classpath*:spring/mvc-config.xml"})
public class RedisTest extends AbstractJUnit4SpringContextTests{
@Autowired
private IUserDao userDao;
@Ignore
@Test
public void testAddUser(){
User user = new User();
user.setId("user1");
user.setName("liuyue");
boolean result = userDao.add(user);
Assert.assertTrue(result);
}
@Ignore
@Test
public void testAddUsers2(){
List<User> list = new ArrayList<User>();
for (int i = 10; i < 50000; i++) {
User user = new User();
user.setId("user"+i);
user.setName("java2000_wl" +i);
list.add(user);
}
long begin = System.currentTimeMillis();
for (User user : list) {
userDao.add(user);
}
System.out.println(System.currentTimeMillis() - begin);
}
@Ignore
@Test
public void testAddUsers(){
List<User> list = new ArrayList<User>();
for (int i = 10; i < 150000; i++) {
User user = new User();
user.setId("user"+i);
user.setName("java2000_wl" +i);
list.add(user);
}
long begin = System.currentTimeMillis();
boolean result = userDao.add(list);
System.out.println(System.currentTimeMillis() - begin);
Assert.assertTrue(result);
}
@Ignore
@Test
public void testUpdate(){
User user = new User();
user.setId("user1");
user.setName("new_user");
boolean result = userDao.update(user);
Assert.assertTrue(result);
}
@Ignore
@Test
public void testDelete(){
String key = "user1";
userDao.delete(key);
}
@Ignore
@Test
public void testDeletes(){
List<String> list = new ArrayList<String>();
for(int i = 0;i<10;i++){
list.add("user"+i);
}
userDao.delete(list);
}
@Test
public void testGetUser(){
String id = "user1";
User user = userDao.get(id);
Assert.assertNotNull(user);
Assert.assertEquals(user.getName(),"liuyue");
}
public void setUserDao(IUserDao userDao){
this.userDao = userDao;
}
}