summaryrefslogtreecommitdiff
path: root/java/test
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2009-10-27 12:00:32 +0100
committerBenoit Foucher <benoit@zeroc.com>2009-10-27 12:00:32 +0100
commit1fdb973182e589b0d20e987360bd694ae783b0a2 (patch)
treea94cbbcc0d078bcf7aa4427951799e09feb80826 /java/test
parentadd support for number protocol in Python (diff)
downloadice-1fdb973182e589b0d20e987360bd694ae783b0a2.tar.bz2
ice-1fdb973182e589b0d20e987360bd694ae783b0a2.tar.xz
ice-1fdb973182e589b0d20e987360bd694ae783b0a2.zip
Cleaned up UDP transceivers, fixes for bug 4223 and 4320
Diffstat (limited to 'java/test')
-rw-r--r--java/test/Ice/info/AllTests.java9
-rw-r--r--java/test/Ice/udp/AllTests.java91
-rw-r--r--java/test/Ice/udp/Client.java1
-rw-r--r--java/test/Ice/udp/Server.java1
-rw-r--r--java/test/Ice/udp/Test.ice3
-rw-r--r--java/test/Ice/udp/TestIntfI.java26
6 files changed, 114 insertions, 17 deletions
diff --git a/java/test/Ice/info/AllTests.java b/java/test/Ice/info/AllTests.java
index e5750cf3b62..9dd3650f2a8 100644
--- a/java/test/Ice/info/AllTests.java
+++ b/java/test/Ice/info/AllTests.java
@@ -144,6 +144,7 @@ public class AllTests
Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)base.ice_getConnection().getInfo();
test(!info.incoming);
test(info.adapterName.length() == 0);
+ test(info.localPort > 0);
test(info.remotePort == 12010);
test(info.remoteAddress.equals(defaultHost));
test(info.localAddress.equals(defaultHost));
@@ -155,6 +156,14 @@ public class AllTests
test(ctx.get("localAddress").equals(info.remoteAddress));
test(ctx.get("remotePort").equals(Integer.toString(info.localPort)));
test(ctx.get("localPort").equals(Integer.toString(info.remotePort)));
+
+ info = (Ice.IPConnectionInfo)base.ice_datagram().ice_getConnection().getInfo();
+ test(!info.incoming);
+ test(info.adapterName.length() == 0);
+ test(info.localPort > 0);
+ test(info.remotePort == 12010);
+ test(info.remoteAddress.equals(defaultHost));
+ test(info.localAddress.equals(defaultHost));
}
out.println("ok");
diff --git a/java/test/Ice/udp/AllTests.java b/java/test/Ice/udp/AllTests.java
index 725003dbe31..22550b6f370 100644
--- a/java/test/Ice/udp/AllTests.java
+++ b/java/test/Ice/udp/AllTests.java
@@ -78,7 +78,7 @@ public class AllTests
System.out.print("testing udp... ");
System.out.flush();
- Ice.ObjectPrx base = communicator.stringToProxy("test:udp -p 12010").ice_datagram();
+ Ice.ObjectPrx base = communicator.stringToProxy("test -d:udp -p 12010");
TestIntfPrx obj = TestIntfPrxHelper.uncheckedCast(base);
int nRetry = 5;
@@ -124,7 +124,7 @@ public class AllTests
{
test(seq.length > 16384);
}
-
+ obj.ice_getConnection().close(false);
communicator.getProperties().setProperty("Ice.UDP.SndSize", "64000");
seq = new byte[50000];
try
@@ -153,28 +153,85 @@ public class AllTests
{
host = "239.255.1.1";
}
- base = communicator.stringToProxy("test:udp -h " + host + " -p 12020").ice_datagram();
- obj = TestIntfPrxHelper.uncheckedCast(base);
+ base = communicator.stringToProxy("test -d:udp -h " + host + " -p 12020");
+ TestIntfPrx objMcast = TestIntfPrxHelper.uncheckedCast(base);
- replyI.reset();
- obj.ping(reply);
- if(!replyI.waitReply(5, 2000))
+ nRetry = 5;
+ while(nRetry-- > 0)
{
- System.out.println("failed (is a firewall enabled?)");
- return obj;
+ replyI.reset();
+ objMcast.ping(reply);
+ ret = replyI.waitReply(5, 2000);
+ if(ret)
+ {
+ break; // Success
+ }
+ replyI = new PingReplyI();
+ reply = (PingReplyPrx)PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram();
}
-
- replyI.reset();
- obj.ping(reply);
- ret = replyI.waitReply(5, 2000);
- if(!replyI.waitReply(5, 2000))
+ if(!ret)
{
System.out.println("failed (is a firewall enabled?)");
- return obj;
+ }
+ else
+ {
+ System.out.println("ok");
}
- System.out.println("ok");
+ System.out.print("testing udp bi-dir connection... ");
+ System.out.flush();
+ obj.ice_getConnection().setAdapter(adapter);
+ objMcast.ice_getConnection().setAdapter(adapter);
+ nRetry = 5;
+ while(nRetry-- > 0)
+ {
+ replyI.reset();
+ obj.pingBiDir(reply.ice_getIdentity());
+ obj.pingBiDir(reply.ice_getIdentity());
+ obj.pingBiDir(reply.ice_getIdentity());
+ ret = replyI.waitReply(3, 2000);
+ if(ret)
+ {
+ break; // Success
+ }
+ replyI = new PingReplyI();
+ reply = (PingReplyPrx)PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram();
+ }
+ test(ret);
+ if(!System.getProperty("os.name").startsWith("Windows"))
+ {
+ //
+ // Windows doesn't support sending replies back on the multicast UDP connection,
+ // see UdpTransceiver constructor for the details.
+ //
+ nRetry = 5;
+ while(nRetry-- > 0)
+ {
+ replyI.reset();
+ objMcast.pingBiDir(reply.ice_getIdentity());
+ ret = replyI.waitReply(5, 2000);
+ if(ret)
+ {
+ break; // Success
+ }
+ replyI = new PingReplyI();
+ reply = (PingReplyPrx)PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram();
+ }
- return obj;
+ if(!ret)
+ {
+ System.out.println("failed (is a firewall enabled?)");
+ }
+ else
+ {
+ System.out.println("ok");
+ }
+ }
+ else
+ {
+ System.out.println("ok");
+ }
+
+ return objMcast;
}
}
diff --git a/java/test/Ice/udp/Client.java b/java/test/Ice/udp/Client.java
index 3cab9099e6e..85611b9b3e1 100644
--- a/java/test/Ice/udp/Client.java
+++ b/java/test/Ice/udp/Client.java
@@ -26,6 +26,7 @@ public class Client extends test.Util.Application
initData.properties = Ice.Util.createProperties(argsH);
initData.properties.setProperty("Ice.Package.Test", "test.Ice.udp");
initData.properties.setProperty("Ice.Warn.Connections", "0");
+ initData.properties.setProperty("Ice.UDP.RcvSize", "16384");
initData.properties.setProperty("Ice.UDP.SndSize", "16384");
return initData;
}
diff --git a/java/test/Ice/udp/Server.java b/java/test/Ice/udp/Server.java
index 9ce5a7869c8..c0549751288 100644
--- a/java/test/Ice/udp/Server.java
+++ b/java/test/Ice/udp/Server.java
@@ -36,6 +36,7 @@ public class Server extends test.Util.Application
initData.properties.setProperty("Ice.Package.Test", "test.Ice.udp");
initData.properties.setProperty("Ice.Warn.Connections", "0");
initData.properties.setProperty("Ice.UDP.RcvSize", "16384");
+ initData.properties.setProperty("Ice.UDP.SndSize", "16384");
String host;
if(initData.properties.getProperty("Ice.IPv6") == "1")
diff --git a/java/test/Ice/udp/Test.ice b/java/test/Ice/udp/Test.ice
index 4db62e371c3..aa60b97402c 100644
--- a/java/test/Ice/udp/Test.ice
+++ b/java/test/Ice/udp/Test.ice
@@ -10,6 +10,8 @@
#ifndef TEST_ICE
#define TEST_ICE
+#include <Ice/Identity.ice>
+
[["java:package:test.Ice.udp"]]
module Test
{
@@ -25,6 +27,7 @@ interface TestIntf
{
void ping(PingReply* reply);
void sendByteSeq(ByteSeq seq, PingReply* reply);
+ void pingBiDir(Ice::Identity id);
void shutdown();
};
diff --git a/java/test/Ice/udp/TestIntfI.java b/java/test/Ice/udp/TestIntfI.java
index 7865321300b..dfb0c231042 100644
--- a/java/test/Ice/udp/TestIntfI.java
+++ b/java/test/Ice/udp/TestIntfI.java
@@ -37,6 +37,32 @@ public final class TestIntfI extends _TestIntfDisp
}
}
+ public void pingBiDir(Ice.Identity id, Ice.Current current)
+ {
+ try
+ {
+ //
+ // Ensure sending too much data doesn't cause the UDP connection
+ // to be closed.
+ //
+ try
+ {
+ byte[] seq = new byte[32 * 1024];
+ TestIntfPrxHelper.uncheckedCast(current.con.createProxy(id)).sendByteSeq(seq, null);
+ }
+ catch(Ice.DatagramLimitException ex)
+ {
+ // Expected.
+ }
+
+ PingReplyPrxHelper.uncheckedCast(current.con.createProxy(id)).reply();
+ }
+ catch(Ice.LocalException ex)
+ {
+ assert(false);
+ }
+ }
+
public void shutdown(Ice.Current current)
{
current.adapter.getCommunicator().shutdown();