From d710c5f04c40abee7b9d79284f79a2295a96c214 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jn.rouvignac@gmail.com>
Date: Mon, 31 Aug 2015 12:20:33 +0000
Subject: [PATCH] TasksTestCase.java: Extracted method waitTaskCompletedSuccessfully() from test classes.

---
 opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java |   31 ++++++++++---------------------
 1 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java
index 9a353a0..3f06a85 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java
@@ -47,9 +47,7 @@
 import static org.opends.server.util.ServerConstants.*;
 import static org.testng.Assert.*;
 
-/**
- * A set of test cases that can be used to test the task backend.
- */
+/** A set of test cases that can be used to test the task backend. */
 public class TaskBackendTestCase
        extends BackendTestCase
 {
@@ -186,11 +184,9 @@
    * @throws  Exception  If an unexpected problem occurs.
    */
   @Test
-  public void testDeleteCompletedTask()
-         throws Exception
+  public void testDeleteCompletedTask() throws Exception
   {
-    // Schedule a task to start immediately that will simply sleep for 30
-    // seconds.
+    // Schedule a task to start immediately that will simply sleep for 30s
     String taskID = "testDeleteCompltedTask";
     String taskDN = "ds-task-id=" + taskID + ",cn=Scheduled Tasks,cn=tasks";
 
@@ -203,10 +199,8 @@
       "ds-task-class-name: org.opends.server.tasks.DummyTask");
 
 
-    // Wait until the task has completed.
-    Task task = TasksTestCase.getCompletedTask(DN.valueOf(taskDN));
-    assertTrue(TaskState.isDone(task.getTaskState()));
-
+    // Wait until the task is done.
+    TasksTestCase.getDoneTask(DN.valueOf(taskDN));
 
     // Perform a modification to delete that task.
     int resultCode = TestCaseUtils.applyModifications(true,
@@ -288,8 +282,7 @@
   public void testModifyRunningTask()
          throws Exception
   {
-    // Schedule a task to start immediately that will simply sleep for 5
-    // minutes.
+    // Schedule a task to start immediately that will simply sleep for 5 minutes
     String taskID = "testModifyRunningTask";
     String taskDN = "ds-task-id=" + taskID + ",cn=Scheduled Tasks,cn=tasks";
 
@@ -337,9 +330,8 @@
 
     // We may have to wait for the task to register as done, but it should
     // definitely be done before it would have stopped normally.
-    task = TasksTestCase.getCompletedTask(DN.valueOf(taskDN));
+    task = TasksTestCase.getDoneTask(DN.valueOf(taskDN));
     assertTrue(System.currentTimeMillis() - startTime < 300000L);
-    assertTrue(TaskState.isDone(task.getTaskState()));
 
 
     // Perform a modification to delete that task unless
@@ -358,8 +350,7 @@
    * @throws  Exception  If an unexpected problem occurs.
    */
   @Test
-  public void testModifyCompletedTask()
-         throws Exception
+  public void testModifyCompletedTask() throws Exception
   {
     // Schedule a task to start and complete immediately.
     String taskID = "testModifyCompltedTask";
@@ -373,10 +364,8 @@
       "ds-task-id: " + taskID,
       "ds-task-class-name: org.opends.server.tasks.DummyTask");
 
-    // Wait until the task has completed.
-    Task task = TasksTestCase.getCompletedTask(DN.valueOf(taskDN));
-    assertTrue(TaskState.isDone(task.getTaskState()));
-
+    // Wait until the task is done
+    TasksTestCase.getDoneTask(DN.valueOf(taskDN));
 
     // Perform a modification to update a non-state attribute.
     int resultCode = TestCaseUtils.applyModifications(true,

--
Gitblit v1.10.0