From cc8d04d24dbeb6ea310def297a6e9354fd93758d Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 09 Jun 2016 11:36:55 +0000
Subject: [PATCH] fix tests broken by commit 6197694d7a0
---
opendj-server-legacy/src/test/java/org/opends/server/tasks/DisconnectClientTaskTestCase.java | 68 +++++++++++++++++----------------
1 files changed, 35 insertions(+), 33 deletions(-)
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/tasks/DisconnectClientTaskTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/tasks/DisconnectClientTaskTestCase.java
index 2ef7ff5..5708385 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/tasks/DisconnectClientTaskTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/tasks/DisconnectClientTaskTestCase.java
@@ -64,41 +64,22 @@
public void testDisconnectWithNotification()
throws Exception
{
- // Establish a connection to the server, bind, and get the connection ID.
try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort()))
{
conn.bind("cn=Directory Manager", "password");
- long connectionID = getConnectionID(conn);
-
- // Invoke the disconnect client task.
- String taskID = "Disconnect Client " + connectionID;
- LocalizableMessage disconnectMessage = LocalizableMessage.raw("testDisconnectWithNotification");
- DN taskDN = DN.valueOf("ds-task-id=" + taskID + ",cn=Scheduled Tasks,cn=Tasks");
- TestCaseUtils.addEntry(
- "dn: " + taskDN,
- "objectClass: top",
- "objectClass: ds-task",
- "objectClass: ds-task-disconnect",
- "ds-task-id: " + taskID,
- "ds-task-class-name: org.opends.server.tasks.DisconnectClientTask",
- "ds-task-disconnect-connection-id: " + connectionID,
- "ds-task-disconnect-notify-client: true",
- "ds-task-disconnect-message: " + disconnectMessage);
-
+ String disconnectMessage = "testDisconnectWithNotification";
+ DN taskDN = invokeClientDisconnectTask(conn, disconnectMessage);
waitTaskCompletedSuccessfully(taskDN);
-
// Make sure that we get a notice of disconnection on the initial connection.
LDAPMessage message = conn.readMessage();
ExtendedResponseProtocolOp extendedResponse = message.getExtendedResponseProtocolOp();
assertEquals(extendedResponse.getOID(), LDAPConstants.OID_NOTICE_OF_DISCONNECTION);
- assertEquals(extendedResponse.getErrorMessage(), disconnectMessage);
+ assertEquals(extendedResponse.getErrorMessage(), LocalizableMessage.raw(disconnectMessage));
}
}
-
-
/**
* Tests the ability of the server to disconnect an arbitrary client
* connection without a notice of disconnection.
@@ -109,17 +90,43 @@
public void testDisconnectWithoutNotification()
throws Exception
{
- // Establish a connection to the server, bind, and get the connection ID.
try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort()))
{
conn.bind("cn=Directory Manager", "password");
- long connectionID = getConnectionID(conn);
+ DN taskDN = invokeClientDisconnectTask(conn, null);
+ waitTaskCompletedSuccessfully(taskDN);
+ // Make sure that the client connection has been closed with no notice of disconnection.
+ try
+ {
+ conn.readMessage();
+ fail("Expected IOException");
+ }
+ catch (IOException expected) { /* nothing to do */ }
+ }
+ }
- // Invoke the disconnect client task.
- String taskID = "Disconnect Client " + connectionID;
- DN taskDN = DN.valueOf("ds-task-id=" + taskID + ",cn=Scheduled Tasks,cn=Tasks");
+ private DN invokeClientDisconnectTask(RemoteConnection conn, String disconnectMessage) throws Exception
+ {
+ long connectionID = getConnectionID(conn);
+ String taskID = "Disconnect Client " + connectionID;
+ DN taskDN = DN.valueOf("ds-task-id=" + taskID + ",cn=Scheduled Tasks,cn=Tasks");
+ if (disconnectMessage != null)
+ {
+ TestCaseUtils.addEntry(
+ "dn: " + taskDN,
+ "objectClass: top",
+ "objectClass: ds-task",
+ "objectClass: ds-task-disconnect",
+ "ds-task-id: " + taskID,
+ "ds-task-class-name: org.opends.server.tasks.DisconnectClientTask",
+ "ds-task-disconnect-connection-id: " + connectionID,
+ "ds-task-disconnect-notify-client: true",
+ "ds-task-disconnect-message: " + disconnectMessage);
+ }
+ else
+ {
TestCaseUtils.addEntry(
"dn: " + taskDN,
"objectClass: top",
@@ -129,13 +136,8 @@
"ds-task-class-name: org.opends.server.tasks.DisconnectClientTask",
"ds-task-disconnect-connection-id: " + connectionID,
"ds-task-disconnect-notify-client: false");
-
- waitTaskCompletedSuccessfully(taskDN);
-
-
- // Make sure that the client connection has been closed with no notice of disconnection.
- assertNull(conn.readMessage());
}
+ return taskDN;
}
private long getConnectionID(RemoteConnection conn) throws IOException, LDAPException, LdapException, DecodeException
--
Gitblit v1.10.0