/* * The contents of this file are subject to the terms of the Common Development and * Distribution License (the License). You may not use this file except in compliance with the * License. * * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the * specific language governing permission and limitations under the License. * * When distributing Covered Software, include this CDDL Header Notice in each file and include * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL * Header, with the fields enclosed by brackets [] replaced by your own identifying * information: "Portions Copyright [year] [name of copyright owner]". * * Copyright 2006-2009 Sun Microsystems, Inc. * Portions Copyright 2011-2014 ForgeRock AS. */ package org.opends.server.tasks; import org.testng.annotations.BeforeClass; import org.testng.annotations.AfterClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import org.opends.server.TestCaseUtils; import org.opends.server.backends.task.TaskState; import org.opends.server.types.Entry; import java.util.UUID; public class TestRebuildTask extends TasksTestCase { private static String suffix="dc=rebuild,dc=jeb"; private static String vBranch="ou=rebuild tests," + suffix; private static String[] template = new String[] { "define suffix="+suffix, "define maildomain=example.com", "define numusers= #numEntries#", "", "branch: [suffix]", "", "branch: " + vBranch, "subordinateTemplate: person:[numusers]", "", "template: person", "rdnAttr: uid", "objectClass: top", "objectClass: person", "objectClass: organizationalPerson", "objectClass: inetOrgPerson", "givenName: ABOVE LIMIT", "sn: ", "cn: {givenName} {sn}", "initials: {givenName:1}{sn:1}", "employeeNumber: ", "uid: user.{employeeNumber}", "mail: {uid}@[maildomain]", "userPassword: password", "telephoneNumber: ", "homePhone: ", "pager: ", "mobile: ", "street: Street", "l: ", "st: ", "postalCode: ", "postalAddress: {cn}${street}${l}, {st} {postalCode}", "description: This is the description for {cn}.", ""}; @BeforeClass public void setup() throws Exception { TestCaseUtils.startServer(); TestCaseUtils.enableBackend("rebuildRoot"); } @AfterClass public void cleanUp() throws Exception { TestCaseUtils.disableBackend("rebuildRoot"); } @DataProvider(name = "taskentry") public Object[][] createData() throws Exception { return new Object[][] { // A fairly simple, valid rebuild task. { TestCaseUtils.makeEntry( "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", "objectclass: top", "objectclass: ds-task", "objectclass: ds-task-rebuild", "ds-task-class-name: org.opends.server.tasks.RebuildTask", "ds-task-rebuild-base-dn: " + suffix, "ds-task-rebuild-index: mail" ), TaskState.COMPLETED_SUCCESSFULLY }, { TestCaseUtils.makeEntry( "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", "objectclass: top", "objectclass: ds-task", "objectclass: ds-task-rebuild", "ds-task-class-name: org.opends.server.tasks.RebuildTask", "ds-task-rebuild-base-dn: " + suffix, "ds-task-rebuild-index: dn2id", "ds-task-rebuild-index: dn2uri", "ds-task-rebuild-index: mail" ), TaskState.COMPLETED_SUCCESSFULLY }, { TestCaseUtils.makeEntry( "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", "objectclass: top", "objectclass: ds-task", "objectclass: ds-task-rebuild", "ds-task-class-name: org.opends.server.tasks.RebuildTask", "ds-task-rebuild-base-dn: ou=bad," + suffix, "ds-task-rebuild-index: dn2id", "ds-task-rebuild-index: dn2uri" ), TaskState.STOPPED_BY_ERROR }, }; } @Test(dataProvider = "taskentry", groups = "slow") public void testRebuildTask(Entry taskEntry, TaskState expectedState) throws Exception { testTask(taskEntry, expectedState, 60); } }