[Arakhnę-Dev] [210] * Fixing code according to unit tests. |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
Revision: 210
Author: galland
Date: 2011-02-28 09:53:51 +0100 (Mon, 28 Feb 2011)
Log Message:
-----------
* Fixing code according to unit tests.
Modified Paths:
--------------
trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/ClasspathUtilTest.java
Modified: trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/ClasspathUtilTest.java
===================================================================
--- trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/ClasspathUtilTest.java 2011-02-28 08:40:45 UTC (rev 209)
+++ trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/ClasspathUtilTest.java 2011-02-28 08:53:51 UTC (rev 210)
@@ -21,8 +21,10 @@
import java.io.File;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
+import java.util.List;
import java.util.regex.Pattern;
import junit.framework.AssertionFailedError;
@@ -76,23 +78,32 @@
String[] paths = System.getProperty("java.class.path").split( //$NON-NLS-1$
Pattern.quote(File.pathSeparator));
+ List<String> list = new ArrayList<String>(Arrays.asList(paths));
while (urls.hasNext()) {
URL u2 = urls.next();
- assertUrl(paths, u2);
+ assertUrl(list, u2);
}
}
- private void assertUrl(String[] expected, URL actual) {
+ private void assertUrl(List<String> expected, URL actual) {
assertNotNull(actual);
assertNotNull(expected);
- for(String u : expected) {
- URL url = FileSystem.convertStringToURL(u, true);
- if (isEquals(url, actual)) {
- return;
+ Iterator<String> iterator = expected.iterator();
+ String u;
+ if (iterator.hasNext()) {
+ while (iterator.hasNext()) {
+ u = iterator.next();
+ URL url = FileSystem.convertStringToURL(u, true);
+ if (isEquals(url, actual)) {
+ iterator.remove();
+ return;
+ }
}
+ throw new AssertionFailedError("expected: "+expected.toString()+"; actual: "+actual); //$NON-NLS-1$//$NON-NLS-2$
}
- throw new AssertionFailedError("expected: "+Arrays.toString(expected)+"; actual: "+actual); //$NON-NLS-1$//$NON-NLS-2$
+
+ System.out.println("Additional class path: "+actual); //$NON-NLS-1$
}
private boolean isEquals(URL expected, URL actual) {