[Arakhnę-Dev] [87] Patching the source code to fix the warnings applied by the new supported IDE (Eclipse Galileo). |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
- To: dev@xxxxxxxxxxx
- Subject: [Arakhnę-Dev] [87] Patching the source code to fix the warnings applied by the new supported IDE (Eclipse Galileo).
- From: subversion@xxxxxxxxxxxxx
- Date: Mon, 23 Nov 2009 16:20:36 +0100
Revision: 87
Author: galland
Date: 2009-11-23 16:20:35 +0100 (Mon, 23 Nov 2009)
Log Message:
-----------
Patching the source code to fix the warnings applied by the new supported IDE (Eclipse Galileo).
Modified Paths:
--------------
trunk/arakhneLogger/src/main/java/org/arakhne/logging/FileLogger.java
trunk/arakhneLogger/src/main/java/org/arakhne/logging/Logger.java
trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractWeakSoftValueMap.java
trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/ComparableSoftReference.java
trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/ComparableWeakReference.java
trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/WeakArrayList.java
trunk/arakhneRefs/src/test/java/org/arakhne/junit/AbstractRepeatedTest.java
trunk/arakhneRefs/src/test/java/org/arakhne/junit/AbstractTestCase.java
trunk/arakhneRefs/src/test/java/org/arakhne/junit/RepeatableTest.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/SoftValueMapTest.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakArrayListTest.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakValueMapTest.java
trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/LibraryLoader.java
trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/ReflectionUtil.java
trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/VMCommandLine.java
trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java
trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/VMCommandLineTest.java
Modified: trunk/arakhneLogger/src/main/java/org/arakhne/logging/FileLogger.java
===================================================================
--- trunk/arakhneLogger/src/main/java/org/arakhne/logging/FileLogger.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneLogger/src/main/java/org/arakhne/logging/FileLogger.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -41,6 +41,7 @@
* Unamed Logger on system console.
*
* @param logFile is the log file to write inside.
+ * @throws IOException when error on log file opening.
*/
public FileLogger(File logFile) throws IOException {
this(logFile, new PrintStream(new FileOutputStream(logFile)));
@@ -51,6 +52,7 @@
*
* @param logFile is the log file to write inside.
* @param name is the name of the logger.
+ * @throws IOException when error on log file opening.
*/
public FileLogger(File logFile, String name) throws IOException {
this(logFile, new PrintStream(new FileOutputStream(logFile)), name);
@@ -67,6 +69,8 @@
}
/** Replies the log file which is written by this logger.
+ *
+ * @return the log file, never <code>null</code>
*/
public File getLogFile() {
return this.logFile;
Modified: trunk/arakhneLogger/src/main/java/org/arakhne/logging/Logger.java
===================================================================
--- trunk/arakhneLogger/src/main/java/org/arakhne/logging/Logger.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneLogger/src/main/java/org/arakhne/logging/Logger.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -29,7 +29,7 @@
* @author Nicolas GAUD <gaud@xxxxxxxxxxx>
* @author Stéphane GALLAND <galland@xxxxxxxxxxx>
* @version $Name$ $Revision$ $Date$
- * @see Logger.LogLevel
+ * @see LogLevel
*/
public interface Logger {
Modified: trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractWeakSoftValueMap.java
===================================================================
--- trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractWeakSoftValueMap.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractWeakSoftValueMap.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,7 +1,7 @@
/*
* $Id: WeakValueMap.java,v 1.1 2007-02-20 08:52:37 sgalland Exp $
*
- * Copyright (C) 2005-2007 Stéphane GALLAND
+ * Copyright (C) 2005-2009 Stéphane GALLAND
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -168,7 +168,7 @@
public final void expurgeQueuedReferences() {
Reference<? extends V> o;
while((o = this.queue.poll()) != null) {
- if (o instanceof WeakSoftValue) {
+ if (o instanceof WeakSoftValue<?,?>) {
this.map.remove(((WeakSoftValue<?,?>)o).getKey());
}
o.clear();
@@ -198,7 +198,7 @@
value = null;
while((o = this.queue.poll()) != null) {
- if (o instanceof WeakSoftValue) {
+ if (o instanceof WeakSoftValue<?,?>) {
this.map.remove(((WeakSoftValue<?,?>)o).getKey());
}
o.clear();
@@ -210,10 +210,10 @@
*
* @param k is the key associated to the value
* @param v is the value
- * @param queue is the reference queue to use
+ * @param refQueue is the reference queue to use
* @return the new storage object
*/
- protected abstract WeakSoftValue<K,V> makeValue(K k, V v, ReferenceQueue<V> queue);
+ protected abstract WeakSoftValue<K,V> makeValue(K k, V v, ReferenceQueue<V> refQueue);
/** Create a storage object that permits to put the specified
* elements inside this map.
@@ -265,6 +265,11 @@
}
/**
+ * This interface provides information about the pairs inside
+ * a map with weak/soft reference values.
+ *
+ * @param <K> is the type of the map keys.
+ * @param <V> is the type of the map values.
* @author Stéphane GALLAND <galland@xxxxxxxxxxx>
* @version $Name: $ $Revision: 1.1 $ $Date: 2007-02-20 08:52:37 $
*/
@@ -326,7 +331,7 @@
@Override
public final boolean contains(Object o) {
- if (o instanceof Entry) {
+ if (o instanceof Entry<?,?>) {
try {
expurgeNow();
return AbstractWeakSoftValueMap.this.map.containsKey(((Entry<?,?>)o).getKey());
@@ -344,7 +349,7 @@
expurgeNow();
for(Object o : c) {
ok = false;
- if (o instanceof Entry) {
+ if (o instanceof Entry<?,?>) {
try {
ok = AbstractWeakSoftValueMap.this.map.containsKey(((Entry<?,?>)o).getKey());
}
@@ -370,7 +375,7 @@
@Override
public final boolean remove(Object o) {
- if (o instanceof Entry) {
+ if (o instanceof Entry<?,?>) {
try {
return AbstractWeakSoftValueMap.this.map.remove(((Entry<?,?>)o).getKey())!=null;
}
@@ -462,17 +467,17 @@
private Entry<K,V> searchNext() {
Entry<K,WeakSoftValue<K,V>> originalNext;
WeakSoftValue<K,V> wValue;
- Entry<K,V> next = null;
- while (next==null && this.originalIterator.hasNext()) {
+ Entry<K,V> cnext = null;
+ while (cnext==null && this.originalIterator.hasNext()) {
originalNext = this.originalIterator.next();
if (originalNext!=null) {
wValue = originalNext.getValue();
if (wValue!=null) {
- next = new InnerEntry(wValue.getValue(), originalNext);
+ cnext = new InnerEntry(wValue.getValue(), originalNext);
}
}
}
- return next;
+ return cnext;
}
@Override
@@ -482,9 +487,9 @@
@Override
public java.util.Map.Entry<K, V> next() {
- Entry<K,V> next = this.next;
+ Entry<K,V> cnext = this.next;
this.next = searchNext();
- return next;
+ return cnext;
}
@Override
Modified: trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/ComparableSoftReference.java
===================================================================
--- trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/ComparableSoftReference.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/ComparableSoftReference.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,7 +1,7 @@
/*
* $Id: ComparableSoftReference.java,v 1.1 2007-02-20 08:52:37 sgalland Exp $
*
- * Copyright (C) 2005-2007 Stéphane GALLAND
+ * Copyright (C) 2005-2009 Stéphane GALLAND
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -51,15 +51,20 @@
}
/** {@inheritDoc}
- *
- * @param o {@inheritDoc}
- * @return {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
return compareTo(o)==0;
}
+ /** {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ T cur = get();
+ return cur==null ? 0 : cur.hashCode();
+ }
+
/** Compare this reference to the specified object
* based on the {@link Object#hashCode()} if the
* references are not equals.
Modified: trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/ComparableWeakReference.java
===================================================================
--- trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/ComparableWeakReference.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/ComparableWeakReference.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,7 +1,7 @@
/*
* $Id: ComparableWeakReference.java,v 1.1 2007-02-20 08:52:37 sgalland Exp $
*
- * Copyright (C) 2005-2007 Stéphane GALLAND
+ * Copyright (C) 2005-2009 Stéphane GALLAND
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -51,15 +51,20 @@
}
/** {@inheritDoc}
- *
- * @param o {@inheritDoc}
- * @return {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
return compareTo(o)==0;
}
+ /** {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ T cur = get();
+ return cur==null ? 0 : cur.hashCode();
+ }
+
/** Compare this reference to the specified object
* based on the {@link Object#hashCode()} if the
* references are not equals.
Modified: trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/WeakArrayList.java
===================================================================
--- trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/WeakArrayList.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/WeakArrayList.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,7 +1,7 @@
/*
* $Id: WeakArrayList.java,v 1.1 2007-02-20 08:52:37 sgalland Exp $
*
- * Copyright (C) 2005-2007 Stéphane GALLAND
+ * Copyright (C) 2005-2009 Stéphane GALLAND
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -273,13 +273,13 @@
* @param allowLast indicates if the last elements is assumed to be valid or not.
*/
protected void assertRange(int index, boolean allowLast) {
- int size = expurge();
+ int csize = expurge();
if (index<0)
throw new IndexOutOfBoundsException("invalid negative value: "+Integer.toString(index)); //$NON-NLS-1$
- if ((allowLast)&&(index>size))
- throw new IndexOutOfBoundsException("index>"+size+": "+Integer.toString(index)); //$NON-NLS-1$ //$NON-NLS-2$
- if ((!allowLast)&&(index>=size))
- throw new IndexOutOfBoundsException("index>="+size+": "+Integer.toString(index)); //$NON-NLS-1$ //$NON-NLS-2$
+ if ((allowLast)&&(index>csize))
+ throw new IndexOutOfBoundsException("index>"+csize+": "+Integer.toString(index)); //$NON-NLS-1$ //$NON-NLS-2$
+ if ((!allowLast)&&(index>=csize))
+ throw new IndexOutOfBoundsException("index>="+csize+": "+Integer.toString(index)); //$NON-NLS-1$ //$NON-NLS-2$
}
/** {@inheritDoc}
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/junit/AbstractRepeatedTest.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/junit/AbstractRepeatedTest.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/junit/AbstractRepeatedTest.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,6 +1,6 @@
/* $Id$
*
- * Copyright (C) 2007 Stéphane GALLAND
+ * Copyright (C) 2007-09 Stéphane GALLAND
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -38,10 +38,18 @@
private final int fTimesRepeat;
+ /**
+ * @param clazz
+ * @param repeat
+ */
public AbstractRepeatedTest(Class<? extends RepeatableTest> clazz, int repeat) {
this(new RepeatableTestSuite(clazz),repeat);
}
+ /**
+ * @param test
+ * @param repeat
+ */
public AbstractRepeatedTest(Test test, int repeat) {
super(test);
if (repeat < 0)
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/junit/AbstractTestCase.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/junit/AbstractTestCase.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/junit/AbstractTestCase.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,3 +1,22 @@
+/* $Id$
+ *
+ * Copyright (C) 2007-09 Stéphane GALLAND
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * This program is free software; you can redistribute it and/or modify
+ */
package org.arakhne.junit;
import java.awt.geom.Point2D;
@@ -17,6 +36,11 @@
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
+/** Test case with utility functions.
+*
+* @author Stéphane GALLAND <galland@xxxxxxxxxxx>
+* @version $Name$ $Revision$ $Date$
+*/
public abstract class AbstractTestCase extends TestCase implements RepeatableTest {
private static String arrayToString(Object o) {
@@ -72,6 +96,14 @@
this.loopIndex = index;
}
+ /**
+ * Format a failure message for invalid value.
+ *
+ * @param message is the message to reply.
+ * @param expected is the expected object.
+ * @param actual is the actual value of the object.
+ * @return the message
+ */
protected String formatFailMessage(String message, Object expected, Object actual) {
StringBuffer formatted = new StringBuffer();
if (message!=null) {
@@ -86,6 +118,14 @@
return formatted.toString();
}
+ /**
+ * Format a failure message for invalid value.
+ *
+ * @param message is the first part of the message (optional).
+ * @param msg is the second part of the message (mandatory).
+ * @param actual is the actual value of the object.
+ * @return the message
+ */
protected String formatFailMessage(String message, String msg, Object actual) {
StringBuffer formatted = new StringBuffer();
if (message!=null) {
@@ -99,6 +139,13 @@
return formatted.toString();
}
+ /**
+ * Format a failure message for not-expected values.
+ *
+ * @param message is the message to reply.
+ * @param notexpected is the not-expected object.
+ * @return the message
+ */
protected String formatFailNegMessage(String message, Object notexpected) {
StringBuffer formatted = new StringBuffer();
if (message!=null) {
@@ -113,6 +160,10 @@
/** Asserts that two objects are not equal. If they are
* an AssertionFailedError is thrown with the given message.
+ *
+ * @param message is the error message to put inside the assertion.
+ * @param notexpected is the value which is not expected by the unit test.
+ * @param actual is the actual value of the object in the unit test.
*/
protected void assertNotEquals(String message, Object notexpected, Object actual) {
if ((notexpected!=actual)&&
@@ -124,6 +175,9 @@
/** Asserts that two objects are not equal. If they are
* an AssertionFailedError is thrown with the given message.
+ *
+ * @param notexpected is the value which is not expected by the unit test.
+ * @param actual is the actual value of the object in the unit test.
*/
protected void assertNotEquals(Object notexpected, Object actual) {
assertNotEquals(null, notexpected, actual);
@@ -131,6 +185,10 @@
/** Asserts that the actuel object is equal to one of the expected objects. If not
* an AssertionFailedError is thrown with the given message.
+ *
+ * @param message is the error message to put inside the assertion.
+ * @param expectedObjects are the set of expected values during the unit test.
+ * @param actual is the actual value of the object in the unit test.
*/
protected void assertEquals(String message, Object[] expectedObjects, Object actual) {
if ((expectedObjects!=null)&&(expectedObjects.length>0)) {
@@ -144,6 +202,9 @@
/** Asserts that the actuel object is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param expectedObjects are the set of expected values during the unit test.
+ * @param actual is the actual value of the object in the unit test.
*/
protected void assertEquals(Object[] expectedObjects, Object actual) {
assertEquals(null, expectedObjects, actual);
@@ -151,6 +212,11 @@
/** Asserts that the actuel object is equal to one of the expected objects. If not
* an AssertionFailedError is thrown with the given message.
+ *
+ * @param <T> is the type of the array.
+ * @param message is the error message to put inside the assertion.
+ * @param expectedObjects are the set of expected values during the unit test.
+ * @param actual is the actual value of the objects in the unit test.
*/
protected <T> void assertEquals(String message, T[] expectedObjects, T[] actual) {
if (expectedObjects==actual) return;
@@ -172,6 +238,10 @@
/** Asserts that the actuel object is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <T> is the type of the array.
+ * @param expectedObjects are the set of expected values during the unit test.
+ * @param actual is the actual value of the objects in the unit test.
*/
protected <T> void assertEquals(T[] expectedObjects, T[] actual) {
assertEquals(null, expectedObjects, actual);
@@ -179,6 +249,11 @@
/** Asserts that the actuel object is not equal to one of the expected objects. If not
* an AssertionFailedError is thrown with the given message.
+ *
+ * @param <T> is the type of the array.
+ * @param message is the error message to put inside the assertion.
+ * @param expectedObjects are the set of expected values during the unit test.
+ * @param actual is the actual value of the objects in the unit test.
*/
protected <T> void assertNotEquals(String message, T[] expectedObjects, T[] actual) {
if (expectedObjects!=actual) {
@@ -202,6 +277,10 @@
/** Asserts that the actuel object is not equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <T> is the type of the array.
+ * @param expectedObjects are the set of expected values during the unit test.
+ * @param actual is the actual value of the objects in the unit test.
*/
protected <T> void assertNotEquals(T[] expectedObjects, T[] actual) {
assertNotEquals(null, expectedObjects, actual);
@@ -212,6 +291,8 @@
* This assertion function tests the types of its parameters to call the best
* {@code assertEquals} function.
*
+ * @param expected is the expected value during the unit test.
+ * @param actual is the actual value of the object during the unit test.
* @see #assertEquals(Object, Object)
* @see #assertEquals(Object[], Object)
* @see #assertEquals(Object[], Object[])
@@ -225,6 +306,9 @@
* This assertion function tests the types of its parameters to call the best
* {@code assertEquals} function.
*
+ * @param message is the error message to put inside the assertion.
+ * @param expected is the expected value during the unit test.
+ * @param actual is the actual value of the object during the unit test.
* @see #assertEquals(Object, Object)
* @see #assertEquals(Object[], Object)
* @see #assertEquals(Object[], Object[])
@@ -241,6 +325,10 @@
/** Asserts that the actuel similar is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <T> is the type of the values
+ * @param expectedObjects are the expected values during the unit test.
+ * @param actual are the actual values of the objects during the unit test.
*/
protected <T> void assertSimilars(T[] expectedObjects, T[] actual) {
assertSimilars(null, expectedObjects, actual);
@@ -248,6 +336,11 @@
/** Asserts that the actuel similar is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <T> is the type of the values
+ * @param message is the error message to put inside the assertion.
+ * @param expectedObjects are the expected values during the unit test.
+ * @param actual are the actual values of the objects during the unit test.
*/
protected <T> void assertSimilars(String message, T[] expectedObjects, T[] actual) {
if (expectedObjects==actual) return;
@@ -258,6 +351,10 @@
/** Asserts that the actuel similar is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <T> is the type of the values
+ * @param expectedObjects are the expected values during the unit test.
+ * @param actual are the actual values of the objects during the unit test.
*/
protected <T> void assertSimilars(Collection<T> expectedObjects, Collection<T> actual) {
assertSimilars(null, expectedObjects, actual);
@@ -265,6 +362,11 @@
/** Asserts that the actuel similar is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <T> is the type of the values
+ * @param message is the error message to put inside the assertion.
+ * @param expectedObjects are the expected values during the unit test.
+ * @param actual are the actual values of the objects during the unit test.
*/
protected <T> void assertSimilars(String message, Collection<T> expectedObjects, Collection<T> actual) {
if (expectedObjects==actual) return;
@@ -285,6 +387,10 @@
/** Asserts that the actuel similar is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <T> is the type of the values
+ * @param expectedObjects are the expected values during the unit test.
+ * @param actual are the actual values of the objects during the unit test.
*/
protected <T> void assertEquals(List<T> expectedObjects, List<T> actual) {
assertEquals(null, expectedObjects, actual);
@@ -292,6 +398,11 @@
/** Asserts that the actuel similar is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <T> is the type of the values.
+ * @param message is the error message to put inside the assertion.
+ * @param expectedObjects are the expected values during the unit test.
+ * @param actual are the actual values of the objects during the unit test.
*/
protected <T> void assertEquals(String message, List<T> expectedObjects, List<T> actual) {
if (expectedObjects==actual) return;
@@ -315,6 +426,10 @@
/** Asserts that the actuel similar is not equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <T> is the type of the values
+ * @param expectedObjects are the expected values during the unit test.
+ * @param actual are the actual values of the objects during the unit test.
*/
protected <T> void assertNotEquals(List<T> expectedObjects, List<T> actual) {
assertNotEquals(null, expectedObjects, actual);
@@ -322,6 +437,11 @@
/** Asserts that the actuel object is not equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <T> is the type of the values
+ * @param message is the error message to put inside the assertion.
+ * @param expectedObjects are the expected values during the unit test.
+ * @param actual are the actual values of the objects during the unit test.
*/
protected <T> void assertNotEquals(String message, List<T> expectedObjects, List<T> actual) {
if ((expectedObjects!=actual)&&(!equals(expectedObjects,actual))) return;
@@ -330,6 +450,12 @@
/** Asserts that the actual object is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <T> is the type of the values
+ * @param <X> is the element's type of the values if they are arrays.
+ * @param message is the error message to put inside the assertion.
+ * @param expected is the expected value during the unit test.
+ * @param actual are the actual value of the object during the unit test.
*/
@SuppressWarnings("unchecked")
protected <T, X> void assertSimilars(String message, T expected, T actual) {
@@ -348,6 +474,12 @@
/** Asserts that the actual object is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <T> is the type of the values.
+ * @param <X> is the element's type of the values if they are arrays.
+ * @param message is the error message to put inside the assertion.
+ * @param expected is the expected value.
+ * @param actual is the current value.
*/
protected <T, X> void assertNotSimilars(String message, T expected, T actual) {
if (expected!=actual) {
@@ -367,6 +499,12 @@
}
/** Replies if the two objects are similars.
+ *
+ * @param <T> is the type of the values
+ * @param <X> is the element's type of the values if they are arrays.
+ * @param obj1
+ * @param obj2
+ * @return <code>true</code> if the objects are similar, otherwise <code>false</code>
*/
protected <T, X> boolean isSimilarObjects(T obj1, T obj2) {
if (obj1==obj2) return true;
@@ -384,6 +522,11 @@
/** Asserts that the actuel similar is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <K> is the type of the map keys.
+ * @param <V> is the type of the map values.
+ * @param expectedObjects is the expected map.
+ * @param actual is the current map.
*/
protected <K,V> void assertDeepSimilars(Map<K,V> expectedObjects, Map<K,V> actual) {
assertDeepSimilars(null, expectedObjects, actual);
@@ -391,6 +534,12 @@
/** Asserts that the actuel similar is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <K> is the type of the map keys.
+ * @param <V> is the type of the map values.
+ * @param message is the error message to put inside the assertion.
+ * @param expectedObjects is the expected map.
+ * @param actual is the current map.
*/
protected <K,V> void assertDeepSimilars(String message, Map<K,V> expectedObjects, Map<K,V> actual) {
if (expectedObjects==actual) return;
@@ -408,6 +557,11 @@
/** Asserts that the actuel similar is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <K> is the type of the map keys.
+ * @param <V> is the type of the map values.
+ * @param expectedObjects is the expected map.
+ * @param actual is the current map.
*/
protected <K,V> void assertNotDeepSimilars(Map<K,V> expectedObjects, Map<K,V> actual) {
assertNotDeepSimilars(null, expectedObjects, actual);
@@ -415,6 +569,12 @@
/** Asserts that the actuel similar is equal to one of the expected objects. If not
* an AssertionFailedError is thrown.
+ *
+ * @param <K> is the type of the map keys.
+ * @param <V> is the type of the map values.
+ * @param message is the error message to put inside the assertion.
+ * @param expectedObjects is the expected map.
+ * @param actual is the current map.
*/
protected <K,V> void assertNotDeepSimilars(String message, Map<K,V> expectedObjects, Map<K,V> actual) {
if (expectedObjects!=actual) {
@@ -430,12 +590,17 @@
}
/** Asserts that the specified value is stricly negative.
+ *
+ * @param number
*/
protected void assertStrictlyNegative(Number number) {
assertStrictlyNegative(null,number);
}
/** Asserts that the specified value is stricly negative.
+ *
+ * @param message is the error message to put inside the assertion.
+ * @param number
*/
protected void assertStrictlyNegative(String message, Number number) {
if (number.doubleValue()<0.) return;
@@ -443,12 +608,17 @@
}
/** Asserts that the specified value is stricly positive.
+ *
+ * @param number
*/
protected void assertStrictlyPositive(Number number) {
assertStrictlyPositive(null,number);
}
/** Asserts that the specified value is stricly positive.
+ *
+ * @param message is the error message to put inside the assertion.
+ * @param number
*/
protected void assertStrictlyPositive(String message, Number number) {
if (number.doubleValue()>0.) return;
@@ -456,12 +626,17 @@
}
/** Asserts that the specified value is negative.
+ *
+ * @param number
*/
protected void assertNegative(Number number) {
assertNegative(null,number);
}
/** Asserts that the specified value is negative.
+ *
+ * @param message is the error message to put inside the assertion.
+ * @param number
*/
protected void assertNegative(String message, Number number) {
if (number.doubleValue()<=0.) return;
@@ -469,18 +644,31 @@
}
/** Asserts that the specified value is positive.
+ *
+ * @param number
*/
protected void assertPositive(Number number) {
assertPositive(null,number);
}
/** Asserts that the specified value is positive.
+ *
+ * @param message is the error message to put inside the assertion.
+ * @param number
*/
protected void assertPositive(String message, Number number) {
if (number.doubleValue()>=0.) return;
fail(formatFailMessage(message, "expected positive value", number)); //$NON-NLS-1$
}
+ /**
+ * Replies an array which is containing values randomly selected from the parameter.
+ * Duplicate values are allowed.
+ *
+ * @param <T> is the type of the values.
+ * @param availableValues is the collection of available values.
+ * @return the selected values (possible duplicated)
+ */
@SuppressWarnings("unchecked")
protected <T> T[] extractRandomValues(T[] availableValues) {
Random rnd = new Random();
@@ -497,12 +685,17 @@
}
/** Replies a randomized string.
+ *
+ * @return a random string.
*/
protected String randomString() {
return randomString(-1);
}
- /** Replies a randomized string.
+ /** Replies a randomized string with a max length.
+ *
+ * @param maxSize is the max length of the string.
+ * @return a random string with a max length.
*/
protected String randomString(int maxSize) {
Random rnd = new Random();
@@ -528,6 +721,7 @@
/** Assert the the specified method thrown an exception
*
+ * @param message is the error message to put in the assertion.
* @param self is the calling object
* @param method is the name of the method to invoke
* @param types is the parameter types of the method
@@ -556,6 +750,7 @@
/** Assert the the specified method thrown an exception
*
+ * @param message is the error message to put in the assertion.
* @param self is the calling object
* @param method is the name of the method to invoke
*/
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/junit/RepeatableTest.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/junit/RepeatableTest.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/junit/RepeatableTest.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,6 +1,6 @@
/* $Id$
*
- * Copyright (C) 2007 Stéphane GALLAND
+ * Copyright (C) 2007-09 Stéphane GALLAND
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -28,12 +28,30 @@
*/
public interface RepeatableTest extends Test {
+ /**
+ * Set the index of the current test.
+ *
+ * @param index
+ */
public void setLoopIndex(int index);
+ /**
+ * Replies the index of the current test.
+ *
+ * @return the index of the current test.
+ */
public int getLoopIndex();
-
+
+ /** Set the name of the unit test.
+ *
+ * @param name is the name of the unit test.
+ */
public void setName(String name);
+ /** Replies the name of the unit test.
+ *
+ * @return the name of the unit test.
+ */
public String getName();
}
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/SoftValueMapTest.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/SoftValueMapTest.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/SoftValueMapTest.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,3 +1,22 @@
+/* $Id$
+ *
+ * Copyright (C) 2007-09 Stéphane GALLAND
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * This program is free software; you can redistribute it and/or modify
+ */
package org.arakhne.util.ref;
import java.util.HashMap;
@@ -8,6 +27,10 @@
import org.arakhne.junit.AbstractTestCase;
+/**
+* @author Stéphane GALLAND <galland@xxxxxxxxxxx>
+* @version $Name$ $Revision$ $Date$
+*/
public class SoftValueMapTest extends AbstractTestCase {
private static final int REFERENCE_SIZE = 0;
@@ -64,11 +87,15 @@
this.reference.clear();
}
+ /**
+ */
public void testSoftValueMapMap() {
SoftValueMap<String,String> test = new SoftValueMap<String,String>(this.reference);
assertDeepSimilars(this.reference, test);
}
+ /**
+ */
public void testSize() {
SoftValueMap<String,String> test = new SoftValueMap<String,String>();
assertEquals(0, test.size());
@@ -87,6 +114,8 @@
assertTrue(((this.reference.size()-count)<=test.size())||(this.reference.size()>test.size()));
}
+ /**
+ */
public void testIsEmpty() {
SoftValueMap<String,String> test = new SoftValueMap<String,String>();
assertTrue(test.isEmpty());
@@ -108,6 +137,8 @@
assertFalse(test.isEmpty());
}
+ /**
+ */
public void testContainsKey() {
SoftValueMap<String,String> test = new SoftValueMap<String,String>(this.reference);
test.setDeeplyExpurge(true);
@@ -149,6 +180,8 @@
}
}
+ /**
+ */
public void testContainsValue() {
SoftValueMap<String,String> test = new SoftValueMap<String,String>(this.reference);
test.setDeeplyExpurge(true);
@@ -190,6 +223,8 @@
}
}
+ /**
+ */
public void testEntryIterator() {
SoftValueMap<String,String> test = new SoftValueMap<String,String>(this.reference);
test.setDeeplyExpurge(true);
@@ -244,6 +279,8 @@
}
}
+ /**
+ */
public void testKeyIterator() {
SoftValueMap<String,String> test = new SoftValueMap<String,String>(this.reference);
test.setDeeplyExpurge(true);
@@ -290,6 +327,8 @@
}
}
+ /**
+ */
public void testValueIterator() {
SoftValueMap<String,String> test = new SoftValueMap<String,String>(this.reference);
test.setDeeplyExpurge(true);
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakArrayListTest.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakArrayListTest.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakArrayListTest.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,3 +1,22 @@
+/* $Id$
+ *
+ * Copyright (C) 2007-09 Stéphane GALLAND
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * This program is free software; you can redistribute it and/or modify
+ */
package org.arakhne.util.ref;
import java.util.ArrayList;
@@ -7,6 +26,10 @@
import org.arakhne.junit.AbstractTestCase;
+/**
+* @author Stéphane GALLAND <galland@xxxxxxxxxxx>
+* @version $Name$ $Revision$ $Date$
+*/
public class WeakArrayListTest extends AbstractTestCase {
private static final int REFERENCE_SIZE = 0;
@@ -29,12 +52,16 @@
return reference;
}
+ /**
+ */
public void testWeakArrayListCollection() {
List<String> reference = spawnReference();
WeakArrayList<String> test = new WeakArrayList<String>(reference);
assertEquals(reference, test);
}
+ /**
+ */
public void testSize() {
List<String> reference = spawnReference();
@@ -51,6 +78,8 @@
assertEquals(0, test.size());
}
+ /**
+ */
public void testIsEmpty() {
List<String> reference = spawnReference();
@@ -843,6 +872,8 @@
// }
// }
//
+ /**
+ */
public void testHashCode() {
List<String> reference = spawnReference();
WeakArrayList<String> test = new WeakArrayList<String>(reference);
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakValueMapTest.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakValueMapTest.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakValueMapTest.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,3 +1,22 @@
+/* $Id$
+ *
+ * Copyright (C) 2007-09 Stéphane GALLAND
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * This program is free software; you can redistribute it and/or modify
+ */
package org.arakhne.util.ref;
import java.util.HashMap;
@@ -8,6 +27,10 @@
import org.arakhne.junit.AbstractTestCase;
+/**
+* @author Stéphane GALLAND <galland@xxxxxxxxxxx>
+* @version $Name$ $Revision$ $Date$
+*/
public class WeakValueMapTest extends AbstractTestCase {
private static final int REFERENCE_SIZE = 0;
@@ -64,6 +87,8 @@
this.reference.clear();
}
+ /**
+ */
public void testEntryIterator() {
WeakValueMap<String,String> test = new WeakValueMap<String,String>(this.reference);
test.setDeeplyExpurge(true);
@@ -122,11 +147,15 @@
}*/
}
+ /**
+ */
public void testWeakValueMapMap() {
WeakValueMap<String,String> test = new WeakValueMap<String,String>(this.reference);
assertDeepSimilars(this.reference, test);
}
+ /**
+ */
public void testSize() {
WeakValueMap<String,String> test = new WeakValueMap<String,String>();
assertEquals(0, test.size());
@@ -142,6 +171,8 @@
assertEquals(this.reference.size(), test.size());
}
+ /**
+ */
public void testIsEmpty() {
WeakValueMap<String,String> test = new WeakValueMap<String,String>();
assertTrue(test.isEmpty());
@@ -163,6 +194,8 @@
assertTrue(test.isEmpty());
}
+ /**
+ */
public void testContainsKey() {
WeakValueMap<String,String> test = new WeakValueMap<String,String>(this.reference);
test.setDeeplyExpurge(true);
@@ -205,6 +238,8 @@
}
}
+ /**
+ */
public void testContainsValue() {
WeakValueMap<String,String> test = new WeakValueMap<String,String>(this.reference);
test.setDeeplyExpurge(true);
@@ -247,6 +282,8 @@
}
}
+ /**
+ */
public void testKeyIterator() {
WeakValueMap<String,String> test = new WeakValueMap<String,String>(this.reference);
test.setDeeplyExpurge(true);
@@ -299,6 +336,8 @@
}
}
+ /**
+ */
public void testValueIterator() {
WeakValueMap<String,String> test = new WeakValueMap<String,String>(this.reference);
test.setDeeplyExpurge(true);
Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -259,12 +259,13 @@
*/
public static boolean hasExtension(String filename, String extension) {
if (filename==null) return false;
- if (!extension.startsWith(EXTENSION_SEPARATOR)) extension = EXTENSION_SEPARATOR+extension;
+ String extent = extension;
+ if (!extent.startsWith(EXTENSION_SEPARATOR)) extent = EXTENSION_SEPARATOR+extent;
String ext = extension(filename);
if (ext==null) return false;
if (isCaseSensitiveFilenameSystem())
- return ext.equals(extension);
- return ext.equalsIgnoreCase(extension);
+ return ext.equals(extent);
+ return ext.equalsIgnoreCase(extent);
}
/** Replies if the specified file has the specified extension.
@@ -312,13 +313,14 @@
*/
public static String replaceExtension(String filename, String extension) {
if (filename==null) return null;
- if (!extension.startsWith(EXTENSION_SEPARATOR)) extension = EXTENSION_SEPARATOR+extension;
+ String extent = extension;
+ if (!extent.startsWith(EXTENSION_SEPARATOR)) extent = EXTENSION_SEPARATOR+extent;
int idx = filename.lastIndexOf(EXTENSION_SEPARATOR_CHAR);
StringBuffer buf = new StringBuffer();
if (idx<=0) buf.append(filename);
else {
buf.append(filename.substring(0, idx));
- buf.append(extension);
+ buf.append(extent);
}
return buf.toString();
}
Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/LibraryLoader.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/LibraryLoader.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/LibraryLoader.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2004-2008 Stéphane GALLAND
+ * Copyright (C) 2004-2009 Stéphane GALLAND
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -134,13 +134,14 @@
public static URL findLibraryURL(String path, String libName) {
ClassLoader cl = ClassLoaderFinder.findClassLoader();
if (cl==null) cl = LibraryLoader.class.getClassLoader();
- if (path==null) path = ""; //$NON-NLS-1$
- else if ((path.length()>0)&&(!path.endsWith("/"))) { //$NON-NLS-1$
- path += "/"; //$NON-NLS-1$
+ String resourcePath = path;
+ if (resourcePath==null) resourcePath = ""; //$NON-NLS-1$
+ else if ((resourcePath.length()>0)&&(!resourcePath.endsWith("/"))) { //$NON-NLS-1$
+ resourcePath += "/"; //$NON-NLS-1$
}
// Find the 64bits version of the DLL
String realLibName = System.mapLibraryName(libName);
- return cl.getResource(path+realLibName);
+ return cl.getResource(resourcePath+realLibName);
}
/**
Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/ReflectionUtil.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/ReflectionUtil.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/ReflectionUtil.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2004-2008 Stéphane GALLAND
+ * Copyright (C) 2004-2009 Stéphane GALLAND
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -337,7 +337,9 @@
/**
* Replies the list of all the subclasses of the given class
- * in the current classpath..
+ * in the current classpath.
+ *
+ * @param <T> is the type of the superclass.
* @param className is the name of the class to explore.
* @return the list of subclasses.
*/
@@ -349,7 +351,9 @@
/**
* Replies the list of all the subclasses of the given class
- * in the current classpath..
+ * in the current classpath.
+ *
+ * @param <T> is the type of the superclass.
* @param className is the name of the class to explore.
* @param allowAbstract is <code>true</code> to allow abstract classes to be put in the replied list
* @param allowInterface is <code>true</code> to allow interfaces to be put in the replied list.
Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/VMCommandLine.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/VMCommandLine.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/VMCommandLine.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -51,7 +51,7 @@
* @return the binary executable filename.
*/
public static String getExecutableFilename(String name) {
- if (OperatingSystem.WIN.isCurrentOS()) name += ".exe"; //$NON-NLS-1$
+ if (OperatingSystem.WIN.isCurrentOS()) return name+".exe"; //$NON-NLS-1$
return name;
}
@@ -251,6 +251,8 @@
private static boolean registerOptionValue(SortedMap<String,List<Object>> options, String name, Object value, OptionType type) {
boolean success = true;
+ Object optValue = value;
+
List<Object> values = options.get(name);
if (values==null) {
values = new ArrayList<Object>();
@@ -262,13 +264,13 @@
long v;
if (values.isEmpty()) v = -1;
else {
- value = values.get(0);
- if (value==null) v = 0;
- else if (!(value instanceof Number)) {
- v = Long.parseLong(value.toString());
+ optValue = values.get(0);
+ if (optValue==null) v = 0;
+ else if (!(optValue instanceof Number)) {
+ v = Long.parseLong(optValue.toString());
}
else {
- v = ((Number)value).longValue();
+ v = ((Number)optValue).longValue();
}
}
if (values.isEmpty()) values.add(Long.valueOf(v+1));
@@ -276,78 +278,78 @@
}
break;
case FLAG:
- if (value==null) {
+ if (optValue==null) {
if (values.isEmpty())
- value = Boolean.TRUE;
+ optValue = Boolean.TRUE;
else
- value = values.get(0);
+ optValue = values.get(0);
}
- else if (!(value instanceof Boolean)) {
- value = Boolean.parseBoolean(value.toString());
+ else if (!(optValue instanceof Boolean)) {
+ optValue = Boolean.parseBoolean(optValue.toString());
}
- if (values.isEmpty()) values.add(value);
- else values.set(0, value);
+ if (values.isEmpty()) values.add(optValue);
+ else values.set(0, optValue);
break;
case MANDATORY_BOOLEAN:
case OPTIONAL_BOOLEAN:
- if (value==null) {
- value = Boolean.TRUE;
+ if (optValue==null) {
+ optValue = Boolean.TRUE;
}
- else if (!(value instanceof Boolean)) {
- value = Boolean.parseBoolean(value.toString());
+ else if (!(optValue instanceof Boolean)) {
+ optValue = Boolean.parseBoolean(optValue.toString());
}
- values.add(value);
+ values.add(optValue);
break;
case MANDATORY_FLOAT:
case OPTIONAL_FLOAT:
try {
- if (value==null) {
- value = Double.valueOf(0.);
+ if (optValue==null) {
+ optValue = Double.valueOf(0.);
}
- else if (!(value instanceof Number)) {
- value = Double.parseDouble(value.toString());
+ else if (!(optValue instanceof Number)) {
+ optValue = Double.parseDouble(optValue.toString());
}
else {
- value = Double.valueOf(((Number)value).doubleValue());
+ optValue = Double.valueOf(((Number)optValue).doubleValue());
}
}
catch(NumberFormatException e) {
if (type.isOptional()) {
success = false;
- value = Double.valueOf(0.);
+ optValue = Double.valueOf(0.);
}
else throw e;
}
- values.add(value);
+ values.add(optValue);
break;
case MANDATORY_INTEGER:
case OPTIONAL_INTEGER:
try {
- if (value==null) {
- value = Long.valueOf(0);
+ if (optValue==null) {
+ optValue = Long.valueOf(0);
}
- else if (!(value instanceof Number)) {
- value = Long.parseLong(value.toString());
+ else if (!(optValue instanceof Number)) {
+ optValue = Long.parseLong(optValue.toString());
}
else {
- value = Long.valueOf(((Number)value).longValue());
+ optValue = Long.valueOf(((Number)optValue).longValue());
}
}
catch(NumberFormatException e) {
if (type.isOptional()) {
success = false;
- value = Long.valueOf(0);
+ optValue = Long.valueOf(0);
}
else throw e;
}
- values.add(value);
+ values.add(optValue);
break;
case MANDATORY_STRING:
case OPTIONAL_STRING:
- values.add(value==null ? "" : value.toString()); //$NON-NLS-1$
+ values.add(optValue==null ? "" : optValue.toString()); //$NON-NLS-1$
break;
case SIMPLE:
- values.add(value);
+ values.add(optValue);
break;
}
@@ -721,6 +723,8 @@
FLAG;
/** Replies if the value is mandatory.
+ *
+ * @return <code>true</code> if the value is mandatory, otherwise <code>false</code>
*/
public boolean isMandatory() {
return this==MANDATORY_BOOLEAN
@@ -730,6 +734,8 @@
}
/** Replies if the value is optional.
+ *
+ * @return <code>true</code> if the value is not mandatory, otherwise <code>false</code>
*/
public boolean isOptional() {
return this==OPTIONAL_BOOLEAN
@@ -738,12 +744,6 @@
|| this==OPTIONAL_INTEGER;
}
- /** Replies if a value is allowed.
- */
- public boolean hasValue() {
- return this!=SIMPLE && this!=AUTO_INCREMENTED && this!=FLAG;
- }
-
}
}
Modified: trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java
===================================================================
--- trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,3 +1,22 @@
+/* $Id$
+ *
+ * Copyright (C) 2007-09 Stéphane GALLAND
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * This program is free software; you can redistribute it and/or modify
+ */
package org.arakhne.vmutil;
import java.io.File;
@@ -6,66 +25,94 @@
import junit.framework.TestCase;
+/**
+* @author Stéphane GALLAND <galland@xxxxxxxxxxx>
+* @version $Name$ $Revision$ $Date$
+*/
public class FileSystemTest extends TestCase {
private static final File f1 = new File("/home/test.x.z.z"); //$NON-NLS-1$
private static final File f2 = new File("/home"); //$NON-NLS-1$
+ /**
+ */
public void testDirname() {
assertEquals("/home", FileSystem.dirname(f1.getAbsolutePath())); //$NON-NLS-1$
assertEquals("/", FileSystem.dirname(f2.getAbsolutePath())); //$NON-NLS-1$
}
+ /**
+ */
public void testLargeBasenameString() {
assertEquals("test.x.z.z", FileSystem.largeBasename(f1.getAbsolutePath())); //$NON-NLS-1$
assertEquals("home", FileSystem.largeBasename(f2.getAbsolutePath())); //$NON-NLS-1$
}
+ /**
+ */
public void testLargeBasenameFile() {
assertEquals("test.x.z.z", FileSystem.largeBasename(f1)); //$NON-NLS-1$
assertEquals("home", FileSystem.largeBasename(f2)); //$NON-NLS-1$
}
+ /**
+ */
public void testBasenameString() {
assertEquals("test.x.z", FileSystem.basename(f1.getAbsolutePath())); //$NON-NLS-1$
assertEquals("home", FileSystem.basename(f2.getAbsolutePath())); //$NON-NLS-1$
}
+ /**
+ */
public void testBasenameFile() {
assertEquals("test.x.z", FileSystem.basename(f1)); //$NON-NLS-1$
assertEquals("home", FileSystem.basename(f2)); //$NON-NLS-1$
}
+ /**
+ */
public void testShortBasenameString() {
assertEquals("test", FileSystem.shortBasename(f1.getAbsolutePath())); //$NON-NLS-1$
assertEquals("home", FileSystem.shortBasename(f2.getAbsolutePath())); //$NON-NLS-1$
}
+ /**
+ */
public void testShortBasenameFile() {
assertEquals("test", FileSystem.shortBasename(f1)); //$NON-NLS-1$
assertEquals("home", FileSystem.shortBasename(f2)); //$NON-NLS-1$
}
+ /**
+ */
public void testExtensionString() {
assertEquals(".z", FileSystem.extension(f1.getAbsolutePath())); //$NON-NLS-1$
assertEquals("", FileSystem.extension(f2.getAbsolutePath())); //$NON-NLS-1$
}
+ /**
+ */
public void testExtensionFile() {
assertEquals(".z", FileSystem.extension(f1)); //$NON-NLS-1$
assertEquals("", FileSystem.extension(f2)); //$NON-NLS-1$
}
+ /**
+ */
public void testExtensionsString() {
assertTrue(Arrays.equals(new String[]{"x","z","z"}, FileSystem.extensions(f1.getAbsolutePath()))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertTrue(Arrays.equals(new String[0], FileSystem.extensions(f2.getAbsolutePath())));
}
+ /**
+ */
public void testExtensionsFile() {
assertTrue(Arrays.equals(new String[]{"x","z","z"}, FileSystem.extensions(f1))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertTrue(Arrays.equals(new String[0], FileSystem.extensions(f2)));
}
+ /**
+ */
public void testSplitString() {
assertTrue(Arrays.equals(
new String[] {
@@ -82,6 +129,8 @@
FileSystem.split(f2.getAbsolutePath())));
}
+ /**
+ */
public void testSplitFile() {
assertTrue(Arrays.equals(
new String[] {
@@ -98,6 +147,8 @@
FileSystem.split(f2)));
}
+ /**
+ */
public void testJoin() {
assertEquals(f1.getAbsolutePath(),
FileSystem.join(
@@ -106,6 +157,8 @@
"test.x.z.z")); //$NON-NLS-1$
}
+ /**
+ */
public void testHasExtensionStringString() {
/*assertTrue(FileSystem.hasExtension(f1.getAbsolutePath(), ".z")); //$NON-NLS-1$
assertTrue(FileSystem.hasExtension(f1.getAbsolutePath(), "z")); //$NON-NLS-1$
@@ -116,6 +169,8 @@
*/
}
+ /**
+ */
public void testHasExtensionFileString() {
/*assertTrue(FileSystem.hasExtension(f1, ".z")); //$NON-NLS-1$
assertTrue(FileSystem.hasExtension(f1, "z")); //$NON-NLS-1$
@@ -126,26 +181,37 @@
*/
}
+ /**
+ */
public void testRemoveExtensionString() {
assertEquals("/home/test.x.z", FileSystem.removeExtension(f1.getAbsolutePath())); //$NON-NLS-1$
assertEquals("/home", FileSystem.removeExtension(f2.getAbsolutePath())); //$NON-NLS-1$
}
+ /**
+ */
public void testRemoveExtensionFile() {
assertEquals("/home/test.x.z", FileSystem.removeExtension(f1)); //$NON-NLS-1$
assertEquals("/home", FileSystem.removeExtension(f2)); //$NON-NLS-1$
}
+ /**
+ */
public void testReplaceExtensionStringString() {
assertEquals("/home/test.x.z.toto", FileSystem.replaceExtension(f1.getAbsolutePath(), ".toto")); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("/home", FileSystem.replaceExtension(f2.getAbsolutePath(), ".toto")); //$NON-NLS-1$ //$NON-NLS-2$
}
+ /**
+ */
public void testReplaceExtensionFileString() {
assertEquals(new File("/home/test.x.z.toto"), FileSystem.replaceExtension(f1, ".toto")); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(new File("/home"), FileSystem.replaceExtension(f2, ".toto")); //$NON-NLS-1$ //$NON-NLS-2$
}
+ /**
+ * @throws Exception
+ */
public void testConvertStringToUrl() throws Exception {
assertNull(FileSystem.convertStringToUrl(null, true));
assertNull(FileSystem.convertStringToUrl("", true)); //$NON-NLS-1$
@@ -192,6 +258,9 @@
FileSystem.convertStringToUrl("/org/arakhne/vmutil/test.txt", false)); //$NON-NLS-1$
}
+ /**
+ * @throws Exception
+ */
public void testConvertUrlToFile() throws Exception {
assertEquals(f1,
FileSystem.convertUrlToFile(new URL("file:"+f1.getAbsolutePath()))); //$NON-NLS-1$
Modified: trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/VMCommandLineTest.java
===================================================================
--- trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/VMCommandLineTest.java 2009-11-03 14:44:09 UTC (rev 86)
+++ trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/VMCommandLineTest.java 2009-11-23 15:20:35 UTC (rev 87)
@@ -1,3 +1,22 @@
+/* $Id$
+ *
+ * Copyright (C) 2007-09 Stéphane GALLAND
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * This program is free software; you can redistribute it and/or modify
+ */
package org.arakhne.vmutil;
import java.util.Arrays;
@@ -7,6 +26,10 @@
import junit.framework.TestCase;
+/**
+* @author Stéphane GALLAND <galland@xxxxxxxxxxx>
+* @version $Name$ $Revision$ $Date$
+*/
public class VMCommandLineTest extends TestCase {
private static final String[] commandLine = new String[] {
@@ -26,6 +49,8 @@
VMCommandLine.saveVMParameters(null, new String[0]);
}
+ /**
+ */
public final void testSaveVMParameters() {
assertTrue(Arrays.equals(new String[0], VMCommandLine.getCommandLineParameters()));
VMCommandLine.saveVMParameters(VMCommandLineTest.class, commandLine);
@@ -34,6 +59,8 @@
assertTrue(Arrays.equals(commandLine2, VMCommandLine.getCommandLineParameters()));
}
+ /**
+ */
public final void testSaveVMParametersIfNotSet() {
assertTrue(Arrays.equals(new String[0], VMCommandLine.getCommandLineParameters()));
VMCommandLine.saveVMParametersIfNotSet(VMCommandLineTest.class, commandLine);
@@ -42,6 +69,8 @@
assertTrue(Arrays.equals(commandLine, VMCommandLine.getCommandLineParameters()));
}
+ /**
+ */
public final void testShiftCommandLineParameters() {
VMCommandLine.saveVMParameters(VMCommandLineTest.class, commandLine);
assertEquals("-D=true", VMCommandLine.shiftCommandLineParameters()); //$NON-NLS-1$
@@ -53,10 +82,14 @@
VMCommandLine.getCommandLineParameters()));
}
+ /**
+ */
public final void testGetCommandLineOptions() {
assertEquals(Collections.emptyMap(), VMCommandLine.getCommandLineOptions());
}
+ /**
+ */
public final void testSplitOptionsAndParameters() {
VMCommandLine.saveVMParameters(VMCommandLineTest.class, commandLine);
VMCommandLine.splitOptionsAndParameters(optionDefinitions);
@@ -110,6 +143,8 @@
assertEquals("-v", parameters[3]); //$NON-NLS-1$
}
+ /**
+ */
public final void testGetCommandLineOption() {
assertNull(VMCommandLine.getCommandLineOption("S")); //$NON-NLS-1$
@@ -125,6 +160,8 @@
assertNull(VMCommandLine.getCommandLineOption("nob")); //$NON-NLS-1$
}
+ /**
+ */
public final void testHasCommandLineOption() {
assertFalse(VMCommandLine.hasCommandLineOption("S")); //$NON-NLS-1$
@@ -135,11 +172,15 @@
assertFalse(VMCommandLine.hasCommandLineOption("nob")); //$NON-NLS-1$
}
+ /**
+ */
public final void testVMCommandLineClassOfQStringArray() {
VMCommandLine c = new VMCommandLine(VMCommandLineTest.class, commandLine);
assertTrue(Arrays.equals(commandLine, c.getParameters()));
}
+ /**
+ */
public final void testVMCommandLineClassOfQStringArrayStringArray() {
VMCommandLine c = new VMCommandLine(VMCommandLineTest.class, optionDefinitions, commandLine);
assertTrue(Arrays.equals(new String[] {
@@ -147,6 +188,8 @@
}, c.getParameters()));
}
+ /**
+ */
public final void testHasOption() {
VMCommandLine c = new VMCommandLine(VMCommandLineTest.class, optionDefinitions, commandLine);
assertTrue(c.hasOption("S")); //$NON-NLS-1$
@@ -154,6 +197,8 @@
assertFalse(c.hasOption("nob")); //$NON-NLS-1$
}
+ /**
+ */
public final void testGetFirstOptionValue() {
VMCommandLine c = new VMCommandLine(VMCommandLineTest.class, optionDefinitions, commandLine);
assertEquals("-b", c.getFirstOptionValue("S")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -162,6 +207,8 @@
assertNull(c.getFirstOptionValue("nob")); //$NON-NLS-1$
}
+ /**
+ */
public final void testGetOptionValues() {
VMCommandLine c = new VMCommandLine(VMCommandLineTest.class, optionDefinitions, commandLine);
List<Object> values;
@@ -195,6 +242,8 @@
assertNull(c.getOptionValues("nob")); //$NON-NLS-1$
}
+ /**
+ */
public final void testGetParameters() {
VMCommandLine c = new VMCommandLine(VMCommandLineTest.class, optionDefinitions, commandLine);
assertNotSame(commandLine, c.getParameters());
@@ -203,6 +252,8 @@
}, c.getParameters()));
}
+ /**
+ */
public final void testShiftParameters() {
VMCommandLine c = new VMCommandLine(VMCommandLineTest.class, optionDefinitions, commandLine);
assertEquals("clean", c.shiftParameters()); //$NON-NLS-1$
@@ -212,11 +263,15 @@
}, c.getParameters()));
}
+ /**
+ */
public final void testGetParameterCount() {
VMCommandLine c = new VMCommandLine(VMCommandLineTest.class, optionDefinitions, commandLine);
assertEquals(4, c.getParameterCount());
}
+ /**
+ */
public final void testGetParameterAt() {
VMCommandLine c = new VMCommandLine(VMCommandLineTest.class, optionDefinitions, commandLine);
assertEquals("clean", c.getParameterAt(0)); //$NON-NLS-1$
@@ -225,6 +280,8 @@
assertEquals("-v", c.getParameterAt(3)); //$NON-NLS-1$
}
+ /**
+ */
public final void testIsParameterExists() {
VMCommandLine c = new VMCommandLine(VMCommandLineTest.class, optionDefinitions, commandLine);
assertTrue(c.isParameterExists(0));