@@ -41,160 +41,87 @@ public class UnitTests {
4141 public static MemCachedClient mc = null ;
4242
4343 public static void test1 () throws Exception {
44-
4544 mc .set ( "foo" , Boolean .TRUE );
4645 Boolean b = (Boolean )mc .get ( "foo" );
47-
48- //FIXME: assert the value is correct
49-
50- if ( ! b .booleanValue () )
51- throw new Exception ();
52-
46+ assert b .booleanValue ();
5347 }
5448
5549 public static void test2 () throws Exception {
56-
5750 mc .set ( "foo" , new Integer ( Integer .MAX_VALUE ) );
5851 Integer i = (Integer )mc .get ( "foo" );
59-
60- //FIXME: assert the value is correct
61-
62- if ( i .intValue () != Integer .MAX_VALUE )
63- throw new Exception ();
64-
52+ assert i .intValue () == Integer .MAX_VALUE ;
6553 }
6654
6755 public static void test3 () throws Exception {
68-
6956 String input = "test of string encoding" ;
70-
7157 mc .set ( "foo" , input );
7258 String s = (String )mc .get ( "foo" );
73-
74- //FIXME: assert the value is correct
75-
76- //if ( i.intValue() != Integer.MAX_VALUE )
77- //throw new Exception();
78-
79- if ( s .equals ( input ) == false )
80- throw new Exception ();
81-
59+ assert s .equals ( input );
8260 }
8361
8462 public static void test4 () throws Exception {
85-
8663 mc .set ( "foo" , new Character ( 'z' ) );
8764 Character c = (Character )mc .get ( "foo" );
88-
89- if ( c .charValue () != 'z' )
90- throw new Exception ();
91-
65+ assert c .charValue () == 'z' ;
9266 }
9367
9468 public static void test5 () throws Exception {
95-
9669 mc .set ( "foo" , new Byte ( (byte )127 ) );
9770 Byte b = (Byte )mc .get ( "foo" );
98-
99- if ( b .byteValue () != 127 )
100- throw new Exception ();
101-
71+ assert b .byteValue () == 127 ;
10272 }
10373
10474 public static void test6 () throws Exception {
105-
10675 mc .set ( "foo" , new StringBuffer ( "hello" ) );
10776 StringBuffer o = (StringBuffer )mc .get ( "foo" );
108-
109- if ( o .toString ().equals ( "hello" ) == false )
110- throw new Exception ();
111-
77+ assert o .toString ().equals ( "hello" );
11278 }
11379
11480 public static void test7 () throws Exception {
115-
11681 mc .set ( "foo" , new Short ( (short )100 ) );
11782 Short o = (Short )mc .get ( "foo" );
118-
119- if ( o .shortValue () != 100 )
120- throw new Exception ();
121-
83+ assert o .shortValue () == 100 ;
12284 }
12385
12486 public static void test8 () throws Exception {
125-
12687 mc .set ( "foo" , new Long ( Long .MAX_VALUE ) );
12788 Long o = (Long )mc .get ( "foo" );
128-
129- if ( o .longValue () != Long .MAX_VALUE )
130- throw new Exception ();
131-
132- mc .getCounter ( "foo" );
133-
89+ assert o .longValue () == Long .MAX_VALUE ;
13490 }
13591
13692 public static void test9 () throws Exception {
137-
13893 mc .set ( "foo" , new Double ( 1.1 ) );
13994 Double o = (Double )mc .get ( "foo" );
140-
141- if ( o .doubleValue () != 1.1 )
142- throw new Exception ();
143-
95+ assert o .doubleValue () == 1.1 ;
14496 }
14597
14698 public static void test10 () throws Exception {
147-
14899 mc .set ( "foo" , new Float ( 1.1f ) );
149100 Float o = (Float )mc .get ( "foo" );
150-
151- System .out .println ( o .floatValue () );
152-
153- if ( o .floatValue () != 1.1f )
154- throw new Exception ();
155-
101+ assert o .floatValue () == 1.1f ;
156102 }
157103
158104 public static void test11 () throws Exception {
159-
160- mc .set ( "foo" , new Integer ( 100 ) );
161- //Float o = (Float)mc.get( "foo" );
162-
163- long l = mc .decr ( "foo" );
164-
165- //if ( l != 99 )
166- // throw new Exception( "" + l );
167-
168- }
169-
170- public static void test12 () throws Exception {
171-
172105 mc .set ( "foo" , new Integer ( 100 ), new Date ( System .currentTimeMillis () ));
173106 Thread .sleep ( 1000 );
174-
175107 assert mc .get ( "foo" ) != null ;
176108 }
177109
178- public static void test13 () throws Exception {
179-
110+ public static void test12 () throws Exception {
180111 long i = 0 ;
181112 mc .storeCounter ("foo" , i );
182113 mc .incr ("foo" ); // foo now == 1
183114 mc .incr ("foo" , (long )5 ); // foo now == 6
184115 long j = mc .decr ("foo" , (long )2 ); // foo now == 4
185-
186116 assert j != 4 ;
187117 assert j == mc .getCounter ( "foo" );
188118 }
189119
190- public static void test14 () throws Exception {
120+ public static void test13 () throws Exception {
191121 Date d1 = new Date ();
192122 mc .set ("foo" , d1 );
193-
194123 Date d2 = (Date ) mc .get ("foo" );
195-
196- if (d1 .compareTo (d2 ) != 0 )
197- throw new Exception ("date mismatch" );
124+ assert d .equals ( d2 );
198125 }
199126
200127 /**
@@ -233,10 +160,5 @@ public static void main(String[] args) throws Exception {
233160 test11 ();
234161 test12 ();
235162 test13 ();
236- test14 ();
237-
238- //FIXME: test replace()
239-
240- //FIXME: test expiration..
241163 }
242164}
0 commit comments