diff options
author | Michi Henning <michi@zeroc.com> | 2004-12-07 03:53:54 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2004-12-07 03:53:54 +0000 |
commit | 517d158d746bfa6f5722d9ecd0264137269bfa79 (patch) | |
tree | 4a4e3dbb6ee6c1493e332ff14ffe09117f740425 /java/test | |
parent | minor fixes (diff) | |
download | ice-517d158d746bfa6f5722d9ecd0264137269bfa79.tar.bz2 ice-517d158d746bfa6f5722d9ecd0264137269bfa79.tar.xz ice-517d158d746bfa6f5722d9ecd0264137269bfa79.zip |
Added context parameter to checkedCast().
Diffstat (limited to 'java/test')
-rw-r--r-- | java/test/Ice/operations/AllTests.java | 18 | ||||
-rw-r--r-- | java/test/Ice/operations/CheckedCastLocator.java | 37 | ||||
-rw-r--r-- | java/test/Ice/operations/Collocated.java | 9 | ||||
-rw-r--r-- | java/test/Ice/operations/Server.java | 11 | ||||
-rw-r--r-- | java/test/Ice/operations/Test.ice | 5 | ||||
-rw-r--r-- | java/test/Ice/operations/TestCheckedCastI.java | 25 | ||||
-rw-r--r-- | java/test/Ice/operationsAMD/CheckedCastLocator.java | 37 | ||||
-rw-r--r-- | java/test/Ice/operationsAMD/Server.java | 11 | ||||
-rw-r--r-- | java/test/Ice/operationsAMD/TestAMD.ice | 7 | ||||
-rw-r--r-- | java/test/Ice/operationsAMD/TestCheckedCastI.java | 25 | ||||
-rw-r--r-- | java/test/Ice/operationsAMD/build.xml | 20 |
11 files changed, 205 insertions, 0 deletions
diff --git a/java/test/Ice/operations/AllTests.java b/java/test/Ice/operations/AllTests.java index a53b1c88aad..40797e9b72f 100644 --- a/java/test/Ice/operations/AllTests.java +++ b/java/test/Ice/operations/AllTests.java @@ -39,6 +39,24 @@ public class AllTests test(cl.equals(derived)); System.out.println("ok"); + System.out.print("testing checked cast with context... "); + System.out.flush(); + String cref = "test:default -p 12346 -t 10000"; + Ice.ObjectPrx cbase = communicator.stringToProxy(cref); + test(cbase != null); + + Test.TestCheckedCastPrx tccp = Test.TestCheckedCastPrxHelper.checkedCast(cbase); + java.util.Map c = tccp.getContext(); + test(c == null || c.size() == 0); + + c = new java.util.HashMap(); + c.put("one", "hello"); + c.put("two", "world"); + tccp = Test.TestCheckedCastPrxHelper.checkedCast(cbase, c); + java.util.Map c2 = tccp.getContext(); + test(c.equals(c2)); + System.out.println("ok"); + System.out.print("testing twoway operations... "); System.out.flush(); Twoways.twoways(cl); diff --git a/java/test/Ice/operations/CheckedCastLocator.java b/java/test/Ice/operations/CheckedCastLocator.java new file mode 100644 index 00000000000..ed737ad384e --- /dev/null +++ b/java/test/Ice/operations/CheckedCastLocator.java @@ -0,0 +1,37 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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. +// +// ********************************************************************** + +public final class CheckedCastLocator extends Ice.LocalObjectImpl implements Ice.ServantLocator +{ + public CheckedCastLocator() + { + _servant = new TestCheckedCastI(); + } + + public Ice.Object + locate(Ice.Current c, Ice.LocalObjectHolder cookie) + { + if(c.operation.equals("ice_isA")) + { + _servant.setContext(c.ctx); + } + return _servant; + } + + public void + finished(Ice.Current current, Ice.Object servant, Ice.LocalObject cookie) + { + } + + public void deactivate(String s) + { + } + + TestCheckedCastI _servant; +} diff --git a/java/test/Ice/operations/Collocated.java b/java/test/Ice/operations/Collocated.java index a8de2b7cc8e..441fe39dfe2 100644 --- a/java/test/Ice/operations/Collocated.java +++ b/java/test/Ice/operations/Collocated.java @@ -17,6 +17,15 @@ public class Collocated Ice.Object object = new MyDerivedClassI(adapter, Ice.Util.stringToIdentity("test")); adapter.add(object, Ice.Util.stringToIdentity("test")); + // + // Make a separate adapter with a servant locator. We use this to test + // that ::Ice::Context is correctly passed to checkedCast() operation. + // + communicator.getProperties().setProperty("CheckedCastAdapter.Endpoints", "default -p 12346 -t 10000"); + adapter = communicator.createObjectAdapter("CheckedCastAdapter"); + Ice.ServantLocator checkedCastLocator = new CheckedCastLocator(); + adapter.addServantLocator(checkedCastLocator, ""); + AllTests.allTests(communicator, true); return 0; diff --git a/java/test/Ice/operations/Server.java b/java/test/Ice/operations/Server.java index eb61addc6f5..df43d08eda3 100644 --- a/java/test/Ice/operations/Server.java +++ b/java/test/Ice/operations/Server.java @@ -17,6 +17,17 @@ public class Server Ice.Object object = new MyDerivedClassI(adapter, Ice.Util.stringToIdentity("test")); adapter.add(object, Ice.Util.stringToIdentity("test")); adapter.activate(); + + // + // Make a separate adapter with a servant locator. We use this to test + // that ::Ice::Context is correctly passed to checkedCast() operation. + // + communicator.getProperties().setProperty("CheckedCastAdapter.Endpoints", "default -p 12346 -t 10000"); + adapter = communicator.createObjectAdapter("CheckedCastAdapter"); + Ice.ServantLocator checkedCastLocator = new CheckedCastLocator(); + adapter.addServantLocator(checkedCastLocator, ""); + adapter.activate(); + communicator.waitForShutdown(); return 0; } diff --git a/java/test/Ice/operations/Test.ice b/java/test/Ice/operations/Test.ice index c57cb879968..47284aaf973 100644 --- a/java/test/Ice/operations/Test.ice +++ b/java/test/Ice/operations/Test.ice @@ -155,6 +155,11 @@ dictionary<string, MyEnum> StringMyEnumD; void opDerived(); }; +interface TestCheckedCast +{ + Ice::Context getContext(); +}; + }; #endif diff --git a/java/test/Ice/operations/TestCheckedCastI.java b/java/test/Ice/operations/TestCheckedCastI.java new file mode 100644 index 00000000000..503fd7d3a4b --- /dev/null +++ b/java/test/Ice/operations/TestCheckedCastI.java @@ -0,0 +1,25 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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. +// +// ********************************************************************** + +public final class TestCheckedCastI extends Test._TestCheckedCastDisp +{ + public java.util.Map + getContext(Ice.Current current) + { + return _ctx; + } + + public void + setContext(java.util.Map ctx) + { + _ctx = ctx; + } + + private java.util.Map _ctx; +} diff --git a/java/test/Ice/operationsAMD/CheckedCastLocator.java b/java/test/Ice/operationsAMD/CheckedCastLocator.java new file mode 100644 index 00000000000..ed737ad384e --- /dev/null +++ b/java/test/Ice/operationsAMD/CheckedCastLocator.java @@ -0,0 +1,37 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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. +// +// ********************************************************************** + +public final class CheckedCastLocator extends Ice.LocalObjectImpl implements Ice.ServantLocator +{ + public CheckedCastLocator() + { + _servant = new TestCheckedCastI(); + } + + public Ice.Object + locate(Ice.Current c, Ice.LocalObjectHolder cookie) + { + if(c.operation.equals("ice_isA")) + { + _servant.setContext(c.ctx); + } + return _servant; + } + + public void + finished(Ice.Current current, Ice.Object servant, Ice.LocalObject cookie) + { + } + + public void deactivate(String s) + { + } + + TestCheckedCastI _servant; +} diff --git a/java/test/Ice/operationsAMD/Server.java b/java/test/Ice/operationsAMD/Server.java index eb61addc6f5..df43d08eda3 100644 --- a/java/test/Ice/operationsAMD/Server.java +++ b/java/test/Ice/operationsAMD/Server.java @@ -17,6 +17,17 @@ public class Server Ice.Object object = new MyDerivedClassI(adapter, Ice.Util.stringToIdentity("test")); adapter.add(object, Ice.Util.stringToIdentity("test")); adapter.activate(); + + // + // Make a separate adapter with a servant locator. We use this to test + // that ::Ice::Context is correctly passed to checkedCast() operation. + // + communicator.getProperties().setProperty("CheckedCastAdapter.Endpoints", "default -p 12346 -t 10000"); + adapter = communicator.createObjectAdapter("CheckedCastAdapter"); + Ice.ServantLocator checkedCastLocator = new CheckedCastLocator(); + adapter.addServantLocator(checkedCastLocator, ""); + adapter.activate(); + communicator.waitForShutdown(); return 0; } diff --git a/java/test/Ice/operationsAMD/TestAMD.ice b/java/test/Ice/operationsAMD/TestAMD.ice index 650fce73cd8..b2eae6c4e5c 100644 --- a/java/test/Ice/operationsAMD/TestAMD.ice +++ b/java/test/Ice/operationsAMD/TestAMD.ice @@ -10,6 +10,8 @@ #ifndef TEST_AMD_ICE #define TEST_AMD_ICE +#include<Ice/Current.ice> + module Test { @@ -154,6 +156,11 @@ dictionary<string, MyEnum> StringMyEnumD; void opDerived(); }; +["ami", "amd"] interface TestCheckedCast +{ + Ice::Context getContext(); +}; + }; #endif diff --git a/java/test/Ice/operationsAMD/TestCheckedCastI.java b/java/test/Ice/operationsAMD/TestCheckedCastI.java new file mode 100644 index 00000000000..a92cdef0f96 --- /dev/null +++ b/java/test/Ice/operationsAMD/TestCheckedCastI.java @@ -0,0 +1,25 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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. +// +// ********************************************************************** + +public final class TestCheckedCastI extends Test._TestCheckedCastDisp +{ + public void + getContext_async(Test.AMD_TestCheckedCast_getContext cb, Ice.Current current) + { + cb.ice_response(_ctx); + } + + public void + setContext(java.util.Map ctx) + { + _ctx = ctx; + } + + private java.util.Map _ctx; +} diff --git a/java/test/Ice/operationsAMD/build.xml b/java/test/Ice/operationsAMD/build.xml index 4d09acbf06f..359229a7322 100644 --- a/java/test/Ice/operationsAMD/build.xml +++ b/java/test/Ice/operationsAMD/build.xml @@ -11,6 +11,9 @@ <project name="test_Ice_operations" default="all" basedir="."> + <!-- get access to env variables globally --> + <property environment="env" /> + <!-- set global properties for this build --> <property name="top.dir" value="../../.."/> <property name="lib.dir" value="${top.dir}/lib"/> @@ -27,6 +30,20 @@ <target name="init"> <!-- Create the time stamp --> <tstamp/> + + <!-- Define the slice.dir property --> + <condition property="slice.dir" value="slice"> + <available file="slice" type="dir"/> + </condition> + <condition property="slice.dir" value="${env.ICE_HOME}/slice"> + <and> + <available type="dir" file="${env.ICE_HOME}/slice"/> + <not> + <available file="slice" type="dir"/> + </not> + </and> + </condition> + <fail message="Slice source directory not found" unless="slice.dir"/> </target> <target name="generate" depends="init"> @@ -34,6 +51,9 @@ <mkdir dir="${generated.dir}"/> <slice2java outputdir="${generated.dir}"> <fileset dir="." includes="TestAMD.ice"/> + <includepath> + <pathelement path="${slice.dir}" /> + </includepath> </slice2java> </target> |