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