01: package jaxx.junit;
02:
03: import java.awt.*;
04: import junit.framework.TestCase;
05:
06: import jaxx.types.*;
07:
08: public class InsetsConverterTest extends TestCase {
09: private InsetsConverter converter;
10:
11: public void setUp() {
12: converter = new InsetsConverter();
13: }
14:
15: public void testSingleValue() {
16: Insets value = (Insets) converter.convertFromString("3",
17: Insets.class);
18: assertEquals(value, new Insets(3, 3, 3, 3));
19: }
20:
21: public void testFourValues() {
22: Insets value = (Insets) converter.convertFromString(
23: "3, 0, 12, 1000000", Insets.class);
24: assertEquals(value, new Insets(3, 0, 12, 1000000));
25: }
26:
27: public void testTwoValues() {
28: try {
29: Insets value = (Insets) converter.convertFromString("0, 4",
30: Insets.class);
31: fail("Expected IllegalArgumentException");
32: } catch (IllegalArgumentException e) {
33: }
34: }
35:
36: public void testThreeValues() {
37: try {
38: Insets value = (Insets) converter.convertFromString(
39: "0, 4, 9", Insets.class);
40: fail("Expected IllegalArgumentException");
41: } catch (IllegalArgumentException e) {
42: }
43: }
44:
45: public void testInvalidNumber() {
46: try {
47: Insets value = (Insets) converter.convertFromString(
48: "0, 4, 9, A", Insets.class);
49: fail("Expected IllegalArgumentException");
50: } catch (IllegalArgumentException e) {
51: }
52: }
53:
54: public void testBadFormatting() {
55: try {
56: Insets value = (Insets) converter.convertFromString(
57: "0 - 1 - 2 - 3", Insets.class);
58: fail("Expected IllegalArgumentException");
59: } catch (IllegalArgumentException e) {
60: }
61: }
62: }
|