Changeset 3448

Show
Ignore:
Timestamp:
02/25/10 17:22:18 (5 months ago)
Author:
mgray
Message:

Implementation of ScriptLoginTest? for testing scriptable login services provided by the Session Services in Community.

Location:
tests/trunk/ScriptLoginTest
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • tests/trunk/ScriptLoginTest

    • Property svn:ignore
      •  

        old new  
        11CMakeLists.txt 
         2Community.sqlite 
        23config.xml 
        34loginTest.bat 
  • tests/trunk/ScriptLoginTest/LoginTest.cpp

    r3333 r3448  
    8181    if (m_pScriptObject == NULL) 
    8282    { 
    83         // Register the script engine.  This cannot be done earlier 
    84         m_pEventService->registerScriptEngine(m_pModule->getScriptModule()->getScriptEngine()); 
    85  
    8683        m_pScriptObject = new ScriptWrapper_type(m_pModule->getScriptModule(), 
    8784            m_pModule->getScriptModule()->getScriptType(getScriptTypeName()), 
  • tests/trunk/ScriptLoginTest/config.xml.example

    r3315 r3448  
    33<application 
    44   id="ConsoleTest" 
    5    name="IndieZen Script Test Application" 
    6    version="0.1.0" 
     5   name="IndieZen Script Login Test Application" 
     6   version="0.6.0" 
    77   provider-name="IndieZen.org"> 
    88 
    99  <plugin-path path="C:/dev/Zen/plugins"/> 
     10  <plugin-path path="C:/dev/Zen/Community" /> 
    1011  <module-path path="C:/dev/bin"/> 
    1112 
    12 ` <requires> 
    13     <import plugin="ZPython"/> 
    14         <import plugin="ZLua"/> 
    15   </requires> 
     13    <requires> 
     14        <import plugin="ZLua" /> 
     15        <import plugin="ZSQLite" /> 
     16        <import plugin="ZBoostNetworking" /> 
     17        <import plugin="SessionClient" /> 
     18        <import plugin="SessionServer" /> 
     19    </requires> 
     20 
     21    <databases> 
     22        <database type="sqlite" name="sessionConnection"> 
     23            <fileName value="Community.sqlite" /> 
     24        </database> 
     25    </databases> 
     26     
     27    <applications> 
     28        <application type="SessionClient" location="/loginClient" /> 
     29        <application type="SessionServer" location="/loginServer" > 
     30            <database connection="sessionConnection" /> 
     31        </application> 
     32    </applications> 
     33 
     34    <protocols> 
     35        <protocol type="tcp-binary" address="localhost" port="10000" threads="2" name="sessionServer" /> 
     36        <protocol type="tcp-binary" name="sessionClient" threads="2" /> 
     37    </protocols> 
    1638 
    1739</application> 
  • tests/trunk/ScriptLoginTest/loginTest.lua

    r3333 r3448  
    11 
    2 -- Create the script event queue 
    3 local eventQueue = eventService:getEventQueue("script"); 
     2print("starting loginTest"); 
    43 
    5 local sessionEvent = sessionClient:getSessionEvent(); 
     4function runLoginTest() 
     5    -- Create the script event queue 
     6    print("Getting event queue"); 
     7    local eventQueue = eventService:getEventQueue("script"); 
    68 
    7 SessionEventHandler = {} 
     9    print("Getting session event"); 
     10    local sessionEvent = sessionClient:getSessionEvent(); 
    811 
    9 function SessionEventHandler:onSessionChanged(session) 
    10         -- Handle session change events. 
     12    SessionEventHandler = {} 
     13 
     14    SessionStates =  
     15    {  
     16        INITIALIZED = 0,  
     17        CONNECTED = 1, 
     18        NOT_AUTHORIZED = 2, 
     19        DISCONNECTED = 3, 
     20    } 
     21     
     22    SessionStates[SessionStates.INITIALIZED] = "Initialized"; 
     23    SessionStates[SessionStates.CONNECTED] = "Connected"; 
     24    SessionStates[SessionStates.NOT_AUTHORIZED] = "Not Authorized"; 
     25    SessionStates[SessionStates.DISCONNECTED] = "Disconnected"; 
     26 
     27 
     28    function SessionEventHandler:onSessionChanged(session) 
     29        -- Handle session change events. 
     30        print("Session state: " .. SessionStates[session:getSessionState()]); 
     31    end 
     32     
     33    -- Connect 
     34    SessionEventHandler.connection = sessionEvent:connect(SessionEventHandler, SessionEventHandler.onSessionChanged); 
     35 
     36    sessionClient:requestLogin("localhost", "10000", "test user", "test password"); 
     37 
     38    -- TODO Eventually we are going to have to call loginTest:quit() 
     39    -- Possibly use the one second tick that's in LoginTest and after a period of time, exit. 
     40 
     41    --errorHere:notAnObject(); 
     42     
     43    -- Run.  This will continue running and processing events until  
     44    -- loginTest:quit() is called. 
     45    loginTest:run(); 
     46     
    1147end 
    1248 
    13 -- Connect 
    14 SessionEventHandler.connection = sessionEvent:connect(SessionEventHandler, SessionEventHandler.onSessionChanged); 
    1549 
    16 sessionClient:requestLogin("localhost", "10000", "sgtflame", "test"); 
     50print("calling runLoginTest"); 
    1751 
    18 -- TODO Eventually we are going to have to call loginTest:quit() 
    19 -- Possibly use the one second tick that's in LoginTest and after a period of time, exit. 
    2052 
    21 -- Run.  This will continue running and processing events until  
    22 -- loginTest:quit() is called. 
    23 loginTest:run(); 
     53runLoginTest(); 
  • tests/trunk/ScriptLoginTest/main.cpp

    r3368 r3448  
     1#include <Zen/Core/Event/I_EventManager.hpp> 
     2#include <Zen/Core/Event/I_EventService.hpp> 
     3 
    14#include <Zen/Enterprise/AppServer/I_Container.hpp> 
    25#include <Zen/Enterprise/AppServer/I_ApplicationServer.hpp> 
     
    58 
    69#include "LoginTest.hpp" 
     10 
     11#include <iostream> 
    712 
    813int main(int _argc, const char* _argv[]) 
     
    2328    module.activate(); 
    2429 
     30    Zen::Event::I_EventManager::pEventService_type pEventService =  
     31        Zen::Event::I_EventManager::getSingleton().create("eventService"); 
     32 
     33    pEventService->registerScriptEngine(module.getScriptModule()->getScriptEngine()); 
     34 
    2535    // Run the container.  This should invoke the script and when the script 
    2636    // returns, we should shutdown the app server and exit. 
    27     int rc = container.run(); 
     37    try 
     38    { 
     39        int rc = container.run(); 
    2840 
    29     // TODO Shutdown the app server. 
     41        // TODO Shutdown the app server. 
    3042 
    31     return rc; 
     43        return rc; 
     44    } 
     45    catch(Zen::Utility::runtime_exception& _ex) 
     46    { 
     47        std::cout << "Caught unhandled exception: " << _ex.what() << std::endl; 
     48    } 
     49 
     50    return 1; 
    3251}