@@ -29,7 +29,7 @@ public class CachedEnforcerUnitTest {
2929 private Cache cache ;
3030
3131 private void testEnforceCache (String sub , String obj , String act , boolean expectedRes ) throws Exception {
32- boolean actualRes = cachedEnforcer .enforce (sub , obj , act );
32+ Boolean actualRes = cachedEnforcer .enforce (sub , obj , act );
3333 assertEquals (String .format ("%s, %s, %s: %s, supposed to be %s" , sub , obj , act , actualRes , expectedRes ), expectedRes , actualRes );
3434 }
3535
@@ -87,17 +87,17 @@ public void testCache() throws Exception {
8787 public void testInvalidateCache () throws Exception {
8888 cachedEnforcer = new CachedEnforcer ("examples/basic_model.conf" , "examples/basic_policy.csv" , false );
8989
90- boolean cacheKey = cachedEnforcer .getCache ().get (cachedEnforcer .getCacheKey ("alice" , "data1" , "read" ));
91- assertFalse (String .format ("alice, data1, read: %s, supposed to be %s" , cacheKey , false ), cacheKey );
90+ Boolean cacheKey = cachedEnforcer .getCache ().get (cachedEnforcer .getCacheKey ("alice" , "data1" , "read" ));
91+ assertNull (String .format ("alice, data1, read: %s, supposed to be %s" , cacheKey , null ), cacheKey );
9292
93- boolean actualRes = cachedEnforcer .enforce ("alice" , "data1" , "read" );
93+ Boolean actualRes = cachedEnforcer .enforce ("alice" , "data1" , "read" );
9494 cacheKey = cachedEnforcer .getCache ().get (cachedEnforcer .getCacheKey ("alice" , "data1" , "read" ));
9595 assertTrue (String .format ("alice, data1, read: %s, supposed to be %s" , actualRes , true ), actualRes );
9696 assertTrue (String .format ("alice, data1, read: %s, supposed to be %s" , cacheKey , true ), cacheKey );
9797
9898 cachedEnforcer .invalidateCache ();
9999 cacheKey = cachedEnforcer .getCache ().get (cachedEnforcer .getCacheKey ("alice" , "data1" , "read" ));
100- assertFalse (String .format ("alice, data1, read: %s, supposed to be %s" , cacheKey , false ), cacheKey );
100+ assertNull (String .format ("alice, data1, read: %s, supposed to be %s" , cacheKey , null ), cacheKey );
101101
102102 }
103103
@@ -132,14 +132,14 @@ public void testCacheExpiration() throws Exception {
132132 // Test cache expiration
133133 cache .set (getKey ("alice" , "data1" , "read" ),true ,Duration .ofMillis (10 ));
134134 cachedEnforcer .setCache (cache );
135- boolean cacheKey = cachedEnforcer .getCache ().get (cachedEnforcer .getCacheKey ("alice" , "data1" , "read" ));
135+ Boolean cacheKey = cachedEnforcer .getCache ().get (cachedEnforcer .getCacheKey ("alice" , "data1" , "read" ));
136136 assertTrue (String .format ("alice, data1, read: %s, supposed to be %s" , cacheKey , true ), cacheKey );
137137
138138 // Wait for the cache to expire
139139 Thread .sleep (15 );
140140
141141 cacheKey = cachedEnforcer .getCache ().get (cachedEnforcer .getCacheKey ("alice" , "data1" , "read" ));
142- assertFalse (String .format ("alice, data1, read: %s, supposed to be %s" , cacheKey , false ), cacheKey );
142+ assertNull (String .format ("alice, data1, read: %s, supposed to be %s" , cacheKey , null ), cacheKey );
143143
144144 // Replace cache during test run
145145 cache .clear ();
@@ -152,7 +152,7 @@ public void testCacheExpiration() throws Exception {
152152 cache .set (getKey ("jack" , "data1" , "write" ),true ,Duration .ofMillis (1000 ));
153153 cachedEnforcer .setCache (cache );
154154 cacheKey = cachedEnforcer .getCache ().get (cachedEnforcer .getCacheKey ("bob" , "data1" , "read" ));
155- assertFalse (String .format ("bob, data1, read: %s, supposed to be %s" , cacheKey , false ), cacheKey );
155+ assertNull (String .format ("bob, data1, read: %s, supposed to be %s" , cacheKey , null ), cacheKey );
156156
157157 cacheKey = cachedEnforcer .getCache ().get (cachedEnforcer .getCacheKey ("jack" , "data1" , "write" ));
158158 assertTrue (String .format ("jack, data1, write: %s, supposed to be %s" , cacheKey , true ), cacheKey );
0 commit comments