X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Ftest%2FAssertionUtils.java;h=e6e0b155c72650cc06b3d42bc913d44f66ee77fa;hb=e84a037d2ee2d2d2e8d991128f83978f2e98201c;hp=c0387e0cf8b4e92d43b8a593c0e7a5eae304e3a0;hpb=17775e14ecfb286e59f67117e5cee7e21e95ab1f;p=utils diff --git a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java index c0387e0c..e6e0b155 100644 --- a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java +++ b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java @@ -12,18 +12,16 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test; -import junit.framework.TestCase; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import java.util.Arrays; -import java.util.Iterator; import java.util.Map; import java.util.Set; +import java.util.Map.Entry; +import java.util.logging.Logger; + +import junit.framework.TestCase; /** * Useful assertions for use in test cases. @@ -31,7 +29,8 @@ import java.util.Set; * @author Erik Brakkee */ public final class AssertionUtils { - private static final Log LOG = LogFactory.getLog(AssertionUtils.class); + private static final Logger LOG = Logger.getLogger(AssertionUtils.class + .getName()); /** * Disabled constructor. @@ -76,7 +75,7 @@ public final class AssertionUtils { /** * Asserts that two objects are equal, and in case the object is an Object[] - * delegates to {@link #assertEquals(String, Object[], Object[]). + * delegates to {@link #assertEquals(String, Object[], Object[])}. * * @param aMsg * Message. @@ -112,21 +111,21 @@ public final class AssertionUtils { TestCase.assertEquals("Map sizes differ", aExpectedMap.size(), aActual .size()); - Set keys = aExpectedMap.keySet(); + Set> expectedEntries = aExpectedMap.entrySet(); - for (Iterator i = keys.iterator(); i.hasNext();) { - String key = (String) i.next(); + for (Entry entry : expectedEntries) { + Key key = entry.getKey(); TestCase.assertTrue("Map does not containg entry for key:" + key, aActual.containsKey(key)); AssertionUtils.assertEquals("Value of key " + key + " of map", - aExpectedMap.get(key), aActual.get(key)); + entry.getValue(), aActual.get(key)); } } /** * Asserts that an exception occurs. * - * @param aRunnable + * @param aObject Erroneious code. * Test cases should create a subclass of this which contains the * code that should throw an exception. * @param aType @@ -141,9 +140,8 @@ public final class AssertionUtils { LOG.info("Expected exception occured " + t.getMessage()); return; // ok - } else { - throw new RuntimeException(t); } + throw new RuntimeException(t); } }