mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
09.50.2016 ddc834f5aa8f311192cc419cf57b0648b4971b5b
opendj-server-legacy/src/test/java/org/opends/server/tasks/TasksTestCase.java
@@ -19,6 +19,7 @@
import java.util.Set;
import java.util.concurrent.Callable;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.DirectoryServerTestCase;
@@ -29,8 +30,6 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.AttributeParser;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.Entry;
import org.opends.server.util.TestTimer;
import org.testng.annotations.Test;
@@ -62,13 +61,13 @@
    // Check that the task state is as expected.
    Entry resultEntry = getCompletedTaskEntry(taskEntry.getName(), timeoutInSec);
    String stateString = parseAttribute(resultEntry, ATTR_TASK_STATE).asString();
    String stateString = resultEntry.parseAttribute(ATTR_TASK_STATE).asString();
    TaskState taskState = TaskState.fromString(stateString);
    assertEquals(taskState, expectedState,
                 "The task completed in an unexpected state");
    // Check that the task contains some log messages.
    Set<String> logMessages = parseAttribute(resultEntry, ATTR_TASK_LOG_MESSAGES).asSetOfString();
    Set<String> logMessages = resultEntry.parseAttribute(ATTR_TASK_LOG_MESSAGES).asSetOfString();
    assertTrue(taskState == TaskState.COMPLETED_SUCCESSFULLY || !logMessages.isEmpty(),
        "No log messages were written to the task entry on a failed task.\n"
          + "taskState=" + taskState
@@ -90,7 +89,7 @@
      {
        InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
        Entry resultEntry = searchOperation.getSearchEntries().getFirst();
        String completionTime = parseAttribute(resultEntry, ATTR_TASK_COMPLETION_TIME).asString();
        String completionTime = resultEntry.parseAttribute(ATTR_TASK_COMPLETION_TIME).asString();
        assertNotNull(completionTime,
            "The task had not completed after " + timeoutInSec + " seconds.\nresultEntry=[" + resultEntry + "]");
        return resultEntry;
@@ -98,11 +97,6 @@
    });
  }
  private AttributeParser parseAttribute(Entry resultEntry, String attrName)
  {
    return resultEntry.parseAttribute(attrName.toLowerCase());
  }
  /**
   * Retrieves the specified task from the server, regardless of its current
   * state.