01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: TestClassUtils.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.tools;
09:
10: import com.uwyn.rife.tools.ClassUtils;
11: import java.math.BigDecimal;
12: import java.math.BigInteger;
13: import java.util.Date;
14: import junit.framework.TestCase;
15:
16: public class TestClassUtils extends TestCase {
17: public TestClassUtils(String name) {
18: super (name);
19: }
20:
21: public void testIsNumeric() {
22: assertTrue(ClassUtils.isNumeric(Byte.class));
23: assertTrue(ClassUtils.isNumeric(Short.class));
24: assertTrue(ClassUtils.isNumeric(Integer.class));
25: assertTrue(ClassUtils.isNumeric(Long.class));
26: assertTrue(ClassUtils.isNumeric(Float.class));
27: assertTrue(ClassUtils.isNumeric(Double.class));
28: assertTrue(ClassUtils.isNumeric(BigDecimal.class));
29: assertTrue(ClassUtils.isNumeric(BigInteger.class));
30: assertTrue(ClassUtils.isNumeric(byte.class));
31: assertTrue(ClassUtils.isNumeric(short.class));
32: assertTrue(ClassUtils.isNumeric(int.class));
33: assertTrue(ClassUtils.isNumeric(long.class));
34: assertTrue(ClassUtils.isNumeric(float.class));
35: assertTrue(ClassUtils.isNumeric(double.class));
36: assertFalse(ClassUtils.isNumeric(Character.class));
37: assertFalse(ClassUtils.isNumeric(String.class));
38: assertFalse(ClassUtils.isNumeric(StringBuffer.class));
39: assertFalse(ClassUtils.isNumeric(char.class));
40: assertFalse(ClassUtils.isNumeric(Date.class));
41: }
42:
43: public void testIsText() {
44: assertFalse(ClassUtils.isText(Byte.class));
45: assertFalse(ClassUtils.isText(Short.class));
46: assertFalse(ClassUtils.isText(Integer.class));
47: assertFalse(ClassUtils.isText(Long.class));
48: assertFalse(ClassUtils.isText(Float.class));
49: assertFalse(ClassUtils.isText(Double.class));
50: assertFalse(ClassUtils.isText(BigDecimal.class));
51: assertFalse(ClassUtils.isText(BigInteger.class));
52: assertFalse(ClassUtils.isText(byte.class));
53: assertFalse(ClassUtils.isText(short.class));
54: assertFalse(ClassUtils.isText(int.class));
55: assertFalse(ClassUtils.isText(long.class));
56: assertFalse(ClassUtils.isText(float.class));
57: assertFalse(ClassUtils.isText(double.class));
58: assertTrue(ClassUtils.isText(Character.class));
59: assertTrue(ClassUtils.isText(String.class));
60: assertTrue(ClassUtils.isText(StringBuffer.class));
61: assertTrue(ClassUtils.isText(char.class));
62: assertFalse(ClassUtils.isText(Date.class));
63: }
64: }
65:
66: interface Interface1 {
67: }
68:
69: interface Interface2 extends Interface1 {
70: }
71:
72: class Parent implements Interface1 {
73: }
74:
75: class Child1 extends Parent {
76: }
77:
78: class Child2 extends Child1 implements Interface2, Interface1 {
79: }
80:
81: class Child3 extends Parent {
82: }
83:
84: class Child4 extends Object {
85: }
|