From ef3652a119b7a387364f72837530a05690aad5b3 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Mon, 09 Dec 2013 10:53:55 +0000
Subject: [PATCH] Investigate unit test failures: dump unexpected content of reject file.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/ImportLDIFTestCase.java | 33 ++++++++++++++++++++++++---------
1 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/ImportLDIFTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/ImportLDIFTestCase.java
index bfe3470..1e39dd9 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/ImportLDIFTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/ImportLDIFTestCase.java
@@ -23,6 +23,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions copyright 2013 ForgeRock AS.
*/
package org.opends.server.tools;
@@ -30,15 +31,16 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
+
+import static org.opends.server.TestCaseUtils.readFile;
import static org.testng.Assert.*;
+
import java.io.*;
import java.util.*;
import org.testng.annotations.AfterClass;
-
import org.opends.server.tasks.TaskUtils;
import org.opends.server.types.Attributes;
import org.opends.server.types.Entry;
@@ -47,6 +49,7 @@
+@SuppressWarnings("javadoc")
public class ImportLDIFTestCase extends ToolsTestCase
{
@@ -526,25 +529,37 @@
/**
- * Utility method which is called by the testcase for asserting the
- * rejected file.
+ * Utility method which is called by the testcase for asserting the rejected
+ * file.
*
* @param reject
* The file to be asserted
* @param shouldBeEmpty
* whether the file should be empty.
+ * @throws IOException
+ * If the reject file could not be read.
*/
private void assertRejectedFile(File reject, boolean shouldBeEmpty)
+ throws IOException
{
- if (shouldBeEmpty)
+ try
{
- assertEquals(reject.length(), 0);
+ if (shouldBeEmpty)
+ {
+ if (reject.length() > 0)
+ {
+ fail("Unexpected content in reject file:\n\n" + readFile(reject));
+ }
+ }
+ else
+ {
+ assertFalse(reject.length() == 0);
+ }
}
- else
+ finally
{
- assertFalse(reject.length() == 0);
+ reject.delete();
}
- reject.delete();
}
--
Gitblit v1.10.0