diff test/sematest/TestEditor.java @ 407:de4ef4313adc current-release

looks like working...
author one
date Tue, 25 Nov 2008 17:54:54 +0900
parents 8009dd7b2013
children 2724cf17e9f3
line wrap: on
line diff
--- a/test/sematest/TestEditor.java	Tue Nov 25 09:07:52 2008 +0900
+++ b/test/sematest/TestEditor.java	Tue Nov 25 17:54:54 2008 +0900
@@ -8,6 +8,7 @@
 import rep.REP;
 import rep.REPCommand;
 import rep.REPCommandPacker;
+import rep.SessionManager;
 import rep.channel.REPLogger;
 import rep.channel.REPSelectionKey;
 import rep.channel.REPSelector;
@@ -61,8 +62,8 @@
 			this.master=true;
 			text = new Text(txts);
 			cmds.add(new REPCommand(REP.SMCMD_PUT,0,0,0,0,name+"-file"));
-			//cmds.add(new REPCommand(REP.REPCMD_INSERT_USER,0,0,0,0,"m0"));
-			//cmds.add(new REPCommand(REP.REPCMD_DELETE_USER,0,0,0,0,"m0"));
+			cmds.add(new REPCommand(REP.REPCMD_INSERT_USER,0,0,0,0,"m0"));
+			cmds.add(new REPCommand(REP.REPCMD_DELETE_USER,0,0,0,0,"m0"));
 			//cmds.add(new REPCommand(REP.SMCMD_QUIT,0,0,0,0,""));
 		} else {
 			text = new Text(new String[0]);
@@ -150,6 +151,7 @@
 		 * all clients. SYNC is requested by the session manager.
 		 */
 		if (syncCounter>text.size()) {
+			SessionManager.logger.writeLog("Sync Completed.");
 			syncCounter=0;
 		} else {
 			int i=syncCounter-1;
@@ -227,7 +229,7 @@
 
 	private void handle(REPCommand cmd) {
 		if (cmd==null) return;
-		ns.writeLog(name +": read "+cmd);
+		ns.writeLog(name +": read "+cmd + " textsize="+text.size());
 		switch(cmd.cmd) {
 		case REPCMD_INSERT	:
 			if (cmd.eid!=eid) {
@@ -238,7 +240,7 @@
 		case REPCMD_DELETE	:
 			if (cmd.eid!=eid) {
 				String del=""; 
-				if(cmd.lineno>text.size()) {
+				if(cmd.lineno<text.size()) {
 					del = text.delete(cmd.lineno);
 				}
 				cmd.setString(del);