Mercurial > hg > RemoteEditor > REPSessionManager
view test/sematest/TestSessionManager.java @ 291:9e162e0a114f
*** empty log message ***
author | kono |
---|---|
date | Mon, 29 Sep 2008 06:34:13 +0900 |
parents | 4b773ba03556 |
children | 975383c0548e |
line wrap: on
line source
package test.sematest; import java.io.IOException; import rep.SessionManager; import rep.SessionManagerEvent; import rep.SessionManagerGUI; import rep.channel.REPLogger; import rep.channel.REPServerSocketChannel; public class TestSessionManager { static public REPLogger logger = REPLogger.singleton(); final int masterPort = 8766; String host = "localhost"; SessionManager sessionManagers[]; SessionManager slaveSessionManagers[]; TestEditor editors[]; SessionManagerEvent ev1[] = { new SessionManagerEvent() { // executed before first select(); public void exec() { for(TestEditor editor:editors) { editor.start(); } } }}; int editorPort[] = {masterPort,masterPort}; boolean editorMaster[] = {true,false}; public TestSessionManager(int sm, int ss, int e) { sessionManagers = new SessionManager[sm]; slaveSessionManagers = new SessionManager[ss]; editors = new TestEditor[e]; for(int i=0;i<sm;i++) { sessionManagers[i] = new SessionManager(); } for(int i=0;i<ss;i++) { slaveSessionManagers[i] = new SessionManager(); } for(int i=0;i<e;i++) { int port = editorPort[i%editorPort.length]; boolean master = editorMaster[i%editorMaster.length]; editors[i] = new TestEditor("Editor"+i,host,port,master); } } private int startSessionManager(final SessionManager sm,int i,int port) { final SessionManagerGUI gui = new TestGUI(sm); final int port1 = port; logger.writeLog("TestSessionManager.startSessionManager() : start SessionManager"); if (i<ev1.length) sm.syncExec(ev1[i]); Runnable start = new Runnable() { public void run() { try { sm.init(port1,gui); } catch (IOException e) { } catch (InterruptedException e) { } } }; new Thread(start).run(); return i+1; } public static void main(String[] args){ REPServerSocketChannel.isSimulation = true; TestSessionManager test = new TestSessionManager(1, 0, 2); logger.setLogLevel(5); test.startTest(); } private void startTest() { int i = 0; for(SessionManager master:sessionManagers) { i = startSessionManager(master,i, masterPort + i); } for(SessionManager slave:slaveSessionManagers) { i = startSessionManager(slave,i,masterPort + i); } } }