Mercurial > hg > RemoteEditor > REPSessionManager
view test/sematest/TestSessionManager.java @ 286:30c993e89286
TestEditor
author | kono |
---|---|
date | Sun, 28 Sep 2008 15:41:42 +0900 |
parents | c410eda661e8 |
children | d59f4e9e7ad1 |
line wrap: on
line source
package test.sematest; import java.io.IOException; import java.util.LinkedList; import rep.REP; import rep.REPCommand; 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(); protected boolean isStart = false; public TestSessionManager(int sm, int ss, int e) { } private void startTest() { int masterPort = 8766; String[] strs ={String.valueOf(masterPort), String.valueOf(masterPort)}; startSessionManager(strs); while(!isStart){ try { Thread.sleep(5); } catch (InterruptedException e) { e.printStackTrace(); } } logger.writeLog("TestSessionManager.startTest()", 1); //test1(); test2(); } public void test1() { putTest(); joinTest(); } public void test2() { editor(true); editor(false); } private void editor(boolean master) { TestEditor e = new TestEditor("Editor", "localhost", 8766, master); e.start(); } private void joinTest() { REPCommand command = new REPCommand(); command.setCMD(REP.SMCMD_JOIN); command.setString("JoinTest"); LinkedList<REPCommand> commands = new LinkedList<REPCommand>(); commands.add(command); Tester tester = new Tester("JoinTester", "localhost", 8766); tester.setCommands(commands); tester.start(); } private void putTest() { REPCommand command = new REPCommand(); command.setCMD(REP.SMCMD_PUT); command.setString("PutTest.txt"); LinkedList<REPCommand> commands = new LinkedList<REPCommand>(); commands.add(command); Tester tester = new Tester("PutTester", "localhost", 8766); tester.setCommands(commands); tester.start(); } private void startSessionManager(final String[] strs) { new Thread(new Runnable(){ public void run(){ try { int port = 8766; if(strs.length > 0){ port = Integer.parseInt(strs[0]); } SessionManager sm = new SessionManager(); SessionManagerGUI gui = new testGUI(sm); logger.writeLog("TestSessionManager.startSessionManager() : start SessionManager"); sm.syncExec(new SessionManagerEvent() { // executed before first select(); public void exec() { isStart = true; } }); sm.init(port,gui); } catch (InterruptedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }).start(); } public static void main(String[] args){ REPServerSocketChannel.isSimulation = true; TestSessionManager test = new TestSessionManager(1, 0, 2); logger.setLogLevel(5); test.startTest(); } }