# HG changeset patch # User Nobuyasu Oshiro # Date 1336671059 -32400 # Node ID d86770305c8bbac73337fa1b2708d9a22428f555 add TestJava diff -r 000000000000 -r d86770305c8b .classpath --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.classpath Fri May 11 02:30:59 2012 +0900 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r d86770305c8b .cvsignore --- /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 diff -r 000000000000 -r d86770305c8b .project --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.project Fri May 11 02:30:59 2012 +0900 @@ -0,0 +1,18 @@ + + + Test + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + com.sysdeo.eclipse.tomcat.tomcatnature + + diff -r 000000000000 -r d86770305c8b .tomcatplugin --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.tomcatplugin Fri May 11 02:30:59 2012 +0900 @@ -0,0 +1,11 @@ + + + / + false + true + false + true + + + /Test + diff -r 000000000000 -r d86770305c8b lib/javassist.jar Binary file lib/javassist.jar has changed diff -r 000000000000 -r d86770305c8b lib/log4j-1.2.16.jar Binary file lib/log4j-1.2.16.jar has changed diff -r 000000000000 -r d86770305c8b lib/msgpack-0.6.7-SNAPSHOT-sources.jar Binary file lib/msgpack-0.6.7-SNAPSHOT-sources.jar has changed diff -r 000000000000 -r d86770305c8b lib/msgpack-0.6.7-SNAPSHOT.jar Binary file lib/msgpack-0.6.7-SNAPSHOT.jar has changed diff -r 000000000000 -r d86770305c8b lib/msgpack-rpc-0.7.0-SNAPSHOT.jar Binary file lib/msgpack-rpc-0.7.0-SNAPSHOT.jar has changed diff -r 000000000000 -r d86770305c8b lib/netty-3.2.1.Final.jar Binary file lib/netty-3.2.1.Final.jar has changed diff -r 000000000000 -r d86770305c8b lib/slf4j-api-1.6.1.jar Binary file lib/slf4j-api-1.6.1.jar has changed diff -r 000000000000 -r d86770305c8b lib/slf4j-log4j12-1.6.1.jar Binary file lib/slf4j-log4j12-1.6.1.jar has changed diff -r 000000000000 -r d86770305c8b src/Test/SystemTest.java --- /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(); + } + + } + + +} diff -r 000000000000 -r d86770305c8b src/msgpack/test/ForkTestMsgPack.java --- /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(); + } + } + + } + +} diff -r 000000000000 -r d86770305c8b src/msgpack/test/TestMsgPackClient.java --- /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 diff -r 000000000000 -r d86770305c8b src/msgpack/test/TestMsgPackServer.java --- /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