gvsig-projects-pool / org.gvsig.vcsgis / trunk / org.gvsig.vcsgis / org.gvsig.vcsgis.lib / org.gvsig.vcsgis.lib.impl / src / test / java / org / gvsig / vcsgis / lib / impl / Test04AddEntity.java @ 2742
History | View | Annotate | Download (2.28 KB)
1 |
package org.gvsig.vcsgis.lib.impl; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import junit.framework.TestCase; |
5 |
import static junit.framework.TestCase.assertEquals; |
6 |
import org.apache.commons.io.FileUtils; |
7 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
8 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
9 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
10 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
11 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
12 |
import org.gvsig.vcsgis.lib.repository.VCSGisRepository; |
13 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
14 |
import org.slf4j.Logger; |
15 |
import org.slf4j.LoggerFactory; |
16 |
|
17 |
public class Test04AddEntity extends TestCase { |
18 |
|
19 |
private static final Logger LOGGER = LoggerFactory.getLogger(Test04AddEntity.class); |
20 |
|
21 |
public Test04AddEntity(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 testAdd_entity1() throws Exception { |
40 |
VCSGisManager manager = VCSGisLocator.getVCSGisManager(); |
41 |
JDBCServerExplorer server = TestUtils.openServerExplorer("srv-adde");
|
42 |
File wsfile = TestUtils.getFile(FileUtils.getFile("test-dbs","ws-adde")); |
43 |
|
44 |
int r = manager.initRepository(server.getParameters(), null); |
45 |
assertEquals("srv-init status", 0, r); |
46 |
|
47 |
VCSGisRepository repo = manager.openRepository(server.getParameters()); |
48 |
TestUtils.h2sql_repository(repo); |
49 |
|
50 |
r = manager.initWorkspace(wsfile, repo, "Test add entity", null); |
51 |
assertEquals("ws-init status", 0, r); |
52 |
|
53 |
VCSGisWorkspace ws = manager.openWorkspace(wsfile); |
54 |
TestUtils.h2sql_workspace(ws); |
55 |
|
56 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
57 |
r = ws.addEntity(sourceStore.getDefaultFeatureType(), "sourceStore1", null, "ID"); |
58 |
assertEquals("ws-add-entity status", 0, r); |
59 |
|
60 |
FeatureStore store = ws.getFeatureStore("sourceStore1");
|
61 |
assertNotNull("added store is null",store);
|
62 |
|
63 |
store.dispose(); |
64 |
|
65 |
} |
66 |
} |