gvsig-projects-pool / org.gvsig.vcsgis / trunk / org.gvsig.vcsgis / org.gvsig.vcsgis.lib / org.gvsig.vcsgis.lib.impl / src / test / java / org / gvsig / cvsgis / lib / impl / TestAddCommit.java @ 2381
History | View | Annotate | Download (2.45 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.vcsgis.client.tables.ChangesTable; |
8 |
import org.gvsig.vcsgis.lib.vcsgis; |
9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
10 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
11 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
12 |
import org.slf4j.Logger; |
13 |
import org.slf4j.LoggerFactory; |
14 |
import org.gvsig.vcsgis.lib.vcsgisadmin; |
15 |
import org.gvsig.tools.dispose.DisposeUtils; |
16 |
import org.gvsig.vcsgis.client.VCSGisWorkspaceEx; |
17 |
import org.gvsig.vcsgis.lib.VCSGisRepository; |
18 |
|
19 |
public class TestAddCommit extends TestCase { |
20 |
|
21 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestAddCommit.class); |
22 |
|
23 |
// public static final String DBNAME = "testInitws";
|
24 |
|
25 |
public TestAddCommit(String testName) { |
26 |
super(testName);
|
27 |
} |
28 |
|
29 |
@Override
|
30 |
protected void setUp() throws Exception { |
31 |
super.setUp();
|
32 |
new DefaultLibrariesInitializer().fullInitialize();
|
33 |
} |
34 |
|
35 |
@Override
|
36 |
protected void tearDown() throws Exception { |
37 |
super.tearDown();
|
38 |
} |
39 |
|
40 |
// TODO add test methods here. The name must begin with 'test'. For example:
|
41 |
// public void testHello() {}
|
42 |
|
43 |
public void testAddCommit() throws Exception { |
44 |
JDBCServerExplorer server = TestUtils.openServerExplorer("srv-addco");
|
45 |
File wsfile = TestUtils.getFile(FileUtils.getFile("test-dbs","ws-addco")); |
46 |
|
47 |
int r = vcsgisadmin.init(server);
|
48 |
assertEquals("srv-init status", 0, r); |
49 |
|
50 |
VCSGisRepository repo = vcsgisadmin.open_repository(server); |
51 |
TestUtils.h2sql_repository(repo); |
52 |
|
53 |
|
54 |
r = vcsgis.init_workspace(wsfile, repo, "Test add and commit");
|
55 |
assertEquals("ws-init status", 0, r); |
56 |
|
57 |
VCSGisWorkspaceEx ws = (VCSGisWorkspaceEx) vcsgis.open_workspace(wsfile); |
58 |
TestUtils.h2sql_workspace(ws); |
59 |
|
60 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
61 |
r = ws.add("sourceStore1", sourceStore, null, null, true); |
62 |
assertEquals("ws-add status", 0, r); |
63 |
sourceStore.dispose(); |
64 |
|
65 |
r = ws.commit(); |
66 |
assertEquals("ws-commit status", 0, r); |
67 |
|
68 |
FeatureStore changesStore = ws.getFeatureStore(ChangesTable.TABLE_NAME); |
69 |
assertEquals("Changes", 0, changesStore.size64()); |
70 |
|
71 |
DisposeUtils.disposeQuietly(changesStore); |
72 |
} |
73 |
} |