01: package org.geotools.util;
02:
03: import junit.framework.TestCase;
04:
05: public class BooleanConverterFactoryTest extends TestCase {
06:
07: BooleanConverterFactory factory;
08:
09: protected void setUp() throws Exception {
10: factory = new BooleanConverterFactory();
11: }
12:
13: public void testFromString() throws Exception {
14: assertEquals(Boolean.TRUE, convert("true"));
15: assertEquals(Boolean.TRUE, convert("1"));
16: assertEquals(Boolean.FALSE, convert("false"));
17: assertEquals(Boolean.FALSE, convert("0"));
18:
19: }
20:
21: public void testFromInteger() throws Exception {
22: assertEquals(Boolean.TRUE, convert(new Integer(1)));
23: assertEquals(Boolean.FALSE, convert(new Integer(0)));
24: }
25:
26: Boolean convert(Object value) throws Exception {
27: return (Boolean) factory.createConverter(value.getClass(),
28: Boolean.class, null).convert(value, Boolean.class);
29: }
30: }
|