Package org.jboss.cache.mock

Examples of org.jboss.cache.mock.NodeSpiMock


      control.verify();
   }

   public void testDeadBeackup() throws Exception
   {
      NodeSpiMock root = new NodeSpiMock(Fqn.ROOT);

      //add first dead child
      IpAddress firstAddress = new IpAddress("127.0.0.1", 1234);
      NodeSpiMock firstDeadNode = (NodeSpiMock) root.addChildDirect(fqnTransformer.getDeadBackupRoot(firstAddress));
      firstDeadNode.addChildDirect(Fqn.fromElements(0));
      firstDeadNode.addChildDirect(Fqn.fromElements(1));
      firstDeadNode.addChildDirect(Fqn.fromElements(2));

      //add second dead child
      IpAddress secondAddress = new IpAddress("127.0.0.1", 4321);
      NodeSpiMock secondDeadNode = (NodeSpiMock) root.addChildDirect(fqnTransformer.getDeadBackupRoot(secondAddress));
      secondDeadNode.addChildDirect(Fqn.fromElements(0));


      expect(spiMock.getNode(fqn)).andReturn(null);
      NodeSPI buddyBackupRoot = (NodeSPI) root.getChild(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
      expect(containerMock.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)).andReturn(buddyBackupRoot);

      control.checkOrder(false);
      expect(spiMock.getChildrenNames(firstDeadNode.getFqn())).andReturn(firstDeadNode.getChildrenNames());
      Object fqnElement = fqn.getLastElement();//this is only composed from one element
      expect(spiMock.peek(Fqn.fromRelativeElements(firstDeadNode.getFqn(), 0, fqnElement), false)).andReturn(null);
      expect(spiMock.peek(Fqn.fromRelativeElements(firstDeadNode.getFqn(), 1, fqnElement), false)).andReturn(null);
      expect(spiMock.peek(Fqn.fromRelativeElements(firstDeadNode.getFqn(), 2, fqnElement), false)).andReturn(null);

      expect(spiMock.getChildrenNames(secondDeadNode.getFqn())).andReturn(secondDeadNode.getChildrenNames());
      expect(spiMock.peek(Fqn.fromRelativeElements(secondDeadNode.getFqn(), 0, fqnElement), false)).andReturn(null);
      control.checkOrder(true);

      control.replay();
      assert GravitateResult.noDataFound().equals(command.perform(ctx));
      control.verify();
View Full Code Here


   {
      InvocationContext ctx = new MVCCInvocationContext();
      ctx.putLookedUpNode(testFqn, null);
      assert !((Boolean) command.perform(ctx));

      ctx.putLookedUpNode(testFqn, new NodeSpiMock(testFqn));

      assert Boolean.TRUE == command.perform(ctx);
   }
View Full Code Here

      assert null == command.perform(ctx);
   }

   public void testForExistingNode()
   {
      NodeSpiMock node = new NodeSpiMock(testFqn);
      node.putDirect("k1", "v1");
      node.putDirect("k2", "v2");
      expect(container.peek(testFqn)).andReturn(node);
      replay(container);
      Map result = (Map) command.perform(ctx);
      assert 2 == result.entrySet().size();
      assert result.get("k1").equals("v1");
View Full Code Here

      assert null == command.perform(ctx);
   }

   public void testForExistingNode()
   {
      NodeSpiMock node = new NodeSpiMock(testFqn);
      node.putDirect("k1", "v1");
      node.putDirect("k2", "v2");
      expect(container.peek(testFqn)).andReturn(node);
      replay(container);
      Set result = (Set) command.perform(ctx);
      assert 2 == result.size();
      assert result.contains("k1");
View Full Code Here

      command.initialize(container);
   }

   public void testPerformNoChildren()
   {
      NodeSpiMock node = new NodeSpiMock(testFqn);
      expect(container.peek(testFqn)).andReturn(node);
      replay(container);
      Set result = (Set) command.perform(ctx);
      assert result.isEmpty() : "empty result expected";
   }
View Full Code Here

      assert null == command.perform(ctx);
   }

   public void testExistentNodeNoNotifications()
   {
      NodeSpiMock node = new NodeSpiMock(fqn);
      String value = "vvv";
      node.put(key, value);
      expect(containerMock.peek(fqn)).andReturn(node);
      control.replay();
      assert value.equals(command.perform(ctx));
   }
View Full Code Here

   }

   public void testExistentNodeWithNotifications()
   {
      command.sendNodeEvent = true;
      NodeSpiMock node = new NodeSpiMock(fqn);
      String value = "vvv";
      node.put(key, value);
      //not ordred because the peek hapens before notification - that is to make sure that no notification
      // is sent for an nonexistent node.
      control.checkOrder(false);
      notifierMock.notifyNodeVisited(fqn, true, ctx);
      expect(containerMock.peek(fqn)).andReturn(node);
View Full Code Here

      assert null == command.perform(ctx);
   }

   public void testExistentNodeNoNotifications()
   {
      NodeSpiMock node = new NodeSpiMock(fqn);
      String value = "vvv";
      node.put(key, value);
      expect(containerMock.peek(fqn)).andReturn(node);
      control.replay();
      assert value.equals(command.perform(ctx));
   }
View Full Code Here

   }

   public void testExistentNodeWithNotifications()
   {
      command.sendNodeEvent = true;
      NodeSpiMock node = new NodeSpiMock(fqn);
      String value = "vvv";
      node.put(key, value);
      //not ordred because the peek hapens before notification - that is to make sure that no notification
      // is sent for an nonexistent node.
      control.checkOrder(false);
      notifierMock.notifyNodeVisited(fqn, true, ctx);
      expect(containerMock.peek(fqn)).andReturn(node);
View Full Code Here

   {
      InvocationContext ctx = new MVCCInvocationContext();
      ctx.putLookedUpNode(testFqn, null);
      assert !((Boolean) command.perform(ctx));

      ctx.putLookedUpNode(testFqn, new NodeSpiMock(testFqn));

      assert Boolean.TRUE == command.perform(ctx);
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.mock.NodeSpiMock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.