From 71784f5fa50be5ed3f7b7b539c3622dd7b8b875e Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Fri, 04 May 2007 03:08:21 +0000
Subject: [PATCH] Update TestCaseUtils.startServer() so that the unit test package that it creates can actually be used to run the server (it copies all of the necessary class files and libraries into place so the scripts in bin can find them).

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java |   35 ++++++++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 9 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 c356d62..a27e69a 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
@@ -170,9 +170,9 @@
 
     // Get the build root and use it to create a test package directory.
     String buildRoot = System.getProperty(PROPERTY_BUILD_ROOT);
-    File   testRoot  = new File(buildRoot + File.separator + "build" +
-                                File.separator + "unit-tests" + File.separator +
-                                "package");
+    File   buildDir  = new File(buildRoot, "build");
+    File   unitRoot  = new File(buildDir, "unit-tests");
+    File   testRoot  = new File(unitRoot, "package");
     File   testSrcRoot = new File(buildRoot + File.separator + "tests" +
                                   File.separator + "unit-tests-testng");
 
@@ -197,11 +197,19 @@
 
     // Copy the configuration, schema, and MakeLDIF resources into the
     // appropriate place under the test package.
-    File resourceDir   = new File(buildRoot, "resource");
-    File testResourceDir = new File(testSrcRoot, "resource");
-    File testConfigDir = new File(testRoot, "config");
-    File testBinDir = new File(testRoot, "bin");
+    File serverClassesDir = new File(buildDir, "classes");
+    File unitClassesDir   = new File(unitRoot, "classes");
+    File libDir           = new File(buildRoot, "lib");
+    File resourceDir      = new File(buildRoot, "resource");
+    File testResourceDir  = new File(testSrcRoot, "resource");
+    File testConfigDir    = new File(testRoot, "config");
+    File testClassesDir   = new File(testRoot, "classes");
+    File testLibDir       = new File(testRoot, "lib");
+    File testBinDir       = new File(testRoot, "bin");
 
+    copyDirectory(serverClassesDir, testClassesDir);
+    copyDirectory(unitClassesDir, testClassesDir);
+    copyDirectory(libDir, testLibDir);
     copyDirectory(new File(resourceDir, "bin"), testBinDir);
     copyDirectory(new File(resourceDir, "config"), testConfigDir);
     copyDirectory(new File(resourceDir, "schema"),
@@ -222,6 +230,15 @@
              new File(testConfigDir, "client-cert.p12"));
 
 
+    for (File f : testBinDir.listFiles())
+    {
+      try
+      {
+        FilePermission.setPermissions(f, FilePermission.decodeUNIXMode("755"));
+      } catch (Exception e) {}
+    }
+
+
     // Make the shell scripts in the bin directory executable, if possible.
     OperatingSystem os = DirectoryServer.getOperatingSystem();
     if ((os != null) && OperatingSystem.isUNIXBased(os) &&
@@ -354,7 +371,7 @@
    * to make sure that the server has finished processing all operations
    * from previous tests.
    */
-  public static void quiesceServer() 
+  public static void quiesceServer()
   {
     waitForOpsToComplete();
   }
@@ -1115,7 +1132,7 @@
    * Returns the contents of file as a List of the lines as defined by
    * java.io.BufferedReader#readLine() (i.e. the line terminator is not
    * included).  An ArrayList is explicitly returned, so that callers know that
-   * random access is not expensive.  
+   * random access is not expensive.
    */
   public static ArrayList<String> readFileToLines(File file)
           throws IOException {

--
Gitblit v1.10.0