[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: cvs commit: jakarta-commons-sandbox/transaction/src/test/org/apache/commons/transaction/file FileRes
From: ozeigermann () apache ! org
Date: 2004-10-31 10:41:35
Message-ID: 20041031104135.39231.qmail () minotaur ! apache ! org
[Download RAW message or body]
ozeigermann 2004/10/31 02:41:35
Modified: transaction/src/test/org/apache/commons/transaction/file
FileResourceManagerTest.java
Log:
Fixed wrong test helper that got confused when files from the system
were returned in a different order than expected
Revision Changes Path
1.6 +33 -34 \
jakarta-commons-sandbox/transaction/src/test/org/apache/commons/transaction/file/FileResourceManagerTest.java
Index: FileResourceManagerTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/transaction/src/test/org/apache/commons/transaction/file/FileResourceManagerTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FileResourceManagerTest.java 12 Jun 2004 13:39:25 -0000 1.5
+++ FileResourceManagerTest.java 31 Oct 2004 10:41:35 -0000 1.6
@@ -49,7 +49,10 @@
private static final String STORE = "tmp/store";
private static final String WORK = "tmp/work";
private static final String ENCODING = "ISO-8859-15";
- private static final long BARRIER_TIMEOUT = 2000;
+ // FIXME
+ // XXX INCREASE THIS WHEN DEBUGGING OTHERWISE THE BARRIER WILL TIME OUT AFTER \
TWO SECONDS + // MOST LIKELY CONFUSING YOU COMPLETELY
+ private static final long BARRIER_TIMEOUT = 200000;
private static final String[] INITIAL_FILES = new String[] { STORE + \
"/olli/Hubert6", STORE + "/olli/Hubert" };
@@ -188,7 +191,8 @@
checkExactlyContains(dirPath, fileNames, null);
}
- private static final void checkExactlyContains(String dirPath, String[] \
fileNames, String[] contents) { + private static final void \
checkExactlyContains(String dirPath, String[] fileNames, + String[] \
contents) { File dir = new File(dirPath);
if (dir.isDirectory()) {
@@ -201,39 +205,34 @@
}
}
- List fileNameList = new ArrayList(Arrays.asList(fileNames));
+ if (files.length != fileNames.length) {
+ fail(dirPath + " contains " + files.length + " instead of " + \
fileNames.length + + " files");
+ }
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
- String fileName = file.getName();
- if (!fileNameList.contains(fileName)) {
- fail(dirPath + " does not contain required " + fileName);
- } else {
- fileNameList.remove(fileName);
- String content = null;
- if (contents != null && contents.length > i) {
- content = contents[i];
- }
- if (content != null && !compare(file, content)) {
- fail(
- "Contents of "
- + fileName
- + " in "
- + dirPath
- + " does not contain required content '"
- + content
- + "'");
+ for (int i = 0; i < fileNames.length; i++) {
+ String fileName = fileNames[i];
+ boolean match = false;
+ File file = null;
+ for (int j = 0; j < files.length; j++) {
+ file = files[j];
+ if (file.getName().equals(fileName)) {
+ match = true;
+ break;
}
}
- }
+ if (!match) {
+ fail(dirPath + " does not contain required " + fileName);
+ }
- if (fileNameList.size() != 0) {
- StringBuffer missingFiles = new StringBuffer("Missing files: ");
- for (Iterator it = fileNameList.iterator(); it.hasNext();) {
- String fileName = (String) it.next();
- missingFiles.append(fileName + (it.hasNext() ? ", " : ""));
+ String content = null;
+ if (contents != null && i < contents.length) {
+ content = contents[i];
+ }
+ if (content != null && !compare(file, content)) {
+ fail("Contents of " + fileName + " in " + dirPath
+ + " does not contain required content '" + content + \
"'"); }
- fail(missingFiles.toString());
}
} else {
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic