diff options
34 files changed, 1834 insertions, 887 deletions
diff --git a/cs/allTests.py b/cs/allTests.py index 7bc216e0de6..5505265a20a 100755 --- a/cs/allTests.py +++ b/cs/allTests.py @@ -63,6 +63,7 @@ tests = [ \ "Ice/stream", \ "Ice/retry", \ "Ice/timeout", \ + "Ice/servantLocator", \ # "IceSSL/configuration", \ # Commented out for the moment because it fails with Mono 1.2 "Glacier2/router", \ "Glacier2/attack", \ diff --git a/cs/src/Ice/ConnectionI.cs b/cs/src/Ice/ConnectionI.cs index d508b92f6f5..258ea94ebf4 100755 --- a/cs/src/Ice/ConnectionI.cs +++ b/cs/src/Ice/ConnectionI.cs @@ -1339,6 +1339,30 @@ namespace Ice } } + public void invokeException(LocalException ex, int invokeNum) + { + // + // Fatal exception while invoking a request. Since sendResponse/sendNoResponse isn't + // called in case of a fatal exception we decrement _dispatchCount here. + // + + lock(this) + { + setState(StateClosed, ex); + + if(invokeNum > 0) + { + Debug.Assert(_dispatchCount > 0); + _dispatchCount -= invokeNum; + Debug.Assert(_dispatchCount >= 0); + if(_dispatchCount == 0) + { + Monitor.PulseAll(this); + } + } + } + } + public string type() { return _type; // No mutex lock, _type is immutable. @@ -2030,19 +2054,7 @@ namespace Ice } catch(LocalException ex) { - lock(this) - { - setState(StateClosed, ex); - } - } - catch(System.Exception ex) - { - lock(this) - { - UnknownException uex = new UnknownException(); - uex.unknown = ex.ToString(); - setState(StateClosed, uex); - } + invokeException(ex, invokeNum); } finally { @@ -2050,26 +2062,7 @@ namespace Ice { reclaimIncoming(inc); } - } - - // - // If invoke() above raised an exception, and therefore - // neither sendResponse() nor sendNoResponse() has been - // called, then we must decrement _dispatchCount here. - // - if(invokeNum > 0) - { - lock(this) - { - Debug.Assert(_dispatchCount > 0); - _dispatchCount -= invokeNum; - Debug.Assert(_dispatchCount >= 0); - if(_dispatchCount == 0) - { - Monitor.PulseAll(this); - } - } - } + } } private void run() diff --git a/cs/src/Ice/Incoming.cs b/cs/src/Ice/Incoming.cs index 3094e45dacc..03b39760b6a 100755 --- a/cs/src/Ice/Incoming.cs +++ b/cs/src/Ice/Incoming.cs @@ -119,158 +119,16 @@ namespace IceInternal os_.instance().initializationData().logger.warning(sw.ToString()); } } - - protected internal Ice.Current current_; - protected internal Ice.Object servant_; - protected internal Ice.ServantLocator locator_; - protected internal Ice.LocalObject cookie_; - - protected internal bool response_; - protected internal byte compress_; - - protected internal BasicStream os_; - - protected Ice.ConnectionI connection_; - } - - sealed public class Incoming : IncomingBase - { - public Incoming(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, - bool response, byte compress, int requestId) - : base(instance, connection, adapter, response, compress, requestId) - { - _is = new BasicStream(instance); - } - - // - // These functions allow this object to be reused, rather than reallocated. - // - public override void reset(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, - bool response, byte compress, int requestId) - { - if(_is == null) - { - _is = new BasicStream(instance); - } - - base.reset(instance, connection, adapter, response, compress, requestId); - } - - public override void reclaim() - { - if(_is != null) - { - _is.reset(); - } - - base.reclaim(); - } - - public void invoke(ServantManager servantManager) - { - // - // Read the current. - // - current_.id.read__(_is); - - // - // For compatibility with the old FacetPath. - // - string[] facetPath = _is.readStringSeq(); - if(facetPath.Length > 0) - { - if(facetPath.Length > 1) - { - throw new Ice.MarshalException(); - } - current_.facet = facetPath[0]; - } - else - { - current_.facet = ""; - } - current_.operation = _is.readString(); - current_.mode = (Ice.OperationMode)(int)_is.readByte(); - int sz = _is.readSize(); - while(sz-- > 0) - { - string first = _is.readString(); - string second = _is.readString(); - if(current_.ctx == null) - { - current_.ctx = new Ice.Context(); - } - current_.ctx[first] = second; - } - - _is.startReadEncaps(); - - if(response_) - { - Debug.Assert(os_.size() == Protocol.headerSize + 4); // Dispatch status position. - os_.writeByte((byte)0); - os_.startWriteEncaps(); - } - - // Initialize status to some value, to keep the compiler happy. - DispatchStatus status = DispatchStatus.DispatchOK; - - // - // Don't put the code above into the try block below. Exceptions - // in the code above are considered fatal, and must propagate to - // the caller of this operation. - // - + protected internal void handleException__(System.Exception exc) + { try { - try - { - if(servantManager != null) - { - servant_ = servantManager.findServant(current_.id, current_.facet); - if(servant_ == null) - { - locator_ = servantManager.findServantLocator(current_.id.category); - if(locator_ == null && current_.id.category.Length > 0) - { - locator_ = servantManager.findServantLocator(""); - } - if(locator_ != null) - { - servant_ = locator_.locate(current_, out cookie_); - } - } - } - if(servant_ == null) - { - if(servantManager != null && servantManager.hasServant(current_.id)) - { - status = DispatchStatus.DispatchFacetNotExist; - } - else - { - status = DispatchStatus.DispatchObjectNotExist; - } - } - else - { - status = servant_.dispatch__(this, current_); - } - } - finally - { - if(locator_ != null && servant_ != null && status != DispatchStatus.DispatchAsync) - { - locator_.finished(current_, servant_, cookie_); - } - } + throw exc; } catch(Ice.RequestFailedException ex) { - _is.endReadEncaps(); - - if(ex.id.name == null) + if(ex.id == null) { ex.id = current_.id; } @@ -339,8 +197,6 @@ namespace IceInternal } catch(Ice.UnknownLocalException ex) { - _is.endReadEncaps(); - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Dispatch", 1) > 0) { @@ -364,8 +220,6 @@ namespace IceInternal } catch(Ice.UnknownUserException ex) { - _is.endReadEncaps(); - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Dispatch", 1) > 0) { @@ -389,8 +243,6 @@ namespace IceInternal } catch(Ice.UnknownException ex) { - _is.endReadEncaps(); - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Dispatch", 1) > 0) { @@ -414,8 +266,6 @@ namespace IceInternal } catch(Ice.LocalException ex) { - _is.endReadEncaps(); - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Dispatch", 1) > 0) { @@ -440,8 +290,6 @@ namespace IceInternal catch(Ice.UserException ex) { - _is.endReadEncaps(); - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Dispatch", 1) > 0) { @@ -466,8 +314,6 @@ namespace IceInternal catch(System.Exception ex) { - _is.endReadEncaps(); - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Dispatch", 1) > 0) { @@ -489,6 +335,160 @@ namespace IceInternal return; } + } + + protected internal Ice.Current current_; + protected internal Ice.Object servant_; + protected internal Ice.ServantLocator locator_; + protected internal Ice.LocalObject cookie_; + + protected internal bool response_; + protected internal byte compress_; + + protected internal BasicStream os_; + + protected Ice.ConnectionI connection_; + } + + sealed public class Incoming : IncomingBase + { + public Incoming(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, + bool response, byte compress, int requestId) + : base(instance, connection, adapter, response, compress, requestId) + { + _is = new BasicStream(instance); + } + + // + // These functions allow this object to be reused, rather than reallocated. + // + public override void reset(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, + bool response, byte compress, int requestId) + { + if(_is == null) + { + _is = new BasicStream(instance); + } + + base.reset(instance, connection, adapter, response, compress, requestId); + } + + public override void reclaim() + { + if(_is != null) + { + _is.reset(); + } + + base.reclaim(); + } + + public void invoke(ServantManager servantManager) + { + // + // Read the current. + // + current_.id.read__(_is); + + // + // For compatibility with the old FacetPath. + // + string[] facetPath = _is.readStringSeq(); + if(facetPath.Length > 0) + { + if(facetPath.Length > 1) + { + throw new Ice.MarshalException(); + } + current_.facet = facetPath[0]; + } + else + { + current_.facet = ""; + } + + current_.operation = _is.readString(); + current_.mode = (Ice.OperationMode)(int)_is.readByte(); + int sz = _is.readSize(); + while(sz-- > 0) + { + string first = _is.readString(); + string second = _is.readString(); + if(current_.ctx == null) + { + current_.ctx = new Ice.Context(); + } + current_.ctx[first] = second; + } + + _is.startReadEncaps(); + + if(response_) + { + Debug.Assert(os_.size() == Protocol.headerSize + 4); // Dispatch status position. + os_.writeByte((byte)0); + os_.startWriteEncaps(); + } + + // Initialize status to some value, to keep the compiler happy. + DispatchStatus status = DispatchStatus.DispatchOK; + + // + // Don't put the code above into the try block below. Exceptions + // in the code above are considered fatal, and must propagate to + // the caller of this operation. + // + + try + { + try + { + if(servantManager != null) + { + servant_ = servantManager.findServant(current_.id, current_.facet); + if(servant_ == null) + { + locator_ = servantManager.findServantLocator(current_.id.category); + if(locator_ == null && current_.id.category.Length > 0) + { + locator_ = servantManager.findServantLocator(""); + } + if(locator_ != null) + { + servant_ = locator_.locate(current_, out cookie_); + } + } + } + if(servant_ == null) + { + if(servantManager != null && servantManager.hasServant(current_.id)) + { + status = DispatchStatus.DispatchFacetNotExist; + } + else + { + status = DispatchStatus.DispatchObjectNotExist; + } + } + else + { + status = servant_.dispatch__(this, current_); + } + } + finally + { + if(locator_ != null && servant_ != null && status != DispatchStatus.DispatchAsync) + { + locator_.finished(current_, servant_, cookie_); + } + } + } + catch(System.Exception ex) + { + _is.endReadEncaps(); + handleException__(ex); + return; + } // // Don't put the code below into the try block above. Exceptions diff --git a/cs/src/Ice/IncomingAsync.cs b/cs/src/Ice/IncomingAsync.cs index 412729398d7..c77e4f4851e 100755 --- a/cs/src/Ice/IncomingAsync.cs +++ b/cs/src/Ice/IncomingAsync.cs @@ -23,9 +23,9 @@ namespace IceInternal { try { - if(locator_ != null && servant_ != null) + if(!servantLocatorFinished__()) { - locator_.finished(current_, servant_, cookie_); + return; } if(response_) @@ -55,13 +55,7 @@ namespace IceInternal } catch(Ice.LocalException ex) { - connection_.exception(ex); - } - catch(System.Exception ex) - { - Ice.UnknownException uex = new Ice.UnknownException(); - uex.unknown = ex.ToString(); - connection_.exception(uex); + connection_.invokeException(ex, 1); } } @@ -69,218 +63,16 @@ namespace IceInternal { try { - if(locator_ != null && servant_ != null) + if(!servantLocatorFinished__()) { - locator_.finished(current_, servant_, cookie_); + return; } - try - { - throw exc; - } - catch(Ice.RequestFailedException ex) - { - if(ex.id.name == null) - { - ex.id = current_.id; - } - - if(ex.facet == null) - { - ex.facet = current_.facet; - } - - if(ex.operation == null || ex.operation.Length == 0) - { - ex.operation = current_.operation; - } - - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 1) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - if(ex is Ice.ObjectNotExistException) - { - os_.writeByte((byte)DispatchStatus.DispatchObjectNotExist); - } - else if(ex is Ice.FacetNotExistException) - { - os_.writeByte((byte)DispatchStatus.DispatchFacetNotExist); - } - else if(ex is Ice.OperationNotExistException) - { - os_.writeByte((byte)DispatchStatus.DispatchOperationNotExist); - } - else - { - Debug.Assert(false); - } - ex.id.write__(os_); - - // - // For compatibility with the old FacetPath. - // - if(ex.facet == null || ex.facet.Length == 0) - { - os_.writeStringSeq(null); - } - else - { - string[] facetPath = { ex.facet }; - os_.writeStringSeq(facetPath); - } - - os_.writeString(ex.operation); - - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } - catch(Ice.UnknownLocalException ex) - { - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - os_.writeByte((byte)DispatchStatus.DispatchUnknownLocalException); - os_.writeString(ex.unknown); - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } - catch(Ice.UnknownUserException ex) - { - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - os_.writeByte((byte)DispatchStatus.DispatchUnknownUserException); - os_.writeString(ex.unknown); - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } - catch(Ice.UnknownException ex) - { - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - os_.writeByte((byte)DispatchStatus.DispatchUnknownException); - os_.writeString(ex.unknown); - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } - catch(Ice.LocalException ex) - { - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - os_.writeByte((byte)DispatchStatus.DispatchUnknownLocalException); - os_.writeString(ex.ToString()); - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } - catch(Ice.UserException ex) - { - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - os_.writeByte((byte)DispatchStatus.DispatchUnknownUserException); - os_.writeString(ex.ToString()); - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } - catch(System.Exception ex) - { - if(os_.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - warning__(ex); - } - - if(response_) - { - os_.endWriteEncaps(); - os_.resize(Protocol.headerSize + 4, false); // Dispatch status position. - os_.writeByte((byte)DispatchStatus.DispatchUnknownException); - os_.writeString(ex.ToString()); - connection_.sendResponse(os_, compress_); - } - else - { - connection_.sendNoResponse(); - } - } + handleException__(exc); } catch(Ice.LocalException ex) { - connection_.exception(ex); - } - catch(System.Exception ex) - { - Ice.UnknownException uex = new Ice.UnknownException(); - uex.unknown = ex.ToString(); - connection_.exception(uex); + connection_.invokeException(ex, 1); } } @@ -288,6 +80,23 @@ namespace IceInternal { return os_; } + + private bool servantLocatorFinished__() + { + try + { + if(locator_ != null && servant_ != null) + { + locator_.finished(current_, servant_, cookie_); + } + return true; + } + catch(System.Exception ex) + { + handleException__(ex); + return false; + } + } } } diff --git a/cs/test/Ice/Makefile b/cs/test/Ice/Makefile index 1f16f817680..9c3a7db182d 100644 --- a/cs/test/Ice/Makefile +++ b/cs/test/Ice/Makefile @@ -26,7 +26,8 @@ SUBDIRS = application \ checksum \ stream \ retry \ - timeout + timeout \ + servantLocator $(EVERYTHING):: @for subdir in $(SUBDIRS); \ diff --git a/cs/test/Ice/servantLocator/AllTests.cs b/cs/test/Ice/servantLocator/AllTests.cs new file mode 100755 index 00000000000..66754cd5c8b --- /dev/null +++ b/cs/test/Ice/servantLocator/AllTests.cs @@ -0,0 +1,187 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +using System; +using Test; +using Ice; + +public class AllTests +{ + private static void test(bool b) + { + if(!b) + { + throw new System.Exception(); + } + } + + public static void testExceptions(TestIntfPrx obj, bool collocated) + { + try + { + obj.requestFailedException(); + test(false); + } + catch(ObjectNotExistException ex) + { + if(!collocated) + { + test(ex.id.Equals(obj.ice_getIdentity())); + test(ex.facet.Equals(obj.ice_getFacet())); + test(ex.operation.Equals("requestFailedException")); + } + } + + try + { + obj.unknownUserException(); + test(false); + } + catch(UnknownUserException ex) + { + test(ex.unknown.Equals("reason")); + } + + try + { + obj.unknownLocalException(); + test(false); + } + catch(UnknownLocalException ex) + { + test(ex.unknown.Equals("reason")); + } + + try + { + obj.unknownException(); + test(false); + } + catch(UnknownException ex) + { + test(ex.unknown.Equals("reason")); + } + + try + { + obj.userException(); + test(false); + } + catch(UnknownUserException ex) + { + //Console.Error.WriteLine(ex.unknown); + test(!collocated); + test(ex.unknown.IndexOf("Test.TestIntfUserException") >= 0); + } + catch(TestIntfUserException) + { + test(collocated); + } + + try + { + obj.localException(); + test(false); + } + catch(UnknownLocalException ex) + { + //Console.Error.WriteLine(ex.unknown); + test(!collocated); + test(ex.unknown.IndexOf("Ice.SocketException") >= 0); + } + catch(SocketException) + { + test(collocated); + } + + try + { + obj.csException(); + test(false); + } + catch(UnknownException ex) + { + //Console.Error.WriteLine(ex.unknown); + test(!collocated); + test(ex.unknown.IndexOf("System.Exception: message") >= 0); + } + catch(System.Exception) + { + test(collocated); + } + } + + public static TestIntfPrx allTests(Ice.Communicator communicator, bool collocated) + { + Console.Out.Write("testing stringToProxy... "); + Console.Out.Flush(); + string @ref = "asm:default -p 12010 -t 2000"; + Ice.ObjectPrx @base = communicator.stringToProxy(@ref); + test(@base != null); + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing checked cast... "); + Console.Out.Flush(); + TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base); + test(obj != null); + test(obj.Equals(@base)); + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing servant locator..."); + Console.Out.Flush(); + @base = communicator.stringToProxy("category/locate:default -p 12010 -t 10000"); + obj = TestIntfPrxHelper.checkedCast(@base); + try + { + TestIntfPrxHelper.checkedCast(communicator.stringToProxy("category/unknown:default -p 12010 -t 10000")); + } + catch(ObjectNotExistException) + { + } + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing default servant locator..."); + Console.Out.Flush(); + @base = communicator.stringToProxy("anothercat/locate:default -p 12010 -t 10000"); + obj = TestIntfPrxHelper.checkedCast(@base); + @base = communicator.stringToProxy("locate:default -p 12010 -t 10000"); + obj = TestIntfPrxHelper.checkedCast(@base); + try + { + TestIntfPrxHelper.checkedCast(communicator.stringToProxy("anothercat/unknown:default -p 12010 -t 10000")); + } + catch(ObjectNotExistException) + { + } + try + { + TestIntfPrxHelper.checkedCast(communicator.stringToProxy("unknown:default -p 12010 -t 10000")); + } + catch(ObjectNotExistException) + { + } + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing locate exceptions... "); + Console.Out.Flush(); + @base = communicator.stringToProxy("category/locate:default -p 12010 -t 10000"); + obj = TestIntfPrxHelper.checkedCast(@base); + testExceptions(obj, collocated); + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing finished exceptions... "); + Console.Out.Flush(); + @base = communicator.stringToProxy("category/finished:default -p 12010 -t 10000"); + obj = TestIntfPrxHelper.checkedCast(@base); + testExceptions(obj, collocated); + Console.Out.WriteLine("ok"); + + return obj; + } +} diff --git a/cs/test/Ice/servantLocator/Client.cs b/cs/test/Ice/servantLocator/Client.cs new file mode 100755 index 00000000000..e926daaf993 --- /dev/null +++ b/cs/test/Ice/servantLocator/Client.cs @@ -0,0 +1,33 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +using Test; + +public class Client +{ + internal class TestClient : Ice.Application + { + public override int run(string[] args) + { + TestIntfPrx obj = AllTests.allTests(communicator(), false); + obj.shutdown(); + return 0; + } + } + + public static void Main(string[] args) + { + TestClient app = new TestClient(); + int result = app.main(args); + if(result != 0) + { + System.Environment.Exit(result); + } + } +} diff --git a/cs/test/Ice/servantLocator/Collocated.cs b/cs/test/Ice/servantLocator/Collocated.cs new file mode 100755 index 00000000000..fcb518de41f --- /dev/null +++ b/cs/test/Ice/servantLocator/Collocated.cs @@ -0,0 +1,41 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +using Test; + +public class Collocated +{ + internal class TestClient : Ice.Application + { + public override int run(string[] args) + { + communicator().getProperties().setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000"); + communicator().getProperties().setProperty("Ice.Warn.Dispatch", "0"); + + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter"); + adapter.addServantLocator(new ServantLocatorI("category"), "category"); + adapter.addServantLocator(new ServantLocatorI(""), ""); + adapter.add(new TestI(), communicator().stringToIdentity("asm")); + + AllTests.allTests(communicator(), true); + + return 0; + } + } + + public static void Main(string[] args) + { + TestClient app = new TestClient(); + int result = app.main(args); + if(result != 0) + { + System.Environment.Exit(result); + } + } +} diff --git a/cs/test/Ice/servantLocator/CookieI.cs b/cs/test/Ice/servantLocator/CookieI.cs new file mode 100755 index 00000000000..f225eac92bb --- /dev/null +++ b/cs/test/Ice/servantLocator/CookieI.cs @@ -0,0 +1,18 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +using Test; + +public sealed class CookieI : Cookie +{ + public override string message() + { + return "blahblah"; + } +} diff --git a/cs/test/Ice/servantLocator/Makefile b/cs/test/Ice/servantLocator/Makefile new file mode 100644 index 00000000000..522ef811e98 --- /dev/null +++ b/cs/test/Ice/servantLocator/Makefile @@ -0,0 +1,44 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2007 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. +# +# ********************************************************************** + +top_srcdir = ../../.. + +TARGETS = client.exe server.exe serveramd.exe collocated.exe + +C_SRCS = Client.cs AllTests.cs +S_SRCS = Server.cs CookieI.cs ServantLocatorI.cs TestI.cs +COL_SRCS = Collocated.cs AllTests.cs CookieI.cs ServantLocatorI.cs TestI.cs +SAMD_SRCS = Server.cs CookieI.cs ServantLocatorI.cs TestAMDI.cs + +SLICE_SRCS = $(SDIR)/Test.ice +SLICE_AMD_SRCS = $(SDIR)/TestAMD.ice + +SDIR = . + +GDIR = generated + +include $(top_srcdir)/config/Make.rules.cs + +MCSFLAGS := $(MCSFLAGS) -target:exe + +SLICE2CSFLAGS := $(SLICE2CSFLAGS) -I. + +client.exe: $(C_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ $(call ref,icecs) $(subst /,$(DSEP),$^) + +server.exe: $(S_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ $(call ref,icecs) $(subst /,$(DSEP),$^) + +collocated.exe: $(COL_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ $(call ref,icecs) $(subst /,$(DSEP),$^) + +serveramd.exe: $(SAMD_SRCS) $(GEN_AMD_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ $(call ref,icecs) $(subst /,$(DSEP),$^) + +include .depend diff --git a/cs/test/Ice/servantLocator/Makefile.mak b/cs/test/Ice/servantLocator/Makefile.mak new file mode 100644 index 00000000000..2f95cdcc1d0 --- /dev/null +++ b/cs/test/Ice/servantLocator/Makefile.mak @@ -0,0 +1,39 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2007 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. +# +# ********************************************************************** + +top_srcdir = ..\..\.. + +TARGETS = client.exe server.exe collocated.exe + +C_SRCS = Client.cs AllTests.cs +S_SRCS = Server.cs CookieI.cs ServantLocatorI.cs TestI.cs +COL_SRCS = Collocated.cs AllTests.cs CookieI.cs ServantLocatorI.cs TestI.cs + +GEN_SRCS = $(GDIR)\Test.cs + +SDIR = . + +GDIR = generated + +!include $(top_srcdir)\config\Make.rules.mak + +MCSFLAGS = $(MCSFLAGS) -target:exe + +SLICE2CSFLAGS = $(SLICE2CSFLAGS) -I. + +client.exe: $(C_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ -r:$(bindir)\icecs.dll $(C_SRCS) $(GEN_SRCS) + +server.exe: $(S_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ -r:$(bindir)\icecs.dll $(S_SRCS) $(GEN_SRCS) + +collocated.exe: $(COL_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ -r:$(bindir)\icecs.dll $(COL_SRCS) $(GEN_SRCS) + +!include .depend diff --git a/cs/test/Ice/servantLocator/ServantLocatorI.cs b/cs/test/Ice/servantLocator/ServantLocatorI.cs new file mode 100755 index 00000000000..1ebb6ae20f6 --- /dev/null +++ b/cs/test/Ice/servantLocator/ServantLocatorI.cs @@ -0,0 +1,135 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +using System; +using Test; +using Ice; + +public sealed class ServantLocatorI : Ice.LocalObjectImpl, Ice.ServantLocator +{ + public ServantLocatorI(String category) + { + _category = category; + _deactivated = false; + } + + ~ServantLocatorI() + { + lock(this) + { + test(_deactivated); + } + } + + private static void test(bool b) + { + if(!b) + { + throw new System.Exception(); + } + } + + public Ice.Object locate(Ice.Current current, out Ice.LocalObject cookie) + { + lock(this) + { + test(!_deactivated); + } + + test(current.id.category.Equals(_category) || _category.Length == 0); + + if(current.id.name.Equals("unknown")) + { + cookie = null; + return null; + } + + test(current.id.name.Equals("locate") || current.id.name.Equals("finished")); + if(current.id.name.Equals("locate")) + { + exception(current); + } + + cookie = new CookieI(); + + return new TestI(); + } + + public void finished(Ice.Current current, Ice.Object servant, Ice.LocalObject cookie) + { + lock(this) + { + test(!_deactivated); + } + + test(current.id.category.Equals(_category) || _category.Length == 0); + test(current.id.name.Equals("locate") || current.id.name.Equals("finished")); + + if(current.id.name.Equals("finished")) + { + exception(current); + } + + Cookie co = (Cookie) cookie; + test(co.message().Equals("blahblah")); + } + + public void deactivate(string category) + { + lock(this) + { + test(!_deactivated); + + _deactivated = true; + } + } + + private void exception(Ice.Current current) + { + if(current.operation.Equals("requestFailedException")) + { + throw new ObjectNotExistException(); + } + else if(current.operation.Equals("unknownUserException")) + { + UnknownUserException ex = new UnknownUserException(); + ex.unknown = "reason"; + throw ex; + } + else if(current.operation.Equals("unknownLocalException")) + { + UnknownLocalException ex = new UnknownLocalException(); + ex.unknown = "reason"; + throw ex; + } + else if(current.operation.Equals("unknownException")) + { + UnknownException ex = new UnknownException(); + ex.unknown = "reason"; + throw ex; + } + else if(current.operation.Equals("userException")) + { + throw new TestIntfUserException(); + } + else if(current.operation.Equals("localException")) + { + SocketException ex = new SocketException(); + ex.error = 0; + throw ex; + } + else if(current.operation.Equals("csException")) + { + throw new System.Exception("message"); + } + } + + private bool _deactivated; + private string _category; +} diff --git a/cs/test/Ice/servantLocator/Server.cs b/cs/test/Ice/servantLocator/Server.cs new file mode 100755 index 00000000000..6280e1373d4 --- /dev/null +++ b/cs/test/Ice/servantLocator/Server.cs @@ -0,0 +1,39 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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 class Server +{ + internal class TestServer : Ice.Application + { + public override int run(string[] args) + { + communicator().getProperties().setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 2000"); + communicator().getProperties().setProperty("Ice.Warn.Dispatch", "0"); + + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter"); + adapter.addServantLocator(new ServantLocatorI("category"), "category"); + adapter.addServantLocator(new ServantLocatorI(""), ""); + adapter.add(new TestI(), communicator().stringToIdentity("asm")); + + adapter.activate(); + adapter.waitForDeactivate(); + return 0; + } + } + + public static void Main(string[] args) + { + TestServer app = new TestServer(); + int result = app.main(args); + if(result != 0) + { + System.Environment.Exit(result); + } + } +} diff --git a/cs/test/Ice/servantLocator/Test.ice b/cs/test/Ice/servantLocator/Test.ice new file mode 100755 index 00000000000..82f3679d75f --- /dev/null +++ b/cs/test/Ice/servantLocator/Test.ice @@ -0,0 +1,40 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 + +module Test +{ + +exception TestIntfUserException +{ +}; + +interface TestIntf +{ + void requestFailedException(); + void unknownUserException(); + void unknownLocalException(); + void unknownException(); + void localException(); + void userException(); + void csException(); + + void shutdown(); +}; + +local class Cookie +{ + ["cpp:const"] string message(); +}; + +}; + +#endif diff --git a/cs/test/Ice/servantLocator/TestAMD.ice b/cs/test/Ice/servantLocator/TestAMD.ice new file mode 100644 index 00000000000..fdd81edd0db --- /dev/null +++ b/cs/test/Ice/servantLocator/TestAMD.ice @@ -0,0 +1,40 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 + +module Test +{ + +exception TestIntfUserException +{ +}; + +["amd"] interface TestIntf +{ + void requestFailedException(); + void unknownUserException(); + void unknownLocalException(); + void unknownException(); + void localException(); + void userException(); + void csException(); + + void shutdown(); +}; + +local class Cookie +{ + ["cpp:const"] string message(); +}; + +}; + +#endif diff --git a/cs/test/Ice/servantLocator/TestAMDI.cs b/cs/test/Ice/servantLocator/TestAMDI.cs new file mode 100644 index 00000000000..555c6ada355 --- /dev/null +++ b/cs/test/Ice/servantLocator/TestAMDI.cs @@ -0,0 +1,54 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +using Test; + +public sealed class TestI : TestIntfDisp_ +{ + public override void requestFailedException_async(AMD_TestIntf_requestFailedException cb, Ice.Current current) + { + cb.ice_response(); + } + + public override void unknownUserException_async(AMD_TestIntf_unknownUserException cb, Ice.Current current) + { + cb.ice_response(); + } + + public override void unknownLocalException_async(AMD_TestIntf_unknownLocalException cb, Ice.Current current) + { + cb.ice_response(); + } + + public override void unknownException_async(AMD_TestIntf_unknownException cb, Ice.Current current) + { + cb.ice_response(); + } + + public override void localException_async(AMD_TestIntf_localException cb, Ice.Current current) + { + cb.ice_response(); + } + + public override void userException_async(AMD_TestIntf_userException cb, Ice.Current current) + { + cb.ice_response(); + } + + public override void csException_async(AMD_TestIntf_csException cb, Ice.Current current) + { + cb.ice_response(); + } + + public override void shutdown_async(AMD_TestIntf_shutdown cb, Ice.Current current) + { + current.adapter.deactivate(); + cb.ice_response(); + } +} diff --git a/cs/test/Ice/servantLocator/TestI.cs b/cs/test/Ice/servantLocator/TestI.cs new file mode 100755 index 00000000000..85f67a82bf7 --- /dev/null +++ b/cs/test/Ice/servantLocator/TestI.cs @@ -0,0 +1,46 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +using Test; + +public sealed class TestI : TestIntfDisp_ +{ + public override void requestFailedException(Ice.Current current) + { + } + + public override void unknownUserException(Ice.Current current) + { + } + + public override void unknownLocalException(Ice.Current current) + { + } + + public override void unknownException(Ice.Current current) + { + } + + public override void localException(Ice.Current current) + { + } + + public override void userException(Ice.Current current) + { + } + + public override void csException(Ice.Current current) + { + } + + public override void shutdown(Ice.Current current) + { + current.adapter.deactivate(); + } +} diff --git a/cs/test/Ice/servantLocator/generated/.dummy b/cs/test/Ice/servantLocator/generated/.dummy new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/cs/test/Ice/servantLocator/generated/.dummy diff --git a/cs/test/Ice/servantLocator/run.py b/cs/test/Ice/servantLocator/run.py new file mode 100755 index 00000000000..f5d55842c4b --- /dev/null +++ b/cs/test/Ice/servantLocator/run.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 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, getopt + +for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")): + break +else: + raise "can't find toplevel directory!" + +sys.path.append(os.path.join(toplevel, "config")) +import TestUtil + +name = os.path.join("Ice", "servantLocator") + +print "tests with regular server." +TestUtil.clientServerTest(name) +print "tests with AMD server." +TestUtil.clientServerTestWithOptionsAndNames(name, "", "", "serveramd", "client") +print "tests with collocated server." +TestUtil.collocatedTest(name) + +sys.exit(0) diff --git a/java/allTests.py b/java/allTests.py index 6b0a3e960bf..2b73738e008 100755 --- a/java/allTests.py +++ b/java/allTests.py @@ -90,7 +90,10 @@ tests = [ \ "Ice/checksum", \ "Ice/package", \ "Ice/stream", \ + "Ice/hold", \ "Ice/retry", \ + "Ice/timeout", \ + "Ice/servantLocator", \ "Freeze/dbmap", \ "Freeze/complex", \ "Freeze/evictor", \ diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java index d9ba8889fa9..7dedaa5b00a 100644 --- a/java/src/Ice/ConnectionI.java +++ b/java/src/Ice/ConnectionI.java @@ -1416,6 +1416,28 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne setState(StateClosed, ex); } + public synchronized void + invokeException(LocalException ex, int invokeNum) + { + // + // Fatal exception while invoking a request. Since sendResponse/sendNoResponse isn't + // called in case of a fatal exception we decrement _dispatchCount here. + // + + setState(StateClosed, ex); + + if(invokeNum > 0) + { + assert(_dispatchCount > 0); + _dispatchCount -= invokeNum; + assert(_dispatchCount >= 0); + if(_dispatchCount == 0) + { + notifyAll(); + } + } + } + public String type() { @@ -2189,37 +2211,18 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } catch(LocalException ex) { - synchronized(this) - { - setState(StateClosed, ex); - } + invokeException(ex, invokeNum); } catch(java.lang.AssertionError ex) // Upon assertion, we print the stack trace. { - synchronized(this) - { - UnknownException uex = new UnknownException(); - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - ex.printStackTrace(pw); - pw.flush(); - uex.unknown = sw.toString(); - _logger.error(uex.unknown); - setState(StateClosed, uex); - } - } - catch(java.lang.Exception ex) - { - synchronized(this) - { - UnknownException uex = new UnknownException(); - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - ex.printStackTrace(pw); - pw.flush(); - uex.unknown = sw.toString(); - setState(StateClosed, uex); - } + UnknownException uex = new UnknownException(); + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + uex.unknown = sw.toString(); + _logger.error(uex.unknown); + invokeException(uex, invokeNum); } finally { @@ -2228,25 +2231,6 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne reclaimIncoming(in); } } - - // - // If invoke() above raised an exception, and therefore - // neither sendResponse() nor sendNoResponse() has been - // called, then we must decrement _dispatchCount here. - // - if(invokeNum > 0) - { - synchronized(this) - { - assert(_dispatchCount > 0); - _dispatchCount -= invokeNum; - assert(_dispatchCount >= 0); - if(_dispatchCount == 0) - { - notifyAll(); - } - } - } } private void diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java index 70615982807..8b8b1f1619a 100644 --- a/java/src/IceInternal/Incoming.java +++ b/java/src/IceInternal/Incoming.java @@ -155,177 +155,6 @@ final public class Incoming extends IncomingBase } } } - catch(Ice.RequestFailedException ex) - { - _is.endReadEncaps(); - - if(ex.id == null) - { - ex.id = _current.id; - } - - if(ex.facet == null) - { - ex.facet = _current.facet; - } - - if(ex.operation == null || ex.operation.length() == 0) - { - ex.operation = _current.operation; - } - - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - if(ex instanceof Ice.ObjectNotExistException) - { - _os.writeByte((byte)DispatchStatus._DispatchObjectNotExist); - } - else if(ex instanceof Ice.FacetNotExistException) - { - _os.writeByte((byte)DispatchStatus._DispatchFacetNotExist); - } - else if(ex instanceof Ice.OperationNotExistException) - { - _os.writeByte((byte)DispatchStatus._DispatchOperationNotExist); - } - else - { - assert(false); - } - ex.id.__write(_os); - - // - // For compatibility with the old FacetPath. - // - if(ex.facet == null || ex.facet.length() == 0) - { - _os.writeStringSeq(null); - } - else - { - String[] facetPath2 = { ex.facet }; - _os.writeStringSeq(facetPath2); - } - - _os.writeString(ex.operation); - - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } - - return; - } - catch(Ice.UnknownLocalException ex) - { - _is.endReadEncaps(); - - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - _os.writeByte((byte)DispatchStatus._DispatchUnknownLocalException); - _os.writeString(ex.unknown); - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } - - return; - } - catch(Ice.UnknownUserException ex) - { - _is.endReadEncaps(); - - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - _os.writeByte((byte)DispatchStatus._DispatchUnknownUserException); - _os.writeString(ex.unknown); - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } - - return; - } - catch(Ice.UnknownException ex) - { - _is.endReadEncaps(); - - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - _os.writeByte((byte)DispatchStatus._DispatchUnknownException); - _os.writeString(ex.unknown); - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } - - return; - } - catch(Ice.LocalException ex) - { - _is.endReadEncaps(); - - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - _os.writeByte((byte)DispatchStatus._DispatchUnknownLocalException); - //_os.writeString(ex.toString()); - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - ex.printStackTrace(pw); - pw.flush(); - _os.writeString(sw.toString()); - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } - - return; - } /* Not possible in Java - UserExceptions are checked exceptions catch(Ice.UserException ex) { @@ -335,30 +164,7 @@ final public class Incoming extends IncomingBase catch(java.lang.Exception ex) { _is.endReadEncaps(); - - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - _os.writeByte((byte)DispatchStatus._DispatchUnknownException); - //_os.writeString(ex.toString()); - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - ex.printStackTrace(pw); - pw.flush(); - _os.writeString(sw.toString()); - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } - + __handleException(ex); return; } diff --git a/java/src/IceInternal/IncomingAsync.java b/java/src/IceInternal/IncomingAsync.java index e8e891b49f0..7a7bb90678f 100644 --- a/java/src/IceInternal/IncomingAsync.java +++ b/java/src/IceInternal/IncomingAsync.java @@ -22,9 +22,9 @@ public class IncomingAsync extends IncomingBase { try { - if(_locator != null && _servant != null) + if(!__servantLocatorFinished()) { - _locator.finished(_current, _servant, _cookie.value); + return; } if(_response) @@ -54,18 +54,7 @@ public class IncomingAsync extends IncomingBase } catch(Ice.LocalException ex) { - _connection.exception(ex); - } - catch(java.lang.Exception ex) - { - Ice.UnknownException uex = new Ice.UnknownException(); - //uex.unknown = ex.toString(); - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - ex.printStackTrace(pw); - pw.flush(); - uex.unknown = sw.toString(); - _connection.exception(uex); + _connection.invokeException(ex, 1); } } @@ -74,239 +63,35 @@ public class IncomingAsync extends IncomingBase { try { - if(_locator != null && _servant != null) - { - _locator.finished(_current, _servant, _cookie.value); - } - - try - { - throw exc; - } - catch(Ice.RequestFailedException ex) - { - if(ex.id == null) - { - ex.id = _current.id; - } - - if(ex.facet == null) - { - ex.facet = _current.facet; - } - - if(ex.operation == null || ex.operation.length() == 0) - { - ex.operation = _current.operation; - } - - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 1) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - if(ex instanceof Ice.ObjectNotExistException) - { - _os.writeByte((byte)DispatchStatus._DispatchObjectNotExist); - } - else if(ex instanceof Ice.FacetNotExistException) - { - _os.writeByte((byte)DispatchStatus._DispatchFacetNotExist); - } - else if(ex instanceof Ice.OperationNotExistException) - { - _os.writeByte((byte)DispatchStatus._DispatchOperationNotExist); - } - else - { - assert(false); - } - ex.id.__write(_os); - - // - // For compatibility with the old FacetPath. - // - if(ex.facet == null || ex.facet.length() == 0) - { - _os.writeStringSeq(null); - } - else - { - String[] facetPath = { ex.facet }; - _os.writeStringSeq(facetPath); - } - - _os.writeString(ex.operation); - - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } - } - catch(Ice.UnknownLocalException ex) - { - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - _os.writeByte((byte)DispatchStatus._DispatchUnknownLocalException); - _os.writeString(ex.unknown); - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } - } - catch(Ice.UnknownUserException ex) - { - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - _os.writeByte((byte)DispatchStatus._DispatchUnknownUserException); - _os.writeString(ex.unknown); - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } - } - catch(Ice.UnknownException ex) - { - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - _os.writeByte((byte)DispatchStatus._DispatchUnknownException); - _os.writeString(ex.unknown); - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } - } - catch(Ice.LocalException ex) - { - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - _os.writeByte((byte)DispatchStatus._DispatchUnknownLocalException); - //_os.writeString(ex.toString()); - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - ex.printStackTrace(pw); - pw.flush(); - _os.writeString(sw.toString()); - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } - } - catch(Ice.UserException ex) + if(!__servantLocatorFinished()) { - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - __warning(ex); - } - - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - _os.writeByte((byte)DispatchStatus._DispatchUnknownUserException); - //_os.writeString(ex.toString()); - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - ex.printStackTrace(pw); - pw.flush(); - _os.writeString(sw.toString()); - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } + return; } - catch(java.lang.Exception ex) - { - if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.Warn.Dispatch", 1) > 0) - { - __warning(ex); - } - if(_response) - { - _os.endWriteEncaps(); - _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. - _os.writeByte((byte)DispatchStatus._DispatchUnknownException); - //_os.writeString(ex.toString()); - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - ex.printStackTrace(pw); - pw.flush(); - _os.writeString(sw.toString()); - _connection.sendResponse(_os, _compress); - } - else - { - _connection.sendNoResponse(); - } - } + __handleException(exc); } catch(Ice.LocalException ex) { - _connection.exception(ex); + _connection.invokeException(ex, 1); } - catch(java.lang.Exception ex) + } + + final private boolean + __servantLocatorFinished() + { + try { - Ice.UnknownException uex = new Ice.UnknownException(); - //uex.unknown = ex.toString(); - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - ex.printStackTrace(pw); - pw.flush(); - uex.unknown = sw.toString(); - _connection.exception(uex); + if(_locator != null && _servant != null) + { + _locator.finished(_current, _servant, _cookie.value); + } + return true; } + catch(java.lang.Exception ex) + { + __handleException(ex); + return false; + } } final protected BasicStream diff --git a/java/src/IceInternal/IncomingBase.java b/java/src/IceInternal/IncomingBase.java index 0f6908502b1..98b6777ed05 100644 --- a/java/src/IceInternal/IncomingBase.java +++ b/java/src/IceInternal/IncomingBase.java @@ -128,6 +128,216 @@ public class IncomingBase _os.instance().initializationData().logger.warning(sw.toString()); } + final protected void + __handleException(java.lang.Exception exc) + { + try + { + throw exc; + } + catch(Ice.RequestFailedException ex) + { + if(ex.id == null) + { + ex.id = _current.id; + } + + if(ex.facet == null) + { + ex.facet = _current.facet; + } + + if(ex.operation == null || ex.operation.length() == 0) + { + ex.operation = _current.operation; + } + + if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1) + { + __warning(ex); + } + + if(_response) + { + _os.endWriteEncaps(); + _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. + if(ex instanceof Ice.ObjectNotExistException) + { + _os.writeByte((byte)DispatchStatus._DispatchObjectNotExist); + } + else if(ex instanceof Ice.FacetNotExistException) + { + _os.writeByte((byte)DispatchStatus._DispatchFacetNotExist); + } + else if(ex instanceof Ice.OperationNotExistException) + { + _os.writeByte((byte)DispatchStatus._DispatchOperationNotExist); + } + else + { + assert(false); + } + ex.id.__write(_os); + + // + // For compatibility with the old FacetPath. + // + if(ex.facet == null || ex.facet.length() == 0) + { + _os.writeStringSeq(null); + } + else + { + String[] facetPath2 = { ex.facet }; + _os.writeStringSeq(facetPath2); + } + + _os.writeString(ex.operation); + + _connection.sendResponse(_os, _compress); + } + else + { + _connection.sendNoResponse(); + } + } + catch(Ice.UnknownLocalException ex) + { + if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + { + __warning(ex); + } + + if(_response) + { + _os.endWriteEncaps(); + _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. + _os.writeByte((byte)DispatchStatus._DispatchUnknownLocalException); + _os.writeString(ex.unknown); + _connection.sendResponse(_os, _compress); + } + else + { + _connection.sendNoResponse(); + } + } + catch(Ice.UnknownUserException ex) + { + if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + { + __warning(ex); + } + + if(_response) + { + _os.endWriteEncaps(); + _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. + _os.writeByte((byte)DispatchStatus._DispatchUnknownUserException); + _os.writeString(ex.unknown); + _connection.sendResponse(_os, _compress); + } + else + { + _connection.sendNoResponse(); + } + } + catch(Ice.UnknownException ex) + { + if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + { + __warning(ex); + } + + if(_response) + { + _os.endWriteEncaps(); + _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. + _os.writeByte((byte)DispatchStatus._DispatchUnknownException); + _os.writeString(ex.unknown); + _connection.sendResponse(_os, _compress); + } + else + { + _connection.sendNoResponse(); + } + } + catch(Ice.LocalException ex) + { + if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + { + __warning(ex); + } + + if(_response) + { + _os.endWriteEncaps(); + _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. + _os.writeByte((byte)DispatchStatus._DispatchUnknownLocalException); + //_os.writeString(ex.toString()); + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + _os.writeString(sw.toString()); + _connection.sendResponse(_os, _compress); + } + else + { + _connection.sendNoResponse(); + } + } + catch(Ice.UserException ex) + { + if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + { + __warning(ex); + } + + if(_response) + { + _os.endWriteEncaps(); + _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. + _os.writeByte((byte)DispatchStatus._DispatchUnknownUserException); + //_os.writeString(ex.toString()); + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + _os.writeString(sw.toString()); + _connection.sendResponse(_os, _compress); + } + else + { + _connection.sendNoResponse(); + } + } + catch(java.lang.Exception ex) + { + if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + { + __warning(ex); + } + + if(_response) + { + _os.endWriteEncaps(); + _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. + _os.writeByte((byte)DispatchStatus._DispatchUnknownException); + //_os.writeString(ex.toString()); + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + _os.writeString(sw.toString()); + _connection.sendResponse(_os, _compress); + } + else + { + _connection.sendNoResponse(); + } + } + } + protected Ice.Current _current; protected Ice.Object _servant; protected Ice.ServantLocator _locator; diff --git a/java/test/Ice/build.xml b/java/test/Ice/build.xml index bdcdfa92e18..755ac9195df 100644 --- a/java/test/Ice/build.xml +++ b/java/test/Ice/build.xml @@ -32,6 +32,8 @@ <ant dir="stream"/> <ant dir="retry"/> <ant dir="timeout"/> + <ant dir="servantLocator"/> + <ant dir="servantLocatorAMD"/> </target> <target name="clean"> diff --git a/java/test/Ice/servantLocator/AllTests.java b/java/test/Ice/servantLocator/AllTests.java new file mode 100644 index 00000000000..e4ee71a9e16 --- /dev/null +++ b/java/test/Ice/servantLocator/AllTests.java @@ -0,0 +1,192 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 Test.*; +import Ice.*; + +public class AllTests +{ + private static void + test(boolean b) + { + if(!b) + { + throw new RuntimeException(); + } + } + + public static void + testExceptions(TestIntfPrx obj, boolean collocated) + { + try + { + obj.requestFailedException(); + test(false); + } + catch(ObjectNotExistException ex) + { + if(!collocated) + { + test(ex.id.equals(obj.ice_getIdentity())); + test(ex.facet.equals(obj.ice_getFacet())); + test(ex.operation.equals("requestFailedException")); + } + } + + try + { + obj.unknownUserException(); + test(false); + } + catch(UnknownUserException ex) + { + test(ex.unknown.equals("reason")); + } + + try + { + obj.unknownLocalException(); + test(false); + } + catch(UnknownLocalException ex) + { + test(ex.unknown.equals("reason")); + } + + try + { + obj.unknownException(); + test(false); + } + catch(UnknownException ex) + { + test(ex.unknown.equals("reason")); + } + + // + // User exceptions are checked exceptions + // +// try +// { +// obj.userException(); +// test(false); +// } +// catch(UnknownUserException ex) +// { +// //System.err.println(ex.unknown); +// test(!collocated); +// test(ex.unknown.equals("Test::TestIntfUserException")); +// } +// catch(TestIntfUserException ex) +// { +// test(collocated); +// } + + try + { + obj.localException(); + test(false); + } + catch(UnknownLocalException ex) + { + //System.err.println(ex.unknown); + test(!collocated); + test(ex.unknown.indexOf("Ice.SocketException") >= 0); + } + catch(SocketException ex) + { + test(collocated); + } + + try + { + obj.javaException(); + test(false); + } + catch(UnknownException ex) + { + //System.err.println(ex.unknown); + test(!collocated); + test(ex.unknown.indexOf("java.lang.RuntimeException: message") >= 0); + } + catch(java.lang.RuntimeException ex) + { + test(collocated); + } + } + + public static TestIntfPrx + allTests(Ice.Communicator communicator, boolean collocated) + { + System.out.print("testing stringToProxy... "); + System.out.flush(); + String ref = "asm:default -p 12010 -t 10000"; + Ice.ObjectPrx base = communicator.stringToProxy(ref); + test(base != null); + System.out.println("ok"); + + System.out.print("testing checked cast... "); + System.out.flush(); + TestIntfPrx obj = TestIntfPrxHelper.checkedCast(base); + test(obj != null); + test(obj.equals(base)); + System.out.println("ok"); + + System.out.print("testing servant locator..."); + System.out.flush(); + base = communicator.stringToProxy("category/locate:default -p 12010 -t 10000"); + obj = TestIntfPrxHelper.checkedCast(base); + try + { + TestIntfPrxHelper.checkedCast(communicator.stringToProxy("category/unknown:default -p 12010 -t 10000")); + } + catch(ObjectNotExistException ex) + { + } + System.out.println("ok"); + + System.out.print("testing default servant locator..."); + System.out.flush(); + base = communicator.stringToProxy("anothercat/locate:default -p 12010 -t 10000"); + obj = TestIntfPrxHelper.checkedCast(base); + base = communicator.stringToProxy("locate:default -p 12010 -t 10000"); + obj = TestIntfPrxHelper.checkedCast(base); + try + { + TestIntfPrxHelper.checkedCast(communicator.stringToProxy("anothercat/unknown:default -p 12010 -t 10000")); + } + catch(ObjectNotExistException ex) + { + } + try + { + TestIntfPrxHelper.checkedCast(communicator.stringToProxy("unknown:default -p 12010 -t 10000")); + } + catch(ObjectNotExistException ex) + { + } + System.out.println("ok"); + + System.out.print("testing locate exceptions... "); + System.out.flush(); + base = communicator.stringToProxy("category/locate:default -p 12010 -t 10000"); + obj = TestIntfPrxHelper.checkedCast(base); + testExceptions(obj, collocated); + System.out.println("ok"); + + System.out.print("testing finished exceptions... "); + System.out.flush(); + base = communicator.stringToProxy("category/finished:default -p 12010 -t 10000"); + obj = TestIntfPrxHelper.checkedCast(base); + testExceptions(obj, collocated); + System.out.println("ok"); + + return obj; + } +} diff --git a/java/test/Ice/servantLocator/Client.java b/java/test/Ice/servantLocator/Client.java new file mode 100644 index 00000000000..403616d3c10 --- /dev/null +++ b/java/test/Ice/servantLocator/Client.java @@ -0,0 +1,33 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 Test.*; + +public class Client +{ + static class TestClient extends Ice.Application + { + public int + run(String[] args) + { + TestIntfPrx obj = AllTests.allTests(communicator(), false); + obj.shutdown(); + return 0; + } + } + + public static void + main(String[] args) + { + TestClient app = new TestClient(); + int result = app.main("Client", args); + System.gc(); + System.exit(result); + } +} diff --git a/java/test/Ice/servantLocator/CookieI.java b/java/test/Ice/servantLocator/CookieI.java new file mode 100644 index 00000000000..e754004a626 --- /dev/null +++ b/java/test/Ice/servantLocator/CookieI.java @@ -0,0 +1,19 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 Test.*; + +public final class CookieI extends Cookie +{ + public String + message() + { + return "blahblah"; + } +} diff --git a/java/test/Ice/servantLocator/ServantLocatorI.java b/java/test/Ice/servantLocator/ServantLocatorI.java new file mode 100644 index 00000000000..7fab16bfb87 --- /dev/null +++ b/java/test/Ice/servantLocator/ServantLocatorI.java @@ -0,0 +1,134 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 Test.*; +import Ice.*; + +public final class ServantLocatorI extends Ice.LocalObjectImpl implements Ice.ServantLocator +{ + public + ServantLocatorI(String category) + { + _category = category; + _deactivated = false; + } + + protected synchronized void + finalize() + throws Throwable + { + test(_deactivated); + } + + private static void + test(boolean b) + { + if(!b) + { + throw new RuntimeException(); + } + } + + public Ice.Object + locate(Ice.Current current, Ice.LocalObjectHolder cookie) + { + synchronized(this) + { + test(!_deactivated); + } + + test(current.id.category.equals(_category) || _category.length() == 0); + + if(current.id.name.equals("unknown")) + { + return null; + } + + test(current.id.name.equals("locate") || current.id.name.equals("finished")); + if(current.id.name.equals("locate")) + { + exception(current); + } + + cookie.value = new CookieI(); + + return new TestI(); + } + + public void + finished(Ice.Current current, Ice.Object servant, Ice.LocalObject cookie) + { + synchronized(this) + { + test(!_deactivated); + } + + test(current.id.category.equals(_category) || _category.length() == 0); + test(current.id.name.equals("locate") || current.id.name.equals("finished")); + + if(current.id.name.equals("finished")) + { + exception(current); + } + + Cookie co = (Cookie)cookie; + test(co.message().equals("blahblah")); + } + + public synchronized void + deactivate(String category) + { + synchronized(this) + { + test(!_deactivated); + + _deactivated = true; + } + } + + private void + exception(Ice.Current current) + { + if(current.operation.equals("requestFailedException")) + { + throw new ObjectNotExistException(); + } + else if(current.operation.equals("unknownUserException")) + { + throw new UnknownUserException("reason"); + } + else if(current.operation.equals("unknownLocalException")) + { + throw new UnknownLocalException("reason"); + } + else if(current.operation.equals("unknownException")) + { + throw new UnknownException("reason"); + } + // + // User exceptions are checked exceptions in Java, so it's not + // possible to throw it from the servant locator. + // +// else if(current.operation.equals("userException")) +// { +// throw new TestIntfUserException(); +// } + else if(current.operation.equals("localException")) + { + throw new SocketException(0); + } + else if(current.operation.equals("javaException")) + { + throw new java.lang.RuntimeException("message"); + } + } + + private boolean _deactivated; + private final String _category; +} diff --git a/java/test/Ice/servantLocator/Server.java b/java/test/Ice/servantLocator/Server.java new file mode 100644 index 00000000000..a6e9f74be45 --- /dev/null +++ b/java/test/Ice/servantLocator/Server.java @@ -0,0 +1,39 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 class Server +{ + static class TestServer extends Ice.Application + { + public int + run(String[] args) + { + communicator().getProperties().setProperty("Ice.OA.TestAdapter.Endpoints", "default -p 12010 -t 10000"); + communicator().getProperties().setProperty("Ice.Warn.Dispatch", "0"); + + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter"); + adapter.addServantLocator(new ServantLocatorI("category"), "category"); + adapter.addServantLocator(new ServantLocatorI(""), ""); + adapter.add(new TestI(), communicator().stringToIdentity("asm")); + + adapter.activate(); + adapter.waitForDeactivate(); + return 0; + } + } + + public static void + main(String[] args) + { + TestServer app = new TestServer(); + int result = app.main("Server", args); + System.gc(); + System.exit(result); + } +} diff --git a/java/test/Ice/servantLocator/Test.ice b/java/test/Ice/servantLocator/Test.ice new file mode 100644 index 00000000000..c32c7e89538 --- /dev/null +++ b/java/test/Ice/servantLocator/Test.ice @@ -0,0 +1,40 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 + +module Test +{ + +exception TestIntfUserException +{ +}; + +interface TestIntf +{ + void requestFailedException(); + void unknownUserException(); + void unknownLocalException(); + void unknownException(); + void localException(); + //void userException(); + void javaException(); + + void shutdown(); +}; + +local class Cookie +{ + ["cpp:const"] string message(); +}; + +}; + +#endif diff --git a/java/test/Ice/servantLocator/TestI.java b/java/test/Ice/servantLocator/TestI.java new file mode 100644 index 00000000000..15520733750 --- /dev/null +++ b/java/test/Ice/servantLocator/TestI.java @@ -0,0 +1,54 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 Test.*; + +public final class TestI extends _TestIntfDisp +{ + public void + requestFailedException(Ice.Current current) + { + } + + public void + unknownUserException(Ice.Current current) + { + } + + public void + unknownLocalException(Ice.Current current) + { + } + + public void + unknownException(Ice.Current current) + { + } + + public void + localException(Ice.Current current) + { + } + +// public void +// userException(Ice.Current current) +// { +// } + + public void + javaException(Ice.Current current) + { + } + + public void + shutdown(Ice.Current current) + { + current.adapter.deactivate(); + } +} diff --git a/java/test/Ice/servantLocator/build.xml b/java/test/Ice/servantLocator/build.xml new file mode 100644 index 00000000000..7989d984638 --- /dev/null +++ b/java/test/Ice/servantLocator/build.xml @@ -0,0 +1,48 @@ +<!-- + ********************************************************************** + + Copyright (c) 2003-2006 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. + + ********************************************************************** +--> + +<project name="test_Ice_servantLocator" default="all" basedir="."> + + <!-- set global properties for this build --> + <property name="top.dir" value="../../.."/> + + <!-- import common definitions --> + <import file="${top.dir}/config/common.xml"/> + + <target name="generate" depends="init"> + <!-- Create the output directory for generated code --> + <mkdir dir="${generated.dir}"/> + <slice2java outputdir="${generated.dir}"> + <meta value="${java5metadata}"/> + <fileset dir="." includes="Test.ice"/> + </slice2java> + </target> + + <target name="compile" depends="generate"> + <mkdir dir="${class.dir}"/> + <javac srcdir="${generated.dir}" destdir="${class.dir}" + source="${jdk.version}" classpath="${lib.dir}" debug="${debug}"> + <compilerarg value="${javac.lint}" compiler="${javac.lint.compiler}"/> + </javac> + <javac srcdir="." destdir="${class.dir}" source="${jdk.version}" + classpath="${lib.dir}" excludes="generated/**" debug="${debug}"> + <compilerarg value="${javac.lint}" compiler="${javac.lint.compiler}"/> + </javac> + </target> + + <target name="all" depends="compile"/> + + <target name="clean"> + <delete dir="${generated.dir}"/> + <delete dir="${class.dir}"/> + </target> + +</project> diff --git a/java/test/Ice/servantLocator/run.py b/java/test/Ice/servantLocator/run.py new file mode 100755 index 00000000000..3e6d59ec3a7 --- /dev/null +++ b/java/test/Ice/servantLocator/run.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2006 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 + +for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")): + break +else: + raise "can't find toplevel directory!" + +sys.path.append(os.path.join(toplevel, "config")) +import TestUtil + +name = os.path.join("Ice", "servantLocator") +nameAMD = os.path.join("Ice", "servantLocatorAMD") +testdir = os.path.join(toplevel, "test", name) +testdirAMD = os.path.join(toplevel, "test", nameAMD) +os.environ["CLASSPATH"] = os.path.join(testdir, "classes") + TestUtil.sep + os.getenv("CLASSPATH", "") + +# +# We need to use mixedClientServerTest so that, when using SSL, the +# server-side SSL configuration properties are defined. This is +# necessary because the client creates object adapters. +# +print "tests with regular server." +classpath = os.getenv("CLASSPATH", "") +TestUtil.mixedClientServerTest() + +print "tests with AMD server." +TestUtil.clientServerTestWithClasspath(\ + os.path.join(testdirAMD, "classes") + TestUtil.sep + classpath,\ + os.path.join(testdir, "classes") + TestUtil.sep + classpath) + +print "tests with collocated server." +TestUtil.collocatedTest() + +sys.exit(0) |