From 7f7d37421a1861260d90b68745d981fda0aabf6d Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Wed, 30 Jul 2003 23:21:39 +0000 Subject: [PATCH] Bring EnumUtils public constructor testing in line with main package git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137534 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/lang/enum/EnumUtils.java | 6 +++--- .../commons/lang/enum/EnumUtilsTest.java | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/commons/lang/enum/EnumUtils.java b/src/java/org/apache/commons/lang/enum/EnumUtils.java index c974a4ef1..7d5bb1aee 100644 --- a/src/java/org/apache/commons/lang/enum/EnumUtils.java +++ b/src/java/org/apache/commons/lang/enum/EnumUtils.java @@ -64,14 +64,14 @@ import java.util.Map; * @see ValuedEnum * @author Stephen Colebourne * @since 1.0 - * @version $Id: EnumUtils.java,v 1.7 2003/07/14 22:25:04 bayard Exp $ + * @version $Id: EnumUtils.java,v 1.8 2003/07/30 23:21:39 scolebourne Exp $ */ public class EnumUtils { /** - * Restricted constructor. + * Public constructor. This class should not normally be instantiated. */ - private EnumUtils() { + public EnumUtils() { } /** diff --git a/src/test/org/apache/commons/lang/enum/EnumUtilsTest.java b/src/test/org/apache/commons/lang/enum/EnumUtilsTest.java index 2744a4e7f..95c839a12 100644 --- a/src/test/org/apache/commons/lang/enum/EnumUtilsTest.java +++ b/src/test/org/apache/commons/lang/enum/EnumUtilsTest.java @@ -53,6 +53,8 @@ */ package org.apache.commons.lang.enum; +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -65,7 +67,7 @@ import junit.framework.TestSuite; * Test cases for the {@link Enum} class. * * @author Stephen Colebourne - * @version $Id: EnumUtilsTest.java,v 1.4 2003/07/30 23:13:09 scolebourne Exp $ + * @version $Id: EnumUtilsTest.java,v 1.5 2003/07/30 23:21:39 scolebourne Exp $ */ public final class EnumUtilsTest extends TestCase { @@ -83,6 +85,17 @@ public final class EnumUtilsTest extends TestCase { return suite; } + //----------------------------------------------------------------------- + public void testConstructor() { + assertNotNull(new EnumUtils()); + Constructor[] cons = EnumUtils.class.getDeclaredConstructors(); + assertEquals(1, cons.length); + assertEquals(true, Modifier.isPublic(cons[0].getModifiers())); + assertEquals(true, Modifier.isPublic(EnumUtils.class.getModifiers())); + assertEquals(false, Modifier.isFinal(EnumUtils.class.getModifiers())); + } + + //----------------------------------------------------------------------- public void testIterator() { Iterator it = EnumUtils.iterator(ColorEnum.class); assertSame(ColorEnum.RED, it.next()); @@ -103,6 +116,7 @@ public final class EnumUtilsTest extends TestCase { } catch (IllegalArgumentException ex) {} } + //----------------------------------------------------------------------- public void testList() { List list = EnumUtils.getEnumList(ColorEnum.class); Iterator it = list.iterator(); @@ -124,6 +138,7 @@ public final class EnumUtilsTest extends TestCase { } catch (IllegalArgumentException ex) {} } + //----------------------------------------------------------------------- public void testMap() { Map map = EnumUtils.getEnumMap(ColorEnum.class); assertTrue(map.containsValue(ColorEnum.RED)); @@ -147,6 +162,7 @@ public final class EnumUtilsTest extends TestCase { } catch (IllegalArgumentException ex) {} } + //----------------------------------------------------------------------- public void testGet() { assertSame(ColorEnum.RED, EnumUtils.getEnum(ColorEnum.class, "Red")); assertSame(ColorEnum.GREEN, EnumUtils.getEnum(ColorEnum.class, "Green")); @@ -166,6 +182,7 @@ public final class EnumUtilsTest extends TestCase { } catch (IllegalArgumentException ex) {} } + //----------------------------------------------------------------------- public void testGetValue() { assertSame(ValuedColorEnum.RED, EnumUtils.getEnum(ValuedColorEnum.class, 1)); assertSame(ValuedColorEnum.GREEN, EnumUtils.getEnum(ValuedColorEnum.class, 2));