Package org.jboss.test.cluster.web.mocks

Examples of org.jboss.test.cluster.web.mocks.SetAttributesRequestHandler


     
      log.info("All views received");
     
      Object value = "0";
      Map<String, Object> attrs = Collections.unmodifiableMap(Collections.singletonMap("count", value));
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attrs, false);
      SessionTestUtil.invokeRequest(managers[0], setHandler, null);
     
      String id1 = setHandler.getSessionId();
      assertNotNull(id1);
     
      // Add a second session that we can check for replication; this is a proxy
      // for checking that first session has replicated
      setHandler = new SetAttributesRequestHandler(attrs, false);
      SessionTestUtil.invokeRequest(managers[0], setHandler, null);
     
      String id2 = setHandler.getSessionId();
      assertNotNull(id1);
     
      assertFalse(id1.equals(id2));
     
      // Ensure replication of session 2 has occurred
View Full Code Here


      // A war with a maxInactive of 30 mins and a maxIdle of 1
      this.startManagers(warname, 1800000, 1, -1);
     
      this.log.info("Request(1) to manager[3]");
     
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(0)), false);
      invokeRequest(managers[3], setHandler, null);
     
      this.log.info("Request(2) to manager[3]");
     
      String id = setHandler.getSessionId();    
     
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(1)), false);
      invokeRequest(managers[3], setHandler, id);     
      assertEquals(getAttributeValue(0), setHandler.getCheckedAttributes().get("count"));
     
      this.log.info("Sleeping");
     
      sleepThread(1100);
     
      this.log.info("Run passivation");
     
      managers[0].backgroundProcess()
      managers[1].backgroundProcess();
      managers[2].backgroundProcess();
      managers[3].backgroundProcess();
     
      this.log.info("Request(3) to manager[3]");
     
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(2)), false);
      invokeRequest(managers[3], setHandler, id);     
      assertEquals(getAttributeValue(1), setHandler.getCheckedAttributes().get("count"));
     
      this.log.info("Request(4) to manager[3]");
     
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(3)), false);
      invokeRequest(managers[3], setHandler, id);     
      assertEquals(getAttributeValue(2), setHandler.getCheckedAttributes().get("count"));
     
      this.log.info("Invalidate request to manager[0]");
     
      // Invalidate on the failover request
      InvalidateSessionRequestHandler invalidationHandler = new InvalidateSessionRequestHandler(Collections.singleton("count"), false);
      invokeRequest(managers[0], invalidationHandler, id);     
      assertEquals(getAttributeValue(3), invalidationHandler.getCheckedAttributes().get("count"));
     
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(0)), false);
      invokeRequest(managers[0], invalidationHandler, id);     
      assertNull(setHandler.getCheckedAttributes().get("count"));
   }
View Full Code Here

      // A war with a maxInactive of 30 mins and no maxIdle
      this.startManagers(warname, 1800000, -1, -1);
     
      log.info("managers created");
      log.info("creating session");
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(0)), false);
      invokeRequest(managers[0], setHandler, null);
     
      String id = setHandler.getSessionId();    
     
      // Find a node
      int localIndex = 0;
      int remoteIndex = 0;
      for (int i = 0; i < managers.length; ++i)
      {
         if (managers[i].getDistributedCacheManager().isLocal(id))
         {
            localIndex = i;
         }
         else
         {
            remoteIndex = i;
         }
      }
     
      // Modify
      log.info("modifying session");
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(1)), false);
      invokeRequest(managers[localIndex], setHandler, id);     
      assertEquals(getAttributeValue(0), setHandler.getCheckedAttributes().get("count"));   
     
      // Failover and modify
      log.info("failing over");
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(2)), false);
      invokeRequest(managers[localIndex], setHandler, id);     
      assertEquals(getAttributeValue(1), setHandler.getCheckedAttributes().get("count"));      
     
      // Modify
      log.info("modifying session");
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(3)), false);
      invokeRequest(managers[localIndex], setHandler, id);     
      assertEquals(getAttributeValue(2), setHandler.getCheckedAttributes().get("count"));    
     
      // Failover and modify
      log.info("failing over");
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(4)), false);
      invokeRequest(managers[remoteIndex], setHandler, id);     
      assertEquals(getAttributeValue(3), setHandler.getCheckedAttributes().get("count"));      
     
      // Modify
      log.info("modifying session");
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(5)), false);
      invokeRequest(managers[remoteIndex], setHandler, id);     
      assertEquals(getAttributeValue(4), setHandler.getCheckedAttributes().get("count"));
     
      // Failback and modify
      log.info("failing back");
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(6)), false);
      invokeRequest(managers[localIndex], setHandler, id);     
      assertEquals(getAttributeValue(5), setHandler.getCheckedAttributes().get("count"))
     
      // Invalidate
      log.info("invalidating");
      InvalidateSessionRequestHandler invalidationHandler = new InvalidateSessionRequestHandler(Collections.singleton("count"), false);
      invokeRequest(managers[localIndex], invalidationHandler, id);
      assertEquals(getAttributeValue(6), invalidationHandler.getCheckedAttributes().get("count"));
     
      // Reestablish
      log.info("re-establishing");
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(0)), false);
      invokeRequest(managers[localIndex], invalidationHandler, id);     
      assertNull(setHandler.getCheckedAttributes().get("count"));     
   }
