Examples of SetAttributesRequestHandler


Examples of org.jboss.as.web.session.mocks.SetAttributesRequestHandler

        ctx = (Context) managers[1].getContainer();
        ctx.setApplicationSessionLifecycleListeners(new Object[] { hsl1 });
        ctx.setApplicationEventListeners(new Object[] { hsal1 });

        // Initial request
        SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attributes, false);
        SessionTestUtil.invokeRequest(managers[0], 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(managers[0], 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);

        managers[0].backgroundProcess();
        managers[1].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(managers[0], 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(managers[1], setHandler, sessionId);

        if (!notify) {
            validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
        } else {
View Full Code Here

Examples of org.jboss.as.web.session.mocks.SetAttributesRequestHandler

        ctx = (Context) managers[1].getContainer();
        ctx.setApplicationSessionLifecycleListeners(new Object[] { hsl1 });
        ctx.setApplicationEventListeners(new Object[] { hsal1 });

        // Initial request
        SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attributes, false);
        SessionTestUtil.invokeRequest(managers[0], 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(managers[1], setHandler, sessionId);

        if (!notify) {
            validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
        } else {
View Full Code Here

Examples of org.jboss.as.web.session.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

Examples of org.jboss.as.web.session.mocks.SetAttributesRequestHandler

        ctx = (Context) managers[1].getContainer();
        ctx.setApplicationSessionLifecycleListeners(new Object[] { hsl1 });
        ctx.setApplicationEventListeners(new Object[] { hsal1 });

        // Initial request
        SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attributes, false);
        SessionTestUtil.invokeRequest(managers[0], setHandler, null);

        validateNewSession(setHandler);

        if (!notify) {
View Full Code Here

Examples of org.jboss.as.web.session.mocks.SetAttributesRequestHandler

        // A war with a maxInactive of 30 mins maxUnreplicated of 0
        this.startManagers(warname, 1800, 1);

        // Initial request
        SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
        log.info("initial request");
        SessionTestUtil.invokeRequest(managers[0], setHandler, null);

        String sessionId = setHandler.getSessionId();
        WeakReference<Session> session0A = new WeakReference<Session>(managers[0].findSession(sessionId));
        SessionTestUtil.cleanupPipeline(managers[0]);
        assertNotNull(session0A.get());

        // Modify attribute request
        setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
        log.info("Modify attribute request");
        SessionTestUtil.invokeRequest(managers[0], setHandler, sessionId);
        SessionTestUtil.cleanupPipeline(managers[0]);

        System.gc();
        System.runFinalization();
        assertEquals(1, Attribute.attributeCount());

        // Passivate
        Thread.sleep(1100);

        log.info("passivate node 0");
        managers[0].backgroundProcess();
        log.info("passivate node 1");
        managers[1].backgroundProcess();

        System.gc();
        System.runFinalization();
        assertEquals(0, Attribute.attributeCount());
        assertNull(session0A.get());

        // Remove attribute request
        RemoveAttributesRequestHandler removeHandler = new RemoveAttributesRequestHandler(KEYS, false);
        log.info("remove request");
        SessionTestUtil.invokeRequest(managers[0], removeHandler, sessionId);

        WeakReference<Session> session0B = new WeakReference<Session>(managers[0].findSession(sessionId));
        SessionTestUtil.cleanupPipeline(managers[0]);
        System.gc();
        System.runFinalization();
        assertEquals(0, Attribute.attributeCount());
        assertNotNull(session0B.get());

        // Failover request
        setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
        log.info("failover request");
        SessionTestUtil.invokeRequest(managers[1], setHandler, sessionId);

        WeakReference<Session> session1A = new WeakReference<Session>(managers[1].findSession(sessionId));
        SessionTestUtil.cleanupPipeline(managers[1]);
View Full Code Here

Examples of org.jboss.as.web.session.mocks.SetAttributesRequestHandler

        // A war with a maxInactive of 2 secs and a maxIdle of 10 (don't
        // passivate)
        this.startManagers(warname, 2, 10);

        // Initial request
        SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
        log.info("initial request");
        SessionTestUtil.invokeRequest(managers[0], setHandler, null);
        assertEquals(1, Attribute.attributeCount());

        String sessionId = setHandler.getSessionId();
        WeakReference<Session> session0A = new WeakReference<Session>(managers[0].findSession(sessionId));
        SessionTestUtil.cleanupPipeline(managers[0]);
        assertNotNull(session0A.get());
        assertEquals(1, Attribute.attributeCount());

        // Failover request
        setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
        log.info("fail over request");
        SessionTestUtil.invokeRequest(managers[1], setHandler, sessionId);
        assertNotNull(setHandler.getCheckedAttributes().get(KEY));
        assertEquals(Attribute.COUNT.incrementAndGet() - 1, ((Attribute) setHandler.getCheckedAttributes().get(KEY)).getCount());

        WeakReference<Session> session1A = new WeakReference<Session>(managers[1].findSession(sessionId));
        SessionTestUtil.cleanupPipeline(managers[1]);

        System.gc();
View Full Code Here

Examples of org.jboss.as.web.session.mocks.SetAttributesRequestHandler

        // A war with a maxInactive of 30 mins and no maxIdle
        this.startManagers(warname, 1800, -1);

        // Initial request
        SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
        SessionTestUtil.invokeRequest(managers[0], setHandler, null);
        assertEquals(1, Attribute.attributeCount());

        String sessionId = setHandler.getSessionId();
        WeakReference<Session> session0A = new WeakReference<Session>(managers[0].findSession(sessionId));
        SessionTestUtil.cleanupPipeline(managers[0]);
        assertNotNull(session0A.get());

        managers[0].stop();
View Full Code Here

Examples of org.jboss.as.web.session.mocks.SetAttributesRequestHandler

        // 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

Examples of org.jboss.as.web.session.mocks.SetAttributesRequestHandler

        // 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

Examples of org.jboss.as.web.session.mocks.SetAttributesRequestHandler

        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
TOP
Copyright © 2018 www.massapi.com. 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.