01: package jaxx.junit;
02:
03: import java.awt.*;
04: import junit.framework.TestCase;
05:
06: import jaxx.types.*;
07:
08: public class ColorConverterTest extends TestCase {
09: private ColorConverter converter;
10:
11: public void setUp() {
12: converter = new ColorConverter();
13: }
14:
15: public void testHexValue() {
16: Color value = (Color) converter.convertFromString("#3000FF",
17: Color.class);
18: assertEquals(value, new Color(48, 0, 255));
19: }
20:
21: public void testUpperCaseConstant() {
22: Color value = (Color) converter.convertFromString("RED",
23: Color.class);
24: assertEquals(value, Color.RED);
25: }
26:
27: public void testLowerCaseConstant() {
28: Color value = (Color) converter.convertFromString("blue",
29: Color.class);
30: assertEquals(value, Color.blue);
31: }
32:
33: public void testMissingHash() {
34: try {
35: Color value = (Color) converter.convertFromString("ABCDEF",
36: Color.class);
37: fail("Expected IllegalArgumentException");
38: } catch (IllegalArgumentException e) {
39: }
40: }
41:
42: public void testInvalidNumber() {
43: try {
44: Color value = (Color) converter.convertFromString(
45: "#ABCDEG", Color.class);
46: fail("Expected IllegalArgumentException");
47: } catch (IllegalArgumentException e) {
48: }
49: }
50:
51: public void testInvalidConstant() {
52: try {
53: Color value = (Color) converter.convertFromString("rEd",
54: Color.class);
55: fail("Expected IllegalArgumentException");
56: } catch (IllegalArgumentException e) {
57: }
58: }
59: }
|