View Full Code Here

     
      // A war with a maxInactive of 30 mins and a maxIdle of 1
      this.startManagers(warname, 1800000, 1, -1);
     
      Object value = "0";
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", value), false);
      SessionTestUtil.invokeRequest(managers[0], setHandler, null);
     
      String id = setHandler.getSessionId();
     
      SessionTestUtil.sleepThread(1100);
     
      managers[0].backgroundProcess();
      managers[1].backgroundProcess();    
     
      value = "1";
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", value), false);
      SessionTestUtil.invokeRequest(managers[0], setHandler, id);
     
      assertEquals("0", setHandler.getCheckedAttributes().get("count"));
     
      value = "2";
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", value), false);
      SessionTestUtil.invokeRequest(managers[1], setHandler, id);
     
      assertEquals("1", setHandler.getCheckedAttributes().get("count"));
   }
View Full Code Here

     
      // A war with a maxInactive of 30 mins and a maxIdle of 1
      this.startManagers(warname, 1800000, 1, -1);
     
      Object value = "0";
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", value), false);
      SessionTestUtil.invokeRequest(managers[0], setHandler, null);
     
      String id = setHandler.getSessionId();
     
      SessionTestUtil.sleepThread(1100);
     
      managers[0].backgroundProcess();
      managers[1].backgroundProcess();    
     
      value = "1";
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", value), false);
      SessionTestUtil.invokeRequest(managers[1], setHandler, id);
     
      assertEquals("0", setHandler.getCheckedAttributes().get("count"));
   }
View Full Code Here

      String warname = String.valueOf(++testId);
     
      // A war with a maxInactive of 3 secs and a maxUnreplicated of 1
      startManagers(warname, 3, 1);
     
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(allAttributes, false);
      SessionTestUtil.invokeRequest(managers[0], setHandler, null);
     
      validateNewSession(setHandler);
     
      Thread.sleep(250);
     
      // Now make a request that will not trigger replication but keeps the jbcm0 session alive
      BasicRequestHandler getHandler = new BasicRequestHandler(immutables.keySet(), false);
      SessionTestUtil.invokeRequest(managers[0], getHandler, setHandler.getSessionId());
     
      validateExpectedAttributes(immutables, getHandler);
     
      // Sleep long enough that the session will be expired on other server
      // if it doesn't have a maxUnreplicatedInterval grace period
      Thread.sleep(2800);
     
      // jbcm1 considers the session unmodified for > 3 sec maxInactiveInterval.
      // Try to drive the session out of the jbcm1 cache     
      managers[1].backgroundProcess();
     
      // Replicate just one attribute; see if the other is still in jbcm1
      SetAttributesRequestHandler modifyHandler = new SetAttributesRequestHandler(mutables, false);
      SessionTestUtil.invokeRequest(managers[0], modifyHandler, setHandler.getSessionId());
     
      // Fail over and confirm all is well. If the session was removed,
      // the last replication of just one attribute won't restore all
      // attributes and we'll have a failure
View Full Code Here

      String warname = String.valueOf(++testId);
     
      // A war with a maxInactive of 2 secs and a maxUnreplicated of -1
      startManagers(warname, 2, -1);
     
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(allAttributes, false);
      SessionTestUtil.invokeRequest(managers[0], setHandler, null);
     
      validateNewSession(setHandler);
     
      Thread.sleep(250);
     
      SetAttributesRequestHandler modifyHandler = new SetAttributesRequestHandler(mutables, false);
      SessionTestUtil.invokeRequest(managers[0], modifyHandler, setHandler.getSessionId());
     
      Thread.sleep(1760);
     
      // Fail over and confirm all is well
View Full Code Here

     
      String warnameB = "B" + String.valueOf(testId);
      this.startManagers(warnameB, managersB);
     
      // Establish session.
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(allAttributes, false);
      SessionTestUtil.invokeRequest(managersA[0], setHandler, null);
      validateNewSession(setHandler);
      String idA = setHandler.getSessionId();
     
      setHandler = new SetAttributesRequestHandler(allAttributes, false);
      SessionTestUtil.invokeRequest(managersB[0], setHandler, null);
      validateNewSession(setHandler);
      String idB = setHandler.getSessionId();
     
      BasicRequestHandler getHandler = new BasicRequestHandler(allAttributes.keySet(), false);
      SessionTestUtil.invokeRequest(managersA[1], getHandler, idA);
     
      validateExpectedAttributes(allAttributes, getHandler);
