[Arakhnę-Dev] [209] * Fixing code according to unit tests. |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
Revision: 209
Author: galland
Date: 2011-02-28 09:40:45 +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:22:26 UTC (rev 208)
+++ trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/ClasspathUtilTest.java 2011-02-28 08:40:45 UTC (rev 209)
@@ -21,6 +21,7 @@
import java.io.File;
import java.net.URL;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.regex.Pattern;
@@ -75,16 +76,24 @@
String[] paths = System.getProperty("java.class.path").split( //$NON-NLS-1$
Pattern.quote(File.pathSeparator));
-
- for(int i=0; i<paths.length; i++) {
- URL u = FileSystem.convertStringToURL(paths[i], true);
- assertTrue(urls.hasNext());
+
+ while (urls.hasNext()) {
URL u2 = urls.next();
- if (!isEquals(u, u2)) {
- throw new AssertionFailedError("expected: "+u+"; actual: "+u2); //$NON-NLS-1$//$NON-NLS-2$
+ assertUrl(paths, u2);
+ }
+ }
+
+ private void assertUrl(String[] expected, URL actual) {
+ assertNotNull(actual);
+ assertNotNull(expected);
+ for(String u : expected) {
+ URL url = FileSystem.convertStringToURL(u, true);
+ if (isEquals(url, actual)) {
+ return;
}
}
- }
+ throw new AssertionFailedError("expected: "+Arrays.toString(expected)+"; actual: "+actual); //$NON-NLS-1$//$NON-NLS-2$
+ }
private boolean isEquals(URL expected, URL actual) {
String u1 = expected==null ? null : expected.toExternalForm().replaceFirst("/$", ""); //$NON-NLS-1$ //$NON-NLS-2$