Package de.javakaffee.web.msm.integration.TestUtils

Examples of de.javakaffee.web.msm.integration.TestUtils.Response


        final String sessionId1 = post( _httpClient, _portTomcat1, null, "foo", "bar" ).getSessionId();
        assertNotNull( sessionId1, "No session created." );

        _tomcat1.getContext().reload();

        final Response response = get( _httpClient, _portTomcat1, sessionId1 );
        final String actualValue = response.get( "foo" );
        assertEquals( "bar", actualValue );
    }
View Full Code Here


        final String key = "foo";
        final String value = "bar";
        final String sessionId1 = post( _httpClient, _portTomcat1, null, key, value ).getSessionId();
        assertNotNull( sessionId1, "No session created." );

        Response response = get( _httpClient, _portTomcat1, sessionId1 );
        assertEquals( response.getSessionId(), sessionId1 );
        assertEquals( response.get( key ), value );

        final Map<String, String> params = asMap( PARAM_REMOVE, key );
        response = get( _httpClient, _portTomcat1, "/", sessionId1, params );
        assertEquals( response.getSessionId(), sessionId1 );
        assertNull( response.get( key ) );

        // also the next request must not include this session attribute
        response = get( _httpClient, _portTomcat1, sessionId1 );
        assertEquals( response.getSessionId(), sessionId1 );
        assertNull( response.get( key ) );

    }
View Full Code Here

        final String key = "foo";
        final String value = "bar";
        final String sessionId1 = post( _httpClient, _portTomcat1, null, key, value ).getSessionId();
        assertNotNull( sessionId1, "No session created." );

        final Response response = get( _httpClient, _portTomcat1, sessionId1 );
        final String sessionId2 = response.getSessionId();

        assertEquals( sessionId2, sessionId1 );

        /* check session attributes could be read
         */
        final String actualValue = response.get( key );
        assertEquals( value, actualValue );
    }
View Full Code Here

    @Test( enabled = true, dataProviderClass = TestUtils.class, dataProvider = STICKYNESS_PROVIDER )
    public void testSessionAvailableInMemcachedWithCookiesDisabled( final SessionAffinityMode sessionAffinity ) throws Exception {
        _tomcat1.stop();
        _tomcat1 = tcBuilder().sticky(sessionAffinity.isSticky()).cookies(false).jvmRoute("app1").buildAndStart();

        final Response response = get(_httpClient, _portTomcat1, null);
        final String sessionId = response.get( TestServlet.ID );
        assertNotNull( sessionId, "No session created." );
        Thread.sleep( 50 );
        assertNotNull( _memcached.get( sessionId ), "Session not available in memcached." );
    }
View Full Code Here

        setStickyness(sessionAffinity);

        final String sessionId1 = makeRequest( _httpClient, _portTomcat1, null );
        assertNotNull( sessionId1, "No session created." );

        final Response response = get( _httpClient, _portTomcat1, PATH_INVALIDATE, sessionId1 );
        assertNull( response.getResponseSessionId() );
        assertEquals(_daemon.getCache().getGetMisses(), 1); // 1 is ok

        assertNull( _memcached.get( sessionId1 ), "Invalidated session still existing in memcached" );
        if(!sessionAffinity.isSticky()) {
            assertNull( _memcached.get(new SessionIdFormat().createValidityInfoKeyName( sessionId1 )), "ValidityInfo for invalidated session still exists in memcached." );
View Full Code Here

        assertNotNull(sessionId);

        Thread.sleep(200);

        // we want to get the session from the primary node
        Response response = get(_httpClient, TC_PORT_1, sessionId);
        assertEquals(response.getSessionId(), sessionId);
        assertEquals(response.get("k1"), "v1");

        // now we shut down the primary node so that the session is loaded from the backup node
        final SessionIdFormat fmt = new SessionIdFormat();
        final String nodeId = fmt.extractMemcachedId( sessionId );
        final MemCacheDaemon<?> primary = NODE_ID_1.equals(nodeId) ? _daemon1 : _daemon2;
        primary.stop();

        Thread.sleep( 200 );

        // the session should be loaded from the backup node
        response = get(_httpClient, TC_PORT_1, sessionId);
        assertEquals(fmt.createNewSessionId(response.getSessionId(), nodeId), sessionId);
        assertEquals(response.get("k1"), "v1");
    }
View Full Code Here

        assertNotNull(sessionId);

        Thread.sleep(200);

        // we want to get the session from the primary node
        Response response = get(_httpClient, TC_PORT_1, sessionId);
        assertEquals(response.getSessionId(), sessionId);
        assertEquals(response.get("k1"), "v1");

        // now we shut down the primary node so that the session is loaded from the backup node
        final SessionIdFormat fmt = new SessionIdFormat();
        final String nodeId = fmt.extractMemcachedId( sessionId );
        final MemCacheDaemon<?> primary = NODE_ID_1.equals(nodeId) ? _daemon1 : _daemon2;
        primary.stop();

        Thread.sleep( 200 );

        // the session should be loaded from the backup node
        response = get(_httpClient, TC_PORT_1, sessionId);
        assertEquals(fmt.createNewSessionId(response.getSessionId(), nodeId), sessionId);
        assertEquals(response.get("k1"), "v1");
    }
View Full Code Here

        final String sessionId = post(_httpClient, TC_PORT_1, null, "k1", "v1").getSessionId();
        assertNotNull(sessionId);

        // just want to see that we can access/load the session
        Response response = get(_httpClient, TC_PORT_1, sessionId);
        assertEquals(response.getSessionId(), sessionId);
        assertEquals(response.get("k1"), "v1");

        // and we want to be able to update the session
        post(_httpClient, TC_PORT_1, sessionId, "k2", "v2");

        response = get(_httpClient, TC_PORT_1, sessionId);
        assertEquals(response.getSessionId(), sessionId);
        assertEquals(response.get("k1"), "v1");
        assertEquals(response.get("k2"), "v2");
    }
View Full Code Here

        // this request should update the same session instance and reuse the lock.
        post(_httpClient, TC_PORT_1, sessionId, "k3", "v3");

        // this request should wait until the second and third requests have released the
        // session lock.
        final Response finalResponse = get(_httpClient, TC_PORT_2, sessionId);
        assertEquals(finalResponse.getSessionId(), sessionId);
        assertEquals(response2.get().getSessionId(), sessionId);

        // the final response should contain all keys/values
        assertEquals(finalResponse.get("k1"), "v1");
        assertEquals(finalResponse.get("k2"), "v2");
        assertEquals(finalResponse.get("k3"), "v3");
    }
View Full Code Here

        final String sessionId2 = post( _httpClient, TC_PORT_2, sessionId1, key, value2 ).getSessionId();
        assertEquals( sessionId2, sessionId1 );

        /* Check that tc1 reads the updated value
         */
        final Response response = get( _httpClient, TC_PORT_1, sessionId1 );
        assertEquals( response.getSessionId(), sessionId1 );
        assertEquals( response.get( key ), value2 );

    }
View Full Code Here

TOP

Related Classes of de.javakaffee.web.msm.integration.TestUtils.Response

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.