changeset 193:311847db7429

*** empty log message ***
author pin
date Fri, 29 Aug 2008 20:02:23 +0900
parents 6fb97c7a0b42
children be219ba8b39c
files test/sematest/TestEditor.java test/sematest/TestSessionManager.java
diffstat 2 files changed, 52 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sematest/TestEditor.java	Fri Aug 29 20:02:23 2008 +0900
@@ -0,0 +1,48 @@
+package test.sematest;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+
+import rep.REP;
+import rep.REPCommand;
+import rep.REPCommandPacker;
+import rep.channel.REPLogger;
+import rep.channel.REPSocketChannel;
+
+
+public class TestEditor extends Thread{
+	private SocketAddress semaIP;
+	private REPLogger ns;
+	
+	public TestEditor(String name, String _host,int _port){
+		super(name);
+		semaIP = new InetSocketAddress(_host, _port);
+		ns = REPLogger.singleton();
+	}
+
+	public void run(){
+		try {
+			REPSocketChannel<REPCommand> channel;
+			channel = REPSocketChannel.<REPCommand>create(new REPCommandPacker());
+
+			ns.writeLog("try to connect to SessionManager whose ip is "+semaIP, 1);
+			while (!channel.connect(semaIP)){
+				ns.writeLog("SeMa not listen to socket yet, wait", 1);
+				Thread.yield();
+			}
+			ns.writeLog("successes to connect", 1);
+
+			REPCommand command = new REPCommand(REP.SMCMD_JOIN,0,0,0,0,0,getName() + ": send hello");
+			channel.write(command);
+			ns.writeLog("wrote packet", 1);
+
+			REPCommand packet = channel.read();
+
+			ns.writeLog("gets return string==> `"+packet+"\'", 1);
+
+			ns.writeLog("testEditor exits.", 1);
+		} catch (IOException e) {
+		}
+	}
+}
--- a/test/sematest/TestSessionManager.java	Fri Aug 29 19:50:15 2008 +0900
+++ b/test/sematest/TestSessionManager.java	Fri Aug 29 20:02:23 2008 +0900
@@ -2,21 +2,19 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.List;
-
 import rep.SessionManager;
 import rep.channel.REPLogger;
 import rep.channel.REPServerSocketChannel;
-import test.channeltest.testEditor;
+
 
 public class TestSessionManager {
 	
-	private ArrayList<testEditor> editorList;
+	private ArrayList<TestEditor> editorList;
 	private int numberEditor;
 	static public REPLogger logger = REPLogger.singleton();
 
 	public TestSessionManager(int sm, int ss, int e) {
-		editorList = new ArrayList<testEditor>();
+		editorList = new ArrayList<TestEditor>();
 		numberEditor = e;
 	}
 
@@ -36,7 +34,7 @@
 		
 		for (int i=0; i<numberEditor; i++){
 			logger.writeLog("create Editors", 1);
-			testEditor te = new testEditor("Editor"+i,host, masterPort); 
+			TestEditor te = new TestEditor("Editor"+i,host, masterPort); 
 			editorList.add(te);
 			te.start();
 		}