Package org.jboss.web.tomcat.service.session.distributedcache.spi

Examples of org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata


    * Test method for {@link org.jboss.web.tomcat.service.session.persistent.RDBMSStoreBase#storeSessionData(org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingSessionGranularitySessionData)}.
    */
   public void testInsertSessionDataExistingRecord()
   {
      testee.start();
      DistributableSessionMetadata md = new DistributableSessionMetadata();
      String id = nextId();
      md.setId(id + ".full");
      md.setCreationTime(1);
      md.setNew(true);
      md.setValid(true);
      md.setMaxInactiveInterval(30000);
      Long ts = Long.valueOf(2);
      Map<String, Object> attrs = new HashMap<String, Object>();
      attrs.put("key", "value");
      OutgoingSessionGranularitySessionData sessionData = new MockOutgoingSessionData(id, 0, ts, md, attrs);
      testee.storeSessionData(sessionData);
     
      // Don't call md.setNew(false); !! Treat it as a new session
      DistributableSessionMetadata newmd = new DistributableSessionMetadata();
      newmd.setId(id + ".full");
      newmd.setCreationTime(3);
      newmd.setNew(true);
      newmd.setValid(true);
      newmd.setMaxInactiveInterval(30000);
      newmd.setMaxInactiveInterval(20000);
      attrs.clear();
      attrs.put("key", "newvalue");
      Long newts = Long.valueOf(4);
      sessionData = new MockOutgoingSessionData(id, 0, newts, newmd, attrs);
      testee.storeSessionData(sessionData);
     
      IncomingDistributableSessionData incoming = testee.getSessionData(id, true);
      assertEquals(0, incoming.getVersion());
      assertEquals(newts.longValue(), incoming.getTimestamp());
      assertEquals(newmd.getId(), incoming.getMetadata().getId());
      assertEquals(newmd.getCreationTime(), incoming.getMetadata().getCreationTime());
      assertEquals(newmd.isNew(), incoming.getMetadata().isNew());
      assertEquals(newmd.isValid(), incoming.getMetadata().isValid());
      assertEquals(newmd.getMaxInactiveInterval(), incoming.getMetadata().getMaxInactiveInterval());
      assertTrue(incoming.providesSessionAttributes());
      assertEquals(attrs, incoming.getSessionAttributes());
   }
View Full Code Here


    * Test method for {@link org.jboss.web.tomcat.service.session.persistent.RDBMSStoreBase#storeSessionData(org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingSessionGranularitySessionData)}.
    */
   public void testFullUpdateSessionData()
   {
      testee.start();
      DistributableSessionMetadata md = new DistributableSessionMetadata();
      String id = nextId();
      md.setId(id + ".full");
      md.setCreationTime(System.currentTimeMillis());
      md.setNew(true);
      md.setValid(true);
      md.setMaxInactiveInterval(30000);
      Long ts = Long.valueOf(md.getCreationTime() + 1);
      Map<String, Object> attrs = new HashMap<String, Object>();
      attrs.put("key", "value");
      OutgoingSessionGranularitySessionData sessionData = new MockOutgoingSessionData(id, 1, ts, md, attrs);
      testee.storeSessionData(sessionData);
     
      md.setNew(false);
      md.setMaxInactiveInterval(20000);
      attrs.put("key", "newvalue");
      ts = Long.valueOf(System.currentTimeMillis());
      sessionData = new MockOutgoingSessionData(id, 1, ts, md, attrs);
      testee.storeSessionData(sessionData);
     
      IncomingDistributableSessionData incoming = testee.getSessionData(id, true);
      assertEquals(1, incoming.getVersion());
      assertEquals(ts.longValue(), incoming.getTimestamp());
      assertEquals(md.getId(), incoming.getMetadata().getId());
      assertEquals(md.getCreationTime(), incoming.getMetadata().getCreationTime());
      assertEquals(md.isNew(), incoming.getMetadata().isNew());
      assertEquals(md.isValid(), incoming.getMetadata().isValid());
      assertEquals(md.getMaxInactiveInterval(), incoming.getMetadata().getMaxInactiveInterval());
      assertTrue(incoming.providesSessionAttributes());
      assertEquals(attrs, incoming.getSessionAttributes());
   }
View Full Code Here

    * Test method for {@link org.jboss.web.tomcat.service.session.persistent.RDBMSStoreBase#storeSessionData(org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingSessionGranularitySessionData)}.
    */
   public void testAttributeUpdateSessionData()
   {
      testee.start();
      DistributableSessionMetadata md = new DistributableSessionMetadata();
      String id = nextId();
      md.setId(id + ".full");
      md.setCreationTime(System.currentTimeMillis());
      md.setNew(true);
      md.setValid(true);
      md.setMaxInactiveInterval(30000);
      Long ts = Long.valueOf(md.getCreationTime() + 1);
      Map<String, Object> attrs = new HashMap<String, Object>();
      attrs.put("key", "value");
      OutgoingSessionGranularitySessionData sessionData = new MockOutgoingSessionData(id, 1, ts, md, attrs);
      testee.storeSessionData(sessionData);
     
      attrs.put("key", "newvalue");
      ts = Long.valueOf(System.currentTimeMillis());
      sessionData = new MockOutgoingSessionData(id, 1, ts, null, attrs);
      testee.storeSessionData(sessionData);
     
      IncomingDistributableSessionData incoming = testee.getSessionData(id, true);
      assertEquals(1, incoming.getVersion());
      assertEquals(ts.longValue(), incoming.getTimestamp());
      assertEquals(md.getId(), incoming.getMetadata().getId());
      assertEquals(md.getCreationTime(), incoming.getMetadata().getCreationTime());
      assertEquals(md.isNew(), incoming.getMetadata().isNew());
      assertEquals(md.isValid(), incoming.getMetadata().isValid());
      assertEquals(md.getMaxInactiveInterval(), incoming.getMetadata().getMaxInactiveInterval());
      assertTrue(incoming.providesSessionAttributes());
      assertEquals(attrs, incoming.getSessionAttributes());
   }
View Full Code Here

    * Test method for {@link org.jboss.web.tomcat.service.session.persistent.RDBMSStoreBase#storeSessionData(org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingSessionGranularitySessionData)}.
    */
   public void testMetadataUpdateSessionData()
   {
      testee.start();
      DistributableSessionMetadata md = new DistributableSessionMetadata();
      String id = nextId();
      md.setId(id + ".full");
      md.setCreationTime(System.currentTimeMillis());
      md.setNew(true);
      md.setValid(true);
      md.setMaxInactiveInterval(30000);
      Long ts = Long.valueOf(md.getCreationTime() + 1);
      Map<String, Object> attrs = new HashMap<String, Object>();
      attrs.put("key", "value");
      OutgoingSessionGranularitySessionData sessionData = new MockOutgoingSessionData(id, 1, ts, md, attrs);
      testee.storeSessionData(sessionData);
     
      md.setNew(false);
      md.setMaxInactiveInterval(20000);
      ts = Long.valueOf(System.currentTimeMillis());
      sessionData = new MockOutgoingSessionData(id, 1, ts, md, null);
      testee.storeSessionData(sessionData);
     
      IncomingDistributableSessionData incoming = testee.getSessionData(id, true);
      assertEquals(1, incoming.getVersion());
      assertEquals(ts.longValue(), incoming.getTimestamp());
      assertEquals(md.getId(), incoming.getMetadata().getId());
      assertEquals(md.getCreationTime(), incoming.getMetadata().getCreationTime());
      assertEquals(md.isNew(), incoming.getMetadata().isNew());
      assertEquals(md.isValid(), incoming.getMetadata().isValid());
      assertEquals(md.getMaxInactiveInterval(), incoming.getMetadata().getMaxInactiveInterval());
      assertTrue(incoming.providesSessionAttributes());
      assertEquals(attrs, incoming.getSessionAttributes());
   }
View Full Code Here

      Fqn<String> fqn = getSessionFqn(combinedPath_, realId);
     
      Map<Object, Object> map = new HashMap<Object, Object>();
      map.put(VERSION_KEY, Integer.valueOf(sessionData.getVersion()));
     
      DistributableSessionMetadata dsm = sessionData.getMetadata();
      if (dsm != null)
      {  
         map.put(METADATA_KEY, dsm);
      }
     
View Full Code Here

                                       Map<Object, Object> distributedCacheData,
                                       boolean includeAttributes)
   {
      Integer version = (Integer) distributedCacheData.get(VERSION_KEY);
      Long timestamp = (Long) distributedCacheData.get(TIMESTAMP_KEY);
      DistributableSessionMetadata metadata = (DistributableSessionMetadata) distributedCacheData.get(METADATA_KEY);
      IncomingDistributableSessionData result = null;
      if (includeAttributes)
      {
         Map<String, Object> attrs = getSessionAttributes(realId, distributedCacheData);     
         result = new IncomingDistributableSessionDataImpl(version, timestamp, metadata, attrs);
View Full Code Here

      Fqn<String> fqn = getSessionFqn(combinedPath_, realId);
     
      Map<Object, Object> map = new HashMap<Object, Object>();
      map.put(VERSION_KEY, Integer.valueOf(sessionData.getVersion()));
     
      DistributableSessionMetadata dsm = sessionData.getMetadata();
      if (dsm != null)
      {  
         map.put(METADATA_KEY, dsm);
      }
     
View Full Code Here

                                       Map<Object, Object> distributedCacheData,
                                       boolean includeAttributes)
   {
      Integer version = (Integer) distributedCacheData.get(VERSION_KEY);
      Long timestamp = (Long) distributedCacheData.get(TIMESTAMP_KEY);
      DistributableSessionMetadata metadata = (DistributableSessionMetadata) distributedCacheData.get(METADATA_KEY);
      Map<String, Object> attrs = includeAttributes ? getSessionAttributes(realId, distributedCacheData) : null;     
      return new IncomingDistributableSessionDataImpl(version, timestamp, metadata, attrs);
   }
View Full Code Here

   @Override
   protected OutgoingSessionGranularitySessionData getOutgoingSessionData()
   {
      Map<String, Object> attrs = isSessionAttributeMapDirty() ? getSessionAttributeMap() : null;
      DistributableSessionMetadata metadata = isSessionMetadataDirty() ? getSessionMetadata() : null;
      Long timestamp = attrs != null || metadata != null || getMustReplicateTimestamp() ? Long.valueOf(getSessionTimestamp()) : null;
      return new OutgoingData(getRealId(), getVersion(), timestamp, metadata, attrs);
   }
View Full Code Here

   // --------------------------------------------- Overridden Protected Methods

   @Override
   protected OutgoingDistributableSessionData getOutgoingSessionData()
   {
      DistributableSessionMetadata metadata = isSessionMetadataDirty() ? getSessionMetadata() : null;
      Long timestamp = metadata != null || isSessionAttributeMapDirty() || getMustReplicateTimestamp() ? Long.valueOf(getSessionTimestamp()) : null;
      return new OutgoingDistributableSessionDataImpl(getRealId(), getVersion(), timestamp, metadata);
   }
View Full Code Here

TOP

Related Classes of org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata

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.