diff options
Diffstat (limited to 'java/test')
-rw-r--r-- | java/test/Ice/exceptions/AllTests.java | 73 | ||||
-rw-r--r-- | java/test/Ice/exceptions/DummyLogger.java | 31 | ||||
-rw-r--r-- | java/test/Ice/exceptions/Server.java | 9 | ||||
-rw-r--r-- | java/test/Ice/exceptions/Test.ice | 20 | ||||
-rw-r--r-- | java/test/Ice/exceptions/ThrowerI.java | 34 | ||||
-rw-r--r-- | java/test/Ice/exceptionsAMD/DummyLogger.java | 31 | ||||
-rw-r--r-- | java/test/Ice/exceptionsAMD/Server.java | 9 | ||||
-rw-r--r-- | java/test/Ice/exceptionsAMD/TestAMD.ice | 2 | ||||
-rw-r--r-- | java/test/Ice/exceptionsAMD/ThrowerI.java | 36 |
9 files changed, 201 insertions, 44 deletions
diff --git a/java/test/Ice/exceptions/AllTests.java b/java/test/Ice/exceptions/AllTests.java index 21d673c48dc..c13fd3e90ca 100644 --- a/java/test/Ice/exceptions/AllTests.java +++ b/java/test/Ice/exceptions/AllTests.java @@ -617,6 +617,40 @@ public class AllTests private Callback callback = new Callback(); } + private static class AMI_Thrower_throwAssertExceptionI extends AMI_Thrower_throwAssertException + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + try + { + throw exc; + } + catch(Ice.ConnectionLostException ex) + { + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + private static class AMI_WrongOperation_noSuchOperationI extends AMI_WrongOperation_noSuchOperation { public void @@ -962,6 +996,32 @@ public class AllTests System.out.println("ok"); } + if(thrower.supportsAssertException()) + { + System.out.print("testing assert in the server... "); + System.out.flush(); + + try + { + thrower.throwAssertException(); + test(false); + } + catch(java.lang.AssertionError ex) + { + assert(collocated); + } + catch(Ice.ConnectionLostException ex) + { + assert(!collocated); + } + catch(Exception ex) + { + test(false); + } + + System.out.println("ok"); + } + System.out.print("catching object not exist exception... "); System.out.flush(); @@ -1178,6 +1238,18 @@ public class AllTests System.out.println("ok"); } + if(thrower.supportsAssertException()) + { + System.out.print("testing assert in the server with AMI... "); + System.out.flush(); + + AMI_Thrower_throwAssertExceptionI cb = new AMI_Thrower_throwAssertExceptionI(); + thrower.throwAssertException_async(cb); + test(cb.check()); + + System.out.println("ok"); + } + System.out.print("catching object not exist exception with AMI... "); System.out.flush(); @@ -1241,7 +1313,6 @@ public class AllTests test(cb.check()); System.out.println("ok"); - } return thrower; diff --git a/java/test/Ice/exceptions/DummyLogger.java b/java/test/Ice/exceptions/DummyLogger.java new file mode 100644 index 00000000000..c5a0887d5dd --- /dev/null +++ b/java/test/Ice/exceptions/DummyLogger.java @@ -0,0 +1,31 @@ +// ********************************************************************** +// +// Copyright (c) 2003 +// ZeroC, Inc. +// Billerica, MA, USA +// +// All Rights Reserved. +// +// Ice is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License version 2 as published by +// the Free Software Foundation. +// +// ********************************************************************** + +public final class DummyLogger extends Ice.LocalObjectImpl implements Ice.Logger +{ + public void + trace(String category, String message) + { + } + + public void + warning(String message) + { + } + + public void + error(String message) + { + } +} diff --git a/java/test/Ice/exceptions/Server.java b/java/test/Ice/exceptions/Server.java index b768ecfa37a..ec835514335 100644 --- a/java/test/Ice/exceptions/Server.java +++ b/java/test/Ice/exceptions/Server.java @@ -17,8 +17,15 @@ public class Server private static int run(String[] args, Ice.Communicator communicator) { + // + // For this test, we need a dummy logger, otherwise the + // assertion test will print an error message. + // + communicator.setLogger(new DummyLogger()); + Ice.Properties properties = communicator.getProperties(); - properties.setProperty("Ice.Warn.Dispatch", "0"); + // We don't need to disable warnings, because we have a dummy logger. + //properties.setProperty("Ice.Warn.Dispatch", "0"); properties.setProperty("TestAdapter.Endpoints", "default -p 12345 -t 10000"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); Ice.Object object = new ThrowerI(adapter); diff --git a/java/test/Ice/exceptions/Test.ice b/java/test/Ice/exceptions/Test.ice index 095fa989cbc..2ac6482d3e7 100644 --- a/java/test/Ice/exceptions/Test.ice +++ b/java/test/Ice/exceptions/Test.ice @@ -41,23 +41,11 @@ exception D int dMem; }; -/* - * Generates code that cannot be compiled in Java. - * -module Mod -{ - exception A extends :: A - { - int a2Mem; - }; -}; - */ - - ["ami"] interface Thrower { void shutdown(); bool supportsUndeclaredExceptions(); + bool supportsAssertException(); void throwAasA(int a) throws A; void throwAorDasAorD(int a) throws A, D; @@ -67,16 +55,12 @@ module Mod void throwCasB(int a, int b, int c) throws B; void throwCasC(int a, int b, int c) throws C; - // - // Not supported in Java. - // - //void throwModA(int a, int a2) throws Mod::A; - void throwUndeclaredA(int a); void throwUndeclaredB(int a, int b); void throwUndeclaredC(int a, int b, int c); void throwLocalException(); void throwNonIceException(); + void throwAssertException(); }; ["ami"] interface WrongOperation diff --git a/java/test/Ice/exceptions/ThrowerI.java b/java/test/Ice/exceptions/ThrowerI.java index 3d653906ebf..227df0d45ce 100644 --- a/java/test/Ice/exceptions/ThrowerI.java +++ b/java/test/Ice/exceptions/ThrowerI.java @@ -32,6 +32,12 @@ public final class ThrowerI extends _ThrowerDisp return false; } + public boolean + supportsAssertException(Ice.Current current) + { + return true; + } + public void throwAasA(int a, Ice.Current current) throws A @@ -103,36 +109,42 @@ public final class ThrowerI extends _ThrowerDisp } public void - throwLocalException(Ice.Current current) + throwUndeclaredA(int a, Ice.Current current) { - throw new Ice.TimeoutException(); + // Not possible in Java. + throw new Ice.UnknownUserException(); } public void - throwNonIceException(Ice.Current current) + throwUndeclaredB(int a, int b, Ice.Current current) { - throw new RuntimeException(); + // Not possible in Java. + throw new Ice.UnknownUserException(); } public void - throwUndeclaredA(int a, Ice.Current current) + throwUndeclaredC(int a, int b, int c, Ice.Current current) { // Not possible in Java. throw new Ice.UnknownUserException(); } public void - throwUndeclaredB(int a, int b, Ice.Current current) + throwLocalException(Ice.Current current) { - // Not possible in Java. - throw new Ice.UnknownUserException(); + throw new Ice.TimeoutException(); } public void - throwUndeclaredC(int a, int b, int c, Ice.Current current) + throwNonIceException(Ice.Current current) { - // Not possible in Java. - throw new Ice.UnknownUserException(); + throw new RuntimeException(); + } + + public void + throwAssertException(Ice.Current current) + { + throw new java.lang.AssertionError(); } private Ice.ObjectAdapter _adapter; diff --git a/java/test/Ice/exceptionsAMD/DummyLogger.java b/java/test/Ice/exceptionsAMD/DummyLogger.java new file mode 100644 index 00000000000..c5a0887d5dd --- /dev/null +++ b/java/test/Ice/exceptionsAMD/DummyLogger.java @@ -0,0 +1,31 @@ +// ********************************************************************** +// +// Copyright (c) 2003 +// ZeroC, Inc. +// Billerica, MA, USA +// +// All Rights Reserved. +// +// Ice is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License version 2 as published by +// the Free Software Foundation. +// +// ********************************************************************** + +public final class DummyLogger extends Ice.LocalObjectImpl implements Ice.Logger +{ + public void + trace(String category, String message) + { + } + + public void + warning(String message) + { + } + + public void + error(String message) + { + } +} diff --git a/java/test/Ice/exceptionsAMD/Server.java b/java/test/Ice/exceptionsAMD/Server.java index b768ecfa37a..ec835514335 100644 --- a/java/test/Ice/exceptionsAMD/Server.java +++ b/java/test/Ice/exceptionsAMD/Server.java @@ -17,8 +17,15 @@ public class Server private static int run(String[] args, Ice.Communicator communicator) { + // + // For this test, we need a dummy logger, otherwise the + // assertion test will print an error message. + // + communicator.setLogger(new DummyLogger()); + Ice.Properties properties = communicator.getProperties(); - properties.setProperty("Ice.Warn.Dispatch", "0"); + // We don't need to disable warnings, because we have a dummy logger. + //properties.setProperty("Ice.Warn.Dispatch", "0"); properties.setProperty("TestAdapter.Endpoints", "default -p 12345 -t 10000"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); Ice.Object object = new ThrowerI(adapter); diff --git a/java/test/Ice/exceptionsAMD/TestAMD.ice b/java/test/Ice/exceptionsAMD/TestAMD.ice index 462472050f7..a6e0c26ddd3 100644 --- a/java/test/Ice/exceptionsAMD/TestAMD.ice +++ b/java/test/Ice/exceptionsAMD/TestAMD.ice @@ -41,6 +41,7 @@ exception D { void shutdown(); bool supportsUndeclaredExceptions(); + bool supportsAssertException(); void throwAasA(int a) throws A; void throwAorDasAorD(int a) throws A, D; @@ -54,6 +55,7 @@ exception D void throwUndeclaredC(int a, int b, int c); void throwLocalException(); void throwNonIceException(); + void throwAssertException(); }; ["ami", "amd"] interface WrongOperation diff --git a/java/test/Ice/exceptionsAMD/ThrowerI.java b/java/test/Ice/exceptionsAMD/ThrowerI.java index 7e9ccfff246..d6dafa507ec 100644 --- a/java/test/Ice/exceptionsAMD/ThrowerI.java +++ b/java/test/Ice/exceptionsAMD/ThrowerI.java @@ -34,6 +34,12 @@ public final class ThrowerI extends _ThrowerDisp } public void + supportsAssertException_async(AMD_Thrower_supportsAssertException cb, Ice.Current current) + { + cb.ice_response(true); + } + + public void throwAasA_async(AMD_Thrower_throwAasA cb, int a, Ice.Current current) throws A { @@ -117,18 +123,6 @@ public final class ThrowerI extends _ThrowerDisp } public void - throwLocalException_async(AMD_Thrower_throwLocalException cb, Ice.Current current) - { - cb.ice_exception(new Ice.TimeoutException()); - } - - public void - throwNonIceException_async(AMD_Thrower_throwNonIceException cb, Ice.Current current) - { - throw new RuntimeException(); - } - - public void throwUndeclaredA_async(AMD_Thrower_throwUndeclaredA cb, int a, Ice.Current current) { A ex = new A(); @@ -155,5 +149,23 @@ public final class ThrowerI extends _ThrowerDisp cb.ice_exception(ex); } + public void + throwLocalException_async(AMD_Thrower_throwLocalException cb, Ice.Current current) + { + cb.ice_exception(new Ice.TimeoutException()); + } + + public void + throwNonIceException_async(AMD_Thrower_throwNonIceException cb, Ice.Current current) + { + throw new RuntimeException(); + } + + public void + throwAssertException_async(AMD_Thrower_throwAssertException cb, Ice.Current current) + { + throw new java.lang.AssertionError(); + } + private Ice.ObjectAdapter _adapter; } |