diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2009-11-26 14:18:59 -0330 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2009-11-26 14:18:59 -0330 |
commit | eb9894afe8da3a9ef6a7da0ca27e0a6b32676b0c (patch) | |
tree | b0abd1a4d60e7842b1b74ac8c9bbb02797db8a8b /java | |
parent | Removed getCookie from C# AsyncResult (diff) | |
download | ice-eb9894afe8da3a9ef6a7da0ca27e0a6b32676b0c.tar.bz2 ice-eb9894afe8da3a9ef6a7da0ca27e0a6b32676b0c.tar.xz ice-eb9894afe8da3a9ef6a7da0ca27e0a6b32676b0c.zip |
Added invoke test
Cleaned up invoke demo
Fixed order of paramaters in end_ice_invoke in C++
Diffstat (limited to 'java')
-rwxr-xr-x | java/allTests.py | 1 | ||||
-rw-r--r-- | java/build.xml | 3 | ||||
-rw-r--r-- | java/demo/Ice/invoke/Client.java | 262 | ||||
-rw-r--r-- | java/demo/Ice/invoke/README | 4 | ||||
-rw-r--r-- | java/test/Ice/invoke/AllTests.java | 355 | ||||
-rw-r--r-- | java/test/Ice/invoke/BlobjectAsyncI.java | 62 | ||||
-rw-r--r-- | java/test/Ice/invoke/BlobjectI.java | 65 | ||||
-rw-r--r-- | java/test/Ice/invoke/Client.java | 40 | ||||
-rw-r--r-- | java/test/Ice/invoke/ServantLocatorI.java | 43 | ||||
-rw-r--r-- | java/test/Ice/invoke/Server.java | 48 | ||||
-rw-r--r-- | java/test/Ice/invoke/Test.ice | 32 | ||||
-rwxr-xr-x | java/test/Ice/invoke/run.py | 28 |
12 files changed, 723 insertions, 220 deletions
diff --git a/java/allTests.py b/java/allTests.py index 8b6874a4914..ac632fc1b5e 100755 --- a/java/allTests.py +++ b/java/allTests.py @@ -62,6 +62,7 @@ tests = [ ("Ice/defaultServant", ["core"]), ("Ice/threadPoolPriority", ["core"]), ("Ice/classLoader", ["core"]), + ("Ice/invoke", ["core"]), ("IceBox/configuration", ["core", "noipv6"]), ("Freeze/dbmap", ["once"]), ("Freeze/complex", ["once"]), diff --git a/java/build.xml b/java/build.xml index 56c8b93b054..510cc11b733 100644 --- a/java/build.xml +++ b/java/build.xml @@ -291,6 +291,9 @@ <fileset dir="test/Ice/interceptor"> <include name="Test.ice" /> </fileset> + <fileset dir="test/Ice/invoke"> + <include name="Test.ice" /> + </fileset> <fileset dir="test/Ice/location"> <include name="Test.ice" /> </fileset> diff --git a/java/demo/Ice/invoke/Client.java b/java/demo/Ice/invoke/Client.java index 50664b8931e..8ab0ea28158 100644 --- a/java/demo/Ice/invoke/Client.java +++ b/java/demo/Ice/invoke/Client.java @@ -11,97 +11,6 @@ import Demo.*; public class Client extends Ice.Application { - private class CallbackI extends Ice.AsyncCallback - { - @Override - public void completed(Ice.AsyncResult r) - { - Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); - try - { - if(!r.getProxy().end_ice_invoke(outParams, r)) - { - System.out.println("Unknown user exception"); - } - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private class Callback_getValuesI extends Ice.AsyncCallback - { - @Override - public void completed(Ice.AsyncResult r) - { - Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); - try - { - if(r.getProxy().end_ice_invoke(outParams, r)) - { - // - // Unmarshal the results. - // - Ice.InputStream in = Ice.Util.createInputStream(communicator(), outParams.value); - Demo.CHolder c = new Demo.CHolder(); - Demo.CHelper.read(in, c); - String str = in.readString(); - in.readPendingObjects(); - in.destroy(); - System.out.println("Got string `" + str + "' and class: s.name=" + c.value.s.name + - ", s.value=" + c.value.s.value); - } - else - { - System.out.println("Unknown user exception"); - } - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - - private class Callback_throwPrintFailureI extends Ice.AsyncCallback - { - @Override - public void completed(Ice.AsyncResult r) - { - Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); - try - { - if(!r.getProxy().end_ice_invoke(outParams, r)) - { - Ice.InputStream in = Ice.Util.createInputStream(communicator(), outParams.value); - try - { - in.throwException(); - } - catch(Demo.PrintFailure ex) - { - // Expected. - } - catch(Ice.UserException ex) - { - System.out.println("Unknown user exception"); - } - in.destroy(); - } - else - { - System.out.println("Expected user exception"); - } - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - } - private static void menu() { @@ -140,14 +49,9 @@ public class Client extends Ice.Application public int run(String[] args) { - boolean async = false; - if(args.length == 1 && args[0].equals("--async")) - { - async = true; - } - else if(args.length > 0) + if(args.length > 0) { - System.err.println("Usage: " + appName() + " [--async]"); + System.err.println(appName() + ": too many arguments"); return 1; } @@ -187,16 +91,9 @@ public class Client extends Ice.Application // // Invoke operation. // - if(async) + if(!obj.ice_invoke("printString", Ice.OperationMode.Normal, out.finished(), null)) { - obj.begin_ice_invoke("printString", Ice.OperationMode.Normal, out.finished(), new CallbackI()); - } - else - { - if(!obj.ice_invoke("printString", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } + System.out.println("Unknown user exception"); } out.destroy(); @@ -213,17 +110,9 @@ public class Client extends Ice.Application // // Invoke operation. // - if(async) + if(!obj.ice_invoke("printStringSequence", Ice.OperationMode.Normal, out.finished(), null)) { - obj.begin_ice_invoke("printStringSequence", Ice.OperationMode.Normal, out.finished(), - new CallbackI()); - } - else - { - if(!obj.ice_invoke("printStringSequence", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } + System.out.println("Unknown user exception"); } out.destroy(); @@ -242,17 +131,9 @@ public class Client extends Ice.Application // // Invoke operation. // - if(async) - { - obj.begin_ice_invoke("printDictionary", Ice.OperationMode.Normal, out.finished(), - new CallbackI()); - } - else + if(!obj.ice_invoke("printDictionary", Ice.OperationMode.Normal, out.finished(), null)) { - if(!obj.ice_invoke("printDictionary", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } + System.out.println("Unknown user exception"); } out.destroy(); @@ -268,16 +149,9 @@ public class Client extends Ice.Application // // Invoke operation. // - if(async) - { - obj.begin_ice_invoke("printEnum", Ice.OperationMode.Normal, out.finished(), new CallbackI()); - } - else + if(!obj.ice_invoke("printEnum", Ice.OperationMode.Normal, out.finished(), null)) { - if(!obj.ice_invoke("printEnum", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } + System.out.println("Unknown user exception"); } out.destroy(); @@ -296,16 +170,9 @@ public class Client extends Ice.Application // // Invoke operation. // - if(async) + if(!obj.ice_invoke("printStruct", Ice.OperationMode.Normal, out.finished(), null)) { - obj.begin_ice_invoke("printStruct", Ice.OperationMode.Normal, out.finished(), new CallbackI()); - } - else - { - if(!obj.ice_invoke("printStruct", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } + System.out.println("Unknown user exception"); } out.destroy(); @@ -331,17 +198,9 @@ public class Client extends Ice.Application // // Invoke operation. // - if(async) + if(!obj.ice_invoke("printStructSequence", Ice.OperationMode.Normal, out.finished(), null)) { - obj.begin_ice_invoke("printStructSequence", Ice.OperationMode.Normal, out.finished(), - new CallbackI()); - } - else - { - if(!obj.ice_invoke("printStructSequence", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } + System.out.println("Unknown user exception"); } out.destroy(); @@ -362,16 +221,9 @@ public class Client extends Ice.Application // // Invoke operation. // - if(async) - { - obj.begin_ice_invoke("printClass", Ice.OperationMode.Normal, out.finished(), new CallbackI()); - } - else + if(!obj.ice_invoke("printClass", Ice.OperationMode.Normal, out.finished(), null)) { - if(!obj.ice_invoke("printClass", Ice.OperationMode.Normal, out.finished(), null)) - { - System.out.println("Unknown user exception"); - } + System.out.println("Unknown user exception"); } out.destroy(); @@ -382,30 +234,23 @@ public class Client extends Ice.Application // Invoke operation. // Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); - if(async) + if(!obj.ice_invoke("getValues", Ice.OperationMode.Normal, null, outParams)) { - obj.begin_ice_invoke("getValues", Ice.OperationMode.Normal, null, new Callback_getValuesI()); + System.out.println("Unknown user exception"); + continue; } - else - { - if(!obj.ice_invoke("getValues", Ice.OperationMode.Normal, null, outParams)) - { - System.out.println("Unknown user exception"); - continue; - } - // - // Unmarshal the results. - // - Ice.InputStream in = Ice.Util.createInputStream(communicator(), outParams.value); - Demo.CHolder c = new Demo.CHolder(); - Demo.CHelper.read(in, c); - String str = in.readString(); - in.readPendingObjects(); - in.destroy(); - System.out.println("Got string `" + str + "' and class: s.name=" + c.value.s.name + - ", s.value=" + c.value.s.value); - } + // + // Unmarshal the results. + // + Ice.InputStream in = Ice.Util.createInputStream(communicator(), outParams.value); + Demo.CHolder c = new Demo.CHolder(); + Demo.CHelper.read(in, c); + String str = in.readString(); + in.readPendingObjects(); + in.destroy(); + System.out.println("Got string `" + str + "' and class: s.name=" + c.value.s.name + + ", s.value=" + c.value.s.value); } else if(line.equals("9")) { @@ -413,45 +258,30 @@ public class Client extends Ice.Application // Invoke operation. // Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); - if(async) + if(obj.ice_invoke("throwPrintFailure", Ice.OperationMode.Normal, null, outParams)) { - obj.begin_ice_invoke("throwPrintFailure", Ice.OperationMode.Normal, null, - new Callback_throwPrintFailureI()); + System.out.println("Expected exception"); + continue; } - else - { - if(obj.ice_invoke("throwPrintFailure", Ice.OperationMode.Normal, null, outParams)) - { - System.out.println("Expected exception"); - continue; - } - Ice.InputStream in = Ice.Util.createInputStream(communicator(), outParams.value); - try - { - in.throwException(); - } - catch(Demo.PrintFailure ex) - { - // Expected. - } - catch(Ice.UserException ex) - { - System.out.println("Unknown user exception"); - } - in.destroy(); + Ice.InputStream in = Ice.Util.createInputStream(communicator(), outParams.value); + try + { + in.throwException(); } - } - else if(line.equals("s")) - { - if(async) + catch(Demo.PrintFailure ex) { - obj.begin_ice_invoke("shutdown", Ice.OperationMode.Normal, null, new CallbackI()); + // Expected. } - else + catch(Ice.UserException ex) { - obj.ice_invoke("shutdown", Ice.OperationMode.Normal, null, null); + System.out.println("Unknown user exception"); } + in.destroy(); + } + else if(line.equals("s")) + { + obj.ice_invoke("shutdown", Ice.OperationMode.Normal, null, null); } else if(line.equals("x")) { diff --git a/java/demo/Ice/invoke/README b/java/demo/Ice/invoke/README index 954932fbce4..cd086ebeb42 100644 --- a/java/demo/Ice/invoke/README +++ b/java/demo/Ice/invoke/README @@ -7,7 +7,3 @@ $ java Server In a separate window, start the client: $ java Client - -To run the client using asynchronous calls use: - -$ java Client --async diff --git a/java/test/Ice/invoke/AllTests.java b/java/test/Ice/invoke/AllTests.java new file mode 100644 index 00000000000..c5555231f0c --- /dev/null +++ b/java/test/Ice/invoke/AllTests.java @@ -0,0 +1,355 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.invoke; +import java.io.PrintWriter; + +import test.Ice.invoke.Test.MyClassPrx; +import test.Ice.invoke.Test.MyClassPrxHelper; +import test.Ice.invoke.Test.MyException; + +public class AllTests +{ + final static String testString = "This is a test string"; + + private static void + test(boolean b) + { + if(!b) + { + throw new RuntimeException(); + } + } + + private static class Callback + { + Callback() + { + _called = false; + } + + public synchronized void check() + { + while(!_called) + { + try + { + wait(); + } + catch(InterruptedException ex) + { + } + } + + _called = false; + } + + public synchronized void called() + { + assert(!_called); + _called = true; + notify(); + } + + private boolean _called; + } + + private static class opStringI extends Ice.AsyncCallback + { + public opStringI(Ice.Communicator communicator) + { + _communicator = communicator; + } + + @Override + public void completed(Ice.AsyncResult result) + { + Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); + if(result.getProxy().end_ice_invoke(outParams, result)) + { + Ice.InputStream inS = Ice.Util.createInputStream(_communicator, outParams.value); + String s = inS.readString(); + test(s.equals(testString)); + s = inS.readString(); + test(s.equals(testString)); + callback.called(); + } + else + { + test(false); + } + } + + public void check() + { + callback.check(); + } + + private Ice.Communicator _communicator; + private Callback callback = new Callback(); + } + + private static class opExceptionI extends Ice.AsyncCallback + { + public opExceptionI(Ice.Communicator communicator) + { + _communicator = communicator; + } + + @Override + public void completed(Ice.AsyncResult result) + { + Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); + if(result.getProxy().end_ice_invoke(outParams, result)) + { + test(false); + } + else + { + Ice.InputStream inS = Ice.Util.createInputStream(_communicator, outParams.value); + try + { + inS.throwException(); + } + catch(Test.MyException ex) + { + callback.called(); + } + catch(java.lang.Exception ex) + { + test(false); + } + } + } + + public void check() + { + callback.check(); + } + + private Ice.Communicator _communicator; + private Callback callback = new Callback(); + } + + private static class Callback_Object_opStringI extends Ice.Callback_Object_ice_invoke + { + public Callback_Object_opStringI(Ice.Communicator communicator) + { + _communicator = communicator; + } + + @Override + public void response(boolean ok, byte[] outParams) + { + if(ok) + { + Ice.InputStream inS = Ice.Util.createInputStream(_communicator, outParams); + String s = inS.readString(); + test(s.equals(testString)); + s = inS.readString(); + test(s.equals(testString)); + callback.called(); + } + else + { + test(false); + } + } + + @Override + public void exception(Ice.LocalException ex) + { + test(false); + } + + public void check() + { + callback.check(); + } + + private Ice.Communicator _communicator; + private Callback callback = new Callback(); + } + + private static class Callback_Object_opExceptionI extends Ice.Callback_Object_ice_invoke + { + public Callback_Object_opExceptionI(Ice.Communicator communicator) + { + _communicator = communicator; + } + + @Override + public void response(boolean ok, byte[] outParams) + { + if(ok) + { + test(false); + } + else + { + Ice.InputStream inS = Ice.Util.createInputStream(_communicator, outParams); + try + { + inS.throwException(); + } + catch(Test.MyException ex) + { + callback.called(); + } + catch(java.lang.Exception ex) + { + test(false); + } + } + } + + @Override + public void exception(Ice.LocalException ex) + { + test(false); + } + + public void check() + { + callback.check(); + } + + private Ice.Communicator _communicator; + private Callback callback = new Callback(); + } + + public static MyClassPrx + allTests(Ice.Communicator communicator, PrintWriter out) + { + String ref = "test:default -p 12010"; + Ice.ObjectPrx base = communicator.stringToProxy(ref); + MyClassPrx cl = MyClassPrxHelper.checkedCast(base); + + out.print("testing ice_invoke... "); + out.flush(); + + { + Ice.OutputStream outS = Ice.Util.createOutputStream(communicator); + outS.writeString(testString); + byte[] inParams = outS.finished(); + Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); + if(cl.ice_invoke("opString", Ice.OperationMode.Normal, inParams, outParams)) + { + Ice.InputStream inS = Ice.Util.createInputStream(communicator, outParams.value); + String s = inS.readString(); + test(s.equals(testString)); + s = inS.readString(); + test(s.equals(testString)); + } + else + { + test(false); + } + } + + { + Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); + if(cl.ice_invoke("opException", Ice.OperationMode.Normal, null, outParams)) + { + test(false); + } + else + { + Ice.InputStream inS = Ice.Util.createInputStream(communicator, outParams.value); + try + { + inS.throwException(); + } + catch(Test.MyException ex) + { + } + catch(java.lang.Exception ex) + { + test(false); + } + } + } + + out.println("ok"); + + out.print("testing asynchronous ice_invoke... "); + out.flush(); + + { + Ice.OutputStream outS = Ice.Util.createOutputStream(communicator); + outS.writeString(testString); + byte[] inParams = outS.finished(); + + // begin_ice_invoke with no callback + Ice.AsyncResult result = cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inParams); + Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); + if(cl.end_ice_invoke(outParams, result)) + { + Ice.InputStream inS = Ice.Util.createInputStream(communicator, outParams.value); + String s = inS.readString(); + test(s.equals(testString)); + s = inS.readString(); + test(s.equals(testString)); + } + else + { + test(false); + } + + // begin_ice_invoke with Callback + opStringI cb1 = new opStringI(communicator); + cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inParams, cb1); + cb1.check(); + + // begin_ice_invoke with Callback_Object_ice_invoke + Callback_Object_opStringI cb2 = new Callback_Object_opStringI(communicator); + cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inParams, cb2); + cb2.check(); + } + + { + // begin_ice_invoke with no callback + Ice.AsyncResult result = cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null); + Ice.ByteSeqHolder outParams = new Ice.ByteSeqHolder(); + if(cl.end_ice_invoke(outParams, result)) + { + test(false); + } + else + { + Ice.InputStream inS = Ice.Util.createInputStream(communicator, outParams.value); + try + { + inS.throwException(); + } + catch(Test.MyException ex) + { + } + catch(java.lang.Exception ex) + { + test(false); + } + } + + // begin_ice_invoke with Callback + opExceptionI cb1 = new opExceptionI(communicator); + cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, cb1); + cb1.check(); + + // begin_ice_invoke with Callback_Object_ice_invoke + Callback_Object_opExceptionI cb2 = new Callback_Object_opExceptionI(communicator); + cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, cb2); + cb2.check(); + } + + out.println("ok"); + + return cl; + } +} diff --git a/java/test/Ice/invoke/BlobjectAsyncI.java b/java/test/Ice/invoke/BlobjectAsyncI.java new file mode 100644 index 00000000000..07f00734d13 --- /dev/null +++ b/java/test/Ice/invoke/BlobjectAsyncI.java @@ -0,0 +1,62 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.invoke; + +import test.Ice.invoke.Test.MyException; + +public class BlobjectAsyncI extends Ice.BlobjectAsync +{ + public void + ice_invoke_async(Ice.AMD_Object_ice_invoke cb, byte[] inParams, Ice.Current current) + { + Ice.Communicator communicator = current.adapter.getCommunicator(); + Ice.InputStream in = Ice.Util.createInputStream(communicator, inParams); + Ice.OutputStream out = Ice.Util.createOutputStream(communicator); + if(current.operation.equals("opString")) + { + String s = in.readString(); + out.writeString(s); + out.writeString(s); + cb.ice_response(true, out.finished()); + } + else if(current.operation.equals("opException")) + { + MyException ex = new MyException(); + out.writeException(ex); + cb.ice_response(false, out.finished()); + } + else if(current.operation.equals("shutdown")) + { + communicator.shutdown(); + cb.ice_response(true, null); + } + else if(current.operation.equals("ice_isA")) + { + String s = in.readString(); + if(s.equals("::Test::MyClass")) + { + out.writeBool(true); + } + else + { + out.writeBool(false); + } + cb.ice_response(true, out.finished()); + } + else + { + Ice.OperationNotExistException ex = new Ice.OperationNotExistException(); + ex.id = current.id; + ex.facet = current.facet; + ex.operation = current.operation; + throw ex; + } + } +} diff --git a/java/test/Ice/invoke/BlobjectI.java b/java/test/Ice/invoke/BlobjectI.java new file mode 100644 index 00000000000..e667155af05 --- /dev/null +++ b/java/test/Ice/invoke/BlobjectI.java @@ -0,0 +1,65 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.invoke; + +import test.Ice.invoke.Test.MyException; + +public class BlobjectI extends Ice.Blobject +{ + public boolean + ice_invoke(byte[] inParams, Ice.ByteSeqHolder outParams, Ice.Current current) + { + Ice.Communicator communicator = current.adapter.getCommunicator(); + Ice.InputStream in = Ice.Util.createInputStream(communicator, inParams); + Ice.OutputStream out = Ice.Util.createOutputStream(communicator); + if(current.operation.equals("opString")) + { + String s = in.readString(); + out.writeString(s); + out.writeString(s); + outParams.value = out.finished(); + return true; + } + else if(current.operation.equals("opException")) + { + MyException ex = new MyException(); + out.writeException(ex); + outParams.value = out.finished(); + return false; + } + else if(current.operation.equals("shutdown")) + { + communicator.shutdown(); + return true; + } + else if(current.operation.equals("ice_isA")) + { + String s = in.readString(); + if(s.equals("::Test::MyClass")) + { + out.writeBool(true); + } + else + { + out.writeBool(false); + } + outParams.value = out.finished(); + return true; + } + else + { + Ice.OperationNotExistException ex = new Ice.OperationNotExistException(); + ex.id = current.id; + ex.facet = current.facet; + ex.operation = current.operation; + throw ex; + } + } +} diff --git a/java/test/Ice/invoke/Client.java b/java/test/Ice/invoke/Client.java new file mode 100644 index 00000000000..b987c4e3348 --- /dev/null +++ b/java/test/Ice/invoke/Client.java @@ -0,0 +1,40 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.invoke; + +import test.Ice.invoke.Test.MyClassPrx; + +public class Client extends test.Util.Application +{ + public int run(String[] args) + { + MyClassPrx myClass = AllTests.allTests(communicator(), getWriter()); + myClass.shutdown(); + + return 0; + } + + protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH) + { + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(argsH); + initData.properties.setProperty("Ice.Package.Test", "test.Ice.invoke"); + return initData; + } + + public static void main(String[] args) + { + Client c = new Client(); + int status = c.main("Client", args); + + System.gc(); + System.exit(status); + } +} diff --git a/java/test/Ice/invoke/ServantLocatorI.java b/java/test/Ice/invoke/ServantLocatorI.java new file mode 100644 index 00000000000..1e8cd3a3325 --- /dev/null +++ b/java/test/Ice/invoke/ServantLocatorI.java @@ -0,0 +1,43 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.invoke; + +public class ServantLocatorI implements Ice.ServantLocator +{ + public ServantLocatorI( boolean async) + { + if(async) + { + _blobject = new BlobjectAsyncI(); + } + else + { + _blobject = new BlobjectI(); + } + } + + public Ice.Object + locate(Ice.Current current, Ice.LocalObjectHolder cookie) + { + return _blobject; + } + + public void + finished(Ice.Current current, Ice.Object servant, java.lang.Object cookie) + { + } + + public void + deactivate(String category) + { + } + + private Ice.Object _blobject; +} diff --git a/java/test/Ice/invoke/Server.java b/java/test/Ice/invoke/Server.java new file mode 100644 index 00000000000..2cf3bb7cdc2 --- /dev/null +++ b/java/test/Ice/invoke/Server.java @@ -0,0 +1,48 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.invoke; + +public class Server extends test.Util.Application +{ + public int run(String[] args) + { + boolean async = false; + for(int i = 0; i < args.length; ++i) + { + if(args[i].equals("--async")) + { + async = true; + } + } + + communicator().getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter"); + adapter.addServantLocator(new ServantLocatorI(async), ""); + adapter.activate(); + return WAIT; + } + + protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH) + { + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(argsH); + initData.properties.setProperty("Ice.Package.Test", "test.Ice.invoke"); + return initData; + } + + public static void main(String[] args) + { + Server c = new Server(); + int status = c.main("Server", args); + + System.gc(); + System.exit(status); + } +} diff --git a/java/test/Ice/invoke/Test.ice b/java/test/Ice/invoke/Test.ice new file mode 100644 index 00000000000..77492c307db --- /dev/null +++ b/java/test/Ice/invoke/Test.ice @@ -0,0 +1,32 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef TEST_ICE +#define TEST_ICE + +[["java:package:test.Ice.invoke"]] +module Test +{ + +exception MyException +{ +}; + +class MyClass +{ + string opString(string s1, out string s2); + + void opException() throws MyException; + + void shutdown(); +}; + +}; + +#endif diff --git a/java/test/Ice/invoke/run.py b/java/test/Ice/invoke/run.py new file mode 100755 index 00000000000..47f6323efaa --- /dev/null +++ b/java/test/Ice/invoke/run.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import os, sys + +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise "can't find toplevel directory!" +sys.path.append(os.path.join(path[0])) +from scripts import * + +print "tests with Blobject server." +TestUtil.clientServerTest() + +print "tests with BlobjectAsync server." +TestUtil.clientServerTest(additionalServerOptions = "--async") + |