changeset 0:d86770305c8b draft

add TestJava
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Fri, 11 May 2012 02:30:59 +0900
parents
children 830afc6475b0
files .classpath .cvsignore .project .tomcatplugin lib/javassist.jar lib/log4j-1.2.16.jar lib/msgpack-0.6.7-SNAPSHOT-sources.jar lib/msgpack-0.6.7-SNAPSHOT.jar lib/msgpack-rpc-0.7.0-SNAPSHOT.jar lib/netty-3.2.1.Final.jar lib/slf4j-api-1.6.1.jar lib/slf4j-log4j12-1.6.1.jar src/Test/SystemTest.java src/msgpack/test/ForkTestMsgPack.java src/msgpack/test/TestMsgPackClient.java src/msgpack/test/TestMsgPackServer.java
diffstat 16 files changed, 265 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.classpath	Fri May 11 02:30:59 2012 +0900
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="var" path="TOMCAT_HOME/lib/servlet-api.jar"/>
+	<classpathentry kind="var" path="TOMCAT_HOME/lib/jasper.jar"/>
+	<classpathentry kind="var" path="TOMCAT_HOME/lib/jsp-api.jar"/>
+	<classpathentry kind="var" path="TOMCAT_HOME/lib/el-api.jar"/>
+	<classpathentry kind="var" path="TOMCAT_HOME/lib/annotations-api.jar"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="lib" path="lib/msgpack-rpc-0.7.0-SNAPSHOT.jar"/>
+	<classpathentry kind="lib" path="lib/msgpack-0.6.7-SNAPSHOT.jar"/>
+	<classpathentry kind="lib" path="lib/javassist.jar"/>
+	<classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
+	<classpathentry kind="lib" path="lib/slf4j-api-1.6.1.jar"/>
+	<classpathentry kind="lib" path="lib/slf4j-log4j12-1.6.1.jar"/>
+	<classpathentry kind="lib" path="lib/netty-3.2.1.Final.jar"/>
+	<classpathentry kind="output" path="bin/classes"/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.cvsignore	Fri May 11 02:30:59 2012 +0900
@@ -0,0 +1,1 @@
+work
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.project	Fri May 11 02:30:59 2012 +0900
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>Test</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>com.sysdeo.eclipse.tomcat.tomcatnature</nature>
+	</natures>
+</projectDescription>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.tomcatplugin	Fri May 11 02:30:59 2012 +0900
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tomcatProjectProperties>
+    <rootDir>/</rootDir>
+    <exportSource>false</exportSource>
+    <reloadable>true</reloadable>
+    <redirectLogger>false</redirectLogger>
+    <updateXml>true</updateXml>
+    <warLocation></warLocation>
+    <extraInfo></extraInfo>
+    <webPath>/Test</webPath>
+</tomcatProjectProperties>
Binary file lib/javassist.jar has changed
Binary file lib/log4j-1.2.16.jar has changed
Binary file lib/msgpack-0.6.7-SNAPSHOT-sources.jar has changed
Binary file lib/msgpack-0.6.7-SNAPSHOT.jar has changed
Binary file lib/msgpack-rpc-0.7.0-SNAPSHOT.jar has changed
Binary file lib/netty-3.2.1.Final.jar has changed
Binary file lib/slf4j-api-1.6.1.jar has changed
Binary file lib/slf4j-log4j12-1.6.1.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Test/SystemTest.java	Fri May 11 02:30:59 2012 +0900
@@ -0,0 +1,96 @@
+package Test;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+public class SystemTest {
+	
+	private static InputStream in = null;
+	private static InputStream ein = null;
+	static BufferedReader ebr = null;
+	static BufferedReader br = null;
+	
+	public static void main(String[] argv) {
+		
+		String[] cmd = {"/usr/local/bin/konoha","/Users/aotokage/testProgram/konoha/math.k"};
+		Runtime run = Runtime.getRuntime();
+		try {
+			Process p = run.exec(cmd);
+			in = p.getInputStream();
+			ein = p.getErrorStream();
+			
+			
+			Runnable inputStreamThread = new Runnable() {
+				public void run() {
+					String line;
+					try {
+						System.out.println("Thread stdRun start");
+						br = new BufferedReader(new InputStreamReader(in));
+						while ((line = br.readLine()) != null) {
+							System.out.println(line);
+						}
+						System.out.println("Thread stdRun end");
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+				}
+			
+			};
+			
+			Runnable errStreamThread = new Runnable() {
+				public void run() {
+					try {
+						System.out.println("Thread errRun start");
+						ebr = new BufferedReader(new InputStreamReader(ein));
+						String errLine;
+						while((errLine = ebr.readLine()) != null) {
+							System.out.println(errLine);
+						}
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+				}
+				
+			};
+
+			Thread stdRun = new Thread(inputStreamThread);
+			Thread errRun = new Thread(errStreamThread);
+			stdRun.start();
+			errRun.start();
+			
+			int c = p.waitFor();
+			
+			stdRun.join();
+			errRun.join();
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				in.close();
+				ein.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	
+	}
+	
+	public static void printInputStream(InputStream in) throws IOException {
+		BufferedReader br = new BufferedReader(new InputStreamReader(in));
+		try {
+			for (;;) {
+				String line = br.readLine();
+				if (line == null) break;
+				System.out.println(line);
+			}
+			
+		} finally {
+			br.close();
+		}
+	
+	}
+	
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/msgpack/test/ForkTestMsgPack.java	Fri May 11 02:30:59 2012 +0900
@@ -0,0 +1,81 @@
+package msgpack.test;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+public class ForkTestMsgPack {
+
+	private static InputStream in = null;
+	private static InputStream ein = null;
+	static BufferedReader ebr = null;
+	static BufferedReader br = null;
+
+	public static void main(String[] args) {
+		String[] cmd = { "/usr/bin/java","Hello"};
+		Runtime run = Runtime.getRuntime();
+		try {
+			Process p = run.exec(cmd);
+			in = p.getInputStream();
+			ein = p.getErrorStream();
+
+			Runnable inputStreamThread = new Runnable() {
+				public void run() {
+					String line;
+					try {
+						System.out.println("Thread stdRun start");
+						br = new BufferedReader(new InputStreamReader(in));
+						while ((line = br.readLine()) != null) {
+							System.out.println(line);
+						}
+						System.out.println("Thread stdRun end");
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+				}
+
+			};
+
+			Runnable errStreamThread = new Runnable() {
+				public void run() {
+					try {
+						System.out.println("Thread errRun start");
+						ebr = new BufferedReader(new InputStreamReader(ein));
+						String errLine;
+						while ((errLine = ebr.readLine()) != null) {
+							System.out.println(errLine);
+						}
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+				}
+
+			};
+
+			Thread stdRun = new Thread(inputStreamThread);
+			Thread errRun = new Thread(errStreamThread);
+			stdRun.start();
+			errRun.start();
+
+			int c = p.waitFor();
+
+			stdRun.join();
+			errRun.join();
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				in.close();
+				ein.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/msgpack/test/TestMsgPackClient.java	Fri May 11 02:30:59 2012 +0900
@@ -0,0 +1,20 @@
+package msgpack.test;
+
+import org.msgpack.rpc.Client;
+import org.msgpack.rpc.loop.EventLoop;
+ 
+public class TestMsgPackClient {
+    public static interface RPCInterface {
+        String hello(String msg, int a);
+    }
+ 
+    public static void main(String[] args) throws Exception {
+        EventLoop loop = EventLoop.defaultEventLoop();
+        
+        Client cli = new Client("localhost", 8888, loop);
+        RPCInterface iface = cli.proxy(RPCInterface.class);
+ 
+        String msg = iface.hello("hello", 1);
+        System.out.println(msg);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/msgpack/test/TestMsgPackServer.java	Fri May 11 02:30:59 2012 +0900
@@ -0,0 +1,20 @@
+package msgpack.test;
+
+import org.msgpack.rpc.Server;
+import org.msgpack.rpc.loop.EventLoop;
+ 
+public class TestMsgPackServer {
+    public String hello(String msg, int a) {
+        return msg;
+    }
+ 
+    public static void main(String[] args) throws Exception {
+        EventLoop loop = EventLoop.defaultEventLoop();
+ 
+        Server svr = new Server();
+        svr.serve(new TestMsgPackServer());
+        svr.listen(8888);
+ 
+        loop.join();
+    }
+}
\ No newline at end of file