1919package org .apache .ofbiz .base .util .cache ;
2020
2121import static org .apache .ofbiz .base .util .cache .UtilCacheTestTools .createListener ;
22- import static org .hamcrest .MatcherAssert .assertThat ;
23- import static org .hamcrest .Matchers .containsInAnyOrder ;
24- import static org .hamcrest .Matchers .greaterThan ;
2522import static org .junit .Assert .assertEquals ;
2623import static org .junit .Assert .assertFalse ;
2724import static org .junit .Assert .assertNotSame ;
@@ -49,18 +46,18 @@ private <K, V> UtilCache<K, V> createUtilCache(int sizeLimit, int maxInMemory, l
4946 @ Test
5047 public void testCreateUtilCache () {
5148 String name = getClass ().getName ();
52- doUtilCacheSettingsTest (UtilCache .createUtilCache (), null , null , null , null );
53- doUtilCacheSettingsTest (UtilCache .createUtilCache (name ), null , null , null , null );
54- doUtilCacheSettingsTest (UtilCache .createUtilCache (name , false ), null , null , null , Boolean .FALSE );
55- doUtilCacheSettingsTest (UtilCache .createUtilCache (name , true ), null , null , null , Boolean .TRUE );
56- doUtilCacheSettingsTest (UtilCache .createUtilCache (5 , 15000 ), 5 , null , 15000L , null );
57- doUtilCacheSettingsTest (UtilCache .createUtilCache (name , 6 , 16000 ), 6 , null , 16000L , null );
58- doUtilCacheSettingsTest (UtilCache .createUtilCache (name , 7 , 17000 , false ), 7 , null , 17000L , Boolean .FALSE );
59- doUtilCacheSettingsTest (UtilCache .createUtilCache (name , 8 , 18000 , true ), 8 , null , 18000L , Boolean .TRUE );
60- doUtilCacheSettingsTest (UtilCache .createUtilCache (name , 9 , 5 , 19000 , false ), 9 , 5 , 19000L , Boolean .FALSE );
61- doUtilCacheSettingsTest (UtilCache .createUtilCache (name , 10 , 6 , 20000 , false ), 10 , 6 , 20000L , Boolean .FALSE );
62- doUtilCacheSettingsTest (UtilCache .createUtilCache (name , 11 , 7 , 21000 , false , "a" , "b" ), 11 , 7 , 21000L , Boolean .FALSE );
63- doUtilCacheSettingsTest (UtilCache .createUtilCache (name , 12 , 8 , 22000 , false , "c" , "d" ), 12 , 8 , 22000L , Boolean .FALSE );
49+ doUtilCacheCreateTest (UtilCache .createUtilCache (), null , null , null , null );
50+ doUtilCacheCreateTest (UtilCache .createUtilCache (name ), null , null , null , null );
51+ doUtilCacheCreateTest (UtilCache .createUtilCache (name , false ), null , null , null , Boolean .FALSE );
52+ doUtilCacheCreateTest (UtilCache .createUtilCache (name , true ), null , null , null , Boolean .TRUE );
53+ doUtilCacheCreateTest (UtilCache .createUtilCache (5 , 15000 ), 5 , null , 15000L , null );
54+ doUtilCacheCreateTest (UtilCache .createUtilCache (name , 6 , 16000 ), 6 , null , 16000L , null );
55+ doUtilCacheCreateTest (UtilCache .createUtilCache (name , 7 , 17000 , false ), 7 , null , 17000L , Boolean .FALSE );
56+ doUtilCacheCreateTest (UtilCache .createUtilCache (name , 8 , 18000 , true ), 8 , null , 18000L , Boolean .TRUE );
57+ doUtilCacheCreateTest (UtilCache .createUtilCache (name , 9 , 5 , 19000 , false ), 9 , 5 , 19000L , Boolean .FALSE );
58+ doUtilCacheCreateTest (UtilCache .createUtilCache (name , 10 , 6 , 20000 , false ), 10 , 6 , 20000L , Boolean .FALSE );
59+ doUtilCacheCreateTest (UtilCache .createUtilCache (name , 11 , 7 , 21000 , false , "a" , "b" ), 11 , 7 , 21000L , Boolean .FALSE );
60+ doUtilCacheCreateTest (UtilCache .createUtilCache (name , 12 , 8 , 22000 , false , "c" , "d" ), 12 , 8 , 22000L , Boolean .FALSE );
6461 }
6562
6663 @ Test
@@ -83,7 +80,7 @@ public void testSimple() throws Exception {
8380 assertNull ("put" , myCache .put (null , "null" ));
8481 doKeyInCacheTest (myCache , null , "null" );
8582 long nullByteSize = myCache .getSizeInBytes ();
86- assertThat (nullByteSize , greaterThan ( origByteSize ) );
83+ assertTrue (nullByteSize > origByteSize );
8784
8885 controlListener .noteKeyRemoval (myCache , null , "null" );
8986 assertEquals ("remove" , "null" , myCache .remove (null ));
@@ -93,14 +90,14 @@ public void testSimple() throws Exception {
9390 assertNull ("put" , myCache .put ("one" , "uno" ));
9491 doKeyInCacheTest (myCache , "one" , "uno" );
9592 long unoByteSize = myCache .getSizeInBytes ();
96- assertThat (unoByteSize , greaterThan ( origByteSize ) );
93+ assert (unoByteSize > origByteSize );
9794
9895 controlListener .noteKeyUpdate (myCache , "one" , "single" , "uno" );
9996 assertEquals ("replace" , "uno" , myCache .put ("one" , "single" ));
10097 doKeyInCacheTest (myCache , "one" , "single" );
10198 long singleByteSize = myCache .getSizeInBytes ();
102- assertThat (singleByteSize , greaterThan ( origByteSize ) );
103- assertThat (singleByteSize , greaterThan ( unoByteSize ) );
99+ assert (singleByteSize > origByteSize );
100+ assert (singleByteSize > unoByteSize );
104101
105102 controlListener .noteKeyRemoval (myCache , "one" , "single" );
106103 assertEquals ("remove" , "single" , myCache .remove ("one" ));
@@ -191,17 +188,17 @@ public void testChangeMemSize() {
191188 assertEquals ("cache.size" , 2 , myCache .size ());
192189 controlMap .keySet ().retainAll (myCache .getCacheLineKeys ());
193190 assertEquals ("map-keys" , controlMap .keySet (), myCache .getCacheLineKeys ());
194- assertThat ("map-values" , myCache .values (), containsInAnyOrder (controlMap .values (). toArray ()));
191+ assertTrue ("map-values" , myCache .values (). containsAll (controlMap .values ()));
195192 myCache .setMaxInMemory (0 );
196193 assertEquals ("map-keys" , controlMap .keySet (), myCache .getCacheLineKeys ());
197- assertThat ("map-values" , myCache .values (), containsInAnyOrder (controlMap .values (). toArray ()));
194+ assertTrue ("map-values" , myCache .values (). containsAll (controlMap .values ()));
198195 for (int i = size * 2 ; i < size * 3 ; i ++) {
199196 String s = Integer .toString (i );
200197 doSingleKeyTest (s , myCache , i - size * 2 + 3 , controlMap );
201198 }
202199 myCache .setMaxInMemory (0 );
203200 assertEquals ("map-keys" , controlMap .keySet (), myCache .getCacheLineKeys ());
204- assertThat ("map-values" , myCache .values (), containsInAnyOrder (controlMap .values (). toArray ()));
201+ assertTrue ("map-values" , myCache .values (). containsAll (controlMap .values ()));
205202 myCache .setMaxInMemory (size );
206203 for (int i = 0 ; i < size * 2 ; i ++) {
207204 controlMap .remove (Integer .toString (i ));
@@ -226,14 +223,14 @@ public void testExpire() throws Exception {
226223 assertNull ("no-key(" + s + ")" , myCache .get (s ));
227224 }
228225 assertEquals ("map-keys" , controlMap .keySet (), myCache .getCacheLineKeys ());
229- assertThat ("map-values" , myCache .values (), containsInAnyOrder (controlMap .values (). toArray ()));
226+ assertTrue ("map-values" , myCache .values (). containsAll (controlMap .values ()));
230227 doAllKeysTest (5 , myCache , controlMap );
231228 assertEquals ("map-keys" , controlMap .keySet (), myCache .getCacheLineKeys ());
232- assertThat ("map-values" , myCache .values (), containsInAnyOrder (controlMap .values (). toArray ()));
229+ assertTrue ("map-values" , myCache .values (). containsAll (controlMap .values ()));
233230 }
234231
235- static <K , V > void doUtilCacheSettingsTest (UtilCache <K , V > myCache , Integer sizeLimit , Integer maxInMemory ,
236- Long expireTime , Boolean useSoftReference ) {
232+ static <K , V > void doUtilCacheCreateTest (UtilCache <K , V > myCache , Integer sizeLimit , Integer maxInMemory ,
233+ Long expireTime , Boolean useSoftReference ) {
237234 if (sizeLimit != null ) {
238235 assertEquals (myCache .getName () + ":sizeLimit" , sizeLimit .intValue (), myCache .getSizeLimit ());
239236 }
@@ -275,7 +272,7 @@ public static void doSingleKeyTest(String val, UtilCache<String, Serializable> m
275272 assertEquals (label + ":size-value" , size , myCache .size ());
276273 controlMap .put (myKey , myValue );
277274 assertEquals (label + ":map-keys" , controlMap .keySet (), myCache .getCacheLineKeys ());
278- assertThat (label + ":map-values" , myCache .values (), containsInAnyOrder (controlMap .values (). toArray ()));
275+ assertTrue (label + ":map-values" , myCache .values (). containsAll (controlMap .values ()));
279276 }
280277
281278 static <K , V > void doKeyInCacheTest (UtilCache <K , V > myCache , K myKey , V myValue ) {
0 commit comments