From 035055e82695260d05c07cdb6cc4d2a5a04efc68 Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Fri, 1 Aug 2003 00:12:32 +0000 Subject: [PATCH] Extra tests suggested by Clover git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137547 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/lang/time/DateFormatUtilsTest.java | 13 +++++++++++++ .../apache/commons/lang/time/DateUtilsTest.java | 14 ++++++++++++-- .../lang/time/DurationFormatUtilsTest.java | 13 +++++++++++++ .../apache/commons/lang/time/StopWatchTest.java | 15 ++++++++++++--- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/test/org/apache/commons/lang/time/DateFormatUtilsTest.java b/src/test/org/apache/commons/lang/time/DateFormatUtilsTest.java index bd83416fa..04e902e02 100644 --- a/src/test/org/apache/commons/lang/time/DateFormatUtilsTest.java +++ b/src/test/org/apache/commons/lang/time/DateFormatUtilsTest.java @@ -53,6 +53,8 @@ */ package org.apache.commons.lang.time; +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; import java.util.Calendar; import java.util.TimeZone; @@ -85,6 +87,17 @@ public DateFormatUtilsTest(String s) { super(s); } + //----------------------------------------------------------------------- + public void testConstructor() { + assertNotNull(new DateFormatUtils()); + Constructor[] cons = DateFormatUtils.class.getDeclaredConstructors(); + assertEquals(1, cons.length); + assertEquals(true, Modifier.isPublic(cons[0].getModifiers())); + assertEquals(true, Modifier.isPublic(DateFormatUtils.class.getModifiers())); + assertEquals(false, Modifier.isFinal(DateFormatUtils.class.getModifiers())); + } + + //----------------------------------------------------------------------- public void testDateTimeISO(){ TimeZone timeZone = TimeZone.getTimeZone("GMT-3"); Calendar cal = Calendar.getInstance(timeZone); diff --git a/src/test/org/apache/commons/lang/time/DateUtilsTest.java b/src/test/org/apache/commons/lang/time/DateUtilsTest.java index f13da0e2b..56718e2e9 100644 --- a/src/test/org/apache/commons/lang/time/DateUtilsTest.java +++ b/src/test/org/apache/commons/lang/time/DateUtilsTest.java @@ -53,6 +53,8 @@ */ package org.apache.commons.lang.time; +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; @@ -105,8 +107,16 @@ protected void tearDown() throws Exception { } //----------------------------------------------------------------------- - - + public void testConstructor() { + assertNotNull(new DateUtils()); + Constructor[] cons = DateUtils.class.getDeclaredConstructors(); + assertEquals(1, cons.length); + assertEquals(true, Modifier.isPublic(cons[0].getModifiers())); + assertEquals(true, Modifier.isPublic(DateUtils.class.getModifiers())); + assertEquals(false, Modifier.isFinal(DateUtils.class.getModifiers())); + } + + //----------------------------------------------------------------------- /** * Tests various values with the round method */ diff --git a/src/test/org/apache/commons/lang/time/DurationFormatUtilsTest.java b/src/test/org/apache/commons/lang/time/DurationFormatUtilsTest.java index 5cb74fb0d..f082d5a5b 100644 --- a/src/test/org/apache/commons/lang/time/DurationFormatUtilsTest.java +++ b/src/test/org/apache/commons/lang/time/DurationFormatUtilsTest.java @@ -53,6 +53,8 @@ */ package org.apache.commons.lang.time; +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; import java.util.Calendar; import java.util.TimeZone; @@ -86,6 +88,17 @@ public DurationFormatUtilsTest(String s) { super(s); } + //----------------------------------------------------------------------- + public void testConstructor() { + assertNotNull(new DurationFormatUtils()); + Constructor[] cons = DurationFormatUtils.class.getDeclaredConstructors(); + assertEquals(1, cons.length); + assertEquals(true, Modifier.isPublic(cons[0].getModifiers())); + assertEquals(false, Modifier.isPublic(DurationFormatUtils.class.getModifiers())); + assertEquals(false, Modifier.isFinal(DurationFormatUtils.class.getModifiers())); + } + + //----------------------------------------------------------------------- public void testFormatWords(){ String text = null; diff --git a/src/test/org/apache/commons/lang/time/StopWatchTest.java b/src/test/org/apache/commons/lang/time/StopWatchTest.java index 4726109b1..cdd2c84f1 100644 --- a/src/test/org/apache/commons/lang/time/StopWatchTest.java +++ b/src/test/org/apache/commons/lang/time/StopWatchTest.java @@ -62,7 +62,7 @@ * TestCase for StopWatch. * * @author Stephen Colebourne - * @version $Id: StopWatchTest.java,v 1.4 2003/06/24 21:13:55 scolebourne Exp $ + * @version $Id: StopWatchTest.java,v 1.5 2003/08/01 00:12:32 scolebourne Exp $ */ public class StopWatchTest extends TestCase { @@ -80,10 +80,9 @@ public StopWatchTest(String s) { super(s); } + //----------------------------------------------------------------------- public void testStopWatchSimple(){ StopWatch watch = new StopWatch(); - assertEquals(0, watch.getTime()); - watch.start(); try {Thread.sleep(550);} catch (InterruptedException ex) {} watch.stop(); @@ -97,6 +96,16 @@ public void testStopWatchSimple(){ assertEquals(0, watch.getTime()); } + public void testStopWatchSimpleGet(){ + StopWatch watch = new StopWatch(); + assertEquals(0, watch.getTime()); + assertEquals("0:00:00.000", watch.toString()); + + watch.start(); + try {Thread.sleep(500);} catch (InterruptedException ex) {} + assertTrue(watch.getTime() < 2000); + } + public void testStopWatchSplit(){ StopWatch watch = new StopWatch(); watch.start();