diff options
author | Benoit Foucher <benoit@zeroc.com> | 2014-06-27 10:31:41 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2014-06-27 10:31:41 +0200 |
commit | a4f93259dc3494d98addf38e69b87eb557d432b3 (patch) | |
tree | d2b78bb5cea24e33dc1b46be22dba6167e96c9ed /java/test | |
parent | Fix for ICE-5515 (ice_staticId on proxies) in Java, C#, Python, Ruby and PHP ... (diff) | |
download | ice-a4f93259dc3494d98addf38e69b87eb557d432b3.tar.bz2 ice-a4f93259dc3494d98addf38e69b87eb557d432b3.tar.xz ice-a4f93259dc3494d98addf38e69b87eb557d432b3.zip |
Better collocation optimization, fix for ICE-5489, ICE-5484
Diffstat (limited to 'java/test')
38 files changed, 1969 insertions, 1563 deletions
diff --git a/java/test/Ice/ami/AMI.java b/java/test/Ice/ami/AMI.java index 197ca12e276..9a067ea6bcc 100644 --- a/java/test/Ice/ami/AMI.java +++ b/java/test/Ice/ami/AMI.java @@ -1491,6 +1491,8 @@ public class AMI out.print("testing batch requests with proxy... "); out.flush(); { + test(p.ice_batchOneway().begin_ice_flushBatchRequests().sentSynchronously()); + { // // AsyncResult. @@ -1521,6 +1523,7 @@ public class AMI test(p.waitForBatch(2)); } + if(p.ice_getConnection() != null) { // // AsyncResult exception. @@ -1581,6 +1584,7 @@ public class AMI test(p.waitForBatch(2)); } + if(p.ice_getConnection() != null) { // // Type-safe exception. @@ -1613,467 +1617,470 @@ public class AMI } out.println("ok"); - out.print("testing batch requests with connection... "); - out.flush(); + if(p.ice_getConnection() != null) { + out.print("testing batch requests with connection... "); + out.flush(); { - // - // AsyncResult. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - b1.opBatch(); - b1.opBatch(); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( - new Ice.Callback() - { - @Override - public void completed(Ice.AsyncResult result) - { - cb.completedAsync(result); - } - - @Override - public void sent(Ice.AsyncResult result) - { - cb.sentAsync(result); - } - }); - cb.check(); - test(r.isSent()); - test(r.isCompleted()); - test(p.waitForBatch(2)); - } - - { - // - // AsyncResult exception. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - b1.opBatch(); - b1.ice_getConnection().close(false); - final FlushExCallback cb = new FlushExCallback(); - Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( - new Ice.Callback() - { - @Override - public void completed(Ice.AsyncResult result) - { - cb.completedAsync(result); - } - - @Override - public void sent(Ice.AsyncResult result) - { - cb.sentAsync(result); - } - }); - cb.check(); - test(!r.isSent()); - test(r.isCompleted()); - test(p.opBatchCount() == 0); - } - - { - // - // Type-safe. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - b1.opBatch(); - b1.opBatch(); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( - new Ice.Callback_Connection_flushBatchRequests() - { - @Override - public void exception(Ice.LocalException ex) - { - cb.exception(ex); - } - - @Override - public void sent(boolean sentSynchronously) - { - cb.sent(sentSynchronously); - } - }); - cb.check(); - test(r.isSent()); - test(r.isCompleted()); - test(p.waitForBatch(2)); - } - - { - // - // Type-safe exception. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - b1.opBatch(); - b1.ice_getConnection().close(false); - final FlushExCallback cb = new FlushExCallback(); - Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( - new Ice.Callback_Connection_flushBatchRequests() - { - @Override - public void exception(Ice.LocalException ex) - { - cb.exception(ex); - } - - @Override - public void sent(boolean sentSynchronously) - { - cb.sent(sentSynchronously); - } - }); - cb.check(); - test(!r.isSent()); - test(r.isCompleted()); - test(p.opBatchCount() == 0); - } - } - out.println("ok"); - - out.print("testing batch requests with communicator... "); - out.flush(); - { - { - // - // AsyncResult - 1 connection. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - b1.opBatch(); - b1.opBatch(); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - new Ice.Callback() - { - @Override - public void completed(Ice.AsyncResult result) - { - cb.completedAsync(result); - } - - @Override - public void sent(Ice.AsyncResult result) - { - cb.sentAsync(result); - } - }); - cb.check(); - test(r.isSent()); - test(r.isCompleted()); - test(p.waitForBatch(2)); - } - - { - // - // AsyncResult exception - 1 connection. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - b1.opBatch(); - b1.ice_getConnection().close(false); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - new Ice.Callback() - { - @Override - public void completed(Ice.AsyncResult result) - { - cb.completedAsync(result); - } - - @Override - public void sent(Ice.AsyncResult result) - { - cb.sentAsync(result); - } - }); - cb.check(); - test(r.isSent()); // Exceptions are ignored! - test(r.isCompleted()); - test(p.opBatchCount() == 0); - } - - { - // - // AsyncResult - 2 connections. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); - b2.ice_getConnection(); // Ensure connection is established. - b1.opBatch(); - b1.opBatch(); - b2.opBatch(); - b2.opBatch(); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - new Ice.Callback() - { - @Override - public void completed(Ice.AsyncResult result) - { - cb.completedAsync(result); - } - - @Override - public void sent(Ice.AsyncResult result) + { + // + // AsyncResult. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + b1.opBatch(); + b1.opBatch(); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( + new Ice.Callback() { - cb.sentAsync(result); - } - }); - cb.check(); - test(r.isSent()); - test(r.isCompleted()); - test(p.waitForBatch(4)); - } + @Override + public void completed(Ice.AsyncResult result) + { + cb.completedAsync(result); + } - { - // - // AsyncResult exception - 2 connections - 1 failure. - // - // All connections should be flushed even if there are failures on some connections. - // Exceptions should not be reported. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); - b2.ice_getConnection(); // Ensure connection is established. - b1.opBatch(); - b2.opBatch(); - b1.ice_getConnection().close(false); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - new Ice.Callback() - { - @Override - public void completed(Ice.AsyncResult result) - { - cb.completedAsync(result); - } + @Override + public void sent(Ice.AsyncResult result) + { + cb.sentAsync(result); + } + }); + cb.check(); + test(r.isSent()); + test(r.isCompleted()); + test(p.waitForBatch(2)); + } - @Override - public void sent(Ice.AsyncResult result) + { + // + // AsyncResult exception. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + b1.opBatch(); + b1.ice_getConnection().close(false); + final FlushExCallback cb = new FlushExCallback(); + Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( + new Ice.Callback() { - cb.sentAsync(result); - } - }); - cb.check(); - test(r.isSent()); // Exceptions are ignored! - test(r.isCompleted()); - test(p.waitForBatch(1)); - } + @Override + public void completed(Ice.AsyncResult result) + { + cb.completedAsync(result); + } + + @Override + public void sent(Ice.AsyncResult result) + { + cb.sentAsync(result); + } + }); + cb.check(); + test(!r.isSent()); + test(r.isCompleted()); + test(p.opBatchCount() == 0); + } - { - // - // AsyncResult exception - 2 connections - 2 failures. - // - // The sent callback should be invoked even if all connections fail. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); - b2.ice_getConnection(); // Ensure connection is established. - b1.opBatch(); - b2.opBatch(); - b1.ice_getConnection().close(false); - b2.ice_getConnection().close(false); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - new Ice.Callback() - { - @Override - public void completed(Ice.AsyncResult result) + { + // + // Type-safe. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + b1.opBatch(); + b1.opBatch(); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( + new Ice.Callback_Connection_flushBatchRequests() { - cb.completedAsync(result); - } + @Override + public void exception(Ice.LocalException ex) + { + cb.exception(ex); + } + + @Override + public void sent(boolean sentSynchronously) + { + cb.sent(sentSynchronously); + } + }); + cb.check(); + test(r.isSent()); + test(r.isCompleted()); + test(p.waitForBatch(2)); + } - @Override - public void sent(Ice.AsyncResult result) + { + // + // Type-safe exception. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + b1.opBatch(); + b1.ice_getConnection().close(false); + final FlushExCallback cb = new FlushExCallback(); + Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( + new Ice.Callback_Connection_flushBatchRequests() { - cb.sentAsync(result); - } - }); - cb.check(); - test(r.isSent()); // Exceptions are ignored! - test(r.isCompleted()); - test(p.opBatchCount() == 0); + @Override + public void exception(Ice.LocalException ex) + { + cb.exception(ex); + } + + @Override + public void sent(boolean sentSynchronously) + { + cb.sent(sentSynchronously); + } + }); + cb.check(); + test(!r.isSent()); + test(r.isCompleted()); + test(p.opBatchCount() == 0); + } } + out.println("ok"); + out.print("testing batch requests with communicator... "); + out.flush(); { - // - // Type-safe - 1 connection. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - b1.opBatch(); - b1.opBatch(); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - new Ice.Callback_Communicator_flushBatchRequests() - { - @Override - public void exception(Ice.LocalException ex) + { + // + // AsyncResult - 1 connection. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + b1.opBatch(); + b1.opBatch(); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + new Ice.Callback() { - cb.exception(ex); - } + @Override + public void completed(Ice.AsyncResult result) + { + cb.completedAsync(result); + } + + @Override + public void sent(Ice.AsyncResult result) + { + cb.sentAsync(result); + } + }); + cb.check(); + test(r.isSent()); + test(r.isCompleted()); + test(p.waitForBatch(2)); + } - @Override - public void sent(boolean sentSynchronously) + { + // + // AsyncResult exception - 1 connection. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + b1.opBatch(); + b1.ice_getConnection().close(false); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + new Ice.Callback() { - cb.sent(sentSynchronously); - } - }); - cb.check(); - test(r.isSent()); - test(r.isCompleted()); - test(p.waitForBatch(2)); - } + @Override + public void completed(Ice.AsyncResult result) + { + cb.completedAsync(result); + } + + @Override + public void sent(Ice.AsyncResult result) + { + cb.sentAsync(result); + } + }); + cb.check(); + test(r.isSent()); // Exceptions are ignored! + test(r.isCompleted()); + test(p.opBatchCount() == 0); + } - { - // - // Type-safe exception - 1 connection. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - b1.opBatch(); - b1.ice_getConnection().close(false); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - new Ice.Callback_Communicator_flushBatchRequests() - { - @Override - public void exception(Ice.LocalException ex) + { + // + // AsyncResult - 2 connections. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); + b2.ice_getConnection(); // Ensure connection is established. + b1.opBatch(); + b1.opBatch(); + b2.opBatch(); + b2.opBatch(); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + new Ice.Callback() { - cb.exception(ex); - } + @Override + public void completed(Ice.AsyncResult result) + { + cb.completedAsync(result); + } + + @Override + public void sent(Ice.AsyncResult result) + { + cb.sentAsync(result); + } + }); + cb.check(); + test(r.isSent()); + test(r.isCompleted()); + test(p.waitForBatch(4)); + } - @Override - public void sent(boolean sentSynchronously) + { + // + // AsyncResult exception - 2 connections - 1 failure. + // + // All connections should be flushed even if there are failures on some connections. + // Exceptions should not be reported. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); + b2.ice_getConnection(); // Ensure connection is established. + b1.opBatch(); + b2.opBatch(); + b1.ice_getConnection().close(false); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + new Ice.Callback() { - cb.sent(sentSynchronously); - } - }); - cb.check(); - test(r.isSent()); // Exceptions are ignored! - test(r.isCompleted()); - test(p.opBatchCount() == 0); - } + @Override + public void completed(Ice.AsyncResult result) + { + cb.completedAsync(result); + } + + @Override + public void sent(Ice.AsyncResult result) + { + cb.sentAsync(result); + } + }); + cb.check(); + test(r.isSent()); // Exceptions are ignored! + test(r.isCompleted()); + test(p.waitForBatch(1)); + } - { - // - // 2 connections. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); - b2.ice_getConnection(); // Ensure connection is established. - b1.opBatch(); - b1.opBatch(); - b2.opBatch(); - b2.opBatch(); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - new Ice.Callback_Communicator_flushBatchRequests() - { - @Override - public void exception(Ice.LocalException ex) + { + // + // AsyncResult exception - 2 connections - 2 failures. + // + // The sent callback should be invoked even if all connections fail. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); + b2.ice_getConnection(); // Ensure connection is established. + b1.opBatch(); + b2.opBatch(); + b1.ice_getConnection().close(false); + b2.ice_getConnection().close(false); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + new Ice.Callback() { - cb.exception(ex); - } + @Override + public void completed(Ice.AsyncResult result) + { + cb.completedAsync(result); + } + + @Override + public void sent(Ice.AsyncResult result) + { + cb.sentAsync(result); + } + }); + cb.check(); + test(r.isSent()); // Exceptions are ignored! + test(r.isCompleted()); + test(p.opBatchCount() == 0); + } - @Override - public void sent(boolean sentSynchronously) + { + // + // Type-safe - 1 connection. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + b1.opBatch(); + b1.opBatch(); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + new Ice.Callback_Communicator_flushBatchRequests() { - cb.sent(sentSynchronously); - } - }); - cb.check(); - test(r.isSent()); - test(r.isCompleted()); - test(p.waitForBatch(4)); - } + @Override + public void exception(Ice.LocalException ex) + { + cb.exception(ex); + } + + @Override + public void sent(boolean sentSynchronously) + { + cb.sent(sentSynchronously); + } + }); + cb.check(); + test(r.isSent()); + test(r.isCompleted()); + test(p.waitForBatch(2)); + } - { - // - // Exception - 2 connections - 1 failure. - // - // All connections should be flushed even if there are failures on some connections. - // Exceptions should not be reported. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); - b2.ice_getConnection(); // Ensure connection is established. - b1.opBatch(); - b2.opBatch(); - b1.ice_getConnection().close(false); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - new Ice.Callback_Communicator_flushBatchRequests() - { - @Override - public void exception(Ice.LocalException ex) + { + // + // Type-safe exception - 1 connection. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + b1.opBatch(); + b1.ice_getConnection().close(false); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + new Ice.Callback_Communicator_flushBatchRequests() { - cb.exception(ex); - } + @Override + public void exception(Ice.LocalException ex) + { + cb.exception(ex); + } + + @Override + public void sent(boolean sentSynchronously) + { + cb.sent(sentSynchronously); + } + }); + cb.check(); + test(r.isSent()); // Exceptions are ignored! + test(r.isCompleted()); + test(p.opBatchCount() == 0); + } - @Override - public void sent(boolean sentSynchronously) + { + // + // 2 connections. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); + b2.ice_getConnection(); // Ensure connection is established. + b1.opBatch(); + b1.opBatch(); + b2.opBatch(); + b2.opBatch(); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + new Ice.Callback_Communicator_flushBatchRequests() { - cb.sent(sentSynchronously); - } - }); - cb.check(); - test(r.isSent()); // Exceptions are ignored! - test(r.isCompleted()); - test(p.waitForBatch(1)); - } + @Override + public void exception(Ice.LocalException ex) + { + cb.exception(ex); + } + + @Override + public void sent(boolean sentSynchronously) + { + cb.sent(sentSynchronously); + } + }); + cb.check(); + test(r.isSent()); + test(r.isCompleted()); + test(p.waitForBatch(4)); + } - { - // - // Exception - 2 connections - 2 failures. - // - // The sent callback should be invoked even if all connections fail. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); - b2.ice_getConnection(); // Ensure connection is established. - b1.opBatch(); - b2.opBatch(); - b1.ice_getConnection().close(false); - b2.ice_getConnection().close(false); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - new Ice.Callback_Communicator_flushBatchRequests() - { - @Override - public void exception(Ice.LocalException ex) + { + // + // Exception - 2 connections - 1 failure. + // + // All connections should be flushed even if there are failures on some connections. + // Exceptions should not be reported. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); + b2.ice_getConnection(); // Ensure connection is established. + b1.opBatch(); + b2.opBatch(); + b1.ice_getConnection().close(false); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + new Ice.Callback_Communicator_flushBatchRequests() { - cb.exception(ex); - } + @Override + public void exception(Ice.LocalException ex) + { + cb.exception(ex); + } + + @Override + public void sent(boolean sentSynchronously) + { + cb.sent(sentSynchronously); + } + }); + cb.check(); + test(r.isSent()); // Exceptions are ignored! + test(r.isCompleted()); + test(p.waitForBatch(1)); + } - @Override - public void sent(boolean sentSynchronously) + { + // + // Exception - 2 connections - 2 failures. + // + // The sent callback should be invoked even if all connections fail. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); + b2.ice_getConnection(); // Ensure connection is established. + b1.opBatch(); + b2.opBatch(); + b1.ice_getConnection().close(false); + b2.ice_getConnection().close(false); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + new Ice.Callback_Communicator_flushBatchRequests() { - cb.sent(sentSynchronously); - } - }); - cb.check(); - test(r.isSent()); // Exceptions are ignored! - test(r.isCompleted()); - test(p.opBatchCount() == 0); + @Override + public void exception(Ice.LocalException ex) + { + cb.exception(ex); + } + + @Override + public void sent(boolean sentSynchronously) + { + cb.sent(sentSynchronously); + } + }); + cb.check(); + test(r.isSent()); // Exceptions are ignored! + test(r.isCompleted()); + test(p.opBatchCount() == 0); + } } + out.println("ok"); } - out.println("ok"); out.print("testing AsyncResult operations... "); out.flush(); @@ -2101,10 +2108,13 @@ public class AMI new java.util.Random().nextBytes(seq); // Make sure the request doesn't compress too well. while((r2 = p.begin_opWithPayload(seq)).sentSynchronously()); - test(r1.sentSynchronously() && r1.isSent() && !r1.isCompleted() || - !r1.sentSynchronously() && !r1.isCompleted()); - - test(!r2.sentSynchronously() && !r2.isCompleted()); + if(p.ice_getConnection() != null) + { + test(r1.sentSynchronously() && r1.isSent() && !r1.isCompleted() || + !r1.sentSynchronously() && !r1.isCompleted()); + + test(!r2.sentSynchronously() && !r2.isCompleted()); + } } finally { @@ -2163,87 +2173,93 @@ public class AMI test(r.getProxy() == p2); p2.end_ice_flushBatchRequests(r); - // - // Batch request via connection - // - Ice.Connection con = p.ice_getConnection(); - p2 = (TestIntfPrx)p.ice_batchOneway(); - p2.ice_ping(); - r = con.begin_flushBatchRequests(); - test(r.getConnection() == con); - test(r.getCommunicator() == communicator); - test(r.getProxy() == null); // Expected - con.end_flushBatchRequests(r); - - // - // Batch request via communicator - // - p2 = (TestIntfPrx)p.ice_batchOneway(); - p2.ice_ping(); - r = communicator.begin_flushBatchRequests(); - test(r.getConnection() == null); // Expected - test(r.getCommunicator() == communicator); - test(r.getProxy() == null); // Expected - communicator.end_flushBatchRequests(r); + if(p.ice_getConnection() != null) + { + // + // Batch request via connection + // + Ice.Connection con = p.ice_getConnection(); + p2 = (TestIntfPrx)p.ice_batchOneway(); + p2.ice_ping(); + r = con.begin_flushBatchRequests(); + test(r.getConnection() == con); + test(r.getCommunicator() == communicator); + test(r.getProxy() == null); // Expected + con.end_flushBatchRequests(r); + + // + // Batch request via communicator + // + p2 = (TestIntfPrx)p.ice_batchOneway(); + p2.ice_ping(); + r = communicator.begin_flushBatchRequests(); + test(r.getConnection() == null); // Expected + test(r.getCommunicator() == communicator); + test(r.getProxy() == null); // Expected + communicator.end_flushBatchRequests(r); + } } } out.println("ok"); - - out.print("testing close connection with sending queue... "); - out.flush(); - { - byte[] seq = new byte[1024 * 10]; - new java.util.Random().nextBytes(seq); // Make sure the request doesn't compress too well. - // - // Send multiple opWithPayload, followed by a close and followed by multiple opWithPaylod. - // The goal is to make sure that none of the opWithPayload fail even if the server closes - // the connection gracefully in between. - // - int maxQueue = 2; - boolean done = false; - while(!done && maxQueue < 50) + if(p.ice_getConnection() != null) + { + out.print("testing close connection with sending queue... "); + out.flush(); { - done = true; - p.ice_ping(); - java.util.List<Ice.AsyncResult> results = new java.util.ArrayList<Ice.AsyncResult>(); - for(int i = 0; i < maxQueue; ++i) - { - results.add(p.begin_opWithPayload(seq)); - } - if(!p.begin_close(false).isSent()) + byte[] seq = new byte[1024 * 10]; + new java.util.Random().nextBytes(seq); // Make sure the request doesn't compress too well. + + // + // Send multiple opWithPayload, followed by a close and followed by multiple opWithPaylod. + // The goal is to make sure that none of the opWithPayload fail even if the server closes + // the connection gracefully in between. + // + int maxQueue = 2; + boolean done = false; + while(!done && maxQueue < 50) { - for(int i = 0; i < maxQueue; i++) + done = true; + p.ice_ping(); + java.util.List<Ice.AsyncResult> results = new java.util.ArrayList<Ice.AsyncResult>(); + for(int i = 0; i < maxQueue; ++i) + { + results.add(p.begin_opWithPayload(seq)); + } + if(!p.begin_close(false).isSent()) { - Ice.AsyncResult r = p.begin_opWithPayload(seq); - results.add(r); - if(r.isSent()) + for(int i = 0; i < maxQueue; i++) { - done = false; - maxQueue *= 2; - break; + Ice.AsyncResult r = p.begin_opWithPayload(seq); + results.add(r); + if(r.isSent()) + { + done = false; + maxQueue *= 2; + break; + } } } - } - else - { - maxQueue *= 2; - done = false; - } - for(Ice.AsyncResult q : results) - { - q.waitForCompleted(); - try + else { - q.throwLocalException(); + maxQueue *= 2; + done = false; } - catch(Ice.LocalException ex) + for(Ice.AsyncResult q : results) { - test(false); + q.waitForCompleted(); + try + { + q.throwLocalException(); + } + catch(Ice.LocalException ex) + { + test(false); + } } } } + out.println("ok"); } - out.println("ok"); } } diff --git a/java/test/Ice/ami/Collocated.java b/java/test/Ice/ami/Collocated.java new file mode 100644 index 00000000000..d51620a84f8 --- /dev/null +++ b/java/test/Ice/ami/Collocated.java @@ -0,0 +1,47 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.ami; + +public class Collocated extends test.Util.Application +{ + public int run(String[] args) + { + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter"); + Ice.ObjectAdapter adapter2 = communicator().createObjectAdapter("ControllerAdapter"); + + adapter.add(new TestI(), communicator().stringToIdentity("test")); + adapter.activate(); + adapter2.add(new TestControllerI(adapter), communicator().stringToIdentity("testController")); + adapter2.activate(); + + AllTests.allTests(this); + return 0; + } + + protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH) + { + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(argsH); + initData.properties.setProperty("Ice.Package.Test", "test.Ice.ami"); + initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010"); + initData.properties.setProperty("ControllerAdapter.Endpoints", "tcp -p 12011"); + initData.properties.setProperty("ControllerAdapter.ThreadPool.Size", "1"); + initData.properties.setProperty("Ice.Warn.AMICallback", "0"); + return initData; + } + + public static void main(String[] args) + { + Collocated app = new Collocated(); + int result = app.main("Collocated", args); + System.gc(); + System.exit(result); + } +} diff --git a/java/test/Ice/ami/lambda/AMI.java b/java/test/Ice/ami/lambda/AMI.java index 903be5c3f8a..b89a51ae0f5 100644 --- a/java/test/Ice/ami/lambda/AMI.java +++ b/java/test/Ice/ami/lambda/AMI.java @@ -126,7 +126,7 @@ public class AMI { called(); } - catch(Ice.LocalException ex) + catch(Ice.Exception ex) { test(false); } @@ -144,7 +144,7 @@ public class AMI { called(); } - catch(Ice.LocalException ex) + catch(Ice.Exception ex) { test(false); } @@ -162,7 +162,7 @@ public class AMI { called(); } - catch(Ice.LocalException ex) + catch(Ice.Exception ex) { test(false); } @@ -180,7 +180,7 @@ public class AMI { called(); } - catch(Ice.LocalException ex) + catch(Ice.Exception ex) { test(false); } @@ -198,7 +198,7 @@ public class AMI { called(); } - catch(Ice.LocalException ex) + catch(Ice.Exception ex) { test(false); } @@ -216,7 +216,7 @@ public class AMI { called(); } - catch(Ice.LocalException ex) + catch(Ice.Exception ex) { test(false); } @@ -324,14 +324,14 @@ public class AMI } public void - ex(Ice.LocalException ex) + ex(Ice.Exception ex) { test(ex instanceof Ice.NoEndpointException); called(); } public void - noEx(Ice.LocalException ex) + noEx(Ice.Exception ex) { test(false); } @@ -375,7 +375,7 @@ public class AMI } public void - ex(Ice.LocalException ex) + ex(Ice.Exception ex) { } @@ -412,7 +412,7 @@ public class AMI } public void - exception(Ice.LocalException ex) + exception(Ice.Exception ex) { test(false); } @@ -457,14 +457,14 @@ public class AMI } test(false); } - catch(Ice.LocalException ex) + catch(Ice.Exception ex) { called(); } } public void - exception(Ice.LocalException ex) + exception(Ice.Exception ex) { called(); } @@ -511,7 +511,7 @@ public class AMI } public void - ex(Ice.LocalException ex) + ex(Ice.Exception ex) { called(); throwEx(); @@ -562,74 +562,74 @@ public class AMI p.begin_ice_isA("::Test::TestIntf", (boolean r) -> cb.isA(r), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_ice_isA("::Test::TestIntf", (boolean r) -> cb.isA(r), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_ice_ping( () -> cb.ping(), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_ice_ping(ctx, () -> cb.ping(), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_ice_id( (String id) -> cb.id(id), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_ice_id(ctx, (String id) -> cb.id(id), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_ice_ids( (String[] ids) -> cb.ids(ids), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_ice_ids(ctx, (String[] ids) -> cb.ids(ids), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_op( () -> cb.op(), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_op(ctx, () -> cb.op(), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_opWithResult( (int r) -> cb.opWithResult(r), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_opWithResult(ctx, (int r) -> cb.opWithResult(r), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_opWithUE( () -> test(false), (Ice.UserException ex) -> cb.opWithUE(ex), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); p.begin_opWithUE(ctx, () -> test(false), (Ice.UserException ex) -> cb.opWithUE(ex), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } out.println("ok"); @@ -642,27 +642,27 @@ public class AMI i.begin_ice_isA("::Test::TestIntf", (boolean r) -> test(false), - (Ice.LocalException ex) -> cb.ex(ex)); + (Ice.Exception ex) -> cb.ex(ex)); cb.check(); i.begin_ice_ping( () -> test(false), - (Ice.LocalException ex) -> cb.ex(ex)); + (Ice.Exception ex) -> cb.ex(ex)); cb.check(); i.begin_ice_id( (String id) -> test(false), - (Ice.LocalException ex) -> cb.ex(ex)); + (Ice.Exception ex) -> cb.ex(ex)); cb.check(); i.begin_ice_ids( (String[] ids) -> test(false), - (Ice.LocalException ex) -> cb.ex(ex)); + (Ice.Exception ex) -> cb.ex(ex)); cb.check(); i.begin_op( () -> test(false), - (Ice.LocalException ex) -> cb.ex(ex)); + (Ice.Exception ex) -> cb.ex(ex)); cb.check(); } out.println("ok"); @@ -674,31 +674,31 @@ public class AMI p.begin_ice_isA("", (boolean r) -> cb.isA(r), - (Ice.LocalException ex) -> cb.ex(ex), + (Ice.Exception ex) -> cb.ex(ex), (boolean ss) -> cb.sent(ss)); cb.check(); p.begin_ice_ping( () -> cb.ping(), - (Ice.LocalException ex) -> cb.ex(ex), + (Ice.Exception ex) -> cb.ex(ex), (boolean ss) -> cb.sent(ss)); cb.check(); p.begin_ice_id( (String id) -> cb.id(id), - (Ice.LocalException ex) -> cb.ex(ex), + (Ice.Exception ex) -> cb.ex(ex), (boolean ss) -> cb.sent(ss)); cb.check(); p.begin_ice_ids( (String[] ids) -> cb.ids(ids), - (Ice.LocalException ex) -> cb.ex(ex), + (Ice.Exception ex) -> cb.ex(ex), (boolean ss) -> cb.sent(ss)); cb.check(); p.begin_op( () -> cb.op(), - (Ice.LocalException ex) -> cb.ex(ex), + (Ice.Exception ex) -> cb.ex(ex), (boolean ss) -> cb.sent(ss)); cb.check(); @@ -714,7 +714,7 @@ public class AMI final SentCallback cb2 = new SentCallback(); r = p.begin_opWithPayload(seq, () -> {}, - (Ice.LocalException ex) -> cb2.ex(ex), + (Ice.Exception ex) -> cb2.ex(ex), (boolean ss) -> cb2.sent(ss)); cbs.add(cb2); } @@ -748,12 +748,12 @@ public class AMI q.begin_op( () -> cb.op(), - (Ice.LocalException ex) -> cb.ex(ex)); + (Ice.Exception ex) -> cb.ex(ex)); cb.check(); p.begin_op( () -> {}, - (Ice.LocalException ex) -> {}, + (Ice.Exception ex) -> {}, (boolean ss) -> cb.sent(ss)); cb.check(); } @@ -774,7 +774,7 @@ public class AMI final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests( null, - (Ice.LocalException ex) -> cb.exception(ex), + (Ice.Exception ex) -> cb.exception(ex), (boolean sentSynchronously) -> cb.sent(sentSynchronously)); cb.check(); test(r.isSent()); @@ -782,6 +782,7 @@ public class AMI test(p.waitForBatch(2)); } + if(p.ice_getConnection() != null) { // // Type-safe exception. @@ -793,7 +794,7 @@ public class AMI final FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests( null, - (Ice.LocalException ex) -> cb.exception(ex), + (Ice.Exception ex) -> cb.exception(ex), (boolean sentSynchronously) -> cb.sent(sentSynchronously)); cb.check(); test(!r.isSent()); @@ -803,170 +804,173 @@ public class AMI } out.println("ok"); - out.print("testing batch requests with connection... "); - out.flush(); + if(p.ice_getConnection() != null) { + out.print("testing batch requests with connection... "); + out.flush(); { - // - // Type-safe. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - b1.opBatch(); - b1.opBatch(); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( - null, - (Ice.LocalException ex) -> cb.exception(ex), - (boolean sentSynchronously) -> cb.sent(sentSynchronously)); - cb.check(); - test(r.isSent()); - test(r.isCompleted()); - test(p.waitForBatch(2)); - } + { + // + // Type-safe. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + b1.opBatch(); + b1.opBatch(); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( + null, + (Ice.Exception ex) -> cb.exception(ex), + (boolean sentSynchronously) -> cb.sent(sentSynchronously)); + cb.check(); + test(r.isSent()); + test(r.isCompleted()); + test(p.waitForBatch(2)); + } - { - // - // Type-safe exception. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - b1.opBatch(); - b1.ice_getConnection().close(false); - final FlushExCallback cb = new FlushExCallback(); - Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( - null, - (Ice.LocalException ex) -> cb.exception(ex), - (boolean sentSynchronously) -> cb.sent(sentSynchronously)); - cb.check(); - test(!r.isSent()); - test(r.isCompleted()); - test(p.opBatchCount() == 0); + { + // + // Type-safe exception. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + b1.opBatch(); + b1.ice_getConnection().close(false); + final FlushExCallback cb = new FlushExCallback(); + Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( + null, + (Ice.Exception ex) -> cb.exception(ex), + (boolean sentSynchronously) -> cb.sent(sentSynchronously)); + cb.check(); + test(!r.isSent()); + test(r.isCompleted()); + test(p.opBatchCount() == 0); + } } - } - out.println("ok"); + out.println("ok"); - out.print("testing batch requests with communicator... "); - out.flush(); - { + out.print("testing batch requests with communicator... "); + out.flush(); { - // - // Type-safe - 1 connection. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - b1.opBatch(); - b1.opBatch(); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - null, - (Ice.LocalException ex) -> cb.exception(ex), - (boolean sentSynchronously) -> cb.sent(sentSynchronously)); - cb.check(); - test(r.isSent()); - test(r.isCompleted()); - test(p.waitForBatch(2)); - } + { + // + // Type-safe - 1 connection. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + b1.opBatch(); + b1.opBatch(); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + null, + (Ice.Exception ex) -> cb.exception(ex), + (boolean sentSynchronously) -> cb.sent(sentSynchronously)); + cb.check(); + test(r.isSent()); + test(r.isCompleted()); + test(p.waitForBatch(2)); + } - { - // - // Type-safe exception - 1 connection. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - b1.opBatch(); - b1.ice_getConnection().close(false); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - null, - (Ice.LocalException ex) -> cb.exception(ex), - (boolean sentSynchronously) -> cb.sent(sentSynchronously)); - cb.check(); - test(r.isSent()); // Exceptions are ignored! - test(r.isCompleted()); - test(p.opBatchCount() == 0); - } + { + // + // Type-safe exception - 1 connection. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + b1.opBatch(); + b1.ice_getConnection().close(false); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + null, + (Ice.Exception ex) -> cb.exception(ex), + (boolean sentSynchronously) -> cb.sent(sentSynchronously)); + cb.check(); + test(r.isSent()); // Exceptions are ignored! + test(r.isCompleted()); + test(p.opBatchCount() == 0); + } - { - // - // 2 connections. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); - b2.ice_getConnection(); // Ensure connection is established. - b1.opBatch(); - b1.opBatch(); - b2.opBatch(); - b2.opBatch(); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - null, - (Ice.LocalException ex) -> cb.exception(ex), - (boolean sentSynchronously) -> cb.sent(sentSynchronously)); - cb.check(); - test(r.isSent()); - test(r.isCompleted()); - test(p.waitForBatch(4)); - } + { + // + // 2 connections. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); + b2.ice_getConnection(); // Ensure connection is established. + b1.opBatch(); + b1.opBatch(); + b2.opBatch(); + b2.opBatch(); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + null, + (Ice.Exception ex) -> cb.exception(ex), + (boolean sentSynchronously) -> cb.sent(sentSynchronously)); + cb.check(); + test(r.isSent()); + test(r.isCompleted()); + test(p.waitForBatch(4)); + } - { - // - // Exception - 2 connections - 1 failure. - // - // All connections should be flushed even if there are failures on some connections. - // Exceptions should not be reported. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); - b2.ice_getConnection(); // Ensure connection is established. - b1.opBatch(); - b2.opBatch(); - b1.ice_getConnection().close(false); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - null, - (Ice.LocalException ex) -> cb.exception(ex), - (boolean sentSynchronously) -> cb.sent(sentSynchronously)); - cb.check(); - test(r.isSent()); // Exceptions are ignored! - test(r.isCompleted()); - test(p.waitForBatch(1)); - } + { + // + // Exception - 2 connections - 1 failure. + // + // All connections should be flushed even if there are failures on some connections. + // Exceptions should not be reported. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); + b2.ice_getConnection(); // Ensure connection is established. + b1.opBatch(); + b2.opBatch(); + b1.ice_getConnection().close(false); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + null, + (Ice.Exception ex) -> cb.exception(ex), + (boolean sentSynchronously) -> cb.sent(sentSynchronously)); + cb.check(); + test(r.isSent()); // Exceptions are ignored! + test(r.isCompleted()); + test(p.waitForBatch(1)); + } - { - // - // Exception - 2 connections - 2 failures. - // - // The sent callback should be invoked even if all connections fail. - // - test(p.opBatchCount() == 0); - TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); - TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); - b2.ice_getConnection(); // Ensure connection is established. - b1.opBatch(); - b2.opBatch(); - b1.ice_getConnection().close(false); - b2.ice_getConnection().close(false); - final FlushCallback cb = new FlushCallback(); - Ice.AsyncResult r = communicator.begin_flushBatchRequests( - null, - (Ice.LocalException ex) -> cb.exception(ex), - (boolean sentSynchronously) -> cb.sent(sentSynchronously)); - cb.check(); - test(r.isSent()); // Exceptions are ignored! - test(r.isCompleted()); - test(p.opBatchCount() == 0); + { + // + // Exception - 2 connections - 2 failures. + // + // The sent callback should be invoked even if all connections fail. + // + test(p.opBatchCount() == 0); + TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); + TestIntfPrx b2 = (TestIntfPrx)p.ice_connectionId("2").ice_batchOneway(); + b2.ice_getConnection(); // Ensure connection is established. + b1.opBatch(); + b2.opBatch(); + b1.ice_getConnection().close(false); + b2.ice_getConnection().close(false); + final FlushCallback cb = new FlushCallback(); + Ice.AsyncResult r = communicator.begin_flushBatchRequests( + null, + (Ice.Exception ex) -> cb.exception(ex), + (boolean sentSynchronously) -> cb.sent(sentSynchronously)); + cb.check(); + test(r.isSent()); // Exceptions are ignored! + test(r.isCompleted()); + test(p.opBatchCount() == 0); + } } + out.println("ok"); } - out.println("ok"); out.print("testing null callbacks..."); try { IceInternal.Functional_VoidCallback response = null; - IceInternal.Functional_GenericCallback1<Ice.LocalException> exception = null; + IceInternal.Functional_GenericCallback1<Ice.Exception> exception = null; p.begin_ice_ping(response, exception); test(false); } @@ -987,7 +991,7 @@ public class AMI try { - p.begin_ice_ping(null, (Ice.LocalException ex) -> {}); + p.begin_ice_ping(null, (Ice.Exception ex) -> {}); } catch(IllegalArgumentException ex) @@ -998,7 +1002,7 @@ public class AMI try { IceInternal.Functional_BoolCallback response = null; - IceInternal.Functional_GenericCallback1<Ice.LocalException> exception = null; + IceInternal.Functional_GenericCallback1<Ice.Exception> exception = null; p.begin_ice_isA("::Test::TestIntf", response, exception); test(false); } @@ -1019,7 +1023,7 @@ public class AMI try { - p.begin_ice_isA("::Test::TestIntf", null, (Ice.LocalException ex) -> {}); + p.begin_ice_isA("::Test::TestIntf", null, (Ice.Exception ex) -> {}); } catch(IllegalArgumentException ex) @@ -1030,7 +1034,7 @@ public class AMI try { IceInternal.Functional_VoidCallback response = null; - p.begin_opWithUE(response, null, (Ice.LocalException ex) -> {}); + p.begin_opWithUE(response, null, (Ice.Exception ex) -> {}); test(false); } catch(IllegalArgumentException ex) @@ -1057,8 +1061,8 @@ public class AMI { IceInternal.Functional_VoidCallback response = null; IceInternal.Functional_GenericCallback1<Ice.UserException> userException = null; - IceInternal.Functional_GenericCallback1<Ice.LocalException> localException = null; - p.begin_opWithUE(response, userException, localException); + IceInternal.Functional_GenericCallback1<Ice.Exception> exception = null; + p.begin_opWithUE(response, userException, exception); test(false); } catch(IllegalArgumentException ex) diff --git a/java/test/Ice/ami/run.py b/java/test/Ice/ami/run.py index 33fc2e8f3ac..a40df1a1bcb 100755 --- a/java/test/Ice/ami/run.py +++ b/java/test/Ice/ami/run.py @@ -20,4 +20,7 @@ if len(path) == 0: sys.path.append(os.path.join(path[0], "scripts")) import TestUtil +print("tests with regular server.") TestUtil.clientServerTest() +print("tests with collocated server.") +TestUtil.collocatedTest() diff --git a/java/test/Ice/defaultServant/AllTests.java b/java/test/Ice/defaultServant/AllTests.java index c2012aec31f..e68a38e42c7 100644 --- a/java/test/Ice/defaultServant/AllTests.java +++ b/java/test/Ice/defaultServant/AllTests.java @@ -59,7 +59,7 @@ public class AllTests identity.name = names[idx]; MyObjectPrx prx = MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity)); prx.ice_ping(); - test(prx.getName() == names[idx]); + test(prx.getName().equals(names[idx])); } identity.name = "ObjectNotExist"; @@ -163,7 +163,7 @@ public class AllTests identity.name = names[idx]; prx = MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity)); prx.ice_ping(); - test(prx.getName() == names[idx]); + test(prx.getName().equals(names[idx])); } out.println("ok"); diff --git a/java/test/Ice/defaultServant/MyObjectI.java b/java/test/Ice/defaultServant/MyObjectI.java index 50fc10c0483..c9a0cef7e93 100644 --- a/java/test/Ice/defaultServant/MyObjectI.java +++ b/java/test/Ice/defaultServant/MyObjectI.java @@ -17,11 +17,11 @@ public final class MyObjectI extends _MyObjectDisp { String name = current.id.name; - if(name == "ObjectNotExist") + if(name.equals("ObjectNotExist")) { throw new Ice.ObjectNotExistException(); } - else if(name == "FacetNotExist") + else if(name.equals("FacetNotExist")) { throw new Ice.FacetNotExistException(); } @@ -32,11 +32,11 @@ public final class MyObjectI extends _MyObjectDisp { String name = current.id.name; - if(name == "ObjectNotExist") + if(name.equals("ObjectNotExist")) { throw new Ice.ObjectNotExistException(); } - else if(name == "FacetNotExist") + else if(name.equals("FacetNotExist")) { throw new Ice.FacetNotExistException(); } diff --git a/java/test/Ice/exceptions/AllTests.java b/java/test/Ice/exceptions/AllTests.java index 6ce749618d3..0c0256b9bb7 100644 --- a/java/test/Ice/exceptions/AllTests.java +++ b/java/test/Ice/exceptions/AllTests.java @@ -679,6 +679,9 @@ public class AllTests catch(Ice.ConnectionLostException ex) { } + catch(Ice.UnknownException ex) + { + } catch(Throwable ex) { ex.printStackTrace(); @@ -1318,6 +1321,9 @@ public class AllTests catch(Ice.ConnectionLostException ex) { } + catch(Ice.UnknownException ex) + { + } catch(Throwable ex) { ex.printStackTrace(); @@ -1370,7 +1376,7 @@ public class AllTests } public static ThrowerPrx - allTests(Ice.Communicator communicator, boolean collocated, PrintWriter out) + allTests(Ice.Communicator communicator, PrintWriter out) { { out.print("testing object adapter registration exceptions... "); @@ -1662,8 +1668,6 @@ public class AllTests if(thrower.supportsUndeclaredExceptions()) { - test(!collocated); - out.print("catching unknown user exception... "); out.flush(); @@ -1724,11 +1728,9 @@ public class AllTests } catch(Ice.ConnectionLostException ex) { - test(!collocated); } catch(Ice.UnknownException ex) { - test(collocated); } catch(Throwable ex) { @@ -1745,7 +1747,7 @@ public class AllTests try { thrower.throwMemoryLimitException(null); - test(collocated); + test(false); } catch(Ice.UnknownLocalException ex) { @@ -1759,7 +1761,7 @@ public class AllTests try { thrower.throwMemoryLimitException(new byte[20 * 1024]); // 20KB - test(collocated); + test(false); } catch(Ice.MemoryLimitException ex) { @@ -1770,22 +1772,19 @@ public class AllTests test(false); } - if(!collocated) + try { - try - { - thrower.end_throwMemoryLimitException( - thrower.begin_throwMemoryLimitException(new byte[20 * 1024])); // 20KB - test(false); - } - catch(Ice.MemoryLimitException ex) - { - } - catch(Throwable ex) - { - ex.printStackTrace(); - test(false); - } + thrower.end_throwMemoryLimitException( + thrower.begin_throwMemoryLimitException(new byte[20 * 1024])); // 20KB + test(false); + } + catch(Ice.MemoryLimitException ex) + { + } + catch(Throwable ex) + { + ex.printStackTrace(); + test(false); } } out.println("ok"); @@ -1951,340 +1950,337 @@ public class AllTests out.println("ok"); - if(!collocated) + out.print("catching exact types with AMI... "); + out.flush(); + { - out.print("catching exact types with AMI... "); - out.flush(); + AMI_Thrower_throwAasAI cb = new AMI_Thrower_throwAasAI(); + thrower.throwAasA_async(cb, 1); + cb.check(); + // Let's check if we can reuse the same callback object for another call. + thrower.throwAasA_async(cb, 1); + cb.check(); + } - { - AMI_Thrower_throwAasAI cb = new AMI_Thrower_throwAasAI(); - thrower.throwAasA_async(cb, 1); - cb.check(); - // Let's check if we can reuse the same callback object for another call. - thrower.throwAasA_async(cb, 1); - cb.check(); - } + { + AMI_Thrower_throwAorDasAorDI cb = new AMI_Thrower_throwAorDasAorDI(); + thrower.throwAorDasAorD_async(cb, 1); + cb.check(); + } - { - AMI_Thrower_throwAorDasAorDI cb = new AMI_Thrower_throwAorDasAorDI(); - thrower.throwAorDasAorD_async(cb, 1); - cb.check(); - } + { + AMI_Thrower_throwAorDasAorDI cb = new AMI_Thrower_throwAorDasAorDI(); + thrower.throwAorDasAorD_async(cb, -1); + cb.check(); + } - { - AMI_Thrower_throwAorDasAorDI cb = new AMI_Thrower_throwAorDasAorDI(); - thrower.throwAorDasAorD_async(cb, -1); - cb.check(); - } + { + AMI_Thrower_throwBasBI cb = new AMI_Thrower_throwBasBI(); + thrower.throwBasB_async(cb, 1, 2); + cb.check(); + } - { - AMI_Thrower_throwBasBI cb = new AMI_Thrower_throwBasBI(); - thrower.throwBasB_async(cb, 1, 2); - cb.check(); - } + { + AMI_Thrower_throwCasCI cb = new AMI_Thrower_throwCasCI(); + thrower.throwCasC_async(cb, 1, 2, 3); + cb.check(); + // Let's check if we can reuse the same callback object for another call. + thrower.throwCasC_async(cb, 1, 2, 3); + cb.check(); + } - { - AMI_Thrower_throwCasCI cb = new AMI_Thrower_throwCasCI(); - thrower.throwCasC_async(cb, 1, 2, 3); - cb.check(); - // Let's check if we can reuse the same callback object for another call. - thrower.throwCasC_async(cb, 1, 2, 3); - cb.check(); - } + out.println("ok"); - out.println("ok"); + out.print("catching derived types with AMI... "); + out.flush(); + + { + AMI_Thrower_throwBasAI cb = new AMI_Thrower_throwBasAI(); + thrower.throwBasA_async(cb, 1, 2); + cb.check(); + } + + { + AMI_Thrower_throwCasAI cb = new AMI_Thrower_throwCasAI(); + thrower.throwCasA_async(cb, 1, 2, 3); + cb.check(); + } + + { + AMI_Thrower_throwCasBI cb = new AMI_Thrower_throwCasBI(); + thrower.throwCasB_async(cb, 1, 2, 3); + cb.check(); + } - out.print("catching derived types with AMI... "); + out.println("ok"); + + if(thrower.supportsUndeclaredExceptions()) + { + out.print("catching unknown user exception with AMI... "); out.flush(); { - AMI_Thrower_throwBasAI cb = new AMI_Thrower_throwBasAI(); - thrower.throwBasA_async(cb, 1, 2); + AMI_Thrower_throwUndeclaredAI cb = new AMI_Thrower_throwUndeclaredAI(); + thrower.throwUndeclaredA_async(cb, 1); cb.check(); } { - AMI_Thrower_throwCasAI cb = new AMI_Thrower_throwCasAI(); - thrower.throwCasA_async(cb, 1, 2, 3); + AMI_Thrower_throwUndeclaredBI cb = new AMI_Thrower_throwUndeclaredBI(); + thrower.throwUndeclaredB_async(cb, 1, 2); cb.check(); } { - AMI_Thrower_throwCasBI cb = new AMI_Thrower_throwCasBI(); - thrower.throwCasB_async(cb, 1, 2, 3); + AMI_Thrower_throwUndeclaredCI cb = new AMI_Thrower_throwUndeclaredCI(); + thrower.throwUndeclaredC_async(cb, 1, 2, 3); cb.check(); } out.println("ok"); + } - if(thrower.supportsUndeclaredExceptions()) - { - out.print("catching unknown user exception with AMI... "); - out.flush(); - - { - AMI_Thrower_throwUndeclaredAI cb = new AMI_Thrower_throwUndeclaredAI(); - thrower.throwUndeclaredA_async(cb, 1); - cb.check(); - } + if(thrower.supportsAssertException()) + { + out.print("testing assert in the server with AMI... "); + out.flush(); - { - AMI_Thrower_throwUndeclaredBI cb = new AMI_Thrower_throwUndeclaredBI(); - thrower.throwUndeclaredB_async(cb, 1, 2); - cb.check(); - } + AMI_Thrower_throwAssertExceptionI cb = new AMI_Thrower_throwAssertExceptionI(); + thrower.throwAssertException_async(cb); + cb.check(); - { - AMI_Thrower_throwUndeclaredCI cb = new AMI_Thrower_throwUndeclaredCI(); - thrower.throwUndeclaredC_async(cb, 1, 2, 3); - cb.check(); - } - - out.println("ok"); - } + out.println("ok"); + } - if(thrower.supportsAssertException()) - { - out.print("testing assert in the server with AMI... "); - out.flush(); + out.print("catching object not exist exception with AMI... "); + out.flush(); - AMI_Thrower_throwAssertExceptionI cb = new AMI_Thrower_throwAssertExceptionI(); - thrower.throwAssertException_async(cb); - cb.check(); + { + Ice.Identity id = communicator.stringToIdentity("does not exist"); + ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower.ice_identity(id)); + AMI_Thrower_throwAasAObjectNotExistI cb = new AMI_Thrower_throwAasAObjectNotExistI(communicator); + thrower2.throwAasA_async(cb, 1); + cb.check(); + } - out.println("ok"); - } + out.println("ok"); - out.print("catching object not exist exception with AMI... "); - out.flush(); + out.print("catching facet not exist exception with AMI... "); + out.flush(); + try + { + ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower, "no such facet"); { - Ice.Identity id = communicator.stringToIdentity("does not exist"); - ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower.ice_identity(id)); - AMI_Thrower_throwAasAObjectNotExistI cb = new AMI_Thrower_throwAasAObjectNotExistI(communicator); + AMI_Thrower_throwAasAFacetNotExistI cb = new AMI_Thrower_throwAasAFacetNotExistI(); thrower2.throwAasA_async(cb, 1); cb.check(); } + } + catch(Throwable ex) + { + ex.printStackTrace(); + test(false); + } - out.println("ok"); + out.println("ok"); - out.print("catching facet not exist exception with AMI... "); - out.flush(); + out.print("catching operation not exist exception with AMI... "); + out.flush(); - try - { - ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower, "no such facet"); - { - AMI_Thrower_throwAasAFacetNotExistI cb = new AMI_Thrower_throwAasAFacetNotExistI(); - thrower2.throwAasA_async(cb, 1); - cb.check(); - } - } - catch(Throwable ex) - { - ex.printStackTrace(); - test(false); - } + { + AMI_WrongOperation_noSuchOperationI cb = new AMI_WrongOperation_noSuchOperationI(); + WrongOperationPrx thrower2 = WrongOperationPrxHelper.uncheckedCast(thrower); + thrower2.noSuchOperation_async(cb); + cb.check(); + } - out.println("ok"); + out.println("ok"); - out.print("catching operation not exist exception with AMI... "); - out.flush(); + out.print("catching unknown local exception with AMI... "); + out.flush(); - { - AMI_WrongOperation_noSuchOperationI cb = new AMI_WrongOperation_noSuchOperationI(); - WrongOperationPrx thrower2 = WrongOperationPrxHelper.uncheckedCast(thrower); - thrower2.noSuchOperation_async(cb); - cb.check(); - } + { + AMI_Thrower_throwLocalExceptionI cb = new AMI_Thrower_throwLocalExceptionI(); + thrower.throwLocalException_async(cb); + cb.check(); + } - out.println("ok"); + out.println("ok"); - out.print("catching unknown local exception with AMI... "); - out.flush(); + out.print("catching unknown non-Ice exception with AMI... "); + out.flush(); - { - AMI_Thrower_throwLocalExceptionI cb = new AMI_Thrower_throwLocalExceptionI(); - thrower.throwLocalException_async(cb); - cb.check(); - } + { + AMI_Thrower_throwNonIceExceptionI cb = new AMI_Thrower_throwNonIceExceptionI(); + thrower.throwNonIceException_async(cb); + cb.check(); + } - out.println("ok"); + out.println("ok"); - out.print("catching unknown non-Ice exception with AMI... "); - out.flush(); + out.print("catching exact types with new AMI mapping... "); + out.flush(); - { - AMI_Thrower_throwNonIceExceptionI cb = new AMI_Thrower_throwNonIceExceptionI(); - thrower.throwNonIceException_async(cb); - cb.check(); - } + { + Callback_Thrower_throwAasAI cb = new Callback_Thrower_throwAasAI(); + thrower.begin_throwAasA(1, cb); + cb.check(); + } - out.println("ok"); + { + Callback_Thrower_throwAorDasAorDI cb = new Callback_Thrower_throwAorDasAorDI(); + thrower.begin_throwAorDasAorD(1, cb); + cb.check(); + } - out.print("catching exact types with new AMI mapping... "); - out.flush(); + { + Callback_Thrower_throwAorDasAorDI cb = new Callback_Thrower_throwAorDasAorDI(); + thrower.begin_throwAorDasAorD(-1, cb); + cb.check(); + } - { - Callback_Thrower_throwAasAI cb = new Callback_Thrower_throwAasAI(); - thrower.begin_throwAasA(1, cb); - cb.check(); - } + { + Callback_Thrower_throwBasBI cb = new Callback_Thrower_throwBasBI(); + thrower.begin_throwBasB(1, 2, cb); + cb.check(); + } - { - Callback_Thrower_throwAorDasAorDI cb = new Callback_Thrower_throwAorDasAorDI(); - thrower.begin_throwAorDasAorD(1, cb); - cb.check(); - } + { + Callback_Thrower_throwCasCI cb = new Callback_Thrower_throwCasCI(); + thrower.begin_throwCasC(1, 2, 3, cb); + cb.check(); + } - { - Callback_Thrower_throwAorDasAorDI cb = new Callback_Thrower_throwAorDasAorDI(); - thrower.begin_throwAorDasAorD(-1, cb); - cb.check(); - } + out.println("ok"); - { - Callback_Thrower_throwBasBI cb = new Callback_Thrower_throwBasBI(); - thrower.begin_throwBasB(1, 2, cb); - cb.check(); - } + out.print("catching derived types with new AMI mapping... "); + out.flush(); - { - Callback_Thrower_throwCasCI cb = new Callback_Thrower_throwCasCI(); - thrower.begin_throwCasC(1, 2, 3, cb); - cb.check(); - } + { + Callback_Thrower_throwBasAI cb = new Callback_Thrower_throwBasAI(); + thrower.begin_throwBasA(1, 2, cb); + cb.check(); + } - out.println("ok"); + { + Callback_Thrower_throwCasAI cb = new Callback_Thrower_throwCasAI(); + thrower.begin_throwCasA(1, 2, 3, cb); + cb.check(); + } + + { + Callback_Thrower_throwCasBI cb = new Callback_Thrower_throwCasBI(); + thrower.begin_throwCasB(1, 2, 3, cb); + cb.check(); + } + + out.println("ok"); - out.print("catching derived types with new AMI mapping... "); + if(thrower.supportsUndeclaredExceptions()) + { + out.print("catching unknown user exception with new AMI mapping... "); out.flush(); { - Callback_Thrower_throwBasAI cb = new Callback_Thrower_throwBasAI(); - thrower.begin_throwBasA(1, 2, cb); + Callback_Thrower_throwUndeclaredAI cb = new Callback_Thrower_throwUndeclaredAI(); + thrower.begin_throwUndeclaredA(1, cb); cb.check(); } { - Callback_Thrower_throwCasAI cb = new Callback_Thrower_throwCasAI(); - thrower.begin_throwCasA(1, 2, 3, cb); + Callback_Thrower_throwUndeclaredBI cb = new Callback_Thrower_throwUndeclaredBI(); + thrower.begin_throwUndeclaredB(1, 2, cb); cb.check(); } { - Callback_Thrower_throwCasBI cb = new Callback_Thrower_throwCasBI(); - thrower.begin_throwCasB(1, 2, 3, cb); + Callback_Thrower_throwUndeclaredCI cb = new Callback_Thrower_throwUndeclaredCI(); + thrower.begin_throwUndeclaredC(1, 2, 3, cb); cb.check(); } out.println("ok"); + } - if(thrower.supportsUndeclaredExceptions()) - { - out.print("catching unknown user exception with new AMI mapping... "); - out.flush(); - - { - Callback_Thrower_throwUndeclaredAI cb = new Callback_Thrower_throwUndeclaredAI(); - thrower.begin_throwUndeclaredA(1, cb); - cb.check(); - } - - { - Callback_Thrower_throwUndeclaredBI cb = new Callback_Thrower_throwUndeclaredBI(); - thrower.begin_throwUndeclaredB(1, 2, cb); - cb.check(); - } - - { - Callback_Thrower_throwUndeclaredCI cb = new Callback_Thrower_throwUndeclaredCI(); - thrower.begin_throwUndeclaredC(1, 2, 3, cb); - cb.check(); - } - - out.println("ok"); - } - - out.print("catching object not exist exception with new AMI mapping... "); - out.flush(); - - { - Ice.Identity id = communicator.stringToIdentity("does not exist"); - ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower.ice_identity(id)); - AMI_Thrower_throwAasAObjectNotExistI cb = new AMI_Thrower_throwAasAObjectNotExistI(communicator); - thrower2.begin_throwAasA(1, cb); - cb.check(); - } + out.print("catching object not exist exception with new AMI mapping... "); + out.flush(); - out.println("ok"); + { + Ice.Identity id = communicator.stringToIdentity("does not exist"); + ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower.ice_identity(id)); + AMI_Thrower_throwAasAObjectNotExistI cb = new AMI_Thrower_throwAasAObjectNotExistI(communicator); + thrower2.begin_throwAasA(1, cb); + cb.check(); + } - out.print("catching facet not exist exception with new AMI mapping... "); - out.flush(); + out.println("ok"); - { - ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower, "no such facet"); - Callback_Thrower_throwAasAFacetNotExistI cb = new Callback_Thrower_throwAasAFacetNotExistI(); - thrower2.begin_throwAasA(1, cb); - cb.check(); - } + out.print("catching facet not exist exception with new AMI mapping... "); + out.flush(); - out.println("ok"); + { + ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower, "no such facet"); + Callback_Thrower_throwAasAFacetNotExistI cb = new Callback_Thrower_throwAasAFacetNotExistI(); + thrower2.begin_throwAasA(1, cb); + cb.check(); + } - out.print("catching operation not exist exception with new AMI mapping... "); - out.flush(); + out.println("ok"); - { - Callback_WrongOperation_noSuchOperationI cb = new Callback_WrongOperation_noSuchOperationI(); - WrongOperationPrx thrower2 = WrongOperationPrxHelper.uncheckedCast(thrower); - thrower2.begin_noSuchOperation(cb); - cb.check(); - } + out.print("catching operation not exist exception with new AMI mapping... "); + out.flush(); - out.println("ok"); + { + Callback_WrongOperation_noSuchOperationI cb = new Callback_WrongOperation_noSuchOperationI(); + WrongOperationPrx thrower2 = WrongOperationPrxHelper.uncheckedCast(thrower); + thrower2.begin_noSuchOperation(cb); + cb.check(); + } - out.print("catching unknown local exception with new AMI mapping... "); - out.flush(); + out.println("ok"); - { - Callback_Thrower_throwLocalExceptionI cb = new Callback_Thrower_throwLocalExceptionI(); - thrower.begin_throwLocalException(cb); - cb.check(); - } + out.print("catching unknown local exception with new AMI mapping... "); + out.flush(); - { - final Callback_Thrower_throwLocalExceptionI cb = new Callback_Thrower_throwLocalExceptionI(); - thrower.begin_throwLocalExceptionIdempotent(new Callback_Thrower_throwLocalExceptionIdempotent() - { - @Override - public void response() - { - cb.response(); - } + { + Callback_Thrower_throwLocalExceptionI cb = new Callback_Thrower_throwLocalExceptionI(); + thrower.begin_throwLocalException(cb); + cb.check(); + } - @Override - public void exception(Ice.LocalException exc) - { - cb.exception(exc); - } - }); - cb.check(); - } + { + final Callback_Thrower_throwLocalExceptionI cb = new Callback_Thrower_throwLocalExceptionI(); + thrower.begin_throwLocalExceptionIdempotent(new Callback_Thrower_throwLocalExceptionIdempotent() + { + @Override + public void response() + { + cb.response(); + } - out.println("ok"); + @Override + public void exception(Ice.LocalException exc) + { + cb.exception(exc); + } + }); + cb.check(); + } - out.print("catching unknown non-Ice exception with new AMI mapping... "); - out.flush(); + out.println("ok"); - { - Callback_Thrower_throwNonIceExceptionI cb = new Callback_Thrower_throwNonIceExceptionI(); - thrower.begin_throwNonIceException(cb); - cb.check(); - } + out.print("catching unknown non-Ice exception with new AMI mapping... "); + out.flush(); - out.println("ok"); + { + Callback_Thrower_throwNonIceExceptionI cb = new Callback_Thrower_throwNonIceExceptionI(); + thrower.begin_throwNonIceException(cb); + cb.check(); } + out.println("ok"); + return thrower; } } diff --git a/java/test/Ice/exceptions/Client.java b/java/test/Ice/exceptions/Client.java index 677274185e0..1e17f5433a6 100644 --- a/java/test/Ice/exceptions/Client.java +++ b/java/test/Ice/exceptions/Client.java @@ -16,7 +16,7 @@ public class Client extends test.Util.Application public int run(String[] args) { Ice.Communicator communicator = communicator(); - ThrowerPrx thrower = AllTests.allTests(communicator, false, getWriter()); + ThrowerPrx thrower = AllTests.allTests(communicator, getWriter()); thrower.shutdown(); return 0; } diff --git a/java/test/Ice/exceptions/Collocated.java b/java/test/Ice/exceptions/Collocated.java index e825cc19eaf..05ddb1c1be1 100644 --- a/java/test/Ice/exceptions/Collocated.java +++ b/java/test/Ice/exceptions/Collocated.java @@ -19,7 +19,7 @@ public class Collocated extends test.Util.Application Ice.Object object = new ThrowerI(); adapter.add(object, communicator.stringToIdentity("thrower")); - AllTests.allTests(communicator, true, getWriter()); + AllTests.allTests(communicator, getWriter()); return 0; } @@ -27,8 +27,10 @@ public class Collocated extends test.Util.Application protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH) { Ice.InitializationData initData = new Ice.InitializationData(); + initData.logger = new DummyLogger(); initData.properties = Ice.Util.createProperties(argsH); initData.properties.setProperty("Ice.Package.Test", "test.Ice.exceptions"); + initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010"); return initData; } diff --git a/java/test/Ice/invoke/lambda/AllTests.java b/java/test/Ice/invoke/lambda/AllTests.java index 3ce788b2e65..5b7764615a3 100644 --- a/java/test/Ice/invoke/lambda/AllTests.java +++ b/java/test/Ice/invoke/lambda/AllTests.java @@ -60,14 +60,13 @@ public class AllTests private boolean _called; } - private static class Callback_Object_opStringI extends Ice.Callback_Object_ice_invoke + private static class Callback_Object_opStringI { public Callback_Object_opStringI(Ice.Communicator communicator) { _communicator = communicator; } - @Override public void response(boolean ok, byte[] outEncaps) { if(ok) @@ -87,12 +86,15 @@ public class AllTests } } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } + public void sent(boolean sent) + { + } + public void check() { callback.check(); @@ -102,14 +104,13 @@ public class AllTests private Callback callback = new Callback(); } - private static class Callback_Object_opExceptionI extends Ice.Callback_Object_ice_invoke + private static class Callback_Object_opExceptionI { public Callback_Object_opExceptionI(Ice.Communicator communicator) { _communicator = communicator; } - @Override public void response(boolean ok, byte[] outEncaps) { if(ok) @@ -136,8 +137,7 @@ public class AllTests } } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -147,6 +147,10 @@ public class AllTests callback.check(); } + public void sent(boolean sent) + { + } + private Ice.Communicator _communicator; private Callback callback = new Callback(); } @@ -173,7 +177,7 @@ public class AllTests Callback_Object_opStringI cb2 = new Callback_Object_opStringI(communicator); cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, (boolean ret, byte[] outParams) -> cb2.response(ret, outParams), - (Ice.LocalException ex) -> cb2.exception(ex), + (Ice.Exception ex) -> cb2.exception(ex), (boolean sent) -> cb2.sent(sent)); cb2.check(); } @@ -183,7 +187,7 @@ public class AllTests Callback_Object_opExceptionI cb2 = new Callback_Object_opExceptionI(communicator); cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, (boolean ret, byte[] outParams) -> cb2.response(ret, outParams), - (Ice.LocalException ex) -> cb2.exception(ex), + (Ice.Exception ex) -> cb2.exception(ex), (boolean sent) -> cb2.sent(sent)); cb2.check(); } diff --git a/java/test/Ice/location/AllTests.java b/java/test/Ice/location/AllTests.java index b57cf5d1dc8..636376a0253 100644 --- a/java/test/Ice/location/AllTests.java +++ b/java/test/Ice/location/AllTests.java @@ -611,6 +611,7 @@ public class AllTests out.flush(); hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello")); obj.migrateHello(); + hello.ice_getConnection().close(false); hello.sayHello(); obj.migrateHello(); hello.sayHello(); @@ -678,18 +679,12 @@ public class AllTests registry.addObject(adapter.add(new HelloI(), id)); adapter.activate(); - try - { - // Note the quotes are necessary here due to ":" in the - // java generated UUID. - HelloPrx helloPrx = HelloPrxHelper.checkedCast( - communicator.stringToProxy("\"" + communicator.identityToString(id) + "\"")); - Ice.Connection connection = helloPrx.ice_getConnection(); - test(false); - } - catch(Ice.CollocationOptimizationException ex) - { - } + // Note the quotes are necessary here due to ":" in the + // java generated UUID. + HelloPrx helloPrx = HelloPrxHelper.checkedCast( + communicator.stringToProxy("\"" + communicator.identityToString(id) + "\"")); + test(helloPrx.ice_getConnection() == null); + adapter.deactivate(); out.println("ok"); diff --git a/java/test/Ice/metrics/AllTests.java b/java/test/Ice/metrics/AllTests.java index 8af9eba4b6b..796b650cad3 100644 --- a/java/test/Ice/metrics/AllTests.java +++ b/java/test/Ice/metrics/AllTests.java @@ -404,7 +404,7 @@ public class AllTests out.print("testing metrics admin facet checkedCast... "); out.flush(); - Ice.ObjectPrx admin = communicator.getAdmin().ice_collocationOptimized(false); + Ice.ObjectPrx admin = communicator.getAdmin(); Ice.PropertiesAdminPrx clientProps = Ice.PropertiesAdminPrxHelper.checkedCast(admin, "Properties"); IceMX.MetricsAdminPrx clientMetrics = IceMX.MetricsAdminPrxHelper.checkedCast(admin, "Metrics"); test(clientProps != null && clientMetrics != null); diff --git a/java/test/Ice/metrics/InvocationObserverI.java b/java/test/Ice/metrics/InvocationObserverI.java index 015dc75cc3b..2eee2947704 100644 --- a/java/test/Ice/metrics/InvocationObserverI.java +++ b/java/test/Ice/metrics/InvocationObserverI.java @@ -46,6 +46,17 @@ class InvocationObserverI extends ObserverI implements Ice.Instrumentation.Invoc return remoteObserver; } + public synchronized Ice.Instrumentation.RemoteObserver + getCollocatedObserver(int a, int b) + { + if(remoteObserver == null) + { + remoteObserver = new RemoteObserverI(); + remoteObserver.reset(); + } + return remoteObserver; + } + int userExceptionCount; int retriedCount; diff --git a/java/test/Ice/objects/AllTests.java b/java/test/Ice/objects/AllTests.java index 54907b2f1ca..68eb23ef4e5 100644 --- a/java/test/Ice/objects/AllTests.java +++ b/java/test/Ice/objects/AllTests.java @@ -44,7 +44,7 @@ public class AllTests } public static InitialPrx - allTests(Ice.Communicator communicator, boolean collocated, PrintWriter out) + allTests(Ice.Communicator communicator, PrintWriter out) { out.print("testing stringToProxy... "); out.flush(); @@ -99,15 +99,13 @@ public class AllTests test(((B)b1.theA).theB == b1); test(((B)b1.theA).theC instanceof C); test(((C)(((B)b1.theA).theC)).theB == b1.theA); - if(!collocated) - { - test(b1.preMarshalInvoked); - test(b1.postUnmarshalInvoked(null)); - test(b1.theA.preMarshalInvoked); - test(b1.theA.postUnmarshalInvoked(null)); - test(((B)b1.theA).theC.preMarshalInvoked); - test(((B)b1.theA).theC.postUnmarshalInvoked(null)); - } + test(b1.preMarshalInvoked); + test(b1.postUnmarshalInvoked(null)); + test(b1.theA.preMarshalInvoked); + test(b1.theA.postUnmarshalInvoked(null)); + test(((B)b1.theA).theC.preMarshalInvoked); + test(((B)b1.theA).theC.postUnmarshalInvoked(null)); + // More tests possible for b2 and d, but I think this is already // sufficient. test(b2.theA == b2); @@ -149,17 +147,15 @@ public class AllTests test(d.theA == b1); test(d.theB == b2); test(d.theC == null); - if(!collocated) - { - test(d.preMarshalInvoked); - test(d.postUnmarshalInvoked(null)); - test(d.theA.preMarshalInvoked); - test(d.theA.postUnmarshalInvoked(null)); - test(d.theB.preMarshalInvoked); - test(d.theB.postUnmarshalInvoked(null)); - test(d.theB.theC.preMarshalInvoked); - test(d.theB.theC.postUnmarshalInvoked(null)); - } + test(d.preMarshalInvoked); + test(d.postUnmarshalInvoked(null)); + test(d.theA.preMarshalInvoked); + test(d.theA.postUnmarshalInvoked(null)); + test(d.theB.preMarshalInvoked); + test(d.theB.postUnmarshalInvoked(null)); + test(d.theB.theC.preMarshalInvoked); + test(d.theB.theC.postUnmarshalInvoked(null)); + out.println("ok"); out.print("testing protected members... "); @@ -236,32 +232,29 @@ public class AllTests } out.println("ok"); - if(!collocated) + out.print("testing UnexpectedObjectException..."); + out.flush(); + ref = "uoet:default -p 12010"; + base = communicator.stringToProxy(ref); + test(base != null); + UnexpectedObjectExceptionTestPrx uoet = UnexpectedObjectExceptionTestPrxHelper.uncheckedCast(base); + test(uoet != null); + try { - out.print("testing UnexpectedObjectException..."); - out.flush(); - ref = "uoet:default -p 12010"; - base = communicator.stringToProxy(ref); - test(base != null); - UnexpectedObjectExceptionTestPrx uoet = UnexpectedObjectExceptionTestPrxHelper.uncheckedCast(base); - test(uoet != null); - try - { - uoet.op(); - test(false); - } - catch(Ice.UnexpectedObjectException ex) - { - test(ex.type.equals("::Test::AlsoEmpty")); - test(ex.expectedType.equals("::Test::Empty")); - } - catch(java.lang.Exception ex) - { - out.println(ex); - test(false); - } - out.println("ok"); + uoet.op(); + test(false); + } + catch(Ice.UnexpectedObjectException ex) + { + test(ex.type.equals("::Test::AlsoEmpty")); + test(ex.expectedType.equals("::Test::Empty")); } + catch(java.lang.Exception ex) + { + out.println(ex); + test(false); + } + out.println("ok"); return initial; } diff --git a/java/test/Ice/objects/Client.java b/java/test/Ice/objects/Client.java index 88abae70460..a7f29457ed1 100644 --- a/java/test/Ice/objects/Client.java +++ b/java/test/Ice/objects/Client.java @@ -73,7 +73,7 @@ public class Client extends test.Util.Application communicator.addObjectFactory(factory, "::Test::J"); communicator.addObjectFactory(factory, "::Test::H"); - InitialPrx initial = AllTests.allTests(communicator, false, getWriter()); + InitialPrx initial = AllTests.allTests(communicator, getWriter()); initial.shutdown(); return 0; } diff --git a/java/test/Ice/objects/Collocated.java b/java/test/Ice/objects/Collocated.java index e118a0af191..b5a09a1475a 100644 --- a/java/test/Ice/objects/Collocated.java +++ b/java/test/Ice/objects/Collocated.java @@ -13,14 +13,73 @@ import test.Ice.objects.Test.Initial; public class Collocated extends test.Util.Application { + private static class MyObjectFactory implements Ice.ObjectFactory + { + public Ice.Object create(String type) + { + if(type.equals("::Test::B")) + { + return new BI(); + } + else if(type.equals("::Test::C")) + { + return new CI(); + } + else if(type.equals("::Test::D")) + { + return new DI(); + } + else if(type.equals("::Test::E")) + { + return new EI(); + } + else if(type.equals("::Test::F")) + { + return new FI(); + } + else if(type.equals("::Test::I")) + { + return new II(); + } + else if(type.equals("::Test::J")) + { + return new JI(); + } + else if(type.equals("::Test::H")) + { + return new HI(); + } + + assert (false); // Should never be reached + return null; + } + + public void destroy() + { + // Nothing to do + } + } + public int run(String[] args) { Ice.Communicator communicator = communicator(); + Ice.ObjectFactory factory = new MyObjectFactory(); + communicator.addObjectFactory(factory, "::Test::B"); + communicator.addObjectFactory(factory, "::Test::C"); + communicator.addObjectFactory(factory, "::Test::D"); + communicator.addObjectFactory(factory, "::Test::E"); + communicator.addObjectFactory(factory, "::Test::F"); + communicator.addObjectFactory(factory, "::Test::I"); + communicator.addObjectFactory(factory, "::Test::J"); + communicator.addObjectFactory(factory, "::Test::H"); + communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); Initial initial = new InitialI(adapter); adapter.add(initial, communicator.stringToIdentity("initial")); - AllTests.allTests(communicator, true, getWriter()); + UnexpectedObjectExceptionTestI object = new UnexpectedObjectExceptionTestI(); + adapter.add(object, communicator.stringToIdentity("uoet")); + AllTests.allTests(communicator, getWriter()); // We must call shutdown even in the collocated case for cyclic // dependency cleanup initial.shutdown(); diff --git a/java/test/Ice/operations/AllTests.java b/java/test/Ice/operations/AllTests.java index da960e6e5f8..a22474bbfd6 100644 --- a/java/test/Ice/operations/AllTests.java +++ b/java/test/Ice/operations/AllTests.java @@ -18,7 +18,7 @@ import test.Ice.operations.Test.MyDerivedClassPrxHelper; public class AllTests { public static MyClassPrx - allTests(test.Util.Application app, boolean collocated, PrintWriter out) + allTests(test.Util.Application app, PrintWriter out) { Ice.Communicator communicator = app.communicator(); String ref = "test:default -p 12010"; @@ -38,96 +38,95 @@ public class AllTests Oneways.oneways(app, cl); out.println("ok"); - if(!collocated) + out.print("testing twoway operations with AMI... "); + out.flush(); + TwowaysAMI.twowaysAMI(app, cl); + TwowaysAMI.twowaysAMI(app, derived); + out.println("ok"); + + out.print("testing twoway operations with new AMI mapping... "); + out.flush(); + TwowaysNewAMI.twowaysNewAMI(app, cl); + TwowaysNewAMI.twowaysNewAMI(app, derived); + out.println("ok"); + + // + // Use reflection to load TwowaysLambdaAMI as that is only supported with Java >= 1.8 + // + try { - out.print("testing twoway operations with AMI... "); - out.flush(); - TwowaysAMI.twowaysAMI(app, cl); - TwowaysAMI.twowaysAMI(app, derived); - out.println("ok"); - - out.print("testing twoway operations with new AMI mapping... "); - out.flush(); - TwowaysNewAMI.twowaysNewAMI(app, cl); - TwowaysNewAMI.twowaysNewAMI(app, derived); - out.println("ok"); - - // - // Use reflection to load TwowaysLambdaAMI as that is only supported with Java >= 1.8 - // - try - { - Class<?> cls = IceInternal.Util.findClass("test.Ice.operations.lambda.TwowaysLambdaAMI", null); - if(cls != null) - { - java.lang.reflect.Method twowaysLambdaAMI = cls.getDeclaredMethod("twowaysLambdaAMI", - new Class<?>[]{test.Util.Application.class, MyClassPrx.class}); - out.print("testing twoway operations with lambda AMI mapping... "); - out.flush(); - twowaysLambdaAMI.invoke(null, app, cl); - twowaysLambdaAMI.invoke(null, app, derived); - out.println("ok"); - } - } - catch(java.lang.NoSuchMethodException ex) - { - throw new RuntimeException(ex); - } - catch(java.lang.IllegalAccessException ex) + Class<?> cls = IceInternal.Util.findClass("test.Ice.operations.lambda.TwowaysLambdaAMI", null); + if(cls != null) { - throw new RuntimeException(ex); - } - catch(java.lang.reflect.InvocationTargetException ex) - { - throw new RuntimeException(ex); + java.lang.reflect.Method twowaysLambdaAMI = + cls.getDeclaredMethod("twowaysLambdaAMI", + new Class<?>[]{test.Util.Application.class, MyClassPrx.class}); + out.print("testing twoway operations with lambda AMI mapping... "); + out.flush(); + twowaysLambdaAMI.invoke(null, app, cl); + twowaysLambdaAMI.invoke(null, app, derived); + out.println("ok"); } + } + catch(java.lang.NoSuchMethodException ex) + { + throw new RuntimeException(ex); + } + catch(java.lang.IllegalAccessException ex) + { + throw new RuntimeException(ex); + } + catch(java.lang.reflect.InvocationTargetException ex) + { + throw new RuntimeException(ex); + } - out.print("testing oneway operations with AMI... "); - out.flush(); - OnewaysAMI.onewaysAMI(app, cl); - out.println("ok"); + out.print("testing oneway operations with AMI... "); + out.flush(); + OnewaysAMI.onewaysAMI(app, cl); + out.println("ok"); - out.print("testing oneway operations with new AMI mapping... "); - out.flush(); - OnewaysNewAMI.onewaysNewAMI(app, cl); - out.println("ok"); + out.print("testing oneway operations with new AMI mapping... "); + out.flush(); + OnewaysNewAMI.onewaysNewAMI(app, cl); + out.println("ok"); - // - // Use reflection to load OnewaysLambdaAMI as that is only supported with Java >= 1.8 - // - try - { - Class<?> cls = IceInternal.Util.findClass("test.Ice.operations.lambda.OnewaysLambdaAMI", null); - if(cls != null) - { - java.lang.reflect.Method onewaysLambdaAMI = cls.getDeclaredMethod("onewaysLambdaAMI", - new Class<?>[]{test.Util.Application.class, MyClassPrx.class}); - out.print("testing twoway operations with lambda AMI mapping... "); - out.flush(); - onewaysLambdaAMI.invoke(null, app, cl); - onewaysLambdaAMI.invoke(null, app, derived); - out.println("ok"); - } - } - catch(java.lang.NoSuchMethodException ex) - { - throw new RuntimeException(ex); - } - catch(java.lang.IllegalAccessException ex) - { - throw new RuntimeException(ex); - } - catch(java.lang.reflect.InvocationTargetException ex) + // + // Use reflection to load OnewaysLambdaAMI as that is only supported with Java >= 1.8 + // + try + { + Class<?> cls = IceInternal.Util.findClass("test.Ice.operations.lambda.OnewaysLambdaAMI", null); + if(cls != null) { - throw new RuntimeException(ex); + java.lang.reflect.Method onewaysLambdaAMI = + cls.getDeclaredMethod("onewaysLambdaAMI", + new Class<?>[]{test.Util.Application.class, MyClassPrx.class}); + out.print("testing twoway operations with lambda AMI mapping... "); + out.flush(); + onewaysLambdaAMI.invoke(null, app, cl); + onewaysLambdaAMI.invoke(null, app, derived); + out.println("ok"); } - - out.print("testing batch oneway operations... "); - out.flush(); - BatchOneways.batchOneways(cl, out); - BatchOneways.batchOneways(derived, out); - out.println("ok"); } + catch(java.lang.NoSuchMethodException ex) + { + throw new RuntimeException(ex); + } + catch(java.lang.IllegalAccessException ex) + { + throw new RuntimeException(ex); + } + catch(java.lang.reflect.InvocationTargetException ex) + { + throw new RuntimeException(ex); + } + + out.print("testing batch oneway operations... "); + out.flush(); + BatchOneways.batchOneways(cl, out); + BatchOneways.batchOneways(derived, out); + out.println("ok"); return cl; } diff --git a/java/test/Ice/operations/BatchOneways.java b/java/test/Ice/operations/BatchOneways.java index 129c3a36c48..8415f3d6ece 100644 --- a/java/test/Ice/operations/BatchOneways.java +++ b/java/test/Ice/operations/BatchOneways.java @@ -60,6 +60,8 @@ class BatchOneways } MyClassPrx batch = MyClassPrxHelper.uncheckedCast(p.ice_batchOneway()); + batch.ice_flushBatchRequests(); + batch.end_ice_flushBatchRequests(batch.begin_ice_flushBatchRequests()); for(int i = 0 ; i < 30 ; ++i) { @@ -73,40 +75,43 @@ class BatchOneways } } - batch.ice_getConnection().flushBatchRequests(); + if(batch.ice_getConnection() != null) + { + batch.ice_getConnection().flushBatchRequests(); - MyClassPrx batch2 = MyClassPrxHelper.uncheckedCast(p.ice_batchOneway()); + MyClassPrx batch2 = MyClassPrxHelper.uncheckedCast(p.ice_batchOneway()); - batch.ice_ping(); - batch2.ice_ping(); - batch.ice_flushBatchRequests(); - batch.ice_getConnection().close(false); - batch.ice_ping(); - batch2.ice_ping(); + batch.ice_ping(); + batch2.ice_ping(); + batch.ice_flushBatchRequests(); + batch.ice_getConnection().close(false); + batch.ice_ping(); + batch2.ice_ping(); - batch.ice_getConnection(); - batch2.ice_getConnection(); + batch.ice_getConnection(); + batch2.ice_getConnection(); - batch.ice_ping(); - batch.ice_getConnection().close(false); - try - { batch.ice_ping(); - test(false); - } - catch(Ice.CloseConnectionException ex) - { - } - try - { + batch.ice_getConnection().close(false); + try + { + batch.ice_ping(); + test(false); + } + catch(Ice.CloseConnectionException ex) + { + } + try + { + batch2.ice_ping(); + test(false); + } + catch(Ice.CloseConnectionException ex) + { + } + batch.ice_ping(); batch2.ice_ping(); - test(false); - } - catch(Ice.CloseConnectionException ex) - { } - batch.ice_ping(); - batch2.ice_ping(); Ice.Identity identity = new Ice.Identity(); identity.name = "invalid"; diff --git a/java/test/Ice/operations/Client.java b/java/test/Ice/operations/Client.java index 129dbd4f14c..ed4ef912ac6 100644 --- a/java/test/Ice/operations/Client.java +++ b/java/test/Ice/operations/Client.java @@ -16,7 +16,7 @@ public class Client extends test.Util.Application public int run(String[] args) { java.io.PrintWriter out = getWriter(); - MyClassPrx myClass = AllTests.allTests(this, false, out); + MyClassPrx myClass = AllTests.allTests(this, out); out.print("testing server shutdown... "); out.flush(); diff --git a/java/test/Ice/operations/Collocated.java b/java/test/Ice/operations/Collocated.java index 6dffa51dd86..45aa29a6a30 100644 --- a/java/test/Ice/operations/Collocated.java +++ b/java/test/Ice/operations/Collocated.java @@ -13,12 +13,13 @@ public class Collocated extends test.Util.Application { public int run(String[] args) { + communicator().getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); java.io.PrintWriter out = getWriter(); Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter"); adapter.add(new MyDerivedClassI(), communicator().stringToIdentity("test")); adapter.activate(); - AllTests.allTests(this, true, out); + AllTests.allTests(this, out); return 0; } @@ -28,7 +29,21 @@ public class Collocated extends test.Util.Application Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = Ice.Util.createProperties(argsH); initData.properties.setProperty("Ice.Package.Test", "test.Ice.operations"); - initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010"); + + // + // We must set MessageSizeMax to an explicit values, + // because we run tests to check whether + // Ice.MemoryLimitException is raised as expected. + // + initData.properties.setProperty("Ice.MessageSizeMax", "100"); + + // + // Its possible to have batch oneway requests dispatched + // after the adapter is deactivated due to thread + // scheduling so we supress this warning. + // + initData.properties.setProperty("Ice.Warn.Dispatch", "0"); + return initData; } diff --git a/java/test/Ice/operations/TwowaysAMI.java b/java/test/Ice/operations/TwowaysAMI.java index 8ede3f056f3..d9d4aaa8d0b 100644 --- a/java/test/Ice/operations/TwowaysAMI.java +++ b/java/test/Ice/operations/TwowaysAMI.java @@ -1238,6 +1238,7 @@ class TwowaysAMI } catch(java.lang.Exception ex) { + ex.printStackTrace(); test(false); } cb.check(); diff --git a/java/test/Ice/operations/lambda/OnewaysLambdaAMI.java b/java/test/Ice/operations/lambda/OnewaysLambdaAMI.java index af596c9512e..4b1a8141f53 100644 --- a/java/test/Ice/operations/lambda/OnewaysLambdaAMI.java +++ b/java/test/Ice/operations/lambda/OnewaysLambdaAMI.java @@ -9,9 +9,6 @@ package test.Ice.operations.lambda; -import test.Ice.operations.Test.Callback_MyClass_opIdempotent; -import test.Ice.operations.Test.Callback_MyClass_opNonmutating; -import test.Ice.operations.Test.Callback_MyClass_opVoid; import test.Ice.operations.Test.MyClass; import test.Ice.operations.Test.MyClassPrx; import test.Ice.operations.Test.MyClassPrxHelper; @@ -29,9 +26,9 @@ public class OnewaysLambdaAMI } } - private static class CallbackBase + private static class Callback { - CallbackBase() + Callback() { _called = false; } @@ -59,25 +56,18 @@ public class OnewaysLambdaAMI notify(); } - private boolean _called; - } - - static class Callback extends CallbackBase - { - public Callback() - { - } - public void sent(boolean sentSynchronously) { called(); } - void noException(Ice.LocalException ex) + void noException(Ice.Exception ex) { test(false); } + + private boolean _called; } public static void @@ -88,29 +78,9 @@ public class OnewaysLambdaAMI { final Callback cb = new Callback(); - Ice.Callback_Object_ice_ping callback = new Ice.Callback_Object_ice_ping() - { - public void - response() - { - test(false); - } - - public void - exception(Ice.LocalException ex) - { - cb.noException(ex); - } - - public void - sent(boolean sentSynchronously) - { - cb.sent(sentSynchronously); - } - }; p.begin_ice_ping( - () -> callback.response(), - (Ice.LocalException ex) -> callback.exception(ex), + () -> test(false), + (Ice.Exception ex) -> cb.noException(ex), (boolean sent) -> cb.sent(sent) ); cb.check(); @@ -151,29 +121,9 @@ public class OnewaysLambdaAMI { final Callback cb = new Callback(); - Callback_MyClass_opVoid callback = new Callback_MyClass_opVoid() - { - public void - response() - { - test(false); - } - - public void - exception(Ice.LocalException ex) - { - cb.noException(ex); - } - - public void - sent(boolean sentSynchronously) - { - cb.sent(sentSynchronously); - } - }; p.begin_opVoid( - () -> callback.response(), - (Ice.LocalException ex) -> callback.exception(ex), + () -> test(false), + (Ice.Exception ex) -> cb.noException(ex), (boolean sent) -> cb.sent(sent) ); cb.check(); @@ -181,29 +131,9 @@ public class OnewaysLambdaAMI { final Callback cb = new Callback(); - Callback_MyClass_opIdempotent callback = new Callback_MyClass_opIdempotent() - { - public void - response() - { - test(false); - } - - public void - exception(Ice.LocalException ex) - { - cb.noException(ex); - } - - public void - sent(boolean sentSynchronously) - { - cb.sent(sentSynchronously); - } - }; p.begin_opIdempotent( - () -> callback.response(), - (Ice.LocalException ex) -> callback.exception(ex), + () -> test(false), + (Ice.Exception ex) -> cb.noException(ex), (boolean sent) -> cb.sent(sent) ); cb.check(); @@ -211,29 +141,9 @@ public class OnewaysLambdaAMI { final Callback cb = new Callback(); - Callback_MyClass_opNonmutating callback = new Callback_MyClass_opNonmutating() - { - public void - response() - { - test(false); - } - - public void - exception(Ice.LocalException ex) - { - cb.noException(ex); - } - - public void - sent(boolean sentSynchronously) - { - cb.sent(sentSynchronously); - } - }; p.begin_opNonmutating( - () -> callback.response(), - (Ice.LocalException ex) -> callback.exception(ex), + () -> test(false), + (Ice.Exception ex) -> cb.noException(ex), (boolean sent) -> cb.sent(sent) ); cb.check(); diff --git a/java/test/Ice/operations/lambda/TwowaysLambdaAMI.java b/java/test/Ice/operations/lambda/TwowaysLambdaAMI.java index 74eac9f4ff5..d8ff5af661b 100644 --- a/java/test/Ice/operations/lambda/TwowaysLambdaAMI.java +++ b/java/test/Ice/operations/lambda/TwowaysLambdaAMI.java @@ -9,39 +9,6 @@ package test.Ice.operations.lambda; -import test.Ice.operations.Test.Callback_MyClass_opVoid; -import test.Ice.operations.Test.Callback_MyClass_opBool; -import test.Ice.operations.Test.Callback_MyClass_opBoolS; -import test.Ice.operations.Test.Callback_MyClass_opBoolSS; -import test.Ice.operations.Test.Callback_MyClass_opByte; -import test.Ice.operations.Test.Callback_MyClass_opByteBoolD; -import test.Ice.operations.Test.Callback_MyClass_opByteS; -import test.Ice.operations.Test.Callback_MyClass_opByteSS; -import test.Ice.operations.Test.Callback_MyClass_opContext; -import test.Ice.operations.Test.Callback_MyClass_opFloatDouble; -import test.Ice.operations.Test.Callback_MyClass_opFloatDoubleS; -import test.Ice.operations.Test.Callback_MyClass_opFloatDoubleSS; -import test.Ice.operations.Test.Callback_MyClass_opIdempotent; -import test.Ice.operations.Test.Callback_MyClass_opIntS; -import test.Ice.operations.Test.Callback_MyClass_opLongFloatD; -import test.Ice.operations.Test.Callback_MyClass_opMyClass; -import test.Ice.operations.Test.Callback_MyClass_opMyEnum; -import test.Ice.operations.Test.Callback_MyClass_opNonmutating; -import test.Ice.operations.Test.Callback_MyClass_opShortIntD; -import test.Ice.operations.Test.Callback_MyClass_opShortIntLong; -import test.Ice.operations.Test.Callback_MyClass_opShortIntLongS; -import test.Ice.operations.Test.Callback_MyClass_opShortIntLongSS; -import test.Ice.operations.Test.Callback_MyClass_opString; -import test.Ice.operations.Test.Callback_MyClass_opStringMyEnumD; -import test.Ice.operations.Test.Callback_MyClass_opMyEnumStringD; -import test.Ice.operations.Test.Callback_MyClass_opStringS; -import test.Ice.operations.Test.Callback_MyClass_opStringSS; -import test.Ice.operations.Test.Callback_MyClass_opStringSSS; -import test.Ice.operations.Test.Callback_MyClass_opStringStringD; -import test.Ice.operations.Test.Callback_MyClass_opStruct; -import test.Ice.operations.Test.Callback_MyClass_opMyStructMyEnumD; -import test.Ice.operations.Test.Callback_MyClass_opDoubleMarshaling; -import test.Ice.operations.Test.Callback_MyDerivedClass_opDerived; import test.Ice.operations.Test.AnotherStruct; import test.Ice.operations.Test.MyClass; import test.Ice.operations.Test.MyClassPrx; @@ -99,16 +66,14 @@ public class TwowaysLambdaAMI private boolean _called; } - private static class pingI extends Ice.Callback_Object_ice_ping + private static class pingI { - @Override public void response() { callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -121,17 +86,15 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class isAI extends Ice.Callback_Object_ice_isA + private static class isAI { - @Override public void response(boolean r) { test(r); callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -144,17 +107,15 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class idI extends Ice.Callback_Object_ice_id + private static class idI { - @Override public void response(String id) { test(id.equals(MyDerivedClass.ice_staticId())); callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -167,17 +128,15 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class idsI extends Ice.Callback_Object_ice_ids + private static class idsI { - @Override public void response(String[] ids) { test(ids.length == 3); callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -190,16 +149,14 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opVoidI extends Callback_MyClass_opVoid + private static class opVoidI { - @Override public void response() { callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -212,9 +169,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opByteI extends Callback_MyClass_opByte + private static class opByteI { - @Override public void response(byte r, byte b) { test(b == (byte)0xf0); @@ -222,8 +178,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -236,9 +191,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opBoolI extends Callback_MyClass_opBool + private static class opBoolI { - @Override public void response(boolean r, boolean b) { test(b); @@ -246,8 +200,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -260,9 +213,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opShortIntLongI extends Callback_MyClass_opShortIntLong + private static class opShortIntLongI { - @Override public void response(long r, short s, int i, long l) { test(s == 10); @@ -272,8 +224,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -286,9 +237,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opFloatDoubleI extends Callback_MyClass_opFloatDouble + private static class opFloatDoubleI { - @Override public void response(double r, float f, double d) { test(f == 3.14f); @@ -297,8 +247,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -311,9 +260,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opStringI extends Callback_MyClass_opString + private static class opStringI { - @Override public void response(String r, String s) { test(s.equals("world hello")); @@ -321,8 +269,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -335,9 +282,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opMyEnumI extends Callback_MyClass_opMyEnum + private static class opMyEnumI { - @Override public void response(MyEnum r, MyEnum e) { test(e == MyEnum.enum2); @@ -345,8 +291,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -359,14 +304,13 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opMyClassI extends Callback_MyClass_opMyClass + private static class opMyClassI { opMyClassI(Ice.Communicator communicator) { _communicator = communicator; } - @Override public void response(MyClassPrx r, MyClassPrx c1, MyClassPrx c2) { test(c1.ice_getIdentity().equals(_communicator.stringToIdentity("test"))); @@ -389,8 +333,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -404,14 +347,13 @@ public class TwowaysLambdaAMI private Ice.Communicator _communicator; } - private static class opStructI extends Callback_MyClass_opStruct + private static class opStructI { opStructI(Ice.Communicator communicator) { _communicator = communicator; } - @Override public void response(Structure rso, Structure so) { test(rso.p == null); @@ -427,8 +369,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -442,9 +383,8 @@ public class TwowaysLambdaAMI private Ice.Communicator _communicator; } - private static class opByteSI extends Callback_MyClass_opByteS + private static class opByteSI { - @Override public void response(byte[] rso, byte[] bso) { test(bso.length == 4); @@ -464,8 +404,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -478,9 +417,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opBoolSI extends Callback_MyClass_opBoolS + private static class opBoolSI { - @Override public void response(boolean[] rso, boolean[] bso) { test(bso.length == 4); @@ -495,8 +433,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -509,9 +446,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opShortIntLongSI extends Callback_MyClass_opShortIntLongS + private static class opShortIntLongSI { - @Override public void response(long[] rso, short[] sso, int[] iso, long[] lso) { test(sso.length == 3); @@ -537,8 +473,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -551,9 +486,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opFloatDoubleSI extends Callback_MyClass_opFloatDoubleS + private static class opFloatDoubleSI { - @Override public void response(double[] rso, float[] fso, double[] dso) { test(fso.length == 2); @@ -572,8 +506,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -586,9 +519,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opStringSI extends Callback_MyClass_opStringS + private static class opStringSI { - @Override public void response(String[] rso, String[] sso) { test(sso.length == 4); @@ -603,8 +535,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -617,9 +548,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opByteSSI extends Callback_MyClass_opByteSS + private static class opByteSSI { - @Override public void response(byte[][] rso, byte[][] bso) { test(bso.length == 2); @@ -644,8 +574,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -658,16 +587,14 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opBoolSSI extends Callback_MyClass_opBoolSS + private static class opBoolSSI { - @Override public void response(boolean[][] rso, boolean[][] bso) { callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -680,16 +607,14 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opShortIntLongSSI extends Callback_MyClass_opShortIntLongSS + private static class opShortIntLongSSI { - @Override public void response(long[][] rso, short[][] sso, int[][] iso, long[][] lso) { callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -702,9 +627,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opFloatDoubleSSI extends Callback_MyClass_opFloatDoubleSS + private static class opFloatDoubleSSI { - @Override public void response(double[][] rso, float[][] fso, double[][] dso) { test(fso.length == 3); @@ -730,8 +654,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -744,9 +667,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opStringSSI extends Callback_MyClass_opStringSS + private static class opStringSSI { - @Override public void response(String[][] rso, String[][] sso) { test(sso.length == 5); @@ -767,8 +689,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -781,9 +702,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opStringSSSI extends Callback_MyClass_opStringSSS + private static class opStringSSSI { - @Override public void response(String[][][] rsso, String[][][] ssso) { test(ssso.length == 5); @@ -821,8 +741,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -835,9 +754,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opByteBoolDI extends Callback_MyClass_opByteBoolD + private static class opByteBoolDI { - @Override public void response(java.util.Map<Byte, Boolean> ro, java.util.Map<Byte, Boolean> _do) { java.util.Map<Byte, Boolean> di1 = new java.util.HashMap<Byte, Boolean>(); @@ -852,8 +770,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -866,9 +783,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opShortIntDI extends Callback_MyClass_opShortIntD + private static class opShortIntDI { - @Override public void response(java.util.Map<Short, Integer> ro, java.util.Map<Short, Integer> _do) { java.util.Map<Short, Integer> di1 = new java.util.HashMap<Short, Integer>(); @@ -883,8 +799,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -897,9 +812,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opLongFloatDI extends Callback_MyClass_opLongFloatD + private static class opLongFloatDI { - @Override public void response(java.util.Map<Long, Float> ro, java.util.Map<Long, Float> _do) { java.util.Map<Long, Float> di1 = new java.util.HashMap<Long, Float>(); @@ -914,8 +828,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -928,9 +841,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opStringStringDI extends Callback_MyClass_opStringStringD + private static class opStringStringDI { - @Override public void response(java.util.Map<String, String> ro, java.util.Map<String, String> _do) { java.util.Map<String, String> di1 = new java.util.HashMap<String, String>(); @@ -945,8 +857,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -959,9 +870,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opStringMyEnumDI extends Callback_MyClass_opStringMyEnumD + private static class opStringMyEnumDI { - @Override public void response(java.util.Map<String, MyEnum> ro, java.util.Map<String, MyEnum> _do) { java.util.Map<String, MyEnum> di1 = new java.util.HashMap<String, MyEnum>(); @@ -976,8 +886,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -990,9 +899,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opMyEnumStringDI extends Callback_MyClass_opMyEnumStringD + private static class opMyEnumStringDI { - @Override public void response(java.util.Map<MyEnum, String> ro, java.util.Map<MyEnum, String> _do) { java.util.Map<MyEnum, String> di1 = new java.util.HashMap<MyEnum, String>(); @@ -1005,8 +913,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -1019,9 +926,8 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opMyStructMyEnumDI extends Callback_MyClass_opMyStructMyEnumD + private static class opMyStructMyEnumDI { - @Override public void response(java.util.Map<MyStruct, MyEnum> ro, java.util.Map<MyStruct, MyEnum> _do) { MyStruct s11 = new MyStruct(1, 1); @@ -1040,8 +946,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -1054,14 +959,13 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opIntSI extends Callback_MyClass_opIntS + private static class opIntSI { opIntSI(int l) { _l = l; } - @Override public void response(int[] r) { test(r.length == _l); @@ -1072,8 +976,7 @@ public class TwowaysLambdaAMI callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -1087,16 +990,14 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opDerivedI extends Callback_MyDerivedClass_opDerived + private static class opDerivedI { - @Override public void response() { callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -1109,16 +1010,14 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opDoubleMarshalingI extends Callback_MyClass_opDoubleMarshaling + private static class opDoubleMarshalingI { - @Override public void response() { callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -1131,16 +1030,14 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opIdempotentI extends Callback_MyClass_opIdempotent + private static class opIdempotentI { - @Override public void response() { callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -1153,16 +1050,14 @@ public class TwowaysLambdaAMI private Callback callback = new Callback(); } - private static class opNonmutatingI extends Callback_MyClass_opNonmutating + private static class opNonmutatingI { - @Override public void response() { callback.called(); } - @Override - public void exception(Ice.LocalException ex) + public void exception(Ice.Exception ex) { test(false); } @@ -1182,31 +1077,31 @@ public class TwowaysLambdaAMI { pingI cb = new pingI(); - p.begin_ice_ping(() -> cb.response(), (Ice.LocalException ex) -> test(false)); + p.begin_ice_ping(() -> cb.response(), (Ice.Exception ex) -> test(false)); cb.check(); } { isAI cb = new isAI(); - p.begin_ice_isA(MyClass.ice_staticId(), (boolean r) -> cb.response(r), (Ice.LocalException ex) -> test(false)); + p.begin_ice_isA(MyClass.ice_staticId(), (boolean r) -> cb.response(r), (Ice.Exception ex) -> test(false)); cb.check(); } { idI cb = new idI(); - p.begin_ice_id((String id) -> cb.response(id), (Ice.LocalException ex) -> test(false)); + p.begin_ice_id((String id) -> cb.response(id), (Ice.Exception ex) -> test(false)); cb.check(); } { idsI cb = new idsI(); - p.begin_ice_ids((String[] ids) -> cb.response(ids), (Ice.LocalException ex) -> test(false)); + p.begin_ice_ids((String[] ids) -> cb.response(ids), (Ice.Exception ex) -> test(false)); cb.check(); } { opVoidI cb = new opVoidI(); - p.begin_opVoid(() -> cb.response(), (Ice.LocalException ex) -> test(false)); + p.begin_opVoid(() -> cb.response(), (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1214,7 +1109,7 @@ public class TwowaysLambdaAMI opByteI cb = new opByteI(); p.begin_opByte((byte)0xff, (byte)0x0f, (byte p1, byte p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1222,7 +1117,7 @@ public class TwowaysLambdaAMI opBoolI cb = new opBoolI(); p.begin_opBool(true, false, (boolean p1, boolean p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1230,7 +1125,7 @@ public class TwowaysLambdaAMI opShortIntLongI cb = new opShortIntLongI(); p.begin_opShortIntLong((short)10, 11, 12L, (long p1, short p2, int p3, long p4) -> cb.response(p1, p2, p3, p4), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1238,7 +1133,7 @@ public class TwowaysLambdaAMI opFloatDoubleI cb = new opFloatDoubleI(); p.begin_opFloatDouble(3.14f, 1.1E10, (double p1, float p2, double p3) -> cb.response(p1, p2, p3), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1246,7 +1141,7 @@ public class TwowaysLambdaAMI opStringI cb = new opStringI(); p.begin_opString("hello", "world", (String p1, String p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1254,7 +1149,7 @@ public class TwowaysLambdaAMI opMyEnumI cb = new opMyEnumI(); p.begin_opMyEnum(MyEnum.enum2, (MyEnum p1, MyEnum p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1262,7 +1157,7 @@ public class TwowaysLambdaAMI opMyClassI cb = new opMyClassI(communicator); p.begin_opMyClass(p, (MyClassPrx p1, MyClassPrx p2, MyClassPrx p3) -> cb.response(p1, p2, p3), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1281,7 +1176,7 @@ public class TwowaysLambdaAMI opStructI cb = new opStructI(communicator); p.begin_opStruct(si1, si2, (Structure p1, Structure p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1304,7 +1199,7 @@ public class TwowaysLambdaAMI opByteSI cb = new opByteSI(); p.begin_opByteS(bsi1, bsi2, (byte[] p1, byte[] p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1315,7 +1210,7 @@ public class TwowaysLambdaAMI opBoolSI cb = new opBoolSI(); p.begin_opBoolS(bsi1, bsi2, (boolean[] p1, boolean[] p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1327,7 +1222,7 @@ public class TwowaysLambdaAMI opShortIntLongSI cb = new opShortIntLongSI(); p.begin_opShortIntLongS(ssi, isi, lsi, (long[] p1, short[] p2, int[] p3, long[] p4) -> cb.response(p1, p2, p3, p4), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1338,7 +1233,7 @@ public class TwowaysLambdaAMI opFloatDoubleSI cb = new opFloatDoubleSI(); p.begin_opFloatDoubleS(fsi, dsi, (double[] p1, float[] p2, double[] p3) -> cb.response(p1, p2, p3), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1349,7 +1244,7 @@ public class TwowaysLambdaAMI opStringSI cb = new opStringSI(); p.begin_opStringS(ssi1, ssi2, (String[] p1, String[] p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1368,7 +1263,7 @@ public class TwowaysLambdaAMI opByteSSI cb = new opByteSSI(); p.begin_opByteSS(bsi1, bsi2, (byte[][] p1, byte[][] p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1387,7 +1282,7 @@ public class TwowaysLambdaAMI opFloatDoubleSSI cb = new opFloatDoubleSSI(); p.begin_opFloatDoubleSS(fsi, dsi, (double[][] p1, float[][] p2, double[][] p3) -> cb.response(p1, p2, p3), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1407,7 +1302,7 @@ public class TwowaysLambdaAMI opStringSSI cb = new opStringSSI(); p.begin_opStringSS(ssi1, ssi2, (String[][] p1, String[][] p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1451,7 +1346,7 @@ public class TwowaysLambdaAMI opStringSSSI cb = new opStringSSSI(); p.begin_opStringSSS(sssi1, sssi2, (String[][][] p1, String[][][] p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1467,7 +1362,7 @@ public class TwowaysLambdaAMI opByteBoolDI cb = new opByteBoolDI(); p.begin_opByteBoolD(di1, di2, (Map<Byte, Boolean> p1, Map<Byte, Boolean> p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1483,7 +1378,7 @@ public class TwowaysLambdaAMI opShortIntDI cb = new opShortIntDI(); p.begin_opShortIntD(di1, di2, (Map<Short, Integer> p1, Map<Short, Integer> p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1499,7 +1394,7 @@ public class TwowaysLambdaAMI opLongFloatDI cb = new opLongFloatDI(); p.begin_opLongFloatD(di1, di2, (Map<Long, Float> p1, Map<Long, Float> p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1515,7 +1410,7 @@ public class TwowaysLambdaAMI opStringStringDI cb = new opStringStringDI(); p.begin_opStringStringD(di1, di2, (Map<String, String> p1, Map<String, String> p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1531,7 +1426,7 @@ public class TwowaysLambdaAMI opStringMyEnumDI cb = new opStringMyEnumDI(); p.begin_opStringMyEnumD(di1, di2, (Map<String, MyEnum> p1, Map<String, MyEnum> p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1545,7 +1440,7 @@ public class TwowaysLambdaAMI opMyEnumStringDI cb = new opMyEnumStringDI(); p.begin_opMyEnumStringD(di1, di2, (Map<MyEnum, String> p1, Map<MyEnum, String> p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1565,7 +1460,7 @@ public class TwowaysLambdaAMI opMyStructMyEnumDI cb = new opMyStructMyEnumDI(); p.begin_opMyStructMyEnumD(di1, di2, (Map<MyStruct, MyEnum> p1, Map<MyStruct, MyEnum> p2) -> cb.response(p1, p2), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1582,7 +1477,7 @@ public class TwowaysLambdaAMI opIntSI cb = new opIntSI(l); p.begin_opIntS(s, (int[] p1) -> cb.response(p1), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } } @@ -1597,13 +1492,15 @@ public class TwowaysLambdaAMI opDoubleMarshalingI cb = new opDoubleMarshalingI(); p.begin_opDoubleMarshaling(d, ds, () -> cb.response(), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } { opIdempotentI cb = new opIdempotentI(); - p.begin_opIdempotent(cb); + p.begin_opIdempotent( + () -> cb.response(), + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1611,7 +1508,7 @@ public class TwowaysLambdaAMI opNonmutatingI cb = new opNonmutatingI(); p.begin_opNonmutating( () -> cb.response(), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } @@ -1621,7 +1518,7 @@ public class TwowaysLambdaAMI opDerivedI cb = new opDerivedI(); derived.begin_opDerived( () -> cb.response(), - (Ice.LocalException ex) -> test(false)); + (Ice.Exception ex) -> test(false)); cb.check(); } } diff --git a/java/test/Ice/optional/lambda/AllTests.java b/java/test/Ice/optional/lambda/AllTests.java index 4ba65813336..db9fce3f89d 100644 --- a/java/test/Ice/optional/lambda/AllTests.java +++ b/java/test/Ice/optional/lambda/AllTests.java @@ -84,7 +84,7 @@ public class AllTests initial.begin_opByte(p1.get(), (Ice.ByteOptional ret, Ice.ByteOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -93,7 +93,7 @@ public class AllTests initial.begin_opByte(p1, (Ice.ByteOptional ret, Ice.ByteOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -105,7 +105,7 @@ public class AllTests initial.begin_opBool(p1.get(), (Ice.BooleanOptional ret, Ice.BooleanOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -114,7 +114,7 @@ public class AllTests initial.begin_opBool(p1, (Ice.BooleanOptional ret, Ice.BooleanOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -126,7 +126,7 @@ public class AllTests initial.begin_opShort(p1.get(), (Ice.ShortOptional ret, Ice.ShortOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } { @@ -134,7 +134,7 @@ public class AllTests initial.begin_opShort(p1, (Ice.ShortOptional ret, Ice.ShortOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -146,7 +146,7 @@ public class AllTests initial.begin_opInt(p1.get(), (Ice.IntOptional ret, Ice.IntOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -155,7 +155,7 @@ public class AllTests initial.begin_opInt(p1, (Ice.IntOptional ret, Ice.IntOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -167,7 +167,7 @@ public class AllTests initial.begin_opLong(p1.get(), (Ice.LongOptional ret, Ice.LongOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -176,7 +176,7 @@ public class AllTests initial.begin_opLong(p1, (Ice.LongOptional ret, Ice.LongOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -188,7 +188,7 @@ public class AllTests initial.begin_opFloat(p1.get(), (Ice.FloatOptional ret, Ice.FloatOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -197,7 +197,7 @@ public class AllTests initial.begin_opFloat(p1, (Ice.FloatOptional ret, Ice.FloatOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -209,7 +209,7 @@ public class AllTests initial.begin_opDouble(p1.get(), (Ice.DoubleOptional ret, Ice.DoubleOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -218,7 +218,7 @@ public class AllTests initial.begin_opDouble(p1, (Ice.DoubleOptional ret, Ice.DoubleOptional p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -230,7 +230,7 @@ public class AllTests initial.begin_opString(p1.get(), (Ice.Optional<String> ret, Ice.Optional<String> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -239,7 +239,7 @@ public class AllTests initial.begin_opString(p1, (Ice.Optional<String> ret, Ice.Optional<String> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -251,7 +251,7 @@ public class AllTests initial.begin_opMyEnum(p1.get(), (Ice.Optional<MyEnum> ret, Ice.Optional<MyEnum> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -260,7 +260,7 @@ public class AllTests initial.begin_opMyEnum(p1, (Ice.Optional<MyEnum> ret, Ice.Optional<MyEnum> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get() == p2.get() && ret.get() == p1.get()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -272,7 +272,7 @@ public class AllTests initial.begin_opSmallStruct(p1.get(), (Ice.Optional<SmallStruct> ret, Ice.Optional<SmallStruct> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -281,7 +281,7 @@ public class AllTests initial.begin_opSmallStruct(p1, (Ice.Optional<SmallStruct> ret, Ice.Optional<SmallStruct> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -293,7 +293,7 @@ public class AllTests initial.begin_opFixedStruct(p1.get(), (Ice.Optional<FixedStruct> ret, Ice.Optional<FixedStruct> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -302,7 +302,7 @@ public class AllTests initial.begin_opFixedStruct(p1, (Ice.Optional<FixedStruct> ret, Ice.Optional<FixedStruct> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -314,7 +314,7 @@ public class AllTests initial.begin_opVarStruct(p1.get(), (Ice.Optional<VarStruct> ret, Ice.Optional<VarStruct> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -323,7 +323,7 @@ public class AllTests initial.begin_opVarStruct(p1, (Ice.Optional<VarStruct> ret, Ice.Optional<VarStruct> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -336,7 +336,7 @@ public class AllTests (Ice.Optional<OneOptional> ret, Ice.Optional<OneOptional> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().getA() == p2.get().getA() && ret.get().getA() == p1.get().getA()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -346,7 +346,7 @@ public class AllTests (Ice.Optional<OneOptional> ret, Ice.Optional<OneOptional> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().getA() == p2.get().getA() && ret.get().getA() == p1.get().getA()), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -359,7 +359,7 @@ public class AllTests initial.begin_opOneOptionalProxy(p1.get(), (Ice.Optional<OneOptionalPrx> ret, Ice.Optional<OneOptionalPrx> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -368,7 +368,7 @@ public class AllTests initial.begin_opOneOptionalProxy(p1, (Ice.Optional<OneOptionalPrx> ret, Ice.Optional<OneOptionalPrx> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -383,7 +383,7 @@ public class AllTests (Ice.Optional<byte[]> ret, Ice.Optional<byte[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -393,7 +393,7 @@ public class AllTests (Ice.Optional<byte[]> ret, Ice.Optional<byte[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -407,7 +407,7 @@ public class AllTests (Ice.Optional<boolean[]> ret, Ice.Optional<boolean[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -417,7 +417,7 @@ public class AllTests (Ice.Optional<boolean[]> ret, Ice.Optional<boolean[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -431,7 +431,7 @@ public class AllTests (Ice.Optional<short[]> ret, Ice.Optional<short[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -441,7 +441,7 @@ public class AllTests (Ice.Optional<short[]> ret, Ice.Optional<short[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -455,7 +455,7 @@ public class AllTests (Ice.Optional<int[]> ret, Ice.Optional<int[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -465,7 +465,7 @@ public class AllTests (Ice.Optional<int[]> ret, Ice.Optional<int[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -479,7 +479,7 @@ public class AllTests (Ice.Optional<long[]> ret, Ice.Optional<long[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -489,7 +489,7 @@ public class AllTests (Ice.Optional<long[]> ret, Ice.Optional<long[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -503,7 +503,7 @@ public class AllTests (Ice.Optional<float[]> ret, Ice.Optional<float[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -513,7 +513,7 @@ public class AllTests (Ice.Optional<float[]> ret, Ice.Optional<float[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -527,7 +527,7 @@ public class AllTests (Ice.Optional<double[]> ret, Ice.Optional<double[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -537,7 +537,7 @@ public class AllTests (Ice.Optional<double[]> ret, Ice.Optional<double[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -551,7 +551,7 @@ public class AllTests (Ice.Optional<String[]> ret, Ice.Optional<String[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -561,7 +561,7 @@ public class AllTests (Ice.Optional<String[]> ret, Ice.Optional<String[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -580,7 +580,7 @@ public class AllTests (Ice.Optional<SmallStruct[]> ret, Ice.Optional<SmallStruct[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -590,7 +590,7 @@ public class AllTests (Ice.Optional<SmallStruct[]> ret, Ice.Optional<SmallStruct[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -608,7 +608,7 @@ public class AllTests initial.begin_opSmallStructList(p1.get(), (Ice.Optional<java.util.List<SmallStruct>> ret, Ice.Optional<java.util.List<SmallStruct>> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -617,7 +617,7 @@ public class AllTests initial.begin_opSmallStructList(p1, (Ice.Optional<java.util.List<SmallStruct>> ret, Ice.Optional<java.util.List<SmallStruct>> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -636,7 +636,7 @@ public class AllTests (Ice.Optional<FixedStruct[]> ret, Ice.Optional<FixedStruct[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -646,7 +646,7 @@ public class AllTests (Ice.Optional<FixedStruct[]> ret, Ice.Optional<FixedStruct[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -664,7 +664,7 @@ public class AllTests initial.begin_opFixedStructList(p1.get(), (Ice.Optional<java.util.List<FixedStruct>> ret, Ice.Optional<java.util.List<FixedStruct>> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -673,7 +673,7 @@ public class AllTests initial.begin_opFixedStructList(p1, (Ice.Optional<java.util.List<FixedStruct>> ret, Ice.Optional<java.util.List<FixedStruct>> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -692,7 +692,7 @@ public class AllTests (Ice.Optional<VarStruct[]> ret, Ice.Optional<VarStruct[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -702,7 +702,7 @@ public class AllTests (Ice.Optional<VarStruct[]> ret, Ice.Optional<VarStruct[]> p2) -> cb.called(ret.isSet() && p2.isSet() && java.util.Arrays.equals(ret.get(), p2.get()) && java.util.Arrays.equals(ret.get(), p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -715,7 +715,7 @@ public class AllTests initial.begin_opSerializable(p1.get(), (Ice.Optional<SerializableClass> ret, Ice.Optional<SerializableClass> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -724,7 +724,7 @@ public class AllTests initial.begin_opSerializable(p1, (Ice.Optional<SerializableClass> ret, Ice.Optional<SerializableClass> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -741,7 +741,7 @@ public class AllTests (Ice.Optional<java.util.Map<Integer, Integer>> ret, Ice.Optional<java.util.Map<Integer, Integer>> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -751,7 +751,7 @@ public class AllTests (Ice.Optional<java.util.Map<Integer, Integer>> ret, Ice.Optional<java.util.Map<Integer, Integer>> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } @@ -768,7 +768,7 @@ public class AllTests (Ice.Optional<java.util.Map<String, Integer>> ret, Ice.Optional<java.util.Map<String, Integer>> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } @@ -778,7 +778,7 @@ public class AllTests (Ice.Optional<java.util.Map<String, Integer>> ret, Ice.Optional<java.util.Map<String, Integer>> p2) -> cb.called(ret.isSet() && p2.isSet() && ret.get().equals(p2.get()) && ret.get().equals(p1.get())), - (Ice.LocalException ex) -> cb.called(false)); + (Ice.Exception ex) -> cb.called(false)); cb.check(); } } diff --git a/java/test/Ice/proxy/AllTests.java b/java/test/Ice/proxy/AllTests.java index bf601d4eb7b..8699bdbbf5f 100644 --- a/java/test/Ice/proxy/AllTests.java +++ b/java/test/Ice/proxy/AllTests.java @@ -633,13 +633,7 @@ public class AllTests String ref13 = "test -e 1.3:default -p 12010"; MyClassPrx cl13 = MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref13)); cl13.ice_ping(); - try - { - cl13.end_ice_ping(cl13.begin_ice_ping()); - } - catch(Ice.CollocationOptimizationException ex) - { - } + cl13.end_ice_ping(cl13.begin_ice_ping()); try { @@ -706,13 +700,7 @@ public class AllTests ref13 = "test -p 1.3:default -p 12010"; cl13 = MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref13)); cl13.ice_ping(); - try - { - cl13.end_ice_ping(cl13.begin_ice_ping()); - } - catch(Ice.CollocationOptimizationException ex) - { - } + cl13.end_ice_ping(cl13.begin_ice_ping()); out.println("ok"); out.print("testing opaque endpoints... "); diff --git a/java/test/Ice/retry/AllTests.java b/java/test/Ice/retry/AllTests.java index 553e5b987dd..42f40727eef 100644 --- a/java/test/Ice/retry/AllTests.java +++ b/java/test/Ice/retry/AllTests.java @@ -99,7 +99,7 @@ public class AllTests public void exception(Ice.LocalException ex) { - test(ex instanceof Ice.ConnectionLostException); + test(ex instanceof Ice.ConnectionLostException || ex instanceof Ice.UnknownLocalException); callback.called(); } @@ -139,6 +139,8 @@ public class AllTests retry1.op(false); out.println("ok"); + int invocationCount = 3; + out.print("calling operation to kill connection with second proxy... "); out.flush(); try @@ -146,14 +148,24 @@ public class AllTests retry2.op(true); test(false); } + catch(Ice.UnknownLocalException ex) + { + // Expected with collocation + } catch(Ice.ConnectionLostException ex) { - out.println("ok"); } - + Instrumentation.testInvocationCount(invocationCount + 1); + Instrumentation.testFailureCount(1); + Instrumentation.testRetryCount(0); + out.println("ok"); + out.print("calling regular operation with first proxy again... "); out.flush(); retry1.op(false); + Instrumentation.testInvocationCount(invocationCount + 2); + Instrumentation.testFailureCount(1); + Instrumentation.testRetryCount(0); out.println("ok"); AMIRegular cb1 = new AMIRegular(); @@ -162,18 +174,92 @@ public class AllTests out.print("calling regular AMI operation with first proxy... "); retry1.begin_op(false, cb1); cb1.check(); + Instrumentation.testInvocationCount(invocationCount + 3); + Instrumentation.testFailureCount(1); + Instrumentation.testRetryCount(0); out.println("ok"); out.print("calling AMI operation to kill connection with second proxy... "); retry2.begin_op(true, cb2); cb2.check(); + Instrumentation.testInvocationCount(invocationCount + 4); + Instrumentation.testFailureCount(2); + Instrumentation.testRetryCount(0); out.println("ok"); out.print("calling regular AMI operation with first proxy again... "); retry1.begin_op(false, cb1); cb1.check(); + Instrumentation.testInvocationCount(invocationCount + 5); + Instrumentation.testFailureCount(2); + Instrumentation.testRetryCount(0); + out.println("ok"); + + out.print("testing idempotent operation... "); + test(retry1.opIdempotent(0) == 4); + Instrumentation.testInvocationCount(invocationCount + 6); + Instrumentation.testFailureCount(2); + Instrumentation.testRetryCount(4); + test(retry1.end_opIdempotent(retry1.begin_opIdempotent(4)) == 8); + Instrumentation.testInvocationCount(invocationCount + 7); + Instrumentation.testFailureCount(2); + Instrumentation.testRetryCount(8); + out.println("ok"); + + out.print("testing non-idempotent operation... "); + try + { + retry1.opNotIdempotent(8); + test(false); + } + catch(Ice.LocalException ex) + { + } + Instrumentation.testInvocationCount(invocationCount + 8); + Instrumentation.testFailureCount(3); + Instrumentation.testRetryCount(8); + try + { + retry1.end_opNotIdempotent(retry1.begin_opNotIdempotent(9)); + test(false); + } + catch(Ice.LocalException ex) + { + } + Instrumentation.testInvocationCount(invocationCount + 9); + Instrumentation.testFailureCount(4); + Instrumentation.testRetryCount(8); out.println("ok"); + if(retry1.ice_getConnection() == null) + { + invocationCount = invocationCount + 10; + out.print("testing system exception... "); + try + { + retry1.opSystemException(); + test(false); + } + catch(SystemFailure ex) + { + } + Instrumentation.testInvocationCount(invocationCount + 1); + Instrumentation.testFailureCount(5); + Instrumentation.testRetryCount(8); + try + { + retry1.end_opSystemException(retry1.begin_opSystemException()); + test(false); + } + catch(SystemFailure ex) + { + } + Instrumentation.testInvocationCount(invocationCount + 2); + Instrumentation.testFailureCount(6); + Instrumentation.testRetryCount(8); + out.println("ok"); + } + return retry1; } } diff --git a/java/test/Ice/retry/Client.java b/java/test/Ice/retry/Client.java index c87c6160088..df8d88c92c9 100644 --- a/java/test/Ice/retry/Client.java +++ b/java/test/Ice/retry/Client.java @@ -25,11 +25,11 @@ public class Client extends test.Util.Application { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = Ice.Util.createProperties(argsH); + initData.observer = Instrumentation.getObserver(); + initData.properties.setProperty("Ice.Package.Test", "test.Ice.retry"); - // - // For this test, we want to disable retries. - // - initData.properties.setProperty("Ice.RetryIntervals", "-1"); + + initData.properties.setProperty("Ice.RetryIntervals", "0 10 20 30"); // // We don't want connection warnings because of the timeout diff --git a/java/test/Ice/retry/Collocated.java b/java/test/Ice/retry/Collocated.java new file mode 100644 index 00000000000..388d6888f30 --- /dev/null +++ b/java/test/Ice/retry/Collocated.java @@ -0,0 +1,57 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.retry; + +import test.Ice.retry.Test.RetryPrx; + +public class Collocated extends test.Util.Application +{ + public int run(String[] args) + { + Ice.Communicator communicator = communicator(); + Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); + adapter.add(new RetryI(), communicator.stringToIdentity("retry")); + //adapter.activate(); + + RetryPrx retry = AllTests.allTests(communicator, getWriter()); + retry.shutdown(); + return 0; + } + + protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH) + { + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(argsH); + initData.observer = Instrumentation.getObserver(); + + initData.properties.setProperty("Ice.Package.Test", "test.Ice.retry"); + + initData.properties.setProperty("Ice.RetryIntervals", "0 10 20 30"); + + // + // We don't want connection warnings because of the timeout + // + initData.properties.setProperty("Ice.Warn.Connections", "0"); + initData.properties.setProperty("Ice.Warn.Dispatch", "0"); + + initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010"); + + return initData; + } + + public static void main(String[] args) + { + Collocated app = new Collocated(); + int result = app.main("Client", args); + System.gc(); + System.exit(result); + } +} + diff --git a/java/test/Ice/retry/Instrumentation.java b/java/test/Ice/retry/Instrumentation.java new file mode 100644 index 00000000000..05916a2293d --- /dev/null +++ b/java/test/Ice/retry/Instrumentation.java @@ -0,0 +1,184 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.retry; + +public class Instrumentation +{ + private static void + test(boolean b) + { + if(!b) + { + throw new RuntimeException(); + } + } + + static class InvocationObserverI implements Ice.Instrumentation.InvocationObserver + { + public void + attach() + { + } + + public void + detach() + { + synchronized(Instrumentation.class) + { + ++nInvocation.value; + } + } + + public void + failed(String msg) + { + synchronized(Instrumentation.class) + { + ++nFailure.value; + } + } + + public void + retried() + { + synchronized(Instrumentation.class) + { + ++nRetry.value; + } + } + + public void + userException() + { + } + + public Ice.Instrumentation.RemoteObserver + getRemoteObserver(Ice.ConnectionInfo ci, Ice.Endpoint ei, int i, int j) + { + return null; + } + + public Ice.Instrumentation.RemoteObserver + getCollocatedObserver(int i , int j) + { + return null; + } + + }; + static private Ice.Instrumentation.InvocationObserver invocationObserver = new InvocationObserverI(); + + static class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorObserver + { + public Ice.Instrumentation.Observer + getConnectionEstablishmentObserver(Ice.Endpoint e, String s) + { + return null; + } + + public Ice.Instrumentation.Observer + getEndpointLookupObserver(Ice.Endpoint e) + { + return null; + } + + public Ice.Instrumentation.ConnectionObserver + getConnectionObserver(Ice.ConnectionInfo ci, + Ice.Endpoint ei, + Ice.Instrumentation.ConnectionState s, + Ice.Instrumentation.ConnectionObserver o) + { + return null; + } + + public Ice.Instrumentation.ThreadObserver + getThreadObserver(String p, + String n, + Ice.Instrumentation.ThreadState s, + Ice.Instrumentation.ThreadObserver o) + { + return null; + } + + public Ice.Instrumentation.InvocationObserver + getInvocationObserver(Ice.ObjectPrx p, String o, java.util.Map<String, String> c) + { + return invocationObserver; + } + + public Ice.Instrumentation.DispatchObserver + getDispatchObserver(Ice.Current c, int i) + { + return null; + } + + public void + setObserverUpdater(Ice.Instrumentation.ObserverUpdater u) + { + } + }; + + static private Ice.Instrumentation.CommunicatorObserver communicatorObserver = new CommunicatorObserverI(); + + static public Ice.Instrumentation.CommunicatorObserver + getObserver() + { + return communicatorObserver; + } + + static private void + testEqual(Ice.IntHolder value, int expected) + { + int retry = 0; + while(retry < 100) + { + synchronized(Instrumentation.class) + { + if(value.value == expected) + { + break; + } + } + try + { + Thread.sleep(10); + } + catch(java.lang.InterruptedException ex) + { + } + } + if(value.value != expected) + { + System.err.println("value = " + value.value + ", expected = " + expected); + test(false); + } + } + + static public void + testRetryCount(int expected) + { + testEqual(nRetry, expected); + } + + static public void + testFailureCount(int expected) + { + testEqual(nFailure, expected); + } + + static public void + testInvocationCount(int expected) + { + testEqual(nInvocation, expected); + } + + static private Ice.IntHolder nRetry = new Ice.IntHolder(0); + static private Ice.IntHolder nFailure = new Ice.IntHolder(0); + static private Ice.IntHolder nInvocation = new Ice.IntHolder(0); +}; diff --git a/java/test/Ice/retry/RetryI.java b/java/test/Ice/retry/RetryI.java index 22a98b566ad..ae336cac007 100644 --- a/java/test/Ice/retry/RetryI.java +++ b/java/test/Ice/retry/RetryI.java @@ -22,13 +22,66 @@ public final class RetryI extends _RetryDisp { if(kill) { - current.con.close(true); + if(current.con != null) + { + current.con.close(true); + } + else + { + throw new Ice.ConnectionLostException(); + } } } + public int + opIdempotent(int counter, Ice.Current current) + { + if(counter + nRetry > _counter) + { + ++_counter; + if(current.con != null) + { + current.con.close(true); + } + else + { + throw new Ice.ConnectionLostException(); + } + } + return _counter; + } + + public void + opNotIdempotent(int counter, Ice.Current current) + { + if(_counter != counter) + { + return; + } + + ++_counter; + if(current.con != null) + { + current.con.close(true); + } + else + { + throw new Ice.ConnectionLostException(); + } + } + + public void + opSystemException(Ice.Current c) + { + throw new SystemFailure(); + } + public void shutdown(Ice.Current current) { current.adapter.getCommunicator().shutdown(); } + + private int _counter; + static final int nRetry = 4; } diff --git a/java/test/Ice/retry/SystemFailure.java b/java/test/Ice/retry/SystemFailure.java new file mode 100644 index 00000000000..f6c81c39694 --- /dev/null +++ b/java/test/Ice/retry/SystemFailure.java @@ -0,0 +1,19 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.retry; + +class SystemFailure extends Ice.SystemException +{ + public String + ice_name() + { + return "SystemFailure"; + } +}; diff --git a/java/test/Ice/retry/Test.ice b/java/test/Ice/retry/Test.ice index 8b749ba2f6a..aeffa8e72fc 100644 --- a/java/test/Ice/retry/Test.ice +++ b/java/test/Ice/retry/Test.ice @@ -16,6 +16,11 @@ module Test interface Retry { void op(bool kill); + + idempotent int opIdempotent(int c); + void opNotIdempotent(int c); + void opSystemException(); + void shutdown(); }; diff --git a/java/test/Ice/retry/run.py b/java/test/Ice/retry/run.py index 33fc2e8f3ac..a40df1a1bcb 100755 --- a/java/test/Ice/retry/run.py +++ b/java/test/Ice/retry/run.py @@ -20,4 +20,7 @@ if len(path) == 0: sys.path.append(os.path.join(path[0], "scripts")) import TestUtil +print("tests with regular server.") TestUtil.clientServerTest() +print("tests with collocated server.") +TestUtil.collocatedTest() diff --git a/java/test/Ice/servantLocator/AllTests.java b/java/test/Ice/servantLocator/AllTests.java index a66a8906a61..15273a5b687 100644 --- a/java/test/Ice/servantLocator/AllTests.java +++ b/java/test/Ice/servantLocator/AllTests.java @@ -36,7 +36,7 @@ public class AllTests } public static void - testExceptions(TestIntfPrx obj, boolean collocated) + testExceptions(TestIntfPrx obj) { try { @@ -45,12 +45,9 @@ public class AllTests } catch(ObjectNotExistException ex) { - if(!collocated) - { - test(ex.id.equals(obj.ice_getIdentity())); - test(ex.facet.equals(obj.ice_getFacet())); - test(ex.operation.equals("requestFailedException")); - } + test(ex.id.equals(obj.ice_getIdentity())); + test(ex.facet.equals(obj.ice_getFacet())); + test(ex.operation.equals("requestFailedException")); } try @@ -210,9 +207,9 @@ public class AllTests } public static TestIntfPrx - allTests(Ice.Communicator communicator, boolean collocated, PrintWriter out) + allTests(Ice.Communicator communicator, PrintWriter out) { - out.print("testing stringToProxy... "); + out.print("testing stringToProxy... "); out.flush(); String ref = "asm:default -p 12010"; Ice.ObjectPrx base = communicator.stringToProxy(ref); @@ -298,14 +295,14 @@ public class AllTests out.flush(); base = communicator.stringToProxy("category/locate:default -p 12010"); obj = TestIntfPrxHelper.checkedCast(base); - testExceptions(obj, collocated); + testExceptions(obj); out.println("ok"); out.print("testing finished exceptions... "); out.flush(); base = communicator.stringToProxy("category/finished:default -p 12010"); obj = TestIntfPrxHelper.checkedCast(base); - testExceptions(obj, collocated); + testExceptions(obj); // // Only call these for category/finished. diff --git a/java/test/Ice/servantLocator/Client.java b/java/test/Ice/servantLocator/Client.java index 00097374f4d..6b173584769 100644 --- a/java/test/Ice/servantLocator/Client.java +++ b/java/test/Ice/servantLocator/Client.java @@ -15,7 +15,7 @@ public class Client extends test.Util.Application { public int run(String[] args) { - TestIntfPrx obj = AllTests.allTests(communicator(), false, getWriter()); + TestIntfPrx obj = AllTests.allTests(communicator(), getWriter()); obj.shutdown(); return 0; } diff --git a/java/test/Ice/servantLocator/Collocated.java b/java/test/Ice/servantLocator/Collocated.java index 8d53f1206bb..0c0d2d9e35d 100644 --- a/java/test/Ice/servantLocator/Collocated.java +++ b/java/test/Ice/servantLocator/Collocated.java @@ -18,7 +18,7 @@ public class Collocated extends test.Util.Application adapter.addServantLocator(new ServantLocatorI(""), ""); adapter.add(new TestI(), communicator().stringToIdentity("asm")); adapter.add(new TestActivationI(), communicator().stringToIdentity("test/activation")); - AllTests.allTests(communicator(), true, getWriter()); + AllTests.allTests(communicator(), getWriter()); return 0; } diff --git a/java/test/Ice/timeout/AllTests.java b/java/test/Ice/timeout/AllTests.java index 20614e308fb..0d2a1cc2f05 100644 --- a/java/test/Ice/timeout/AllTests.java +++ b/java/test/Ice/timeout/AllTests.java @@ -428,6 +428,69 @@ public class AllTests } out.println("ok"); + out.print("testing invocation timeouts with collocated calls... "); + out.flush(); + { + communicator.getProperties().setProperty("TimeoutCollocated.AdapterId", "timeoutAdapter"); + + Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TimeoutCollocated"); + adapter.activate(); + + TimeoutPrx proxy = TimeoutPrxHelper.uncheckedCast(adapter.addWithUUID(new TimeoutI())); + proxy = (TimeoutPrx)proxy.ice_invocationTimeout(100); + try + { + proxy.sleep(150); + test(false); + } + catch(Ice.InvocationTimeoutException ex) + { + } + + try + { + proxy.end_sleep(proxy.begin_sleep(150)); + test(false); + } + catch(Ice.InvocationTimeoutException ex) + { + } + + ((TimeoutPrx)proxy.ice_invocationTimeout(-1)).ice_ping(); + + TimeoutPrx batchTimeout = (TimeoutPrx)proxy.ice_batchOneway(); + batchTimeout.ice_ping(); + batchTimeout.ice_ping(); + batchTimeout.ice_ping(); + + ((TimeoutPrx)proxy.ice_invocationTimeout(-1)).begin_sleep(150); // Keep the server thread pool busy. + try + { + batchTimeout.ice_flushBatchRequests(); + test(false); + } + catch(Ice.InvocationTimeoutException ex) + { + } + + batchTimeout.ice_ping(); + batchTimeout.ice_ping(); + batchTimeout.ice_ping(); + + ((TimeoutPrx)proxy.ice_invocationTimeout(-1)).begin_sleep(150); // Keep the server thread pool busy. + try + { + batchTimeout.end_ice_flushBatchRequests(batchTimeout.begin_ice_flushBatchRequests()); + test(false); + } + catch(Ice.InvocationTimeoutException ex) + { + } + + adapter.destroy(); + } + out.println("ok"); + return timeout; } } diff --git a/java/test/Slice/generation/list-generated.out b/java/test/Slice/generation/list-generated.out index d5e237fd5b7..cbacf36a41c 100644 --- a/java/test/Slice/generation/list-generated.out +++ b/java/test/Slice/generation/list-generated.out @@ -9,9 +9,6 @@ <file name="classes/test/Slice/generation/Test/Interface1PrxHolder.java"/> <file name="classes/test/Slice/generation/Test/Interface1PrxHelper.java"/> <file name="classes/test/Slice/generation/Test/Interface1Prx.java"/> - <file name="classes/test/Slice/generation/Test/_Interface1Del.java"/> - <file name="classes/test/Slice/generation/Test/_Interface1DelM.java"/> - <file name="classes/test/Slice/generation/Test/_Interface1DelD.java"/> <file name="classes/test/Slice/generation/Test/_Interface1Disp.java"/> <file name="classes/test/Slice/generation/Test/Callback_Interface1_method.java"/> <output></output> @@ -25,9 +22,6 @@ <file name="classes/test/Slice/generation/Test/Interface2PrxHolder.java"/> <file name="classes/test/Slice/generation/Test/Interface2PrxHelper.java"/> <file name="classes/test/Slice/generation/Test/Interface2Prx.java"/> - <file name="classes/test/Slice/generation/Test/_Interface2Del.java"/> - <file name="classes/test/Slice/generation/Test/_Interface2DelM.java"/> - <file name="classes/test/Slice/generation/Test/_Interface2DelD.java"/> <file name="classes/test/Slice/generation/Test/_Interface2Disp.java"/> <file name="classes/test/Slice/generation/Test/Callback_Interface2_method.java"/> <output></output> |