Revision 3319 org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.lib/org.gvsig.vcsgis.lib.impl/src/test/java/org/gvsig/vcsgis/lib/impl/Test06AddCommit.java
Test06AddCommit.java | ||
---|---|---|
1 | 1 |
package org.gvsig.vcsgis.lib.impl; |
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
4 | 6 |
import junit.framework.TestCase; |
5 | 7 |
import static junit.framework.TestCase.assertEquals; |
6 | 8 |
import org.apache.commons.io.FileUtils; |
... | ... | |
8 | 10 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
9 | 11 |
import org.gvsig.tools.dispose.DisposeUtils; |
10 | 12 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
13 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
11 | 14 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
12 | 15 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
13 | 16 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_OK; |
... | ... | |
90 | 93 |
sourceStore.dispose(); |
91 | 94 |
DisposeUtils.disposeQuietly(dataStore); |
92 | 95 |
} |
96 |
|
|
97 |
public void testAddCommitSelectedTable() throws Exception { |
|
98 |
final String testid = "LocaldbAddCommit"; |
|
99 |
|
|
100 |
VCSGisManager manager = VCSGisLocator.getVCSGisManager(); |
|
101 |
JDBCServerExplorer server = TestUtils.openServerExplorer("srv-"+testid); |
|
102 |
File wsfile = TestUtils.getFile(FileUtils.getFile("test-dbs","ws-"+testid)); |
|
103 |
|
|
104 |
// --------------------------------------------------------- |
|
105 |
// Creamos el respositorio y lo abrimos. |
|
106 |
int r = manager.initRepository(server.getParameters(), null); |
|
107 |
assertEquals("srv-init status", 0, r); |
|
108 |
|
|
109 |
VCSGisRepository repo = manager.openRepository(server.getParameters()); |
|
110 |
TestUtils.h2sql_repository(repo); |
|
111 |
|
|
112 |
|
|
113 |
// --------------------------------------------------------- |
|
114 |
// Creamos un workspace y lo abrimos. |
|
115 |
r = manager.initWorkspace(wsfile, repo, "Test add and commit",null); |
|
116 |
assertEquals("ws-init status", 0, r); |
|
117 |
|
|
118 |
VCSGisWorkspace ws = manager.openWorkspace(wsfile); |
|
119 |
TestUtils.h2sql_workspace(ws); |
|
120 |
|
|
121 |
// --------------------------------------------------------- |
|
122 |
// Adicionamos al workspace la tabla de pruebas1 |
|
123 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
124 |
r = ws.add("sourceStore1", sourceStore, "ID"); |
|
125 |
assertEquals("ws-add status", 0, r); |
|
126 |
|
|
127 |
// Adicionamos al workspace la tabla de pruebas2 |
|
128 |
FeatureStore sourceStore2 = TestUtils.openSourceStore2(); |
|
129 |
r = ws.add("sourceStore2", sourceStore2, "id"); |
|
130 |
assertEquals("ws-add status", 0, r); |
|
131 |
|
|
132 |
List<String> selectedTables = new ArrayList<>(); |
|
133 |
VCSGisEntity entity = ws.getEntity("sourceStore1"); |
|
134 |
selectedTables.add(entity.getEntityCode()); |
|
135 |
r = ws.commit(selectedTables, null, null, null, null); |
|
136 |
assertEquals("ws-commit status", ERR_OK, r); |
|
137 |
|
|
138 |
// --------------------------------------------------------- |
|
139 |
// Comprobamos que tras el commit en la tabla de cambios permanenecen los cambios de la tabla no seleccionada |
|
140 |
FeatureStore changesStore = ws.getFeatureStore(WorkspaceChangesTable.TABLE_NAME); |
|
141 |
assertEquals("Changes", 4, changesStore.size64()); // 3 insert and 1 add_entity |
|
142 |
|
|
143 |
DisposeUtils.disposeQuietly(changesStore); |
|
144 |
|
|
145 |
// --------------------------------------------------------- |
|
146 |
// Comprobamos que la tabla adicionada al espacio ed trabajo contiene |
|
147 |
// los mismos registros que la original. |
|
148 |
FeatureStore dataStore = ((VCSGisRepositoryLocaldb)repo).getFeatureStore(DataRepoTable.TABLE_NAME); |
|
149 |
assertEquals("DataStore", sourceStore.size64(), dataStore.size64()); |
|
150 |
|
|
151 |
sourceStore.dispose(); |
|
152 |
DisposeUtils.disposeQuietly(dataStore); |
|
153 |
} |
|
93 | 154 |
} |
Also available in: Unified diff