Skip to content

Commit

Permalink
Android SSL testing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone committed Dec 26, 2024
1 parent 1d83b9a commit 18c6608
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
26 changes: 15 additions & 11 deletions java/test/src/main/java/test/Ice/idleTimeout/AllTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import com.zeroc.Ice.ConnectionLostException;
import com.zeroc.Ice.InitializationData;
import com.zeroc.Ice.Properties;
import com.zeroc.Ice.Util;

import test.Ice.idleTimeout.Test.TestIntfPrx;
import test.TestHelper;

import java.io.PrintWriter;

Expand All @@ -25,13 +25,13 @@ static void allTests(test.TestHelper helper) {

testIdleCheckDoesNotAbortBackPressuredConnection(p, helper.getWriter());
testConnectionAbortedByIdleCheck(
proxyStringDefaultMax, communicator.getProperties(), helper.getWriter());
helper, proxyStringDefaultMax, communicator.getProperties(), helper.getWriter());
testEnableDisableIdleCheck(
true, proxyString3s, communicator.getProperties(), helper.getWriter());
helper, true, proxyString3s, communicator.getProperties(), helper.getWriter());
testEnableDisableIdleCheck(
false, proxyString3s, communicator.getProperties(), helper.getWriter());
helper, false, proxyString3s, communicator.getProperties(), helper.getWriter());
testNoIdleTimeout(
proxyStringNoIdleTimeout, communicator.getProperties(), helper.getWriter());
helper, proxyStringNoIdleTimeout, communicator.getProperties(), helper.getWriter());

p.shutdown();
}
Expand Down Expand Up @@ -66,7 +66,7 @@ private static void testIdleCheckDoesNotAbortBackPressuredConnection(
// We intentionally misconfigure the client with an idle timeout of 3s to send heartbeats every
// 1.5s, which is too long to prevent the server from aborting the connection.
private static void testConnectionAbortedByIdleCheck(
String proxyString, Properties properties, PrintWriter output) {
TestHelper helper, String proxyString, Properties properties, PrintWriter output) {
output.write(
"testing that the idle check aborts a connection that does not receive anything for 1s... ");
output.flush();
Expand All @@ -77,7 +77,7 @@ private static void testConnectionAbortedByIdleCheck(
properties.setProperty("Ice.Warn.Connections", "0");
var initData = new InitializationData();
initData.properties = properties;
try (var communicator = Util.initialize(initData)) {
try (var communicator = helper.initialize(initData)) {
var p = TestIntfPrx.createProxy(communicator, proxyString);

// Establish connection.
Expand All @@ -100,7 +100,11 @@ private static void testConnectionAbortedByIdleCheck(
// Verifies the behavior with the idle check enabled or disabled when the client and the server
// have mismatched idle timeouts (here: 3s on the server side and 1s on the client side).
private static void testEnableDisableIdleCheck(
boolean enabled, String proxyString, Properties properties, PrintWriter output) {
TestHelper helper,
boolean enabled,
String proxyString,
Properties properties,
PrintWriter output) {
String enabledString = enabled ? "enabled" : "disabled";
output.write("testing connection with idle check " + enabledString + "... ");
output.flush();
Expand All @@ -112,7 +116,7 @@ private static void testEnableDisableIdleCheck(
properties.setProperty("Ice.Warn.Connections", "0");
var initData = new InitializationData();
initData.properties = properties;
try (var communicator = Util.initialize(initData)) {
try (var communicator = helper.initialize(initData)) {
var p = TestIntfPrx.createProxy(communicator, proxyString);

var connection = p.ice_getConnection();
Expand All @@ -130,7 +134,7 @@ private static void testEnableDisableIdleCheck(

// Verifies the idle check is disabled when the idle timeout is set to 0.
private static void testNoIdleTimeout(
String proxyString, Properties properties, PrintWriter output) {
TestHelper helper, String proxyString, Properties properties, PrintWriter output) {
output.write("testing connection with idle timeout set to 0... ");
output.flush();

Expand All @@ -139,7 +143,7 @@ private static void testNoIdleTimeout(
properties.setProperty("Ice.Connection.Client.IdleTimeout", "0");
var initData = new InitializationData();
initData.properties = properties;
try (var communicator = Util.initialize(initData)) {
try (var communicator = helper.initialize(initData)) {
var p = TestIntfPrx.createProxy(communicator, proxyString);
var connection = p.ice_getConnection();
test(connection != null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.zeroc.Ice.Connection;
import com.zeroc.Ice.InitializationData;
import com.zeroc.Ice.Properties;
import com.zeroc.Ice.Util;

import test.Ice.inactivityTimeout.Test.TestIntfPrx;

Expand All @@ -22,7 +21,7 @@ static void allTests(test.TestHelper helper) {

testClientInactivityTimeout(p, helper.getWriter());
testServerInactivityTimeout(
proxyString3s, communicator.getProperties(), helper.getWriter());
helper, proxyString3s, communicator.getProperties(), helper.getWriter());
testWithOutstandingRequest(p, false, helper.getWriter());
testWithOutstandingRequest(p, true, helper.getWriter());

Expand Down Expand Up @@ -53,7 +52,7 @@ private static void testClientInactivityTimeout(TestIntfPrx p, PrintWriter outpu
}

private static void testServerInactivityTimeout(
String proxyString, Properties properties, PrintWriter output) {
test.TestHelper helper, String proxyString, Properties properties, PrintWriter output) {
output.write(
"testing that the server side inactivity timeout shuts down the connection... ");
output.flush();
Expand All @@ -63,7 +62,7 @@ private static void testServerInactivityTimeout(
properties.setProperty("Ice.Connection.Client.InactivityTimeout", "5");
var initData = new InitializationData();
initData.properties = properties;
try (var communicator = Util.initialize(initData)) {
try (var communicator = helper.initialize(initData)) {
TestIntfPrx p = TestIntfPrx.uncheckedCast(communicator.stringToProxy(proxyString));

p.ice_ping();
Expand Down
2 changes: 1 addition & 1 deletion java/test/src/main/java/test/Ice/timeout/AllTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static void allTestsWithController(test.TestHelper helper, ControllerPrx
properties.setProperty("Ice.Connection.Client.ConnectTimeout", "-1");
var initData = new InitializationData();
initData.properties = properties;
try (var communicator2 = com.zeroc.Ice.Util.initialize(initData)) {
try (var communicator2 = helper.initialize(initData)) {
TimeoutPrx to = TimeoutPrx.uncheckedCast(communicator2.stringToProxy(sref));
controller.holdAdapter(100);
try {
Expand Down

0 comments on commit 18c6608

Please sign in to comment.