Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 540   Methods: 9
NCLOC: 412   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
EvictionInterceptorTest.java 100% 100% 100% 100%
coverage
 1    /*
 2    * JBoss, the OpenSource J2EE webOS
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 7    package org.jboss.cache.interceptors;
 8   
 9    import junit.framework.TestCase;
 10    import org.jboss.cache.CacheImpl;
 11    import org.jboss.cache.DefaultCacheFactory;
 12    import org.jboss.cache.Fqn;
 13    import org.jboss.cache.InvocationContext;
 14    import org.jboss.cache.Node;
 15    import org.jboss.cache.Region;
 16    import org.jboss.cache.RegionManager;
 17    import org.jboss.cache.config.EvictionPolicyConfig;
 18    import org.jboss.cache.eviction.DummyEvictionConfiguration;
 19    import org.jboss.cache.eviction.EvictedEventNode;
 20    import org.jboss.cache.eviction.NodeEventType;
 21    import org.jboss.cache.lock.IsolationLevel;
 22    import org.jboss.cache.marshall.MethodCall;
 23    import org.jboss.cache.marshall.MethodCallFactory;
 24    import org.jboss.cache.marshall.MethodDeclarations;
 25   
 26    import java.util.HashMap;
 27    import java.util.Map;
 28   
 29    /**
 30    * @author Daniel Huang (dhuang@jboss.org)
 31    * @version $Revision: $
 32    */
 33    public class EvictionInterceptorTest extends TestCase
 34    {
 35    private static final String fqn1 = "/a/b/c";
 36    private static final String fqn2 = "/a/b";
 37    private static final String fqn3 = "/a/b/d";
 38   
 39    private static final String fqn4 = "/d/e/f";
 40   
 41    private CacheImpl cache;
 42    private Interceptor interceptor;
 43    private RegionManager regionManager;
 44   
 45  7 public void setUp() throws Exception
 46    {
 47  7 super.setUp();
 48  7 regionManager = new RegionManager();
 49  7 EvictionPolicyConfig config = new DummyEvictionConfiguration();
 50  7 regionManager.setUsingEvictions(true);
 51   
 52  7 regionManager.getRegion(RegionManager.DEFAULT_REGION, true).setEvictionPolicy(config);
 53   
 54  7 regionManager.getRegion("/a/b/c", true).setEvictionPolicy(config);
 55  7 regionManager.getRegion("/a/b/c/d", true).setEvictionPolicy(config);
 56  7 regionManager.getRegion("/a/b", true).setEvictionPolicy(config);
 57   
 58  7 regionManager.getRegion("/d/e/f", true).setEvictionPolicy(config);
 59  7 regionManager.getRegion("/d/e/g", true).setEvictionPolicy(config);
 60  7 regionManager.getRegion("/d/e", true).setEvictionPolicy(config);
 61   
 62  7 cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
 63  7 cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
 64  7 cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
 65   
 66    // make the interceptor chain (separate from the CacheImpl object.
 67   
 68  7 interceptor = new CacheMgmtInterceptor();
 69  7 interceptor.setCache(cache);
 70   
 71  7 TxInterceptor ti = new TxInterceptor();
 72  7 ti.setCache(cache);
 73  7 interceptor.setNext(ti);
 74   
 75  7 UnlockInterceptor ui = new UnlockInterceptor();
 76  7 ui.setCache(cache);
 77  7 ti.setNext(ui);
 78   
 79  7 PessimisticLockInterceptor pli = new PessimisticLockInterceptor();
 80  7 pli.setCache(cache);
 81  7 ui.setNext(pli);
 82   
 83  7 EvictionInterceptor ei = new EvictionInterceptor();
 84  7 ei.setCache(cache);
 85  7 ei.setRegionManager(regionManager);
 86  7 pli.setNext(ei);
 87   
 88  7 CallInterceptor ci = new CallInterceptor();
 89  7 ci.setCache(cache);
 90  7 ci.setTreeCacheInstance(cache);
 91  7 ei.setNext(ci);
 92   
 93  7 cache.getConfiguration().setCacheMode("LOCAL");
 94  7 cache.start();
 95    }
 96   
 97  7 public void tearDown() throws Exception
 98    {
 99  7 super.tearDown();
 100  7 cache.remove("/");
 101  7 cache.stop();
 102    }
 103   
 104  1 public void testVisitNode() throws Throwable
 105    {
 106    // make sure node that doesn't exist does not result in a node visit event.
 107   
 108  1 MethodCall mc = MethodCallFactory.create(MethodDeclarations.getNodeMethodLocal,
 109    Fqn.fromString(fqn1));
 110  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 111  1 Region regionABC = regionManager.getRegion(fqn1, false);
 112  1 assertNull(regionABC.takeLastEventNode());
 113   
 114  1 cache.put(fqn1, "key", "value");
 115  1 assertEquals("value", cache.get(fqn1, "key"));
 116  1 Node node = cache.get(fqn1);
 117  1 assertNotNull(node);
 118  1 assertEquals("value", node.get("key"));
 119   
 120  1 cache.put(fqn3, "key", "value");
 121  1 assertEquals("value", cache.get(fqn3, "key"));
 122  1 node = cache.get(fqn3);
 123  1 assertNotNull(node);
 124  1 assertEquals("value", node.get("key"));
 125   
 126   
 127  1 mc = MethodCallFactory.create(MethodDeclarations.getNodeMethodLocal,
 128    Fqn.fromString(fqn1));
 129  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 130   
 131  1 regionABC = regionManager.getRegion(fqn1, false);
 132  1 EvictedEventNode event = regionABC.takeLastEventNode();
 133  1 assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
 134  1 assertEquals(fqn1, event.getFqn().toString());
 135  1 assertNull(regionABC.takeLastEventNode());
 136   
 137  1 mc = MethodCallFactory.create(MethodDeclarations.getNodeMethodLocal,
 138    Fqn.fromString(fqn2));
 139  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 140   
 141  1 Region regionAB = regionManager.getRegion(fqn2, false);
 142  1 event = regionAB.takeLastEventNode();
 143  1 assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
 144  1 assertEquals(fqn2, event.getFqn().toString());
 145  1 assertNull(regionAB.takeLastEventNode());
 146   
 147  1 mc = MethodCallFactory.create(MethodDeclarations.getDataMapMethodLocal, Fqn.fromString(fqn3));
 148  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 149  1 Region regionABD = regionManager.getRegion(fqn3, false);
 150  1 event = regionABD.takeLastEventNode();
 151  1 assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
 152  1 assertEquals(fqn3, event.getFqn().toString());
 153  1 assertNull(regionABD.takeLastEventNode());
 154   
 155  1 for (int i = 0; i < 10; i++)
 156    {
 157  10 Fqn fqn = Fqn.fromString(fqn3);
 158  10 mc = MethodCallFactory.create(MethodDeclarations.getNodeMethodLocal, fqn);
 159  10 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 160    }
 161   
 162  1 for (int i = 0; i < 10; i++)
 163    {
 164  10 Region region = regionManager.getRegion(fqn3, false);
 165  10 event = region.takeLastEventNode();
 166  10 assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
 167  10 assertEquals(fqn3, event.getFqn().toString());
 168    }
 169   
 170  1 assertNull(regionManager.getRegion(fqn3, false).takeLastEventNode());
 171   
 172    // check null handling.
 173  1 mc = MethodCallFactory.create(MethodDeclarations.getDataMapMethodLocal, new Object[]{null});
 174  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 175   
 176    }
 177   
 178  1 public void testVisitElement() throws Throwable
 179    {
 180    // make sure a get/visit on an empty node and empty element results in no cache events being added to event queue
 181    // aka MarshRegion.
 182  1 Fqn fqn = Fqn.fromString(fqn4);
 183  1 Object key = "key";
 184  1 MethodCall mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, fqn, key, false);
 185  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 186  1 Region region = regionManager.getRegion(fqn.toString(), false);
 187  1 assertNull(region.takeLastEventNode());
 188   
 189    // add the node but try to get on a null element should result in no cache events being added to MarshRegion.
 190  1 cache.put(fqn, "wrongkey", "");
 191  1 mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, fqn, key, false);
 192  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 193  1 assertNull(region.takeLastEventNode());
 194   
 195    // now make sure if we try to get on the node/key we just created in cache, that this DOES add a EvictedEventNode to
 196    // the MarshRegion.
 197  1 mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, fqn, "wrongkey", false);
 198  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 199  1 EvictedEventNode event = region.takeLastEventNode();
 200  1 assertEquals(fqn, event.getFqn());
 201  1 assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
 202   
 203  1 assertNull(region.takeLastEventNode());
 204   
 205  1 cache.put(fqn4, key, "value");
 206    // test on element granularity configured node.
 207  1 fqn = Fqn.fromString(fqn4);
 208  1 mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, fqn, key, false);
 209  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 210   
 211  1 region = regionManager.getRegion(fqn.toString(), false);
 212  1 event = region.takeLastEventNode();
 213   
 214  1 assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
 215  1 assertEquals(fqn, event.getFqn());
 216   
 217  1 assertNull(region.takeLastEventNode());
 218   
 219  1 fqn = Fqn.fromString("/d/e/g");
 220  1 for (int i = 0; i < 1000; i++)
 221    {
 222  1000 key = i;
 223   
 224  1000 cache.put("/d/e/g", key, "");
 225   
 226  1000 mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, fqn, key, true);
 227  1000 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 228    }
 229   
 230  1 region = regionManager.getRegion(fqn.toString(), false);
 231  1 for (int i = 0; i < 1000; i++)
 232    {
 233  1000 event = region.takeLastEventNode();
 234  1000 assertEquals(fqn, event.getFqn());
 235  1000 assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
 236    }
 237   
 238  1 cache.put("/a/b/c", key, "");
 239  1 fqn = Fqn.fromString("/a/b/c");
 240  1 mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, fqn, key, false);
 241  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 242   
 243  1 region = regionManager.getRegion(fqn.toString(), false);
 244  1 event = region.takeLastEventNode();
 245   
 246  1 assertNull(region.takeLastEventNode());
 247  1 assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
 248  1 assertEquals(fqn, event.getFqn());
 249   
 250  1 for (int i = 0; i < 1000; i++)
 251    {
 252  1000 key = i;
 253   
 254  1000 cache.put(fqn.toString(), key, "");
 255   
 256  1000 mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, fqn, key, true);
 257  1000 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 258    }
 259   
 260  1 for (int i = 0; i < 1000; i++)
 261    {
 262  1000 event = region.takeLastEventNode();
 263  1000 assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
 264  1000 assertEquals(fqn, event.getFqn());
 265    }
 266   
 267  1 assertNull(region.takeLastEventNode());
 268   
 269    // check null handling
 270  1 mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, null, key, true);
 271  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 272  1 assertNull(region.takeLastEventNode());
 273   
 274  1 mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, null, null, true);
 275  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 276  1 assertNull(region.takeLastEventNode());
 277   
 278  1 mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, fqn, null, true);
 279  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 280  1 assertNull(region.takeLastEventNode());
 281    }
 282   
 283  1 public void testCreateNode() throws Throwable
 284    {
 285  1 Map data = new HashMap();
 286  1 for (int i = 0; i < 100; i++)
 287    {
 288  100 data.put(i, i);
 289    }
 290   
 291    // this region is node granularity
 292  1 Fqn fqn = Fqn.fromString("/a/b/c");
 293   
 294  1 MethodCall mc = MethodCallFactory.create(MethodDeclarations.putDataMethodLocal, null, fqn, data, false);
 295  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 296   
 297  1 Region region = regionManager.getRegion(fqn.toString(), false);
 298  1 EvictedEventNode event = region.takeLastEventNode();
 299   
 300  1 assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType());
 301  1 assertEquals(fqn, event.getFqn());
 302  1 assertEquals(100, event.getElementDifference());
 303   
 304  1 Node node = cache.get(fqn.toString());
 305  1 assertNotNull(node);
 306   
 307  1 for (int i = 0; i < 100; i++)
 308    {
 309  100 assertTrue(node.getData().containsKey(i));
 310  100 assertEquals(i, node.get(i));
 311    }
 312   
 313  1 for (int i = 0; i < 100; i++)
 314    {
 315  100 mc = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal, null, fqn, i,
 316    "value", false);
 317  100 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 318   
 319  100 assertEquals("value", cache.get(fqn.toString(), i));
 320    }
 321   
 322  1 for (int i = 0; i < 100; i++)
 323    {
 324  100 event = region.takeLastEventNode();
 325  100 assertNotNull(event);
 326  100 assertEquals(fqn, event.getFqn());
 327  100 assertEquals(NodeEventType.ADD_ELEMENT_EVENT, event.getEventType());
 328    }
 329   
 330  1 assertNull(region.takeLastEventNode());
 331   
 332  1 fqn = Fqn.fromString("/a/b");
 333  1 mc = MethodCallFactory.create(MethodDeclarations.putDataEraseMethodLocal, null, fqn, data, false, false);
 334  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 335  1 event = regionManager.getRegion(fqn.toString(), false).takeLastEventNode();
 336  1 assertFalse(event.isResetElementCount());
 337  1 assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType());
 338  1 assertEquals(fqn, event.getFqn());
 339  1 assertEquals(100, event.getElementDifference());
 340  1 assertNull(regionManager.getRegion(fqn.toString(), false).takeLastEventNode());
 341  1 node = cache.get(fqn.toString());
 342  1 assertEquals(100, node.getData().size());
 343   
 344  1 assertNotNull(node);
 345   
 346  1 for (int i = 0; i < 100; i++)
 347    {
 348  100 assertTrue(node.getData().containsKey(i));
 349  100 assertEquals(i, node.get(i));
 350    }
 351   
 352  1 mc = MethodCallFactory.create(MethodDeclarations.putDataEraseMethodLocal, null, fqn, data, false, true);
 353  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 354  1 event = regionManager.getRegion(fqn.toString(), false).takeLastEventNode();
 355  1 assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType());
 356  1 assertEquals(fqn, event.getFqn());
 357  1 assertEquals(100, event.getElementDifference());
 358  1 assertTrue(event.isResetElementCount());
 359  1 assertNull(regionManager.getRegion(fqn.toString(), false).takeLastEventNode());
 360   
 361   
 362  1 node = cache.get(fqn.toString());
 363  1 assertEquals(100, node.getData().size());
 364  1 assertNotNull(node);
 365   
 366  1 for (int i = 0; i < 100; i++)
 367    {
 368  100 assertTrue(node.getData().containsKey(i));
 369  100 assertEquals(i, node.get(i));
 370    }
 371   
 372    }
 373   
 374  1 public void testCreateElement() throws Throwable
 375    {
 376  1 Fqn fqn = Fqn.fromString("/d/e/f");
 377  1 Region region = regionManager.getRegion(fqn.toString(), false);
 378  1 Object key = "key";
 379  1 Object value = "value";
 380   
 381  1 MethodCall mc = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal,
 382    null, fqn, key, value, false);
 383  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 384  1 assertEquals("value", cache.get(fqn, key));
 385  1 EvictedEventNode event = region.takeLastEventNode();
 386  1 assertEquals(NodeEventType.ADD_ELEMENT_EVENT, event.getEventType());
 387  1 assertEquals(1, event.getElementDifference());
 388  1 assertEquals(fqn, event.getFqn());
 389  1 assertEquals("value", cache.get(fqn, key));
 390  1 assertNull(region.takeLastEventNode());
 391   
 392  1 mc = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal,
 393    null, fqn, key, value, false);
 394  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 395  1 assertEquals("value", cache.get(fqn, key));
 396  1 event = region.takeLastEventNode();
 397  1 assertEquals(NodeEventType.ADD_ELEMENT_EVENT, event.getEventType());
 398  1 assertEquals(1, event.getElementDifference());
 399  1 assertEquals(fqn, event.getFqn());
 400  1 assertEquals("value", cache.get(fqn, key));
 401  1 assertNull(region.takeLastEventNode());
 402   
 403    }
 404   
 405  1 public void testRemoveNode() throws Throwable
 406    {
 407  1 Fqn fqn = Fqn.fromString("/a/b/c");
 408  1 cache.put(fqn, "a", "b");
 409  1 cache.put(fqn, "b", "c");
 410   
 411  1 MethodCall mc = MethodCallFactory.create(MethodDeclarations.removeDataMethodLocal, null, fqn, false);
 412  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 413   
 414  1 assertEquals(0, cache.get(fqn).getData().size());
 415  1 Region region = regionManager.getRegion(fqn.toString(), false);
 416  1 EvictedEventNode event = region.takeLastEventNode();
 417  1 assertEquals(NodeEventType.REMOVE_NODE_EVENT, event.getEventType());
 418  1 assertEquals(fqn, event.getFqn());
 419  1 assertNull(region.takeLastEventNode());
 420   
 421  1 mc = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, null, fqn, false);
 422  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 423   
 424  1 assertNull(cache.get(fqn));
 425  1 event = region.takeLastEventNode();
 426  1 assertEquals(NodeEventType.REMOVE_NODE_EVENT, event.getEventType());
 427  1 assertEquals(fqn, event.getFqn());
 428  1 assertNull(region.takeLastEventNode());
 429    }
 430   
 431  1 public void testRemoveElement() throws Throwable
 432    {
 433  1 Fqn fqn = Fqn.fromString("/a/b/c");
 434  1 cache.put(fqn, "a", "b");
 435  1 cache.put(fqn, "b", "c");
 436   
 437  1 MethodCall mc = MethodCallFactory.create(MethodDeclarations.removeKeyMethodLocal,
 438    null, fqn, "a", false);
 439  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 440   
 441  1 assertNull(cache.get(fqn, "a"));
 442  1 Region region = regionManager.getRegion(fqn.toString(), false);
 443  1 EvictedEventNode event = region.takeLastEventNode();
 444  1 assertEquals(NodeEventType.REMOVE_ELEMENT_EVENT, event.getEventType());
 445  1 assertEquals(fqn, event.getFqn());
 446  1 assertEquals(1, event.getElementDifference());
 447  1 assertNull(region.takeLastEventNode());
 448   
 449  1 mc = MethodCallFactory.create(MethodDeclarations.removeKeyMethodLocal,
 450    null, fqn, "b", false);
 451  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 452   
 453  1 assertNull(cache.get(fqn, "b"));
 454  1 event = region.takeLastEventNode();
 455  1 assertEquals(NodeEventType.REMOVE_ELEMENT_EVENT, event.getEventType());
 456  1 assertEquals(fqn, event.getFqn());
 457  1 assertEquals(1, event.getElementDifference());
 458  1 assertNull(region.takeLastEventNode());
 459   
 460  1 mc = MethodCallFactory.create(MethodDeclarations.removeKeyMethodLocal,
 461    null, fqn, "b", false);
 462  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 463   
 464  1 event = region.takeLastEventNode();
 465  1 assertNull(event);
 466    }
 467   
 468  1 public void testMixedEvent() throws Throwable
 469    {
 470  1 Map data = new HashMap();
 471  1 for (int i = 0; i < 100; i++)
 472    {
 473  100 data.put(i, i);
 474    }
 475   
 476    // this region is node granularity
 477  1 Fqn fqn = Fqn.fromString("/a/b/c");
 478   
 479  1 MethodCall mc = MethodCallFactory.create(MethodDeclarations.putDataMethodLocal, null, fqn, data, false);
 480  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 481   
 482  1 Region region = regionManager.getRegion(fqn.toString(), false);
 483  1 EvictedEventNode event = region.takeLastEventNode();
 484   
 485  1 assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType());
 486  1 assertEquals(fqn, event.getFqn());
 487  1 assertEquals(100, event.getElementDifference());
 488  1 assertNull(region.takeLastEventNode());
 489   
 490  1 mc = MethodCallFactory.create(MethodDeclarations.getNodeMethodLocal,
 491    fqn);
 492  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 493  1 event = region.takeLastEventNode();
 494  1 assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
 495  1 assertEquals(fqn, event.getFqn());
 496  1 assertNull(region.takeLastEventNode());
 497   
 498  1 mc = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, null, fqn, false);
 499  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 500  1 assertNull(cache.get(fqn));
 501  1 event = region.takeLastEventNode();
 502  1 assertEquals(NodeEventType.REMOVE_NODE_EVENT, event.getEventType());
 503  1 assertEquals(fqn, event.getFqn());
 504  1 assertNull(region.takeLastEventNode());
 505   
 506  1 Object key = "key";
 507  1 Object value = "value";
 508  1 mc = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal,
 509    null, fqn, key, value, false);
 510  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 511  1 assertEquals("value", cache.get(fqn, key));
 512  1 event = region.takeLastEventNode();
 513  1 assertEquals(NodeEventType.ADD_ELEMENT_EVENT, event.getEventType());
 514  1 assertEquals(1, event.getElementDifference());
 515  1 assertEquals(fqn, event.getFqn());
 516  1 assertEquals("value", cache.get(fqn, key));
 517  1 assertNull(region.takeLastEventNode());
 518   
 519  1 mc = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal, fqn, key, false);
 520  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 521  1 region = regionManager.getRegion(fqn.toString(), false);
 522  1 event = region.takeLastEventNode();
 523  1 assertEquals(NodeEventType.VISIT_NODE_EVENT, event.getEventType());
 524  1 assertEquals(fqn, event.getFqn());
 525  1 assertNull(region.takeLastEventNode());
 526   
 527  1 mc = MethodCallFactory.create(MethodDeclarations.removeKeyMethodLocal,
 528    null, fqn, key, false);
 529  1 interceptor.invoke(InvocationContext.fromMethodCall(mc));
 530   
 531  1 assertNull(cache.get(fqn, key));
 532  1 event = region.takeLastEventNode();
 533  1 assertEquals(NodeEventType.REMOVE_ELEMENT_EVENT, event.getEventType());
 534  1 assertEquals(fqn, event.getFqn());
 535  1 assertEquals(1, event.getElementDifference());
 536  1 assertNull(region.takeLastEventNode());
 537   
 538    }
 539   
 540    }