svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.h2spatial / org.gvsig.h2spatial.h2gis132 / org.gvsig.h2spatial.h2gis132.provider / src / test / java / org / gvsig / fmap / dal / store / h2 / operations / sql / TestCreateTable.java @ 45649
History | View | Annotate | Download (2.2 KB)
1 | 45472 | jjdelcerro | package org.gvsig.fmap.dal.store.h2.operations.sql; |
---|---|---|---|
2 | |||
3 | import java.util.List; |
||
4 | import junit.framework.TestCase; |
||
5 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
6 | import org.gvsig.fmap.dal.feature.FeatureType; |
||
7 | import org.gvsig.fmap.dal.store.h2.TestUtils; |
||
8 | import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
||
9 | import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
||
10 | import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
||
11 | import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
||
12 | import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CreateTableOperation; |
||
13 | import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
||
14 | import org.slf4j.Logger; |
||
15 | import org.slf4j.LoggerFactory; |
||
16 | |||
17 | public class TestCreateTable extends TestCase { |
||
18 | |||
19 | private static final Logger LOGGER = LoggerFactory.getLogger(TestCreateTable.class); |
||
20 | |||
21 | public TestCreateTable(String testName) { |
||
22 | super(testName);
|
||
23 | } |
||
24 | |||
25 | @Override
|
||
26 | protected void setUp() throws Exception { |
||
27 | super.setUp();
|
||
28 | new DefaultLibrariesInitializer().fullInitialize();
|
||
29 | } |
||
30 | |||
31 | @Override
|
||
32 | protected void tearDown() throws Exception { |
||
33 | super.tearDown();
|
||
34 | } |
||
35 | |||
36 | // TODO add test methods here. The name must begin with 'test'. For example:
|
||
37 | // public void testHello() {}
|
||
38 | |||
39 | public void testCreateTable() throws Exception { |
||
40 | 45649 | jjdelcerro | JDBCHelper helper = TestUtils.createJDBCHelper(); |
41 | 45472 | jjdelcerro | JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
42 | OperationsFactory operations = helper.getOperations(); |
||
43 | |||
44 | List<String> expectedSQLs = TestUtils.getSQLs("createTable.sql"); |
||
45 | |||
46 | FeatureStore sourceStore = TestUtils.openSourceStore1(); |
||
47 | |||
48 | TableReference table = operations.createTableReference( |
||
49 | "dbtest",
|
||
50 | sqlbuilder.default_schema(), |
||
51 | "test",
|
||
52 | null
|
||
53 | ); |
||
54 | FeatureType featureType = sourceStore.getDefaultFeatureType(); |
||
55 | CreateTableOperation createTable = operations.createTable( |
||
56 | table, |
||
57 | featureType, |
||
58 | null,
|
||
59 | null
|
||
60 | ); |
||
61 | List<String> SQLs = createTable.getSQLs(); |
||
62 | assertEquals("CreateTable num. SQLs", expectedSQLs.size(), SQLs.size());
|
||
63 | for (int i = 0; i < expectedSQLs.size(); i++) { |
||
64 | assertEquals("CreateTable SQL "+i, expectedSQLs.get(i), SQLs.get(i));
|
||
65 | } |
||
66 | |||
67 | } |
||
68 | |||
69 | } |