ReSyncTest.java revision 987a50dfe113ed235d28716ff080b59e8873655c
/*
* 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 2007 Sun Microsystems, Inc.
*/
/**
*/
public class ReSyncTest extends ReplicationTestCase
{
/**
* Set up the environment for performing the tests in this Class.
*
* @throws Exception
* If the environment could not be set up.
*/
{
/*
* - Start a server and a replicationServer, configure replication
* - Do some changes.
*/
// find a free port for the replicationServer
// Create an internal connection
// Create backend top level entries
+ "objectClass: domain\n");
// top level synchro provider
// Multimaster Synchro plugin
synchroPluginStringDN = "cn=Multimaster Synchronization, "
// Change log
+ "objectClass: top\n"
+ "objectClass: ds-cfg-replication-server\n"
+ "cn: Replication Server\n"
+ "ds-cfg-replication-server-id: 1\n";
// suffix synchronized
+ "objectClass: top\n"
+ "objectClass: ds-cfg-replication-domain\n"
+ "cn: example\n"
+ "ds-cfg-base-dn: dc=example,dc=com\n"
+ "ds-cfg-server-id: 123\n";
// Give some time to the replication to setup
// Create a dummy entry
addEntry("dn: dc=dummy, dc=example,dc=com\n"
+ "objectClass: top\n" + "objectClass: domain\n");
}
/**
* Utility function. Can be used to create and add and entry
* in the local DS from its ldif description.
*
* @param entryString The entry in ldif from.
* @return The ResultCode of the operation.
* @throws Exception If something went wrong.
*/
{
addOp.setInternalOperation(true);
return addOp.getResultCode();
}
/**
*/
public void testResyncAfterRestore() throws Exception
{
/*
* - Backup the server
* - ADD an entry
* - Restore the backup taken previously
* - Check that entry has been added again in the LDAP server.
*/
// Delete the entry we are going to use to make sure that
// we do test something.
+ ",cn=Scheduled Tasks,cn=Tasks\n"
+ "objectclass: top\n"
+ "objectclass: ds-task\n"
+ "objectclass: ds-task-backup\n"
+ "ds-task-class-name: org.opends.server.tasks.BackupTask\n"
+ "ds-backup-directory-path: bak\n"
+ "ds-task-backup-all: TRUE\n");
addEntry("dn: dc=foo, dc=example,dc=com\n"
+ "objectClass: top\n" + "objectClass: domain\n");
+ ",cn=Scheduled Tasks,cn=Tasks\n"
+ "objectclass: top\n"
+ "objectclass: ds-task\n"
+ "objectclass: ds-task-restore\n"
+ "ds-task-class-name: org.opends.server.tasks.RestoreTask\n"
+ "userRoot\n");
fail("The Directory has not been resynchronized after the restore.");
}
/**
*/
public void testResyncAfterImport() throws Exception
{
/*
* - Do an export to a LDIF file
* - Add an entry
* - Import LDIF file generated above.
* - Check that entry has been added again in the LDAP server.
*/
// delete the entry we are going to use to make sure that
// we do test something.
+ ",cn=Scheduled Tasks,cn=Tasks\n"
+ "objectclass: top\n"
+ "objectclass: ds-task\n"
+ "objectclass: ds-task-export\n"
+ "ds-task-class-name: org.opends.server.tasks.ExportTask\n"
+ "ds-task-export-backend-id: userRoot\n"
addEntry("dn: dc=foo, dc=example,dc=com\n"
+ "objectClass: top\n" + "objectClass: domain\n");
+ ",cn=Scheduled Tasks,cn=Tasks\n"
+ "objectclass: top\n"
+ "objectclass: ds-task\n"
+ "objectclass: ds-task-import\n"
+ "ds-task-class-name: org.opends.server.tasks.ImportTask\n"
+ "ds-task-import-backend-id: userRoot\n"
fail("The Directory has not been resynchronized after the restore.");
}
}