01: package org.geotools.data.jdbc.fidmapper;
02:
03: import java.io.IOException;
04: import java.math.BigInteger;
05: import java.sql.Types;
06:
07: import junit.framework.TestCase;
08:
09: public class AutoIncrementFIDMapperTest extends TestCase {
10:
11: /**
12: * A weak test to make sure that AutoIncrementFIDMapper supports multiple
13: * (common) data types for its primary key column.
14: */
15: public void testGetPKAttributes() throws IOException {
16: AutoIncrementFIDMapper mapper = new AutoIncrementFIDMapper(
17: "column_1", Types.INTEGER);
18: Object[] attr = mapper.getPKAttributes("12345");
19: assertEquals(Integer.class, attr[0].getClass());
20:
21: mapper = new AutoIncrementFIDMapper("column_2", Types.BIGINT);
22: attr = mapper.getPKAttributes("1234567");
23: assertEquals(BigInteger.class, attr[0].getClass());
24:
25: mapper = new AutoIncrementFIDMapper("column_3", Types.SMALLINT);
26: attr = mapper.getPKAttributes("123");
27: assertEquals(Integer.class, attr[0].getClass());
28:
29: mapper = new AutoIncrementFIDMapper("column_4", Types.TINYINT);
30: attr = mapper.getPKAttributes("1");
31: assertEquals(Integer.class, attr[0].getClass());
32:
33: mapper = new AutoIncrementFIDMapper("column_5", Types.VARCHAR);
34: attr = mapper.getPKAttributes("UNIQUE_FID");
35: assertEquals(String.class, attr[0].getClass());
36: }
37:
38: }
|