View Full Code Here

      ctx = (Context) jbcm1.getContainer();
      ctx.setApplicationLifecycleListeners(new Object[]{ hsl1 })
      ctx.setApplicationEventListeners(new Object[]{ hsal1 });
     
      // Initial request
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attributes, false);
      SessionTestUtil.invokeRequest(jbcm0, setHandler, null);
     
      validateNewSession(setHandler);
      String sessionId = setHandler.getSessionId();
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, hsl0.invocations.size());
         assertEquals(MockHttpSessionListener.Type.CREATED, hsl0.invocations.get(0));
         assertEquals(1, hsal0.invocations.size());
         assertEquals(MockHttpSessionAttributeListener.Type.ADDED, hsal0.invocations.get(0));
         assertEquals(2, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.BOUND, SessionSpecListenerAttribute.invocations.get(0));
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(1));
        
         validateNoNotifications(null, null, hsl1, hsal1, null);
         clearNotifications(hsl0, hsal0, null, null, SessionSpecListenerAttribute.invocations);
      }
     
      // Modify attribute request
      setHandler = new SetAttributesRequestHandler(newAttributes, false);
      SessionTestUtil.invokeRequest(jbcm0, setHandler, sessionId);
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, hsal0.invocations.size());
         assertEquals(MockHttpSessionAttributeListener.Type.REPLACED, hsal0.invocations.get(0));
         assertEquals(4, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.ACTIVATING, SessionSpecListenerAttribute.invocations.get(0));
         assertEquals(SessionSpecListenerAttribute.Type.BOUND, SessionSpecListenerAttribute.invocations.get(1));
         assertEquals(SessionSpecListenerAttribute.Type.UNBOUND, SessionSpecListenerAttribute.invocations.get(2));
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(3));
        
         validateNoNotifications(hsl0, null, hsl1, hsal1, null);
         clearNotifications(null, hsal0, null, null, SessionSpecListenerAttribute.invocations);
      }
     
      // Passivate
      Thread.sleep(1100);
     
      jbcm0.backgroundProcess();
      jbcm1.backgroundProcess();
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(0));
        
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1, null);
         clearNotifications(null, null, null, null, SessionSpecListenerAttribute.invocations);
      }
     
      // Remove attribute request
      RemoveAttributesRequestHandler removeHandler = new RemoveAttributesRequestHandler(newAttributes.keySet(), false);
      SessionTestUtil.invokeRequest(jbcm0, removeHandler, sessionId);
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, hsal0.invocations.size());
         assertEquals(MockHttpSessionAttributeListener.Type.REMOVED, hsal0.invocations.get(0));
         assertEquals(3, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.ACTIVATING, SessionSpecListenerAttribute.invocations.get(0));
         assertEquals(SessionSpecListenerAttribute.Type.ACTIVATING, SessionSpecListenerAttribute.invocations.get(1));
         assertEquals(SessionSpecListenerAttribute.Type.UNBOUND, SessionSpecListenerAttribute.invocations.get(2));
        
         validateNoNotifications(hsl0, null, hsl1, hsal1, null);
         clearNotifications(null, hsal0, null, null, SessionSpecListenerAttribute.invocations);
      }
     
      // Failover request
      setHandler = new SetAttributesRequestHandler(attributes, false);
      SessionTestUtil.invokeRequest(jbcm1, setHandler, sessionId);
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
View Full Code Here

      ctx = (Context) jbcm1.getContainer();
      ctx.setApplicationLifecycleListeners(new Object[]{ hsl1 })
      ctx.setApplicationEventListeners(new Object[]{ hsal1 });
     
      // Initial request
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attributes, false);
      SessionTestUtil.invokeRequest(jbcm0, setHandler, null);
     
      validateNewSession(setHandler);
     
      String sessionId = setHandler.getSessionId();
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, hsl0.invocations.size());
         assertEquals(MockHttpSessionListener.Type.CREATED, hsl0.invocations.get(0));
         assertEquals(1, hsal0.invocations.size());
         assertEquals(MockHttpSessionAttributeListener.Type.ADDED, hsal0.invocations.get(0));
         assertEquals(2, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.BOUND, SessionSpecListenerAttribute.invocations.get(0));
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(1));
        
         validateNoNotifications(null, null, hsl1, hsal1, null);
         clearNotifications(hsl0, hsal0, null, null, SessionSpecListenerAttribute.invocations);        
      }
     
      // Failover request
      setHandler = new SetAttributesRequestHandler(newAttributes, false);
      SessionTestUtil.invokeRequest(jbcm1, setHandler, sessionId);
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
View Full Code Here

TOP

Related Classes of org.jboss.test.cluster.web.mocks.SetAttributesRequestHandler

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.