From 724dc38dfdca4df6b5426d1feba964aa3892a417 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Thu, 20 Sep 2007 19:31:21 +0000
Subject: [PATCH] Fix for issue 2227 in which unpredictable behavior results from an upgrade or reversion process replacing the upgrade script while the upgrade process is running on Windows.  This code will compare the running version of the script with the new version to see whether or not the script actually needs replacing.  If so the script is copied with an extension NEW.  When the script starts it checks for the existence of upgrade.bat.NEW and if exists prints a message informing the user that they must replace the old version of the script with the new version before continuing.

---
 opends/tests/unit-tests-testng/src/server/org/opends/quicksetup/util/FileManagerTest.java |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/quicksetup/util/FileManagerTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/quicksetup/util/FileManagerTest.java
index 345ca8a..1a33cca 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/quicksetup/util/FileManagerTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/quicksetup/util/FileManagerTest.java
@@ -498,6 +498,39 @@
     assertTrue(ORIGINAL.equals(contentsOf(copiedF2b1)));
   }
 
+  @DataProvider(name = "differTestData")
+  public Object[][] differTestData() {
+    return new Object[][] {
+      new Object[] { "abc", "abc" },
+      new Object[] { "abc", "xyz" },
+      new Object[] { "abc", "abc\n" },
+      new Object[] { "abc\n", "abc\n" },
+      new Object[] { "abc\nabc", "abc\nabc" },
+      new Object[] { "abc\nabc\nabc", "abc\nabc\nabc" }
+    };
+  }
+
+  @Test(dataProvider = "differTestData")
+  public void testFilesDiffer(String contents1, String contents2)
+          throws Exception
+  {
+    File f1 = new File(fmWorkspace, "f1");
+    File f2 = new File(fmWorkspace, "f2");
+    writeContents(f1, contents1);
+    writeContents(f2, contents2);
+    if (!contents1.equals(contents2)) {
+      assertTrue(fileManager.filesDiffer(f1, f2),
+              "File contents '" + contents1 + "' and '" + contents2 + "' are " +
+                      "not equal despite what FileManager claims");
+    } else {
+      assertFalse(fileManager.filesDiffer(f1, f2),
+              "File contents '" + contents1 + "' and '" + contents2 + "' are " +
+                      "equal despite what FileManager claims");
+    }
+    f1.delete();
+    f2.delete();
+  }
+
   /**
    * Creates a set of file for testing.
    * @param parent of the files.

--
Gitblit v1.10.0