@@ -32,94 +32,90 @@ public IRLObject() {
3232
3333public class ClientTest {
3434
35- private JReJSON c ;
3635 private Gson g ;
37- private String host ="52.7.3.128 " ;
36+ private String host ="localhost " ;
3837 private int port =6379 ;
39- Jedis jedis = new Jedis (host ,port );
38+ Jedis jedis = new Jedis (host ,port );
4039
4140 @ Before
4241 public void initialize () {
4342 g = new Gson ();
44-
4543 }
4644
4745 @ Test
4846 public void basicSetGetShouldSucceed () throws Exception {
4947
50-
51-
5248 // naive set with a path
5349 JReJSON .set (jedis , "null" , null , Path .RootPath ());
54- assertNull (JReJSON .get (jedis ,"null" , Path .RootPath ()));
50+ assertNull (JReJSON .get (jedis , "null" , Path .RootPath ()));
5551
5652 // real scalar value and no path
57- JReJSON .set (jedis ,"str" , "strong" );
58- assertEquals ("strong" , JReJSON .get (jedis ,"str" ));
53+ JReJSON .set (jedis , "str" , "strong" );
54+ assertEquals ("strong" , JReJSON .get (jedis , "str" ));
5955
6056 // A slightly more complex object
6157 IRLObject obj = new IRLObject ();
62- JReJSON .set (jedis ,"obj" , obj );
58+ JReJSON .set (jedis , "obj" , obj );
6359 Object expected = g .fromJson (g .toJson (obj ), Object .class );
64- assertTrue (expected .equals (JReJSON .get (jedis ,"obj" )));
60+ assertTrue (expected .equals (JReJSON .get (jedis , "obj" )));
6561
6662 // check an update
6763 Path p = new Path (".str" );
68- JReJSON .set (jedis ,"obj" , "strung" , p );
69- assertEquals ("strung" , JReJSON .get (jedis ,"obj" , p ));
64+ JReJSON .set (jedis , "obj" , "strung" , p );
65+ assertEquals ("strung" , JReJSON .get (jedis , "obj" , p ));
7066 }
7167
7268 @ Test
7369 public void setExistingPathOnlyIfExistsShouldSucceed () throws Exception {
7470 jedis .flushDB ();
7571
76- JReJSON .set (jedis ,"obj" , new IRLObject ());
72+ JReJSON .set (jedis , "obj" , new IRLObject ());
7773 Path p = new Path (".str" );
78- JReJSON .set (jedis ,"obj" , "strangle" , JReJSON .ExistenceModifier .MUST_EXIST , p );
79- assertEquals ("strangle" , JReJSON .get (jedis ,"obj" , p ));
74+ JReJSON .set (jedis , "obj" , "strangle" , JReJSON .ExistenceModifier .MUST_EXIST , p );
75+ assertEquals ("strangle" , JReJSON .get (jedis , "obj" , p ));
8076 }
8177
8278 @ Test
8379 public void setNonExistingOnlyIfNotExistsShouldSucceed () throws Exception {
8480 jedis .flushDB ();
8581
86- JReJSON .set (jedis ,"obj" , new IRLObject ());
82+ JReJSON .set (jedis , "obj" , new IRLObject ());
8783 Path p = new Path (".none" );
88- JReJSON .set (jedis ,"obj" , "strangle" , JReJSON .ExistenceModifier .NOT_EXISTS , p );
89- assertEquals ("strangle" , JReJSON .get (jedis ,"obj" , p ));
84+ JReJSON .set (jedis , "obj" , "strangle" , JReJSON .ExistenceModifier .NOT_EXISTS , p );
85+ assertEquals ("strangle" , JReJSON .get (jedis , "obj" , p ));
9086 }
9187
9288 @ Test (expected = Exception .class )
9389 public void setExistingPathOnlyIfNotExistsShouldFail () throws Exception {
9490 jedis .flushDB ();
9591
96- JReJSON .set (jedis ,"obj" , new IRLObject ());
92+ JReJSON .set (jedis , "obj" , new IRLObject ());
9793 Path p = new Path (".str" );
98- JReJSON .set (jedis ,"obj" , "strangle" , JReJSON .ExistenceModifier .NOT_EXISTS , p );
94+ JReJSON .set (jedis , "obj" , "strangle" , JReJSON .ExistenceModifier .NOT_EXISTS , p );
9995 }
10096
10197 @ Test (expected = Exception .class )
10298 public void setNonExistingPathOnlyIfExistsShouldFail () throws Exception {
10399 jedis .flushDB ();
104100
105- JReJSON .set (jedis ,"obj" , new IRLObject ());
101+ JReJSON .set (jedis , "obj" , new IRLObject ());
106102 Path p = new Path (".none" );
107- JReJSON .set (jedis ,"obj" , "strangle" , JReJSON .ExistenceModifier .MUST_EXIST , p );
103+ JReJSON .set (jedis , "obj" , "strangle" , JReJSON .ExistenceModifier .MUST_EXIST , p );
108104 }
109105
110106 @ Test (expected = Exception .class )
111107 public void setException () throws Exception {
112108 jedis .flushDB ();
113109
114110 // should error on non root path for new key
115- JReJSON .set (jedis ,"test" , "bar" , new Path (".foo" ));
111+ JReJSON .set (jedis , "test" , "bar" , new Path (".foo" ));
116112 }
117113
118114 @ Test (expected = Exception .class )
119115 public void setMultiplePathsShouldFail () throws Exception {
120116 jedis .flushDB ();
121- JReJSON .set (jedis ,"obj" , new IRLObject ());
122- JReJSON .set (jedis ,"obj" , "strange" , new Path (".str" ), new Path (".str" ));
117+ JReJSON .set (jedis , "obj" , new IRLObject ());
118+ JReJSON .set (jedis , "obj" , "strange" , new Path (".str" ), new Path (".str" ));
123119 }
124120
125121 @ Test
@@ -128,89 +124,65 @@ public void getMultiplePathsShouldSucceed() throws Exception {
128124
129125 // check multiple paths
130126 IRLObject obj = new IRLObject ();
131- JReJSON .set (jedis ,"obj" , obj );
127+ JReJSON .set (jedis , "obj" , obj );
132128 Object expected = g .fromJson (g .toJson (obj ), Object .class );
133- assertTrue (expected .equals (JReJSON .get (jedis ,"obj" , new Path ("bTrue" ), new Path ("str" ))));
129+ assertTrue (expected .equals (JReJSON .get (jedis , "obj" , new Path ("bTrue" ), new Path ("str" ))));
134130
135131 }
136132
137133 @ Test (expected = Exception .class )
138134 public void getException () throws Exception {
139135 jedis .flushDB ();
140- JReJSON .set (jedis ,"test" , "foo" , Path .RootPath ());
141- JReJSON .get (jedis ,"test" , new Path (".bar" ));
136+ JReJSON .set (jedis , "test" , "foo" , Path .RootPath ());
137+ JReJSON .get (jedis , "test" , new Path (".bar" ));
142138 }
143139
144140 @ Test
145141 public void delValidShouldSucceed () throws Exception {
146142 jedis .flushDB ();
147143
148144 // check deletion of a single path
149- JReJSON .set (jedis ,"obj" , new IRLObject (), Path .RootPath ());
150- JReJSON .del (jedis ,"obj" , new Path (".str" ));
145+ JReJSON .set (jedis , "obj" , new IRLObject (), Path .RootPath ());
146+ JReJSON .del (jedis , "obj" , new Path (".str" ));
151147 assertTrue (jedis .exists ("obj" ));
152148
153149 // check deletion root using default root -> key is removed
154- JReJSON .del (jedis ,"obj" );
150+ JReJSON .del (jedis , "obj" );
155151 assertFalse (jedis .exists ("obj" ));
156152 }
157153
158154 @ Test (expected = Exception .class )
159155 public void delException () throws Exception {
160156 jedis .flushDB ();
161- JReJSON .set (jedis ,"foobar" , new FooBarObject (), Path .RootPath ());
162- JReJSON .del (jedis ,"foobar" , new Path (".foo[1]" ));
157+ JReJSON .set (jedis , "foobar" , new FooBarObject (), Path .RootPath ());
158+ JReJSON .del (jedis , "foobar" , new Path (".foo[1]" ));
163159 }
164160
165161 @ Test (expected = Exception .class )
166162 public void delMultiplePathsShoudFail () throws Exception {
167163 jedis .flushDB ();
168- JReJSON .del (jedis ,"foobar" , new Path (".foo" ), new Path (".bar" ));
164+ JReJSON .del (jedis , "foobar" , new Path (".foo" ), new Path (".bar" ));
169165 }
170166
171167 @ Test
172168 public void typeChecksShouldSucceed () throws Exception {
173169 jedis .flushDB ();
174- JReJSON .set (jedis ,"foobar" , new FooBarObject (), Path .RootPath ());
175- assertSame (Object .class , c .type (jedis ,"foobar" , Path .RootPath ()));
176- assertSame (String .class , c .type (jedis ,"foobar" , new Path (".foo" )));
170+ JReJSON .set (jedis , "foobar" , new FooBarObject (), Path .RootPath ());
171+ assertSame (Object .class , JReJSON .type (jedis , "foobar" , Path .RootPath ()));
172+ assertSame (String .class , JReJSON .type (jedis , "foobar" , new Path (".foo" )));
177173 }
178174
179175 @ Test (expected = Exception .class )
180176 public void typeException () throws Exception {
181177 jedis .flushDB ();
182- JReJSON .set (jedis ,"foobar" , new FooBarObject (), Path .RootPath ());
178+ JReJSON .set (jedis , "foobar" , new FooBarObject (), Path .RootPath ());
183179 JReJSON .type (jedis , "foobar" , new Path (".foo[1]" ));
184180 }
185181
186182 @ Test (expected = Exception .class )
187183 public void type1Exception () throws Exception {
188184 jedis .flushDB ();
189- JReJSON .set (jedis ,"foobar" , new FooBarObject (), Path .RootPath ());
190- JReJSON .type (jedis ,"foobar" , new Path (".foo[1]" ));
191-
192- // JedisPoolConfig conf = new JedisPoolConfig();
193- // conf.setMaxTotal(55);
194- // conf.setTestOnBorrow(false);
195- // conf.setTestOnReturn(false);
196- // conf.setTestOnCreate(false);
197- // conf.setTestWhileIdle(false);
198- // conf.setMinEvictableIdleTimeMillis(60000);
199- // conf.setTimeBetweenEvictionRunsMillis(30000);
200- // conf.setNumTestsPerEvictionRun(-1);
201- // conf.setFairness(true);
202- //
203- // JedisPool pool = new JedisPool(conf, "localhost", 6379,1000);
204- //
205- // JReJSON jReJSON = (JReJSON) pool.getResource();
206-
207-
208-
209-
210- //Pipeline pipe = jReJSON.pipelined();
211-
212-
185+ JReJSON .set (jedis , "foobar" , new FooBarObject (), Path .RootPath ());
186+ JReJSON .type (jedis , "foobar" , new Path (".foo[1]" ));
213187 }
214-
215-
216188}
0 commit comments