1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.commons.converter;
20
21 import javax.faces.component.UIInput;
22 import javax.faces.convert.ConverterException;
23
24 import junit.framework.Test;
25 import junit.framework.TestSuite;
26
27 import org.apache.myfaces.test.base.AbstractJsfTestCase;
28
29
30
31
32
33 public class BooleanConverterTest extends AbstractJsfTestCase
34 {
35
36 private BooleanConverter converter;
37
38 public BooleanConverterTest(String testName)
39 {
40 super(testName);
41 }
42
43 public void setUp() throws Exception
44 {
45 super.setUp();
46 converter = new BooleanConverter();
47 }
48
49 public void tearDown() throws Exception
50 {
51 super.tearDown();
52 converter = null;
53 }
54
55 public static Test suite()
56 {
57 return new TestSuite(BooleanConverterTest.class);
58 }
59
60 public void testConverterFalse()
61 {
62 UIInput input = new UIInput();
63 input.setId("txt_test");
64
65 converter.setTrueValue("verdadero");
66 converter.setFalseValue("falso");
67
68 try
69 {
70
71 Object value = converter.getAsObject(facesContext, input, "test_invalid_input");
72 assertEquals("falso", converter.getAsString(facesContext, input, value));
73 }
74 catch (ConverterException exception)
75 {
76 fail();
77 }
78 }
79
80 public void testConverterTrueValue()
81 {
82 UIInput input = new UIInput();
83 input.setId("txt_test");
84
85 converter.setTrueValue("verdadero");
86 converter.setFalseValue("falso");
87
88 try
89 {
90 Object value = converter.getAsObject(facesContext, input, "verdadero");
91 assertEquals("verdadero", converter.getAsString(facesContext, input, value));
92 }
93 catch (ConverterException exception)
94 {
95 fail();
96 }
97 }
98 }