Mercurial > hg > RemoteEditor > Eclipse
diff src/pathfinder/mergetest/TestMerger2.java @ 153:6326e5ea4595
*** empty log message ***
author | pin |
---|---|
date | Sat, 23 Aug 2008 11:28:16 +0900 |
parents | 5942e0e3c632 |
children | 6a3c982bd72a |
line wrap: on
line diff
--- a/src/pathfinder/mergetest/TestMerger2.java Fri Aug 22 15:48:52 2008 +0900 +++ b/src/pathfinder/mergetest/TestMerger2.java Sat Aug 23 11:28:16 2008 +0900 @@ -9,7 +9,15 @@ protected NetworkSimulator<REPCommand> ns=null; protected LinkedList<EditorSimulatorWithoutMerger> editors; protected SessionManagerSimulatorWithMerger<REPCommand> sema; - protected UsersSimulator users; + protected LinkedList<UsersSimulator> users = new LinkedList<UsersSimulator>(); + + static private String[] text0 = { + "aaa", "bbb", "ccc", "ddd", "eee", + "fff", "ggg", "hhh", "iii", "jjj", + "kkk", "lll", "mmm", "nnn", "ooo", + "ppp", "qqq", "rrr", "sss", "ttt", + "uuu", "vvv", "www", "xxx", "yyy", "zzz" + }; public TestMerger2(){ editors = new LinkedList<EditorSimulatorWithoutMerger>(); @@ -46,8 +54,16 @@ /* start SessionManager if it exist. */ if (sema!=null) sema.init(); if (sema!=null) sema.start(); - users.init(); - users.start(); + + for(UsersSimulator u: users){ + u.start(); + } + for(UsersSimulator u: users){ + try { + u.join(); + } catch (InterruptedException e) { } + } + /* wait Editors finish. */ for (EditorSimulatorWithoutMerger ee: editors){ @@ -58,9 +74,26 @@ } } /* inform SessionManager to finish. */ - if (sema!=null) sema.finish(); + if (sema!=null) { + sema.finish(); + try { + sema.join(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } + LinkedList<REPCommand> userCommand(int eid){ + LinkedList<REPCommand> cmds = new LinkedList<REPCommand>(); + cmds .add(new REPCommand(REP.REPCMD_REPLACE, 0, eid, 1, 0, 0, "replaced by editor:" + eid + ":1")); + cmds .add(new REPCommand(REP.REPCMD_REPLACE, 0, eid, 2, 0, 0, "replaced by editor:" + eid + ":2")); + cmds .add(new REPCommand(REP.REPCMD_REPLACE, 0, eid, 3, 0, 0, "replaced by editor:" + eid + ":3")); + if(eid == 0) cmds .add(new REPCommand(REP.SMCMD_QUIT, 0, eid, 4, 0, 0, "replaced by editor:" + eid + ":4")); + return cmds; + } + protected void init(boolean sm, int ne, int np, int ll){ /* create NetworkSimulator, and SessionManager if it's required. */ if (sm){ @@ -73,11 +106,14 @@ ns.setLogLevel(ll); /* create UsersSimulator. */ - users = new UsersSimulator(ns, ne, np*ne); + for(int i = 0; i < ne; i++){ + ChannelSimulator<REPCommand> channel = ns.getAcceptedSession(i); + users.add(new UsersSimulator(channel, userCommand(i))); + } /* create ne Editors and np commands. */ for (int i=0; i<ne; i++){ - LinkedList<REPCommand> cmds = new LinkedList<REPCommand>(); + //LinkedList<REPCommand> cmds = new LinkedList<REPCommand>(); // 各エディタが送信するコマンド列を生成 /* create command list. */ @@ -93,7 +129,7 @@ */ /* create a Editor, and pass command list to it. */ - EditorSimulatorWithoutMerger ee = new EditorSimulatorWithoutMerger(i, ns, cmds, "Editor"+i); + EditorSimulatorWithoutMerger ee = new EditorSimulatorWithoutMerger(i, ns, i==0?text0:null, "Editor"+i); if(i==0) ee.setOwner(true); editors.add(ee); }