Package com.pugh.sockso.web

Source Code of com.pugh.sockso.web.SessionCleanerTest

package com.pugh.sockso.web;

import com.pugh.sockso.tests.SocksoTestCase;
import com.pugh.sockso.tests.TestDatabase;

public class SessionCleanerTest extends SocksoTestCase {

    public void testConstructor() {
        assertNotNull( new SessionCleaner(null) );
    }

    public void testCleanSessionsTable() throws Exception {

        final TestDatabase db = new TestDatabase();
        final SessionCleaner c = new SessionCleaner( db );
        final String code = "abcdefghij";
       
        db.update(
            " insert into sessions ( id, code, user_id, date_created ) " +
            " values ( 1, '" +code+ "', 1, 0 ) "
        );
        assertRowExists( db, "sessions", "code", code );
       
        c.cleanSessionsTable();
       
        assertRowDoesntExist( db, "sessions", "code", code );

    }

    public void testCurrentSessionNotDeletedOnClean() throws Exception {

        final TestDatabase db = new TestDatabase();
        final SessionCleaner c = new SessionCleaner( db );
        final String code = "abcdefghij";

        db.update(
            " insert into sessions ( id, code, user_id, date_created ) " +
            " values ( 1, '" +code+ "', 1, current_timestamp ) "
        );
        assertRowExists( db, "sessions", "code", code );

        c.cleanSessionsTable();

        assertRowExists( db, "sessions", "code", code );

    }

}
TOP

Related Classes of com.pugh.sockso.web.SessionCleanerTest

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.