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 / TestTableIsEmpty.java @ 45649
History | View | Annotate | Download (2.07 KB)
1 |
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.TableIsEmptyOperation; |
13 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
14 |
import org.slf4j.Logger; |
15 |
import org.slf4j.LoggerFactory; |
16 |
|
17 |
public class TestTableIsEmpty extends TestCase { |
18 |
|
19 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestTableIsEmpty.class); |
20 |
|
21 |
public TestTableIsEmpty(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 testTableIsEmpty() throws Exception { |
40 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
41 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
42 |
OperationsFactory operations = helper.getOperations(); |
43 |
|
44 |
List<String> expectedSQLs = TestUtils.getSQLs("tableIsEmpty.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 |
TableIsEmptyOperation tableIsEmpty = operations.createTableIsEmpty( |
56 |
featureType, |
57 |
table, |
58 |
null,
|
59 |
null
|
60 |
); |
61 |
|
62 |
String sql = tableIsEmpty.getSQL();
|
63 |
assertEquals("TableIsEmpty SQL", expectedSQLs.get(0), sql); |
64 |
} |
65 |
|
66 |
} |