# HG changeset patch # User one # Date 1337622356 -32400 # Node ID 830afc6475b04aac839da2d6d7040f3be0c75e04 # Parent d86770305c8bbac73337fa1b2708d9a22428f555 add sime files diff -r d86770305c8b -r 830afc6475b0 src/Test/SystemTest.java --- a/src/Test/SystemTest.java Fri May 11 02:30:59 2012 +0900 +++ b/src/Test/SystemTest.java Tue May 22 02:45:56 2012 +0900 @@ -14,7 +14,7 @@ public static void main(String[] argv) { - String[] cmd = {"/usr/local/bin/konoha","/Users/aotokage/testProgram/konoha/math.k"}; + String[] cmd = {"/usr/local/bin/konoha","/Users/aotokage/hg/nobuyasu/konoha/http/postRequest.k"}; Runtime run = Runtime.getRuntime(); try { Process p = run.exec(cmd); diff -r d86770305c8b -r 830afc6475b0 src/msgpack/test/ForkTestMsgPack.java --- a/src/msgpack/test/ForkTestMsgPack.java Fri May 11 02:30:59 2012 +0900 +++ b/src/msgpack/test/ForkTestMsgPack.java Tue May 22 02:45:56 2012 +0900 @@ -7,29 +7,31 @@ 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); + static class CheckStd implements Runnable { + Process p; + InputStream in, ein; + BufferedReader br, ebr; + String name; + CheckStd(Process _p, String str) { + p = _p; in = p.getInputStream(); ein = p.getErrorStream(); + name = str; + } + + @Override + public void run() { Runnable inputStreamThread = new Runnable() { public void run() { String line; try { - System.out.println("Thread stdRun start"); + System.out.println(name+"Thread stdRun start"); br = new BufferedReader(new InputStreamReader(in)); while ((line = br.readLine()) != null) { - System.out.println(line); + System.out.println(name+line); } - System.out.println("Thread stdRun end"); + System.out.println(name+"Thread stdRun end"); } catch (Exception e) { e.printStackTrace(); } @@ -40,11 +42,11 @@ Runnable errStreamThread = new Runnable() { public void run() { try { - System.out.println("Thread errRun start"); + System.out.println(name+"Thread errRun start"); ebr = new BufferedReader(new InputStreamReader(ein)); String errLine; while ((errLine = ebr.readLine()) != null) { - System.out.println(errLine); + System.out.println(name+errLine); } } catch (Exception e) { e.printStackTrace(); @@ -55,25 +57,53 @@ Thread stdRun = new Thread(inputStreamThread); Thread errRun = new Thread(errStreamThread); + stdRun.start(); errRun.start(); - int c = p.waitFor(); + + try { + int c = p.waitFor(); + stdRun.join(); + errRun.join(); + in.close(); + ein.close(); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + private static InputStream in = null; + private static InputStream ein = null; + static BufferedReader ebr = null; + static BufferedReader br = null; - stdRun.join(); - errRun.join(); + static final String[] cmdServer = { "/usr/bin/java", + "TestMsgPackServer","-cp bin/classes/msgpack/test/" }; + static final String[] cmdClient = { "/usr/bin/java", + "TestMsgPackClient", "-cp bin/classes/msgpack/test/" }; + public static void main(String[] args) { + Runtime run = Runtime.getRuntime(); + try { + Process ps = run.exec(cmdServer); + Process pc = run.exec(cmdClient); + + Thread ts = new Thread(new CheckStd(ps, "Server:")); + Thread tc = new Thread(new CheckStd(pc, "Client:")); + + ts.start(); + tc.start(); + + ts.join(); + tc.join(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); - } finally { - try { - in.close(); - ein.close(); - } catch (IOException e) { - e.printStackTrace(); - } } } diff -r d86770305c8b -r 830afc6475b0 src/msgpack/test/TestMsgPackClient.java --- a/src/msgpack/test/TestMsgPackClient.java Fri May 11 02:30:59 2012 +0900 +++ b/src/msgpack/test/TestMsgPackClient.java Tue May 22 02:45:56 2012 +0900 @@ -17,4 +17,4 @@ String msg = iface.hello("hello", 1); System.out.println(msg); } -} \ No newline at end of file +} diff -r d86770305c8b -r 830afc6475b0 src/msgpack/test/TestMsgPackServer.java --- a/src/msgpack/test/TestMsgPackServer.java Fri May 11 02:30:59 2012 +0900 +++ b/src/msgpack/test/TestMsgPackServer.java Tue May 22 02:45:56 2012 +0900 @@ -7,10 +7,10 @@ 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);