Mercurial > hg > RemoteEditor > Eclipse
comparison src/pathfinder/mergetest/TestMerger.java @ 125:34b15dfcb83e
UsersSimulator
author | kent |
---|---|
date | Tue, 25 Dec 2007 20:07:37 +0900 |
parents | f18510fc40e2 |
children | b56b5950cb18 |
comparison
equal
deleted
inserted
replaced
124:f18510fc40e2 | 125:34b15dfcb83e |
---|---|
7 public class TestMerger { | 7 public class TestMerger { |
8 static public int cmdNO[] = { REP.REPCMD_INSERT, REP.REPCMD_REPLACE, REP.REPCMD_DELETE }; | 8 static public int cmdNO[] = { REP.REPCMD_INSERT, REP.REPCMD_REPLACE, REP.REPCMD_DELETE }; |
9 private NetworkSimulator<REPCommand> ns=null; | 9 private NetworkSimulator<REPCommand> ns=null; |
10 private LinkedList<EditorSimulator> editors; | 10 private LinkedList<EditorSimulator> editors; |
11 private SeMaSimulator<REPCommand> sema; | 11 private SeMaSimulator<REPCommand> sema; |
12 private UsersSimulator users; | |
12 | 13 |
13 public TestMerger(){ | 14 public TestMerger(){ |
14 editors = new LinkedList<EditorSimulator>(); | 15 editors = new LinkedList<EditorSimulator>(); |
15 } | 16 } |
16 | 17 |
23 int j = (args.length>1) ? Integer.parseInt(args[1]) : 3; | 24 int j = (args.length>1) ? Integer.parseInt(args[1]) : 3; |
24 System.out.println("number of Packet = "+j); | 25 System.out.println("number of Packet = "+j); |
25 | 26 |
26 /* create, initialize and start test. */ | 27 /* create, initialize and start test. */ |
27 tm = new TestMerger(); | 28 tm = new TestMerger(); |
28 tm.init(false, i, j); | 29 tm.init(true, i, j); |
29 tm.startTest(); | 30 tm.startTest(); |
30 | 31 |
31 tm.printAllTexts(); | 32 //tm.printAllTexts(); |
32 //if (!tm.checkCS()) | 33 //if (!tm.checkCS()) |
33 // System.out.println("Error!! :some ChannelSimulator still have packet!"); | 34 // System.out.println("Error!! :some ChannelSimulator still have packet!"); |
34 if (!tm.checkEquality()) | 35 if (!tm.checkEquality()) |
35 System.out.println("Error!! :all Editor's text is NOT mutch!"); | 36 System.out.println("Error!! :all Editor's text is NOT mutch!"); |
36 assert tm.checkEquality(); | 37 assert tm.checkEquality(); |
40 /* start all Editors. */ | 41 /* start all Editors. */ |
41 for (EditorSimulator ee: editors){ | 42 for (EditorSimulator ee: editors){ |
42 ee.start(); | 43 ee.start(); |
43 } | 44 } |
44 /* start SessionManager if it exist. */ | 45 /* start SessionManager if it exist. */ |
46 if (sema!=null) sema.init(); | |
45 if (sema!=null) sema.start(); | 47 if (sema!=null) sema.start(); |
48 users.init(); | |
49 users.start(); | |
46 | 50 |
47 /* wait Editors finish. */ | 51 /* wait Editors finish. */ |
48 for (EditorSimulator ee: editors){ | 52 for (EditorSimulator ee: editors){ |
49 try { | 53 try { |
50 ee.join(); | 54 ee.join(); |
64 } else { | 68 } else { |
65 ns = new NetworkSimulatorwithoutSeMa<REPCommand>(); | 69 ns = new NetworkSimulatorwithoutSeMa<REPCommand>(); |
66 sema = null; | 70 sema = null; |
67 } | 71 } |
68 | 72 |
73 /* create UsersSimulator. */ | |
74 users = new UsersSimulator(ns, ne, np*ne); | |
75 | |
69 /* create ne Editors and np commands. */ | 76 /* create ne Editors and np commands. */ |
70 for (int i=0; i<ne; i++){ | 77 for (int i=0; i<ne; i++){ |
71 LinkedList<REPCommand> cmds = new LinkedList<REPCommand>(); | 78 LinkedList<REPCommand> cmds = new LinkedList<REPCommand>(); |
72 // 各エディタが送信するコマンド列を生成 | 79 // 各エディタが送信するコマンド列を生成 |
73 | 80 |
74 /* create command list. */ | 81 /* create command list. */ |
82 /* | |
75 for (int j=0; j<np; j++){ | 83 for (int j=0; j<np; j++){ |
76 String str = "created by Editor"+i+":"+j; | 84 String str = "created by Editor"+i+":"+j; |
77 REPCommand cmd = new REPCommand(REP.REPCMD_INSERT, | 85 REPCommand cmd = new REPCommand(REP.REPCMD_INSERT, |
78 0, i, j, | 86 0, i, j, |
79 10, //Verify.random(text.size()-1), //size-1? | 87 10, //Verify.random(text.size()-1), //size-1? |
80 str.length(), str); | 88 str.length(), str); |
81 cmds.add( cmd); | 89 cmds.add( cmd); |
82 } | 90 } |
91 */ | |
83 | 92 |
84 /* create a Editor, and pass command list to it. */ | 93 /* create a Editor, and pass command list to it. */ |
85 EditorSimulator ee = new EditorSimulator(i, ns, cmds, "Editor"+i); | 94 EditorSimulator ee = new EditorSimulator(i, ns, cmds, "Editor"+i); |
86 if(i==0) ee.setOwner(true); | 95 if(i==0) ee.setOwner(true); |
87 editors.add(ee); | 96 editors.add(ee); |