ReplicationTestCase.java revision 336ccbd284177b59fca3636fc5fc7212b2f67061
/*
* 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
* 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
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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
*
*
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
/**
* An abstract class that all Replication unit test should extend.
*/
public abstract class ReplicationTestCase extends DirectoryServerTestCase
{
/**
* The internal connection used for operation
*/
protected InternalClientConnection connection;
/**
* Created entries that need to be deleted for cleanup
*/
protected Entry synchroServerEntry;
protected Entry changeLogEntry;
/**
* schema check flag
*/
protected boolean schemaCheck;
/**
* The replication plugin entry
*/
protected String synchroPluginStringDN =
"cn=Multimaster Synchronization, cn=Synchronization Providers,cn=config";
/**
* Set up the environment for performing the tests in this suite.
*
* @throws Exception
* If the environment could not be set up.
*/
{
// This test suite depends on having the schema available.
// Create an internal connection
}
/**
* Open a changelog session to the local Changelog server.
*
*/
protected ChangelogBroker openChangelogSession(
throws Exception, SocketException
{
if (emptyOldChanges)
else
state = new ServerState();
if (timeout != 0)
// to the changelog server.
if (emptyOldChanges)
{
/*
* loop receiving update until there is nothing left
* to make sure that message from previous tests have been consumed.
*/
try
{
while (true)
{
}
}
catch (Exception e)
{
}
}
return broker;
}
/**
* Open a new session to the Changelog Server
* starting with a given ServerState.
*/
protected ChangelogBroker openChangelogSession(
throws Exception, SocketException
{
if (timeout != 0)
return broker;
}
/**
* Open a changelog session with flow control to the local Changelog server.
*
*/
protected ChangelogBroker openChangelogSession(
boolean emptyOldChanges)
throws Exception, SocketException
{
if (emptyOldChanges)
else
state = new ServerState();
if (timeout != 0)
if (emptyOldChanges)
{
/*
* loop receiving update until there is nothing left
* to make sure that message from previous tests have been consumed.
*/
try
{
while (true)
{
}
}
catch (Exception e)
{ }
}
return broker;
}
/**
* suppress all the config entries created by the tests in this class
*/
protected void cleanConfigEntries()
{
"ReplicationTestCase/Cleaning config entries" , 1);
// Delete entries
try
{
while (true)
{
dn);
}
}
catch (NoSuchElementException e) {
// done
}
}
/**
* suppress all the real entries created by the tests in this class
*/
protected void cleanRealEntries()
{
"ReplicationTestCase/Cleaning entries" , 1);
// Delete entries
try
{
while (true)
{
dn);
}
}
catch (NoSuchElementException e) {
// done
}
}
/**
* Clean up the environment. return null;
*
* @throws Exception
* If the environment could not be set up.
*/
public void classCleanUp() throws Exception
{
}
/**
* Configure the replication for this test.
*/
protected void configureReplication() throws Exception
{
// Add the Multimaster replication plugin
+ "objectClass: top\n"
+ "objectClass: ds-cfg-synchronization-provider\n"
+ "objectClass: ds-cfg-multimaster-synchronization-provider\n"
+ "ds-cfg-synchronization-provider-enabled: true\n"
+ "ds-cfg-synchronization-provider-class: " +
"org.opends.server.replication.plugin.MultimasterReplication\n";
"Unable to add the Multimaster replication plugin");
// domains container entry.
+ "objectClass: top\n"
+ "objectClass: ds-cfg-branch\n";
"Unable to add the Multimaster replication plugin");
// Add the changelog server
"Unable to add the changeLog server");
// We also have a replicated suffix (replication domain)
"Unable to add the synchronized server");
}
/**
* Retrieve the number of replayed updates for a given replication
* domain from the monitor entry.
* @return The number of replayed updates.
* @throws Exception If an error occurs.
*/
{
}
/**
* Check that the entry with the given dn has the given valueString value
* for the given attrTypeStr attribute type.
*/
{
boolean found;
if (count<1)
count=1;
do
{
for (int j=0; j < 3; j++)
{
{
break;
}
}
{
}
try
{
" has incorrectly been deleted from the database.");
}
finally
{
}
if (found != hasAttribute)
return found;
}
/**
* Retrieves an entry from the local Directory Server.
* @throws Exception When the entry cannot be locked.
*/
{
if (count<1)
count=1;
{
count--;
}
for (int i=0; i < 3; i++)
{
{
break;
}
}
{
}
try
{
return null;
else
}
finally
{
}
}
}