Java Code Examples for io.vertx.ext.web.sstore.SessionStore#put()

The following examples show how to use io.vertx.ext.web.sstore.SessionStore#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NearCacheSessionStoreIT.java    From vertx-vaadin with MIT License 6 votes vote down vote up
@Test(timeout = 3000)
public void putShouldUpdateRemoteSession(TestContext context) {
    Vertx vertx = rule.vertx();

    TestObject testObject = new TestObject("TestObject");
    ExtendedSession session = createSession(vertx);
    String testObjKey = "testObjKey";
    session.put(testObjKey, testObject);

    SessionStore sessionStore = NearCacheSessionStore.create(vertx);
    sessionStore.put(session, context.asyncAssertSuccess(b -> {
        doWithRemoteSession(context, session, context.asyncAssertSuccess(s ->
            context.verify(unused -> assertSessionProperties(session, s))
        ));
        doWithLocalSession(context, session, context.asyncAssertSuccess(s ->
            context.verify(unused -> {
                assertSessionProperties(session, s);

            })
        ));
    }));
}
 
Example 2
Source File: NearCacheSessionStoreIT.java    From vertx-vaadin with MIT License 6 votes vote down vote up
@Test(timeout = 3000)
public void consecutiveGetAndPutShouldBeConsistent(TestContext context) {
    Vertx vertx = rule.vertx();

    TestObject testObject = new TestObject("TestObject");
    ExtendedSession session = createSession(vertx);
    String testObjKey = "testObjKey";
    session.put(testObjKey, testObject);

    SessionStore sessionStore = NearCacheSessionStore.create(vertx);
    sessionStore.put(session, context.asyncAssertSuccess(x -> {
        sessionStore.get(session.id(), context.asyncAssertSuccess(freshSession -> {
            sessionStore.put(freshSession, context.asyncAssertSuccess());
        }));
    }));


}
 
Example 3
Source File: NearCacheSessionStoreIT.java    From vertx-vaadin with MIT License 6 votes vote down vote up
@Test
public void storeShouldRemoveExpiredSessionFromLocalAndRemote(TestContext context) {
    Vertx vertx = rule.vertx();
    Async async = context.async();
    SessionStore sessionStore = NearCacheSessionStore.create(vertx);
    Session session = sessionStore.createSession(3000);
    sessionStore.put(session, context.asyncAssertSuccess());


    vertx.setTimer(5000, unused -> {
        sessionStore.get("XY", context.asyncAssertSuccess(u -> {
            doWithRemoteSession(context, session, context.asyncAssertSuccess(s ->
                context.assertNull(s, "Remote session should not be present")
            ));
            doWithLocalSession(context, session, context.asyncAssertSuccess(s ->
                context.assertNull(s, "Local session should not be present")
            ));
        }));
        async.complete();
    });
}
 
Example 4
Source File: NearCacheSessionStoreIT.java    From vertx-vaadin with MIT License 6 votes vote down vote up
@Test(timeout = 3000)
public void putShouldUpdateRemoteSession(TestContext context) {
    Vertx vertx = rule.vertx();

    TestObject testObject = new TestObject("TestObject");
    ExtendedSession session = createSession(vertx);
    String testObjKey = "testObjKey";
    session.put(testObjKey, testObject);

    SessionStore sessionStore = NearCacheSessionStore.create(vertx);
    sessionStore.put(session, context.asyncAssertSuccess(b -> {
        doWithRemoteSession(context, session, context.asyncAssertSuccess(s ->
            context.verify(unused -> assertSessionProperties(session, s))
        ));
        doWithLocalSession(context, session, context.asyncAssertSuccess(s ->
            context.verify(unused -> {
                assertSessionProperties(session, s);

            })
        ));
    }));
}
 
Example 5
Source File: NearCacheSessionStoreIT.java    From vertx-vaadin with MIT License 6 votes vote down vote up
@Test(timeout = 3000)
public void consecutiveGetAndPutShouldBeConsistent(TestContext context) {
    Vertx vertx = rule.vertx();

    TestObject testObject = new TestObject("TestObject");
    ExtendedSession session = createSession(vertx);
    String testObjKey = "testObjKey";
    session.put(testObjKey, testObject);

    SessionStore sessionStore = NearCacheSessionStore.create(vertx);
    sessionStore.put(session, context.asyncAssertSuccess(x -> {
        sessionStore.get(session.id(), context.asyncAssertSuccess(freshSession -> {
            sessionStore.put(freshSession, context.asyncAssertSuccess());
        }));
    }));


}
 
Example 6
Source File: NearCacheSessionStoreIT.java    From vertx-vaadin with MIT License 6 votes vote down vote up
@Test
public void storeShouldRemoveExpiredSessionFromLocalAndRemote(TestContext context) {
    Vertx vertx = rule.vertx();
    Async async = context.async();
    SessionStore sessionStore = NearCacheSessionStore.create(vertx);
    Session session = sessionStore.createSession(3000);
    sessionStore.put(session, context.asyncAssertSuccess());


    vertx.setTimer(5000, unused -> {
        sessionStore.get("XY", context.asyncAssertSuccess(u -> {
            doWithRemoteSession(context, session, context.asyncAssertSuccess(s ->
                context.assertNull(s, "Remote session should not be present")
            ));
            doWithLocalSession(context, session, context.asyncAssertSuccess(s ->
                context.assertNull(s, "Local session should not be present")
            ));
        }));
        async.complete();
    });
}