Revision 3454 org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.server/org.gvsig.vcsgis.server.lib/src/test/java/org/gvsig/vcsgis/server/lib/TestSrv03Checkout.java
TestSrv03Checkout.java | ||
---|---|---|
7 | 7 |
import static junit.framework.TestCase.assertEquals; |
8 | 8 |
import org.apache.commons.io.FileUtils; |
9 | 9 |
import org.eclipse.jetty.server.Server; |
10 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
11 |
import org.gvsig.fmap.dal.feature.Feature; |
|
10 | 12 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
11 | 13 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
14 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
15 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
|
12 | 16 |
import org.gvsig.tools.dispose.DisposeUtils; |
13 | 17 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
14 | 18 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
... | ... | |
19 | 23 |
import org.gvsig.vcsgis.lib.repository.VCSGisRepository; |
20 | 24 |
import org.gvsig.vcsgis.lib.repository.localdb.VCSGisRepositoryLocaldb; |
21 | 25 |
import org.gvsig.vcsgis.lib.repository.localdb.tables.DataRepoTable; |
26 |
import org.gvsig.vcsgis.lib.repository.localdb.tables.EntitiesRepoTable; |
|
22 | 27 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
23 | 28 |
import static org.gvsig.vcsgis.server.lib.VCSGisServerUtils.SERVER_PORT; |
24 | 29 |
import org.slf4j.Logger; |
... | ... | |
46 | 51 |
// TODO add test methods here. The name must begin with 'test'. For example: |
47 | 52 |
// public void testHello() {} |
48 | 53 |
|
49 |
public void testAddCommit() throws Exception {
|
|
54 |
public void testCheckout() throws Exception {
|
|
50 | 55 |
final String testid = "ServerCheckout"; |
51 | 56 |
final URL serverUrl = new URL("http://localhost:"+SERVER_PORT+"/"); |
52 | 57 |
|
53 | 58 |
VCSGisManager vcsgismanager = VCSGisLocator.getVCSGisManager(); |
54 |
JDBCServerExplorerParameters explorerParams = TestUtils.getServerExplorerParameters("srv-"+testid); |
|
59 |
|
|
60 |
JDBCServerExplorer serverdb = TestUtils.openServerExplorer("srv-"+testid); |
|
61 |
|
|
62 |
JDBCServerExplorerParameters explorerParams = serverdb.getParameters(); |
|
63 |
|
|
64 |
// JDBCServerExplorerParameters explorerParams = TestUtils.getServerExplorerParameters("srv-"+testid); |
|
55 | 65 |
File ws1file = TestUtils.getFile(FileUtils.getFile("test-dbs","ws1-"+testid)); |
56 | 66 |
File ws2file = TestUtils.getFile(FileUtils.getFile("test-dbs","ws2-"+testid)); |
57 | 67 |
|
... | ... | |
81 | 91 |
|
82 | 92 |
r = ws1.commit(Timestamp.valueOf("2020-02-17 10:11:12.123"), testid, null); |
83 | 93 |
assertEquals("ws1.commit status", ERR_OK, r); |
94 |
|
|
95 |
entities_setResources(serverdb, "test", "test_res"); |
|
84 | 96 |
|
97 |
|
|
85 | 98 |
DisposeUtils.disposeQuietly(sourceStore); |
86 | 99 |
|
87 | 100 |
|
... | ... | |
96 | 109 |
|
97 | 110 |
VCSGisWorkspaceEntity lentity = ws2.getWorkspaceEntity("test"); |
98 | 111 |
// --------------------------------------------------------- |
99 |
// Comprobamos que la tabla adicionada al espacio ed trabajo contiene
|
|
112 |
// Comprobamos que la tabla adicionada al espacio de trabajo contiene
|
|
100 | 113 |
// los mismos registros que la original. |
101 | 114 |
server.stop(); |
102 | 115 |
|
... | ... | |
105 | 118 |
|
106 | 119 |
assertEquals("Check revision codes 1", lentity.getLocalRevisionCode(), rentity.getRepositoryRevisionCode()); |
107 | 120 |
assertEquals("Check revision codes 2", lentity.getRepositoryRevisionCode(), rentity.getRepositoryRevisionCode()); |
121 |
assertEquals("Check resources", "test_res", lentity.getResources()); |
|
108 | 122 |
|
109 | 123 |
FeatureStore dataStore = repositoryLocal.getFeatureStore(DataRepoTable.TABLE_NAME); |
110 | 124 |
assertEquals("DataStore", expectedRows, dataStore.size64()); |
... | ... | |
113 | 127 |
|
114 | 128 |
repositoryLocal.dispose(); |
115 | 129 |
} |
130 |
|
|
131 |
|
|
132 |
public static void entities_setResources(JDBCServerExplorer server, String tableName, String resource) throws Exception { |
|
133 |
JDBCStoreParameters entitiesOpenParameters = server.get(EntitiesRepoTable.TABLE_NAME); |
|
134 |
FeatureStore store = (FeatureStore) server.open(entitiesOpenParameters); |
|
135 |
store.edit(); |
|
136 |
Feature f = store.findFirst("\""+EntitiesRepoTable.ENTITY_NAME+"\" = '"+tableName+"'"); |
|
137 |
EditableFeature ef = f.getEditable(); |
|
138 |
ef.set(EntitiesRepoTable.RESOURCES, resource); |
|
139 |
store.update(ef); |
|
140 |
store.finishEditing(); |
|
141 |
} |
|
142 |
|
|
116 | 143 |
} |
Also available in: Unified diff