From c64a67b3d0b51743d9f2a2bf110cb365b8b104af Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 26 Aug 2013 08:41:18 +0000
Subject: [PATCH] OPENDJ-1116 Introduce abstraction for the changelog DB

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java |   39 +++++++++++++++++----------------------
 1 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
index f82609b..da7b013 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -28,10 +28,6 @@
  */
 package org.opends.server;
 
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-import static org.testng.Assert.*;
-
 import java.io.*;
 import java.net.*;
 import java.util.*;
@@ -75,9 +71,12 @@
 import org.opends.server.util.EmbeddedUtils;
 import org.opends.server.util.LDIFReader;
 
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+import static org.testng.Assert.*;
+
 /**
- * This class defines some utility functions which can be used by test
- * cases.
+ * This class defines some utility functions which can be used by test cases.
  */
 @SuppressWarnings("javadoc")
 public final class TestCaseUtils {
@@ -348,7 +347,7 @@
       File resourceDir      = new File(buildRoot, "resource");
       File testResourceDir  = new File(testSrcRoot, "resource");
       // Set the class variable
-      testConfigDir    = new File(testInstanceRoot, "config");
+      testConfigDir         = new File(testInstanceRoot, "config");
       File testSchemaDir    = new File(testInstanceRoot, "config");
       File testClassesDir   = new File(testInstanceRoot, "classes");
       File testLibDir       = new File(testInstallRoot, "lib");
@@ -363,11 +362,8 @@
       File   snmpResourceDir = new File(buildRoot + File.separator + "src" +
                                     File.separator + "snmp" + File.separator +
                                     "resource");
-
       File snmpConfigDir = new File(snmpResourceDir, "config");
-
-      File testSnmpResourceDir = new File (testConfigDir + File.separator +
-                                    "snmp");
+      File testSnmpResourceDir = new File (testConfigDir + File.separator + "snmp");
 
       if (Boolean.getBoolean(PROPERTY_COPY_CLASSES_TO_TEST_PKG))
       {
@@ -1045,6 +1041,11 @@
    *           If the directory could not be deleted.
    */
   public static void deleteDirectory(File dir) throws IOException {
+    if (dir == null || !dir.exists())
+    {
+      return;
+    }
+
     if (dir.isDirectory()) {
       // Recursively delete sub-directories and files.
       for (String child : dir.list()) {
@@ -1548,15 +1549,10 @@
 
     if (useAdminPort) {
       return LDAPModify.mainModify(adminArgs, false, null, null);
-    } else {
-      return LDAPModify.mainModify(args, false, null, null);
     }
+    return LDAPModify.mainModify(args, false, null, null);
   }
 
-
-
-
-
   /**
    * Creates a temporary text file with the specified contents.  It will be
    * marked for automatic deletion when the JVM exits.
@@ -1565,8 +1561,7 @@
    *
    * @throws  Exception  If an unexpected problem occurs.
    */
-  public static String createTempFile(String... lines)
-          throws Exception
+  public static String createTempFile(String... lines) throws Exception
   {
     File f = File.createTempFile("LDAPModifyTestCase", ".txt");
     f.deleteOnExit();
@@ -1576,7 +1571,6 @@
     {
       w.write(s + System.getProperty("line.separator"));
     }
-
     w.close();
 
     return f.getAbsolutePath();
@@ -1594,8 +1588,9 @@
   /**
    * Return a Map constructed via alternating key and value pairs.
    */
-  public static LinkedHashMap<String,String> makeMap(String... keyValuePairs) {
-    LinkedHashMap<String,String> map = new LinkedHashMap<String,String>();
+  public static Map<String, String> makeMap(String... keyValuePairs)
+  {
+    Map<String, String> map = new LinkedHashMap<String, String>();
     for (int i = 0; i < keyValuePairs.length; i += 2) {
       map.put(keyValuePairs[i], keyValuePairs[i+1]);
     }

--
Gitblit v1.10.0