AbandonOperationTestCase.java revision ea1068c292e9b341af6d6b563cd8988a96be20a9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS.
*/
/**
* A set of test cases for abandon operations
*/
public class AbandonOperationTestCase
extends OperationTestCase
{
/**
* {@inheritDoc}
*/
protected Operation[] createTestOperations()
throws Exception
{
return new Operation[]
{
};
}
/**
* For some reason, the @BeforeClass method in the super class is not called.
*/
public void startServer() throws Exception {
super.startServer();
}
/**
* Tests the <CODE>getIDToAbandon</CODE> method.
*/
@Test
public void testGetIDToAbandon()
{
}
/**
* Tests the <CODE>cancel</CODE> method.
*/
@Test
public void testCancel()
{
}
/**
* Tests the <CODE>getCancelRequest</CODE> method.
*/
@Test
public void testGetCancelRequest()
{
}
/**
* Invokes a number of operation methods on the provided abandon operation
* for which all processing has been completed.
*
* @param abandonOperation The operation to be tested.
*/
{
}
/**
* Attempts an internal abandon operation, which will fail because internal
* operations cannot be abandoned.
*/
@Test
public void testAbandonInternal()
{
}
/**
* Tests performing an abandon operation on a client connection that gets
* terminated during pre-parse plugin processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testDisconnectInPreParse()
throws Exception
{
// Establish a connection to the server. It can be unauthenticated for the
// purpose of this test.
LDAPWriter w = new LDAPWriter(s);
// Send the abandon request to the server and wait a few seconds to ensure
// it has completed before closing the connection.
w.writeMessage(message);
StaticUtils.close(s);
// NOTE: We can't check to see if pre-parse plugins were called yet
// because there's no plugin ordering. It's possible that the
// disconnect plugin was called before the invocation counter plugin,
// in which case the pre-parse count wouldn't be incremented.
}
/**
* Tests the use of the abandon operation with a target operation that doesn't
* exist.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testNoSuchOperation()
throws Exception
{
// Establish a connection to the server. It can be unauthenticated for the
// purpose of this test.
LDAPWriter w = new LDAPWriter(s);
// Send the abandon request to the server and wait a few seconds to ensure
// it has completed before closing the connection.
s.close();
}
/**
* Tests the ability to abandon an add operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testAbandonAdd()
throws Exception
{
// Establish a connection to the server and bind as a root user.
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
// Create an add request and send it to the server. Make sure to include
// the delay request control so it won't complete before we can send the
// abandon request.
w.writeMessage(message);
// Send the abandon request to the server.
// Normally, abandoned operations don't receive a response. However, the
// testing configuration has been updated to ensure that if an operation
// does get abandoned, the server will return a response for it with a
// result code of "cancelled".
message = r.readMessage();
s.close();
}
/**
* Tests the ability to abandon a compare operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testAbandonCompare()
throws Exception
{
// Establish a connection to the server and bind as a root user.
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
// Create a compare request and send it to the server. Make sure to include
// the delay request control so it won't complete before we can send the
// abandon request.
w.writeMessage(message);
// Send the abandon request to the server and wait a few seconds to ensure
// it has completed before closing the connection.
// Normally, abandoned operations don't receive a response. However, the
// testing configuration has been updated to ensure that if an operation
// does get abandoned, the server will return a response for it with a
// result code of "cancelled".
message = r.readMessage();
s.close();
}
/**
* Tests the ability to abandon a delete operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testAbandonDelete()
throws Exception
{
// Add an entry to the server that we can delete.
"dn: cn=test,o=test",
"objectClass: top",
"objectClass: device",
"cn: test");
// Establish a connection to the server and bind as a root user.
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
// Create a delete request and send it to the server. Make sure to include
// the delay request control so it won't complete before we can send the
// abandon request.
w.writeMessage(message);
// Send the abandon request to the server and wait a few seconds to ensure
// it has completed before closing the connection.
// Normally, abandoned operations don't receive a response. However, the
// testing configuration has been updated to ensure that if an operation
// does get abandoned, the server will return a response for it with a
// result code of "cancelled".
message = r.readMessage();
s.close();
}
/**
* Tests the ability to abandon an extended operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testAbandonExtended()
throws Exception
{
// Establish a connection to the server and bind as a root user.
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
// Create a "Who Am I?" extended operation and send it to the server. Make
// sure to include the delay request control so it won't complete before we
// can send the abandon request.
w.writeMessage(message);
// Send the abandon request to the server and wait a few seconds to ensure
// it has completed before closing the connection.
// Normally, abandoned operations don't receive a response. However, the
// testing configuration has been updated to ensure that if an operation
// does get abandoned, the server will return a response for it with a
// result code of "cancelled".
message = r.readMessage();
s.close();
}
/**
* Tests the ability to abandon a modify operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testAbandonModify()
throws Exception
{
// Establish a connection to the server and bind as a root user.
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
// Create a modify request and send it to the server. Make sure to include
// the delay request control so it won't complete before we can send the
// abandon request.
w.writeMessage(message);
// Send the abandon request to the server and wait a few seconds to ensure
// it has completed before closing the connection.
// Normally, abandoned operations don't receive a response. However, the
// testing configuration has been updated to ensure that if an operation
// does get abandoned, the server will return a response for it with a
// result code of "cancelled".
message = r.readMessage();
s.close();
}
/**
* Tests the ability to abandon a modify DN operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testAbandonModifyDN()
throws Exception
{
// Add an entry to the server that we can rename.
"dn: cn=test,o=test",
"objectClass: top",
"objectClass: device",
"cn: test");
// Establish a connection to the server and bind as a root user.
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
// Create a modify DN request and send it to the server. Make sure to
// include the delay request control so it won't complete before we can send
// the abandon request.
w.writeMessage(message);
// Send the abandon request to the server and wait a few seconds to ensure
// it has completed before closing the connection.
// Normally, abandoned operations don't receive a response. However, the
// testing configuration has been updated to ensure that if an operation
// does get abandoned, the server will return a response for it with a
// result code of "cancelled".
message = r.readMessage();
s.close();
}
/**
* Tests the ability to abandon a search operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testAbandonSearch()
throws Exception
{
// Establish a connection to the server and bind as a root user.
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
// Create a search request and send it to the server. Make sure to include
// the delay request control so it won't complete before we can send the
// abandon request.
0, false,
new LinkedHashSet<String>());
w.writeMessage(message);
// Send the abandon request to the server and wait a few seconds to ensure
// it has completed before closing the connection.
// Normally, abandoned operations don't receive a response. However, the
// testing configuration has been updated to ensure that if an operation
// does get abandoned, the server will return a response for it with a
// result code of "cancelled".
message = r.readMessage();
s.close();
}
/**
* Waits up to ten seconds for the abandoned operation count to reach the
* expected value.
*
* @param expectedCount The abandon count the server is expected to reach.
*
* @throws Exception If an unexpected problem occurs.
*/
private void waitForAbandon(long expectedCount)
throws Exception
{
{
{
return;
}
}
}
}