Revision 5792
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/buildNumber.properties | ||
---|---|---|
1 |
#Wed Feb 16 22:40:47 CET 2022 |
|
2 |
buildNumber=58 |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/src/test/resources/server/vcsgisserver.config | ||
---|---|---|
1 |
{ |
|
2 |
"ConnectionParameters":{ |
|
3 |
"ProviderName":"H2Spatial", |
|
4 |
"JDBCDriverClass":"org.h2.Driver", |
|
5 |
"host":null, |
|
6 |
"port":9123, |
|
7 |
"Schema":"PUBLIC", |
|
8 |
"dbname":"default_repository", |
|
9 |
"Catalog":null, |
|
10 |
"dbuser":"SA", |
|
11 |
"password":null, |
|
12 |
"database_file":{ |
|
13 |
"__classname__":"java.io.File", |
|
14 |
"path":"/home/jjdelcerro/dbs/default_repository" |
|
15 |
}, |
|
16 |
"URL":null, |
|
17 |
"ServerPort":-1, |
|
18 |
"ServerAllowOthers":true, |
|
19 |
"MaxSecondsIdle":10, |
|
20 |
"UseSSL":false, |
|
21 |
"ShowInformationDBTables":false, |
|
22 |
"batchSize":500 |
|
23 |
} |
|
24 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/src/test/resources/org/gvsig/vcsgis/server/lib/expecteds/S04Row.txt | ||
---|---|---|
1 |
|
|
2 |
@rem ---------------------------------------------------------------- |
|
3 |
@rem TestS04Row.java |
|
4 |
@rem Values to check request and response of RowXXX request |
|
5 |
@rem ---------------------------------------------------------------- |
|
6 |
|
|
7 |
@begin RowCreateRequest |
|
8 |
@rem The client request of a RowCreate request |
|
9 |
{ |
|
10 |
"EntityName":"test", |
|
11 |
"LocalRevisionCode":"00000000000010abcdef0123456789", |
|
12 |
"EfectiveDate":null, |
|
13 |
"Comment":null, |
|
14 |
"Data":"\n{\n \"id\":1,\n \"text\":\"AAA\",\n}" |
|
15 |
} |
|
16 |
@end RowCreateRequest |
|
17 |
|
|
18 |
@begin RowCreateResponse |
|
19 |
@rem The server response of commit request for this test |
|
20 |
{ |
|
21 |
"StatusCode":0, |
|
22 |
"StatusMessage":null, |
|
23 |
"RelatedFeatureCode":"00000000000014abcdef0123456789", |
|
24 |
"EntityName":"test", |
|
25 |
"EntityCode":"00000000000002abcdef0123456789", |
|
26 |
"RevisionCode":"00000000000020abcdef0123456789" |
|
27 |
} |
|
28 |
@end RowCreateResponse |
|
29 |
|
|
30 |
|
|
31 |
@begin RowUpdateRequest |
|
32 |
@rem The client request of a RowUpdate request |
|
33 |
{ |
|
34 |
"EntityName":"test", |
|
35 |
"LocalRevisionCode":"00000000000020abcdef0123456789", |
|
36 |
"EfectiveDate":null, |
|
37 |
"Comment":null, |
|
38 |
"Data":"\n{\n \"id\":1,\n \"text\":\"AA2\",\n \"VCSGISCODE\":\"00000000000014abcdef0123456789\"\n}" |
|
39 |
} |
|
40 |
@end RowUpdateRequest |
|
41 |
|
|
42 |
@begin RowUpdateResponse |
|
43 |
@rem The server response of RowUpdate request for this test |
|
44 |
{ |
|
45 |
"StatusCode":0, |
|
46 |
"StatusMessage":null, |
|
47 |
"EntityName":"test", |
|
48 |
"EntityCode":"00000000000002abcdef0123456789", |
|
49 |
"RevisionCode":"00000000000022abcdef0123456789" |
|
50 |
} |
|
51 |
@end RowUpdateResponse |
|
52 |
|
|
53 |
|
|
54 |
@begin RowDeleteRequest |
|
55 |
@rem The client request of a RowDelete request |
|
56 |
{ |
|
57 |
"EntityName":"test", |
|
58 |
"LocalRevisionCode":"00000000000022abcdef0123456789", |
|
59 |
"EfectiveDate":null, |
|
60 |
"Comment":null, |
|
61 |
"RelatedFeatureCode":"00000000000014abcdef0123456789" |
|
62 |
} |
|
63 |
@end RowDeleteRequest |
|
64 |
|
|
65 |
@begin RowDeleteResponse |
|
66 |
@rem The server response of RowDelete request for this test |
|
67 |
{ |
|
68 |
"StatusCode":0, |
|
69 |
"StatusMessage":null, |
|
70 |
"EntityName":"test", |
|
71 |
"EntityCode":"00000000000002abcdef0123456789", |
|
72 |
"RevisionCode":"00000000000023abcdef0123456789", |
|
73 |
} |
|
74 |
@end RowDeleteResponse |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/src/test/resources/org/gvsig/vcsgis/server/lib/testSource1.csv | ||
---|---|---|
1 |
ID/Integer/set/pk=true;Byte/Byte;Bool1/Boolean;Long/Long;Timestamp/TimeStamp;Date/Date;Time/Time;Bool2/Boolean;String/String/set/size=100;Bool3/Boolean;Double/Double;Bool4/Boolean;Float/Float;Bool5/Boolean;Decimal/Decimal/set/precision=6/set/scale=3;Geometry/Geometry/set/geomtype=Point:2D/set/srs=EPSG:4326 |
|
2 |
0; ; ; ; ; ; ; ; ; ; ; ; ;T; ; |
|
3 |
1;10;T;1000;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;456.123;POINT (-3.8945156972987958 42.01053743584765) |
|
4 |
2;20;T;2000;20191129121314;20191129;131314;T;Yo yo2;F;12100.54321;T;100.21;T;456.123;POINT (-2.1079618220646115 41.983079082675474) |
|
5 |
3;30;T;3000;20191029121314;20191029;141314;T;Yo yo3;F;12101.54321;T;101.21;T;456.123;POINT (-2.57249737803327 41.35372113353277) |
|
6 |
4;40;T;4000;20190929121314;20190929;151314;T;Yo yo4;F;12102.54321;T;102.21;T;456.123;POINT (-4.061822048036304 41.35877680235475) |
|
7 |
5;50;T;5000;20190829121314;20190829;161314;T;Yo yo5;F;12103.54321;T;103.21;T;456.123;POINT (-3.974317066986988 40.78701209315094) |
|
8 |
6;60;T;6000;20190729121314;20190729;171314;T;Yo yo6;F;12104.54321;T;104.21;T;456.123;POINT (-2.510509736717547 40.69847453392384) |
|
9 |
7;70;T;7000;20190629121314;20190629;181314;T;Yo yo7;F;12105.54321;T;105.21;T;456.123;POINT (-0.5317736981843011 40.66396082637622) |
|
10 |
8;80;T;8000;20190529121314;20190529;191314;T;Yo yo8;F;12106.54321;T;106.21;T;456.123;POINT (-0.3626917259170671 41.13652386601604) |
|
11 |
9;90;T;9000;20190429121314;20190429;201314;T;Yo yo9;F;12107.54321;T;107.21;T;456.123;POINT (-1.2461823078608523 41.84950010180092) |
|
12 |
10;;T;1001;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;456.123;POINT (-1.2145405488596532 41.22158511004416) |
|
13 |
11;22; ;2002;20191129121314;20191129;131314;T;Yo yo2;F;12100.54321;T;100.21;T;456.123;POINT (-0.7699089544899235 41.630581204431756) |
|
14 |
12;33;T; ;20190929121314;20191029;141314;T;Yo yo3;F;12101.54321;T;101.21;T;456.123;POINT (0.4821915816701051 41.75970939133133) |
|
15 |
13;41;T;4001; ;20190929;151314;T;Yo yo4;F;12102.54321;T;102.21;T;456.123;POINT (0.7912661147227479 41.919324620992036) |
|
16 |
14;52;T;5002;20190829121314; ;161314;T;Yo yo5;F;12103.54321;T;103.21;T;456.123;POINT (1.052534629531243 41.493736996249545) |
|
17 |
15;63;T;6003;20190729121314;20190729; ;T;Yo yo6;F;12104.54321;T;104.21;T;456.123;POINT (0.8097002367335026 41.0899480235613) |
|
18 |
16;74;T;7004;20190629121314;20190629;181314;T; ;F;12105.54321;T;105.21;T;456.123;POINT (-0.4883960310112362 41.17597288081971) |
|
19 |
17;85;T;8005;20190529121314;20190529;191314;T;Yo yo8;F; ;T;106.21;T;456.123;POINT (-0.6439030698437881 40.89530766155764) |
|
20 |
18;96;T;9006;20190429121314;20190429;201314;T;Yo yo9;F;12107.54321;T; ;T; ;POINT (-1.3061826868199504 40.72372835570524) |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/src/test/resources/org/gvsig/vcsgis/server/lib/testSource2.csv | ||
---|---|---|
1 |
id/Integer/set/pk=true;text/String/set/size=100 |
|
2 |
1;AAA |
|
3 |
2;BBB |
|
4 |
3;CCC |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/src/test/resources/log4j.properties | ||
---|---|---|
1 |
log4j.rootLogger=INFO, stdout |
|
2 |
|
|
3 |
log4j.appender.stdout=org.apache.log4j.ConsoleAppender |
|
4 |
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout |
|
5 |
|
|
6 |
# Pattern to output the caller's file name and line number. |
|
7 |
log4j.appender.stdout.layout.ConversionPattern=%5p %r [%t] (%F:%L) - %m%n |
|
8 |
|
|
9 |
log4j.logger.org.gvsig.andami.plugins=INFO |
|
10 |
log4j.logger.org.gvsig.tools=INFO |
|
11 |
log4j.logger.org.gvsig.tools.dataTypes=INFO |
|
12 |
log4j.logger.org.gvsig.tools.library=INFO |
|
13 |
log4j.logger.org.gvsig.tools.persistence=INFO |
|
14 |
log4j.logger.org.gvsig.i18n.Messages=INFO |
|
15 |
log4j.logger.org.gvsig.installer.lib.impl.DefaultDependenciesCalculator=INFO |
|
16 |
# |
|
17 |
# JCRS |
|
18 |
log4j.logger.org.gvsig.crs=INFO |
|
19 |
log4j.logger.es.idr.teledeteccion.connection=INFO |
|
20 |
log4j.logger.org.geotools.referencing.operation.projection=INFO |
|
21 |
# |
|
22 |
# JDBC/BBDD |
|
23 |
# Core |
|
24 |
log4j.logger.org.gvsig.fmap.dal.store.jdbc=INFO |
|
25 |
log4j.logger.org.gvsig.fmap.dal.store.jdbc2=INFO |
|
26 |
log4j.logger.org.gvsig.fmap.dal.feature.spi=INFO |
|
27 |
# Data providers |
|
28 |
log4j.logger.org.gvsig.fmap.dal.store.h2=INFO |
|
29 |
log4j.logger.org.gvsig.postgresql.dal=INFO |
|
30 |
log4j.logger.org.gvsig.mssqlserver.dal=INFO |
|
31 |
log4j.logger.org.gvsig.mysql.dal=INFO |
|
32 |
log4j.logger.org.gvsig.spatialite.dal=INFO |
|
33 |
log4j.logger.org.gvsig.oracle.dal=INFO |
|
34 |
# Exoport providers |
|
35 |
log4j.logger.org.gvsig.exportto.swing.prov.jdbc=INFO |
|
36 |
log4j.logger.org.gvsig.exportto.swing.prov.h2=INFO |
|
37 |
# |
|
38 |
# shp/dbf driver |
|
39 |
log4j.logger.org.gvsig.fmap.dal.store.shp=INFO |
|
40 |
log4j.logger.org.gvsig.fmap.dal.store.dbf=INFO |
|
41 |
# |
|
42 |
log4j.logger.org.gvsig.vcsgis.lib=DEBUG |
|
43 |
#log4j.logger.org.gvsig.vcsgis.lib.repository=DEBUG |
|
44 |
#log4j.logger.org.gvsig.vcsgis.lib.repository.localdb=INFO |
|
45 |
#log4j.logger.org.gvsig.vcsgis.lib.repository.remoteclient=DEBUG |
|
46 |
#log4j.logger.org.gvsig.vcsgis.lib.requests=INFO |
|
47 |
#log4j.logger.org.gvsig.vcsgis.lib.workspace=INFO |
|
48 |
#log4j.logger.org.gvsig.vcsgis.lib.server=DEBUG |
|
49 |
log4j.logger.org.gvsig.vcsgis.server.lib=DEBUG |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/src/test/java/org/gvsig/vcsgis/app/server/TestSrv04Row.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.server; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URL; |
|
5 |
import java.util.Locale; |
|
6 |
import junit.framework.TestCase; |
|
7 |
import org.apache.commons.io.FileUtils; |
|
8 |
import org.eclipse.jetty.server.Server; |
|
9 |
import org.gvsig.fmap.dal.feature.Feature; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
12 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
13 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
14 |
import static org.gvsig.vcsgis.app.server.TestServerUtils.createServer; |
|
15 |
import static org.gvsig.vcsgis.app.server.TestServerUtils.utils; |
|
16 |
import static org.gvsig.vcsgis.app.server.VCSGisJettyServerUtils.SERVER_PORT; |
|
17 |
import org.gvsig.vcsgis.lib.SequentialCodeGenerator; |
|
18 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
|
19 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
|
20 |
import org.gvsig.vcsgis.lib.repository.VCSGisRepository; |
|
21 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
22 |
import org.slf4j.Logger; |
|
23 |
import org.slf4j.LoggerFactory; |
|
24 |
|
|
25 |
public class TestSrv04Row extends TestCase { |
|
26 |
|
|
27 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestSrv04Row.class); |
|
28 |
|
|
29 |
static{ |
|
30 |
Locale.setDefault(Locale.forLanguageTag("es-ES")); |
|
31 |
} |
|
32 |
|
|
33 |
public TestSrv04Row(String testName) { |
|
34 |
super(testName); |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
protected void setUp() throws Exception { |
|
39 |
super.setUp(); |
|
40 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
protected void tearDown() throws Exception { |
|
45 |
super.tearDown(); |
|
46 |
} |
|
47 |
|
|
48 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
49 |
// public void testHello() {} |
|
50 |
|
|
51 |
public void testIsOutOfDate() throws Exception { |
|
52 |
final String testid = "ServerRow"; |
|
53 |
final URL serverUrl = new URL("http://localhost:"+SERVER_PORT+"/"); |
|
54 |
|
|
55 |
VCSGisManager vcsgismanager = VCSGisLocator.getVCSGisManager(); |
|
56 |
vcsgismanager.setCodeGenerator(new SequentialCodeGenerator()); |
|
57 |
|
|
58 |
JDBCServerExplorerParameters explorerParams = utils().getRepositoryServerExplorerParameters("srv-"+testid); |
|
59 |
File ws1file = utils().getFile(FileUtils.getFile("test-dbs","ws1-"+testid)); |
|
60 |
File ws2file = utils().getFile(FileUtils.getFile("test-dbs","ws2-"+testid)); |
|
61 |
|
|
62 |
// --------------------------------------------------------- |
|
63 |
// Creamos el server y obtenemos el repositorio del server |
|
64 |
int r = vcsgismanager.initRepository(explorerParams, null); |
|
65 |
assertEquals("srv-init status", 0, r); |
|
66 |
|
|
67 |
Server server = createServer(utils(),explorerParams); |
|
68 |
server.start(); |
|
69 |
|
|
70 |
VCSGisRepository repositoryService = vcsgismanager.openRepository(serverUrl); |
|
71 |
|
|
72 |
// --------------------------------------------------------- |
|
73 |
// Creamos un workspace y preparamos los datos en el para hacer un commit |
|
74 |
r = vcsgismanager.initWorkspace(ws1file, repositoryService, "Test checkout ws1", null); |
|
75 |
assertEquals("ws1-init status", 0, r); |
|
76 |
|
|
77 |
VCSGisWorkspace ws1 = vcsgismanager.openWorkspace(ws1file); |
|
78 |
utils().info_workspace(ws1); |
|
79 |
|
|
80 |
utils().test_add(ws1); |
|
81 |
|
|
82 |
utils().test_commit(ws1); |
|
83 |
|
|
84 |
// --------------------------------------------------------- |
|
85 |
// Creamos un segundo workspace |
|
86 |
r = vcsgismanager.initWorkspace(ws2file, repositoryService, "Test checkout ws2", null); |
|
87 |
assertEquals("ws2-init status", 0, r); |
|
88 |
|
|
89 |
VCSGisWorkspace ws2 = vcsgismanager.openWorkspace(ws2file); |
|
90 |
utils().info_workspace(ws2); |
|
91 |
|
|
92 |
FeatureStore store2; |
|
93 |
Feature f; |
|
94 |
String id2_code; |
|
95 |
boolean br; |
|
96 |
|
|
97 |
utils().test_checkout(ws2); |
|
98 |
|
|
99 |
store2 = ws2.openFeatureStore("test",false); |
|
100 |
f = store2.findFirst("id=2"); |
|
101 |
id2_code = f.getString("VCSGISCODE"); |
|
102 |
br = ws2.isOutOfDate(store2, f); |
|
103 |
assertFalse(br); |
|
104 |
DisposeUtils.disposeQuietly(store2); |
|
105 |
|
|
106 |
br = ws2.isOutOfDate("test", id2_code); |
|
107 |
assertFalse(br); |
|
108 |
|
|
109 |
utils().test_modify( ws1, |
|
110 |
"update", 2, "BB2" |
|
111 |
); |
|
112 |
utils().test_commit(ws1); |
|
113 |
|
|
114 |
br = ws2.isOutOfDate("test", id2_code); |
|
115 |
assertTrue(br); |
|
116 |
|
|
117 |
repositoryService.dispose(); |
|
118 |
} |
|
119 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/src/test/java/org/gvsig/vcsgis/app/server/TestServerUtils.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.server; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.OutputStreamWriter; |
|
5 |
import java.net.URL; |
|
6 |
import org.apache.commons.io.FileUtils; |
|
7 |
import org.eclipse.jetty.server.Server; |
|
8 |
import org.gvsig.fmap.dal.DataStore; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
10 |
import static org.gvsig.vcsgis.app.server.VCSGisJettyServerUtils.SERVER_PORT; |
|
11 |
import org.gvsig.vcsgis.lib.impl.AbstractTestUtils; |
|
12 |
import org.gvsig.vcsgis.lib.server.VCSGisServerUtils; |
|
13 |
import org.slf4j.Logger; |
|
14 |
import org.slf4j.LoggerFactory; |
|
15 |
|
|
16 |
public class TestServerUtils { |
|
17 |
|
|
18 |
public static final Logger LOGGER = LoggerFactory.getLogger(TestServerUtils.class); |
|
19 |
|
|
20 |
public static final String PROVIDER_NAME = DataStore.H2SPATIAL_PROVIDER_NAME; |
|
21 |
|
|
22 |
static Server createServer(AbstractTestUtils utils, JDBCServerExplorerParameters explorerParams) throws Exception { |
|
23 |
URL config_url = TestServerUtils.class.getResource("/server/vcsgisserver.config"); |
|
24 |
OutputStreamWriter consoleWriter = new OutputStreamWriter(System.out); |
|
25 |
VCSGisServerUtils.setConsoleWriter(consoleWriter); |
|
26 |
VCSGisServerUtils.setConfiguration(config_url); |
|
27 |
VCSGisServerUtils.setConnectionParameters(explorerParams); |
|
28 |
VCSGisServerUtils.writeConfiguration(config_url); |
|
29 |
|
|
30 |
File rootFolder = utils().getFile(new File("static")); |
|
31 |
Server server = VCSGisJettyServerUtils.createServer(SERVER_PORT, null, rootFolder.getAbsolutePath()); |
|
32 |
return server; |
|
33 |
} |
|
34 |
|
|
35 |
private static class LocalTestUtilsH2Spatial extends org.gvsig.vcsgis.lib.impl.h2spatial.TestUtilsH2Spatial { |
|
36 |
// Esto fuerza a que el class loader de esta clase esta en este proyecto. |
|
37 |
} |
|
38 |
|
|
39 |
private static LocalTestUtilsH2Spatial utils = null; |
|
40 |
|
|
41 |
public static AbstractTestUtils utils() { |
|
42 |
if( utils==null ) { |
|
43 |
utils = new LocalTestUtilsH2Spatial(); |
|
44 |
} |
|
45 |
return utils; |
|
46 |
} |
|
47 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/src/test/java/org/gvsig/vcsgis/app/server/TestSrv01AddCommit.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.server; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URL; |
|
5 |
import java.util.Locale; |
|
6 |
import junit.framework.TestCase; |
|
7 |
import static junit.framework.TestCase.assertEquals; |
|
8 |
import org.apache.commons.io.FileUtils; |
|
9 |
import org.eclipse.jetty.server.Server; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
12 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
13 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
14 |
import static org.gvsig.vcsgis.app.server.TestServerUtils.createServer; |
|
15 |
import static org.gvsig.vcsgis.app.server.TestServerUtils.utils; |
|
16 |
import static org.gvsig.vcsgis.app.server.VCSGisJettyServerUtils.SERVER_PORT; |
|
17 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
18 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
|
19 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
|
20 |
import org.gvsig.vcsgis.lib.repository.VCSGisRepository; |
|
21 |
import org.gvsig.vcsgis.lib.repository.localdb.VCSGisRepositoryLocaldbImpl; |
|
22 |
import org.gvsig.vcsgis.lib.repository.localdb.tables.DataRepoTable; |
|
23 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
24 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
|
25 |
import org.slf4j.Logger; |
|
26 |
import org.slf4j.LoggerFactory; |
|
27 |
|
|
28 |
public class TestSrv01AddCommit extends TestCase { |
|
29 |
|
|
30 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestSrv01AddCommit.class); |
|
31 |
|
|
32 |
static{ |
|
33 |
Locale.setDefault(Locale.forLanguageTag("es-ES")); |
|
34 |
} |
|
35 |
|
|
36 |
public TestSrv01AddCommit(String testName) { |
|
37 |
super(testName); |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
protected void setUp() throws Exception { |
|
42 |
super.setUp(); |
|
43 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
protected void tearDown() throws Exception { |
|
48 |
super.tearDown(); |
|
49 |
} |
|
50 |
|
|
51 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
52 |
// public void testHello() {} |
|
53 |
public void testAddCommit() throws Exception { |
|
54 |
final String testid = "ServerAddCommit"; |
|
55 |
final URL serverUrl = new URL("http://localhost:" + SERVER_PORT + "/"); |
|
56 |
|
|
57 |
VCSGisManager vcsgismanager = VCSGisLocator.getVCSGisManager(); |
|
58 |
JDBCServerExplorerParameters explorerParams = utils().getRepositoryServerExplorerParameters("srv-" + testid); |
|
59 |
File wsfile = utils().getFile(FileUtils.getFile("test-dbs", "ws-" + testid)); |
|
60 |
|
|
61 |
// --------------------------------------------------------- |
|
62 |
// Creamos el server y obtenemos el repositorio del server |
|
63 |
int r = vcsgismanager.initRepository(explorerParams, null); |
|
64 |
assertEquals("srv-init status", 0, r); |
|
65 |
|
|
66 |
Server server = createServer(utils(),explorerParams); |
|
67 |
VCSGisWorkspaceEntity lentity = null; |
|
68 |
long expectedRows = -1; |
|
69 |
try { |
|
70 |
server.start(); |
|
71 |
|
|
72 |
VCSGisRepository repositoryRemote = vcsgismanager.openRepository(serverUrl); |
|
73 |
|
|
74 |
// --------------------------------------------------------- |
|
75 |
// Creamos un workspace y preparamos los datos en el para hacer un commit |
|
76 |
r = vcsgismanager.initWorkspace(wsfile, repositoryRemote, "Test add and commit", null); |
|
77 |
assertEquals("ws-init status", 0, r); |
|
78 |
|
|
79 |
VCSGisWorkspace ws = vcsgismanager.openWorkspace(wsfile); |
|
80 |
utils().info_workspace(ws); |
|
81 |
|
|
82 |
FeatureStore sourceStore = utils().openSourceStore1(); |
|
83 |
expectedRows = sourceStore.getFeatureCount(); |
|
84 |
|
|
85 |
r = ws.add("sourceStore1", sourceStore, "id"); |
|
86 |
assertEquals("ws-add status", 0, r); |
|
87 |
|
|
88 |
DisposeUtils.disposeQuietly(sourceStore); |
|
89 |
|
|
90 |
r = ws.commit(); |
|
91 |
assertEquals("ws-commit status", 0, r); |
|
92 |
|
|
93 |
lentity = ws.getWorkspaceEntity("sourceStore1"); |
|
94 |
} finally { |
|
95 |
server.stop(); |
|
96 |
} |
|
97 |
// --------------------------------------------------------- |
|
98 |
// Comprobamos que la tabla adicionada al espacio ed trabajo contiene |
|
99 |
// los mismos registros que la original. |
|
100 |
|
|
101 |
VCSGisRepositoryLocaldbImpl repositoryLocal = (VCSGisRepositoryLocaldbImpl) vcsgismanager.openRepository(explorerParams); |
|
102 |
VCSGisEntity rentity = repositoryLocal.getEntityByName("sourceStore1"); |
|
103 |
|
|
104 |
assertEquals("Check revision codes 1", lentity.getLocalRevisionCode(), rentity.getRepositoryRevisionCode()); |
|
105 |
assertEquals("Check revision codes 2", lentity.getRepositoryRevisionCode(), rentity.getRepositoryRevisionCode()); |
|
106 |
|
|
107 |
FeatureStore dataStore = repositoryLocal.getFeatureStore(DataRepoTable.TABLE_NAME, true); |
|
108 |
assertEquals("DataStore", expectedRows, dataStore.size64()); |
|
109 |
|
|
110 |
DisposeUtils.disposeQuietly(dataStore); |
|
111 |
|
|
112 |
repositoryLocal.dispose(); |
|
113 |
} |
|
114 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/src/test/java/org/gvsig/vcsgis/app/server/TestSrv06Authenticate.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.server; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URL; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Locale; |
|
7 |
import junit.framework.TestCase; |
|
8 |
import static junit.framework.TestCase.assertEquals; |
|
9 |
import org.apache.commons.io.FileUtils; |
|
10 |
import org.eclipse.jetty.server.Server; |
|
11 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
13 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
14 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
15 |
import static org.gvsig.vcsgis.app.server.TestServerUtils.createServer; |
|
16 |
import static org.gvsig.vcsgis.app.server.TestServerUtils.utils; |
|
17 |
import static org.gvsig.vcsgis.app.server.VCSGisJettyServerUtils.SERVER_PORT; |
|
18 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
19 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
|
20 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
|
21 |
import org.gvsig.vcsgis.lib.VCSGisUserIdentificationRequester; |
|
22 |
import org.gvsig.vcsgis.lib.repository.VCSGisRepository; |
|
23 |
import org.gvsig.vcsgis.lib.repository.localdb.VCSGisRepositoryLocaldbImpl; |
|
24 |
import org.gvsig.vcsgis.lib.repository.localdb.tables.ConfigRepoTable; |
|
25 |
import org.gvsig.vcsgis.lib.repository.localdb.tables.UsersRepoTable; |
|
26 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
27 |
import org.slf4j.Logger; |
|
28 |
import org.slf4j.LoggerFactory; |
|
29 |
|
|
30 |
public class TestSrv06Authenticate extends TestCase { |
|
31 |
|
|
32 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestSrv06Authenticate.class); |
|
33 |
|
|
34 |
static{ |
|
35 |
Locale.setDefault(Locale.forLanguageTag("es-ES")); |
|
36 |
} |
|
37 |
|
|
38 |
public TestSrv06Authenticate(String testName) { |
|
39 |
super(testName); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
protected void setUp() throws Exception { |
|
44 |
super.setUp(); |
|
45 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
protected void tearDown() throws Exception { |
|
50 |
super.tearDown(); |
|
51 |
} |
|
52 |
|
|
53 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
54 |
// public void testHello() {} |
|
55 |
public void testAuthenticatedCommit() throws Exception { |
|
56 |
final String testid = "ServerAddCommit"; |
|
57 |
final URL serverUrl = new URL("http://localhost:" + SERVER_PORT + "/"); |
|
58 |
|
|
59 |
VCSGisManager vcsgismanager = VCSGisLocator.getVCSGisManager(); |
|
60 |
JDBCServerExplorerParameters explorerParams = utils().getRepositoryServerExplorerParameters("srv-" + testid); |
|
61 |
File wsfile = utils().getFile(FileUtils.getFile("test-dbs", "ws-" + testid)); |
|
62 |
|
|
63 |
// --------------------------------------------------------- |
|
64 |
// Creamos el server y obtenemos el repositorio del server |
|
65 |
int r = vcsgismanager.initRepository(explorerParams, null); |
|
66 |
assertEquals("srv-init status", 0, r); |
|
67 |
|
|
68 |
VCSGisRepositoryLocaldbImpl repositoryLocal = (VCSGisRepositoryLocaldbImpl) vcsgismanager.openRepository(explorerParams); |
|
69 |
enableAuthentication(repositoryLocal); |
|
70 |
repositoryLocal.dispose(); |
|
71 |
|
|
72 |
Server server = createServer(utils(),explorerParams); |
|
73 |
try { |
|
74 |
server.start(); |
|
75 |
|
|
76 |
VCSGisRepository repositoryRemote = vcsgismanager.openRepository(serverUrl); |
|
77 |
|
|
78 |
// --------------------------------------------------------- |
|
79 |
// Creamos un workspace y preparamos los datos en el para hacer un commit |
|
80 |
r = vcsgismanager.initWorkspace(wsfile, repositoryRemote, "Test add and commit", null); |
|
81 |
assertEquals("ws-init status", 0, r); |
|
82 |
|
|
83 |
VCSGisWorkspace ws = vcsgismanager.openWorkspace(wsfile); |
|
84 |
utils().info_workspace(ws); |
|
85 |
|
|
86 |
ws.setUserIdentificationRequester(new VCSGisUserIdentificationRequester() { |
|
87 |
int retries = 0; |
|
88 |
|
|
89 |
@Override |
|
90 |
public boolean requestIdentification() { |
|
91 |
if (retries++ > 5) { |
|
92 |
return false; |
|
93 |
} |
|
94 |
return true; |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public String getUserId() { |
|
99 |
return "test"; |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public String getPassword() { |
|
104 |
return "password"; |
|
105 |
} |
|
106 |
}); |
|
107 |
|
|
108 |
FeatureStore sourceStore = utils().openSourceStore1(); |
|
109 |
long expectedRows = sourceStore.getFeatureCount(); |
|
110 |
|
|
111 |
r = ws.add("sourceStore1", sourceStore, "ID"); |
|
112 |
assertEquals("ws-add status", 0, r); |
|
113 |
|
|
114 |
DisposeUtils.disposeQuietly(sourceStore); |
|
115 |
|
|
116 |
r = ws.commit(); |
|
117 |
assertEquals("ws-commit status", 0, r); |
|
118 |
|
|
119 |
// --------------------------------------------------------- |
|
120 |
// Comprobamos que en el server esta la tabla que acabamos de adicionar |
|
121 |
ws.updateEntitiesFromRepository(null); |
|
122 |
List<VCSGisEntity> rentities = ws.getRepositoryEntities(); |
|
123 |
assertEquals("Num entities in server", 1, rentities.size()); |
|
124 |
assertEquals("Name of the entity in server", "sourceStore1", rentities.get(0).getEntityName()); |
|
125 |
} finally { |
|
126 |
|
|
127 |
server.stop(); |
|
128 |
} |
|
129 |
} |
|
130 |
|
|
131 |
private void enableAuthentication(VCSGisRepositoryLocaldbImpl repo) { |
|
132 |
ConfigRepoTable varsTable = new ConfigRepoTable(); |
|
133 |
varsTable.set(repo, "AUTHENTICATION", String.valueOf(true)); |
|
134 |
|
|
135 |
UsersRepoTable.UserRepoRow userRow = new UsersRepoTable.UserRepoRow(repo); |
|
136 |
userRow.setIdentifier("test"); |
|
137 |
userRow.setPassword("password"); |
|
138 |
userRow.insert(); |
|
139 |
|
|
140 |
} |
|
141 |
|
|
142 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/src/test/java/org/gvsig/vcsgis/app/server/TestSrv14UpdateWithConflict.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.server; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URL; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Locale; |
|
7 |
import junit.framework.TestCase; |
|
8 |
import static junit.framework.TestCase.assertEquals; |
|
9 |
import org.apache.commons.io.FileUtils; |
|
10 |
import org.eclipse.jetty.server.Server; |
|
11 |
import org.gvsig.expressionevaluator.Expression; |
|
12 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
13 |
import org.gvsig.fmap.dal.feature.Feature; |
|
14 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
15 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
16 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
17 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
18 |
import static org.gvsig.vcsgis.app.server.TestServerUtils.createServer; |
|
19 |
import static org.gvsig.vcsgis.app.server.TestServerUtils.utils; |
|
20 |
import static org.gvsig.vcsgis.app.server.VCSGisJettyServerUtils.SERVER_PORT; |
|
21 |
import org.gvsig.vcsgis.lib.SequentialCodeGenerator; |
|
22 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
|
23 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
|
24 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_NO_ERROR; |
|
25 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_UPDATE_NEED_MERGE; |
|
26 |
import static org.gvsig.vcsgis.lib.VCSGisManager.OP_DELETE; |
|
27 |
import static org.gvsig.vcsgis.lib.VCSGisManager.OP_INSERT; |
|
28 |
import static org.gvsig.vcsgis.lib.VCSGisManager.STATE_CONFLICT; |
|
29 |
import org.gvsig.vcsgis.lib.repository.VCSGisRepository; |
|
30 |
import org.gvsig.vcsgis.lib.repository.localdb.VCSGisRepositoryLocaldbImpl; |
|
31 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
32 |
import org.gvsig.vcsgis.lib.workspace.tables.RemoteChangesTable; |
|
33 |
import org.gvsig.vcsgis.lib.workspace.tables.WorkspaceChangesTable; |
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 |
public class TestSrv14UpdateWithConflict extends TestCase { |
|
38 |
|
|
39 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestSrv14UpdateWithConflict.class); |
|
40 |
private Server server; |
|
41 |
|
|
42 |
static{ |
|
43 |
Locale.setDefault(Locale.forLanguageTag("es-ES")); |
|
44 |
} |
|
45 |
|
|
46 |
public TestSrv14UpdateWithConflict(String testName) { |
|
47 |
super(testName); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
protected void setUp() throws Exception { |
|
52 |
super.setUp(); |
|
53 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
protected void tearDown() throws Exception { |
|
58 |
super.tearDown(); |
|
59 |
} |
|
60 |
|
|
61 |
private VCSGisWorkspace[] initTest() throws Exception { |
|
62 |
|
|
63 |
final String testid = "ServerUpdateWithConflict"; |
|
64 |
final URL serverUrl = new URL("http://localhost:" + SERVER_PORT + "/"); |
|
65 |
|
|
66 |
VCSGisManager vcsgismanager = VCSGisLocator.getVCSGisManager(); |
|
67 |
// JDBCServerExplorer server = TestUtils.openServerExplorer("srv-update"); |
|
68 |
SequentialCodeGenerator.reset(); |
|
69 |
|
|
70 |
JDBCServerExplorerParameters explorerParams = utils().getRepositoryServerExplorerParameters("srv-" + testid); |
|
71 |
File wsfile = utils().getFile(FileUtils.getFile("test-dbs", "ws-" + testid)); |
|
72 |
|
|
73 |
// --------------------------------------------------------- |
|
74 |
// Creamos el server y obtenemos el repositorio del server |
|
75 |
int r = vcsgismanager.initRepository(explorerParams, null); |
|
76 |
assertEquals("srv-init status", 0, r); |
|
77 |
|
|
78 |
VCSGisRepositoryLocaldbImpl repositoryLocal = (VCSGisRepositoryLocaldbImpl) vcsgismanager.openRepository(explorerParams); |
|
79 |
|
|
80 |
repositoryLocal.setAllowAssignTheRevisionDate(true); |
|
81 |
|
|
82 |
utils().info_repository(repositoryLocal); |
|
83 |
|
|
84 |
repositoryLocal.dispose(); |
|
85 |
|
|
86 |
server = createServer(utils(), explorerParams); |
|
87 |
|
|
88 |
server.start(); |
|
89 |
|
|
90 |
VCSGisRepository repo = vcsgismanager.openRepository(serverUrl); |
|
91 |
|
|
92 |
File ws1file = utils().getFile(FileUtils.getFile("test-dbs", "ws1-update")); |
|
93 |
File ws2file = utils().getFile(FileUtils.getFile("test-dbs", "ws2-update")); |
|
94 |
File ws3file = utils().getFile(FileUtils.getFile("test-dbs", "ws3-update")); |
|
95 |
|
|
96 |
vcsgismanager.setCodeGenerator(new SequentialCodeGenerator()); |
|
97 |
|
|
98 |
List<Feature> features; |
|
99 |
FeatureStore store2; |
|
100 |
FeatureStore store3; |
|
101 |
|
|
102 |
// ------------------------------------------------------------ |
|
103 |
// Creamos workspace1 y lo abrimos. |
|
104 |
r = vcsgismanager.initWorkspace(ws1file, repo, "Test update1", null); |
|
105 |
assertEquals("init_ws1 status", ERR_NO_ERROR, r); |
|
106 |
|
|
107 |
VCSGisWorkspace ws1 = vcsgismanager.openWorkspace(ws1file); |
|
108 |
utils().info_workspace(ws1); |
|
109 |
|
|
110 |
// ------------------------------------------------------------ |
|
111 |
// Adicionamos al workspace1 la tabla "test" y la commitamos. |
|
112 |
//REV 0 |
|
113 |
FeatureStore sourceTest = utils().openSourceStore2(); |
|
114 |
r = ws1.add("test", sourceTest, "text"); |
|
115 |
DisposeUtils.disposeQuietly(sourceTest); |
|
116 |
assertEquals("ws1.add status", ERR_NO_ERROR, r); |
|
117 |
|
|
118 |
r = ws1.commit(); |
|
119 |
assertEquals("ws1.commit-1 status", ERR_NO_ERROR, r); |
|
120 |
|
|
121 |
// ------------------------------------------------------------ |
|
122 |
// Inicializamos el workspace2 asociandolo al mismo repositorio que |
|
123 |
// workspace1 y lo abrimos. |
|
124 |
r = vcsgismanager.initWorkspace(ws2file, repo, "Test update2", null); |
|
125 |
assertEquals("init_ws2 status", ERR_NO_ERROR, r); |
|
126 |
VCSGisWorkspace ws2 = vcsgismanager.openWorkspace(ws2file); |
|
127 |
utils().info_workspace(ws2); |
|
128 |
|
|
129 |
// ------------------------------------------------------------ |
|
130 |
// Actualizamos (update) la tabla "test" en el workspace2 |
|
131 |
// y comprobamos que tiene lo que toca. |
|
132 |
r = ws2.checkout("test"); |
|
133 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
134 |
|
|
135 |
store2 = ws2.openFeatureStore("test",false); |
|
136 |
assertEquals("ws2-upfate sizes", 3, store2.size64()); |
|
137 |
features = store2.getFeatures((Expression) null, "id", true); |
|
138 |
|
|
139 |
utils().test_check(features, 0, 1, "AAA"); |
|
140 |
utils().test_check(features, 1, 2, "BBB"); |
|
141 |
utils().test_check(features, 2, 3, "CCC"); |
|
142 |
|
|
143 |
DisposeUtils.disposeQuietly(features); |
|
144 |
DisposeUtils.disposeQuietly(store2); |
|
145 |
|
|
146 |
// ------------------------------------------------------------ |
|
147 |
// Inicializamos el workspace3 asociandolo al mismo repositorio que |
|
148 |
// workspace1 y lo abrimos. |
|
149 |
r = vcsgismanager.initWorkspace(ws3file, repo, "Test update2", null); |
|
150 |
assertEquals("init_ws2 status", ERR_NO_ERROR, r); |
|
151 |
VCSGisWorkspace ws3 = vcsgismanager.openWorkspace(ws3file); |
|
152 |
utils().info_workspace(ws3); |
|
153 |
|
|
154 |
// ------------------------------------------------------------ |
|
155 |
// Actualizamos (update) la tabla "test" en el workspace3 |
|
156 |
// y comprobamos que tiene lo que toca. |
|
157 |
r = ws3.checkout("test"); |
|
158 |
assertEquals("ws3.update-1 status", ERR_NO_ERROR, r); |
|
159 |
|
|
160 |
store3 = ws3.openFeatureStore("test",false); |
|
161 |
assertEquals("ws3-upfate sizes", 3, store3.size64()); |
|
162 |
features = store3.getFeatures((Expression) null, "id", true); |
|
163 |
|
|
164 |
utils().test_check(features, 0, 1, "AAA"); |
|
165 |
utils().test_check(features, 1, 2, "BBB"); |
|
166 |
utils().test_check(features, 2, 3, "CCC"); |
|
167 |
|
|
168 |
DisposeUtils.disposeQuietly(features); |
|
169 |
DisposeUtils.disposeQuietly(store2); |
|
170 |
DisposeUtils.disposeQuietly(store3); |
|
171 |
|
|
172 |
return new VCSGisWorkspace[]{ws1, ws2, ws3}; |
|
173 |
} |
|
174 |
|
|
175 |
public void testTwoUpdatesAndMerge() throws Exception { |
|
176 |
|
|
177 |
try { |
|
178 |
VCSGisWorkspace[] wss = initTest(); |
|
179 |
VCSGisWorkspace ws1 = wss[0]; |
|
180 |
VCSGisWorkspace ws2 = wss[1]; |
|
181 |
|
|
182 |
int r; |
|
183 |
Feature f; |
|
184 |
EditableFeature ef; |
|
185 |
FeatureStore store1; |
|
186 |
FeatureStore store2; |
|
187 |
|
|
188 |
// Añadimos al workspace1 una feature con una id concreta y la commitamos |
|
189 |
store1 = ws1.openFeatureStore("test",false); |
|
190 |
store1.edit(); |
|
191 |
utils().test_update(store1, 3, "CC1"); |
|
192 |
|
|
193 |
store1.finishEditing(); |
|
194 |
DisposeUtils.disposeQuietly(store1); |
|
195 |
|
|
196 |
r = ws1.commit(); |
|
197 |
assertEquals("ws1.commit-1 status", ERR_NO_ERROR, r); |
|
198 |
|
|
199 |
// Añadimos al workspace2 una feature con la misma id |
|
200 |
store2 = ws2.openFeatureStore("test",false); |
|
201 |
store2.edit(); |
|
202 |
utils().test_update(store2, 3, "CC2"); |
|
203 |
|
|
204 |
store2.finishEditing(); |
|
205 |
DisposeUtils.disposeQuietly(store2); |
|
206 |
|
|
207 |
// ------------------------------------------------------------ |
|
208 |
// Preparamos la actualización de (updatePrepare) la tabla "test" en el workspace2 |
|
209 |
// comprobamos que funciona y que tiene lo que toca. |
|
210 |
r = ws2.updatePrepare("test"); |
|
211 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
212 |
|
|
213 |
// assertTrue(false); |
|
214 |
// Actualizamos (update) la tabla "test" en el workspace2 |
|
215 |
// comprobamos que falla |
|
216 |
r = ws2.update("test"); |
|
217 |
assertEquals("ws2.update-1 status", ERR_UPDATE_NEED_MERGE, r); |
|
218 |
|
|
219 |
// Actualizamos (merge) la tabla "test" en el workspace2 |
|
220 |
// comprobamos que no falla |
|
221 |
r = ws2.merge("test"); |
|
222 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
223 |
|
|
224 |
//Comprobar que en la tabla de cambios locales hay 1 elemento |
|
225 |
FeatureStore changes = ws2.getFeatureStore(WorkspaceChangesTable.TABLE_NAME); |
|
226 |
assertEquals("ws2-changes size", 1, changes.size64()); |
|
227 |
DisposeUtils.disposeQuietly(changes); |
|
228 |
} finally { |
|
229 |
server.stop(); |
|
230 |
} |
|
231 |
|
|
232 |
} |
|
233 |
|
|
234 |
public void testTwoUpdatesMergeAndUpdate() throws Exception { |
|
235 |
try { |
|
236 |
VCSGisWorkspace[] wss = initTest(); |
|
237 |
VCSGisWorkspace ws1 = wss[0]; |
|
238 |
VCSGisWorkspace ws2 = wss[1]; |
|
239 |
VCSGisWorkspace ws3 = wss[2]; |
|
240 |
|
|
241 |
int r; |
|
242 |
Feature f; |
|
243 |
EditableFeature ef; |
|
244 |
FeatureStore store1; |
|
245 |
FeatureStore store2; |
|
246 |
FeatureStore store3; |
|
247 |
|
|
248 |
// Editamos en el workspace1 una feature con una id concreta y la commitamos |
|
249 |
store1 = ws1.openFeatureStore("test",false); |
|
250 |
store1.edit(); |
|
251 |
utils().test_update(store1, 3, "CC1"); |
|
252 |
|
|
253 |
store1.finishEditing(); |
|
254 |
DisposeUtils.disposeQuietly(store1); |
|
255 |
|
|
256 |
r = ws1.commit(); |
|
257 |
assertEquals("ws1.commit-1 status", ERR_NO_ERROR, r); |
|
258 |
|
|
259 |
// Editamos en el workspace2 la feature con la misma id |
|
260 |
store2 = ws2.openFeatureStore("test",false); |
|
261 |
store2.edit(); |
|
262 |
utils().test_update(store2, 3, "CC2"); |
|
263 |
|
|
264 |
store2.finishEditing(); |
|
265 |
DisposeUtils.disposeQuietly(store2); |
|
266 |
|
|
267 |
// ------------------------------------------------------------ |
|
268 |
// Preparamos la actualización de (updatePrepare) la tabla "test" en el workspace2 |
|
269 |
// comprobamos que funciona y que tiene lo que toca. |
|
270 |
r = ws2.updatePrepare("test"); |
|
271 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
272 |
|
|
273 |
// assertTrue(false); |
|
274 |
// Actualizamos (update) la tabla "test" en el workspace2 |
|
275 |
// comprobamos que falla |
|
276 |
r = ws2.update("test"); |
|
277 |
assertEquals("ws2.update-1 status", ERR_UPDATE_NEED_MERGE, r); |
|
278 |
|
|
279 |
// Actualizamos (merge) la tabla "test" en el workspace2 |
|
280 |
// comprobamos que no falla |
|
281 |
r = ws2.merge("test"); |
|
282 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
283 |
|
|
284 |
//Comprobar que en la tabla de cambios locales hay 1 elemento |
|
285 |
FeatureStore changes = ws2.getFeatureStore(WorkspaceChangesTable.TABLE_NAME); |
|
286 |
assertEquals("ws2-changes size", 1, changes.size64()); |
|
287 |
DisposeUtils.disposeQuietly(changes); |
|
288 |
|
|
289 |
// Commitamos el workspace2 |
|
290 |
r = ws2.commit(); |
|
291 |
assertEquals("ws2.commit-1 status", ERR_NO_ERROR, r); |
|
292 |
|
|
293 |
// ------------------------------------------------------------ |
|
294 |
// Preparamos la actualización de (updatePrepare) la tabla "test" en el workspace3 |
|
295 |
// comprobamos que funciona y que tiene lo que toca. |
|
296 |
r = ws3.updatePrepare("test"); |
|
297 |
assertEquals("ws3.update-1 status", ERR_NO_ERROR, r); |
|
298 |
|
|
299 |
//Comprobar que en la tabla de cambios remotos hay 1 elemento |
|
300 |
FeatureStore remoteChanges = ws3.getFeatureStore(RemoteChangesTable.TABLE_NAME); |
|
301 |
assertEquals("ws3-remoteChanges size", 1, remoteChanges.size64()); |
|
302 |
DisposeUtils.disposeQuietly(remoteChanges); |
|
303 |
|
|
304 |
// Actualizamos (update) la tabla "test" en el workspace3 |
|
305 |
// comprobamos que no falla |
|
306 |
r = ws3.update("test"); |
|
307 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
308 |
|
|
309 |
store3 = ws3.openFeatureStore("test",false); |
|
310 |
assertEquals("ws3-update sizes", 3, store3.size64()); |
|
311 |
List<Feature> features = store3.getFeatures((Expression) null, "id", true); |
|
312 |
|
|
313 |
utils().test_check(features, 0, 1, "AAA"); |
|
314 |
utils().test_check(features, 1, 2, "BBB"); |
|
315 |
utils().test_check(features, 2, 3, "CC2"); |
|
316 |
|
|
317 |
DisposeUtils.disposeQuietly(store3); |
|
318 |
} finally { |
|
319 |
server.stop(); |
|
320 |
} |
|
321 |
|
|
322 |
} |
|
323 |
|
|
324 |
public void testTwoUpdatesAndUpdate() throws Exception { |
|
325 |
try { |
|
326 |
|
|
327 |
VCSGisWorkspace[] wss = initTest(); |
|
328 |
VCSGisWorkspace ws1 = wss[0]; |
|
329 |
VCSGisWorkspace ws2 = wss[1]; |
|
330 |
|
|
331 |
int r; |
|
332 |
Feature f; |
|
333 |
EditableFeature ef; |
|
334 |
FeatureStore store1; |
|
335 |
FeatureStore store2; |
|
336 |
|
|
337 |
// Añadimos al workspace1 una feature con una id concreta y la commitamos |
|
338 |
store1 = ws1.openFeatureStore("test",false); |
|
339 |
store1.edit(); |
|
340 |
utils().test_update(store1, 3, "CC1"); |
|
341 |
|
|
342 |
store1.finishEditing(); |
|
343 |
DisposeUtils.disposeQuietly(store1); |
|
344 |
|
|
345 |
r = ws1.commit(); |
|
346 |
assertEquals("ws1.commit-1 status", ERR_NO_ERROR, r); |
|
347 |
|
|
348 |
// Añadimos al workspace2 una feature con la misma id |
|
349 |
store2 = ws2.openFeatureStore("test",false); |
|
350 |
store2.edit(); |
|
351 |
utils().test_update(store2, 3, "CC2"); |
|
352 |
|
|
353 |
store2.finishEditing(); |
|
354 |
DisposeUtils.disposeQuietly(store2); |
|
355 |
|
|
356 |
// ------------------------------------------------------------ |
|
357 |
// Preparamos la actualización de (updatePrepare) la tabla "test" en el workspace2 |
|
358 |
// comprobamos que funciona y que tiene lo que toca. |
|
359 |
r = ws2.updatePrepare("test"); |
|
360 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
361 |
|
|
362 |
// Actualizamos (update) la tabla "test" en el workspace2 |
|
363 |
// comprobamos que falla |
|
364 |
r = ws2.update("test"); |
|
365 |
assertEquals("ws2.update-1 status", ERR_UPDATE_NEED_MERGE, r); |
|
366 |
|
|
367 |
//Seleccionar el cambio conflictivo id=4 |
|
368 |
utils().test_selectRemoteChange(ws2, true, 3, "CC1", ws1); |
|
369 |
|
|
370 |
// Actualizamos (merge) la tabla "test" en el workspace2 |
|
371 |
// comprobamos que no falla |
|
372 |
r = ws2.update("test"); |
|
373 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
374 |
|
|
375 |
//Comprobar que en la tabla de cambios locales no hay nada |
|
376 |
FeatureStore changes = ws2.getFeatureStore(WorkspaceChangesTable.TABLE_NAME); |
|
377 |
assertEquals("ws2-changes size", 0, changes.size64()); |
|
378 |
DisposeUtils.disposeQuietly(changes); |
|
379 |
|
|
380 |
} finally { |
|
381 |
server.stop(); |
|
382 |
} |
|
383 |
|
|
384 |
} |
|
385 |
|
|
386 |
public void testTwoInsertsAndUpdate() throws Exception { |
|
387 |
try { |
|
388 |
|
|
389 |
VCSGisWorkspace[] wss = initTest(); |
|
390 |
VCSGisWorkspace ws1 = wss[0]; |
|
391 |
VCSGisWorkspace ws2 = wss[1]; |
|
392 |
|
|
393 |
int r; |
|
394 |
Feature f; |
|
395 |
EditableFeature ef; |
|
396 |
List<Feature> features; |
|
397 |
FeatureStore store1; |
|
398 |
FeatureStore store2; |
|
399 |
|
|
400 |
// Añadimos al workspace1 una feature con una id concreta y la commitamos |
|
401 |
store1 = ws1.openFeatureStore("test",false); |
|
402 |
store1.edit(); |
|
403 |
utils().test_insert(store1, 4, "DD1"); |
|
404 |
|
|
405 |
store1.finishEditing(); |
|
406 |
DisposeUtils.disposeQuietly(store1); |
|
407 |
|
|
408 |
r = ws1.commit(); |
|
409 |
assertEquals("ws1.commit-1 status", ERR_NO_ERROR, r); |
|
410 |
|
|
411 |
// Añadimos al workspace2 una feature con la misma id |
|
412 |
store2 = ws2.openFeatureStore("test",false); |
|
413 |
store2.edit(); |
|
414 |
utils().test_insert(store2, 4, "DD2"); |
|
415 |
|
|
416 |
store2.finishEditing(); |
|
417 |
DisposeUtils.disposeQuietly(store2); |
|
418 |
|
|
419 |
// ------------------------------------------------------------ |
|
420 |
// Preparamos la actualización de (updatePrepare) la tabla "test" en el workspace2 |
|
421 |
// comprobamos que funciona y que tiene lo que toca. |
|
422 |
r = ws2.updatePrepare("test"); |
|
423 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
424 |
|
|
425 |
FeatureStore changes = ws2.getFeatureStore(WorkspaceChangesTable.TABLE_NAME); |
|
426 |
// See in console debug message with |
|
427 |
// "===: UPDATE_PREPARE: conflicts. { "id":4, ..." |
|
428 |
// and use here the value of the field VCSGISCODE |
|
429 |
utils().test_checkLocalChange(store2, changes, "00000000000036abcdef0123456789", OP_INSERT, 4, "DD2", STATE_CONFLICT); |
|
430 |
DisposeUtils.disposeQuietly(changes); |
|
431 |
|
|
432 |
// Actualizamos (update) la tabla "test" en el workspace2 |
|
433 |
// comprobamos que no falla |
|
434 |
r = ws2.update("test"); |
|
435 |
assertEquals("ws2.update-1 status", ERR_UPDATE_NEED_MERGE, r); |
|
436 |
|
|
437 |
//Seleccionar el cambio conflictivo id=4 |
|
438 |
utils().test_selectRemoteChange(ws2, true, 4, "DD1", ws1); |
|
439 |
|
|
440 |
//update y comprobar que funciona y se ha borrado la feature conflictiva nuestra |
|
441 |
r = ws2.update("test"); |
|
442 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
443 |
|
|
444 |
store2 = ws2.openFeatureStore("test",false); |
|
445 |
assertEquals("ws2-upfate sizes", 4, store2.size64()); |
|
446 |
features = store2.getFeatures((Expression) null, "id", true); |
|
447 |
|
|
448 |
utils().test_check(features, 0, 1, "AAA"); |
|
449 |
utils().test_check(features, 1, 2, "BBB"); |
|
450 |
utils().test_check(features, 2, 3, "CCC"); |
|
451 |
utils().test_check(features, 3, 4, "DD1"); |
|
452 |
|
|
453 |
//Comprobar que en la tabla de cambios locales no hay nada |
|
454 |
changes = ws2.getFeatureStore(WorkspaceChangesTable.TABLE_NAME); |
|
455 |
assertEquals("ws2-changes size", 0, changes.size64()); |
|
456 |
DisposeUtils.disposeQuietly(changes); |
|
457 |
} finally { |
|
458 |
server.stop(); |
|
459 |
} |
|
460 |
|
|
461 |
} |
|
462 |
|
|
463 |
public void testTwoInsertsAndMerge() throws Exception { |
|
464 |
try { |
|
465 |
|
|
466 |
VCSGisWorkspace[] wss = initTest(); |
|
467 |
VCSGisWorkspace ws1 = wss[0]; |
|
468 |
VCSGisWorkspace ws2 = wss[1]; |
|
469 |
|
|
470 |
int r; |
|
471 |
Feature f; |
|
472 |
EditableFeature ef; |
|
473 |
List<Feature> features; |
|
474 |
FeatureStore store1; |
|
475 |
FeatureStore store2; |
|
476 |
|
|
477 |
//Insertamos dos registros nuevos y repetirlo todo sin seleccionar cambio conflictivo y hacer un merge y que funcione |
|
478 |
// Añadimos al workspace1 una feature con una id concreta y la commitamos |
|
479 |
store1 = ws1.openFeatureStore("test",false); |
|
480 |
store1.edit(); |
|
481 |
utils().test_insert(store1, 4, "DD1"); |
|
482 |
|
|
483 |
store1.finishEditing(); |
|
484 |
DisposeUtils.disposeQuietly(store1); |
|
485 |
|
|
486 |
r = ws1.commit(); |
|
487 |
assertEquals("ws1.commit-1 status", ERR_NO_ERROR, r); |
|
488 |
|
|
489 |
// Añadimos al workspace2 una feature con la misma id |
|
490 |
store2 = ws2.openFeatureStore("test",false); |
|
491 |
store2.edit(); |
|
492 |
utils().test_insert(store2, 4, "DD2"); |
|
493 |
|
|
494 |
store2.finishEditing(); |
|
495 |
DisposeUtils.disposeQuietly(store2); |
|
496 |
|
|
497 |
// ------------------------------------------------------------ |
|
498 |
// Preparamos la actualización de (updatePrepare) la tabla "test" en el workspace2 |
|
499 |
// comprobamos que funciona y que tiene lo que toca. |
|
500 |
r = ws2.updatePrepare("test"); |
|
501 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
502 |
|
|
503 |
// Actualizamos (update) la tabla "test" en el workspace2 |
|
504 |
// comprobamos que falla |
|
505 |
r = ws2.update("test"); |
|
506 |
assertEquals("ws2.update-1 status", ERR_UPDATE_NEED_MERGE, r); |
|
507 |
|
|
508 |
//merge y comprobar que funciona y no se insertado el cambio conflictivo |
|
509 |
r = ws2.merge("test"); |
|
510 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
511 |
|
|
512 |
store2 = ws2.openFeatureStore("test",false); |
|
513 |
assertEquals("ws2-upfate sizes", 4, store2.size64()); |
|
514 |
features = store2.getFeatures((Expression) null, "id", true); |
|
515 |
|
|
516 |
utils().test_check(features, 0, 1, "AAA"); |
|
517 |
utils().test_check(features, 1, 2, "BBB"); |
|
518 |
utils().test_check(features, 2, 3, "CCC"); |
|
519 |
utils().test_check(features, 3, 4, "DD2"); |
|
520 |
|
|
521 |
//Comprobamos que se ha añadido a la tabla de cambios local el delete del cambio conflictivo |
|
522 |
FeatureStore changes = ws2.getFeatureStore(WorkspaceChangesTable.TABLE_NAME); |
|
523 |
assertEquals("ws2-changes size", 2, changes.size64()); |
|
524 |
|
|
525 |
// See in console debug message with |
|
526 |
// "===: UPDATE: add delete operation to RelatedFeatureCode ..." |
|
527 |
// and use here the value RelatedFeatureCode |
|
528 |
utils().test_checkLocalChange(store2, changes, "00000000000028abcdef0123456789", OP_DELETE, 4, "DD1", -1); |
|
529 |
|
|
530 |
// See in console debug message with |
|
531 |
// "===: UPDATE_PREPARE: conflicts. { "id":4, "text":"DD2"" |
|
532 |
// and use here the value of the field VCSGISCODE |
|
533 |
utils().test_checkLocalChange(store2, changes, "00000000000036abcdef0123456789", OP_INSERT, 4, "DD2", -1); |
|
534 |
DisposeUtils.disposeQuietly(changes); |
|
535 |
} finally { |
|
536 |
server.stop(); |
|
537 |
} |
|
538 |
|
|
539 |
} |
|
540 |
|
|
541 |
public void testOneCommitAndUpdateOverDeleted() throws Exception { |
|
542 |
try { |
|
543 |
|
|
544 |
VCSGisWorkspace[] wss = initTest(); |
|
545 |
VCSGisWorkspace ws1 = wss[0]; |
|
546 |
VCSGisWorkspace ws2 = wss[1]; |
|
547 |
List<Feature> features; |
|
548 |
|
|
549 |
int r; |
|
550 |
Feature f; |
|
551 |
EditableFeature ef; |
|
552 |
FeatureStore store1; |
|
553 |
FeatureStore store2; |
|
554 |
|
|
555 |
// Modificamos en workspace1 una feature con una id concreta y la commitamos |
|
556 |
store1 = ws1.openFeatureStore("test",false); |
|
557 |
store1.edit(); |
|
558 |
utils().test_update(store1, 3, "CC1"); |
|
559 |
|
|
560 |
store1.finishEditing(); |
|
561 |
DisposeUtils.disposeQuietly(store1); |
|
562 |
|
|
563 |
r = ws1.commit(); |
|
564 |
assertEquals("ws1.commit-1 status", ERR_NO_ERROR, r); |
|
565 |
|
|
566 |
// Borramos en el workspace2 la feature con la misma id |
|
567 |
store2 = ws2.openFeatureStore("test",false); |
|
568 |
store2.edit(); |
|
569 |
utils().test_delete(store2, 3, "CCC"); |
|
570 |
|
|
571 |
store2.finishEditing(); |
|
572 |
DisposeUtils.disposeQuietly(store2); |
|
573 |
|
|
574 |
// ------------------------------------------------------------ |
|
575 |
// Preparamos la actualización de (updatePrepare) la tabla "test" en el workspace2 |
|
576 |
// comprobamos que funciona y que tiene lo que toca. |
|
577 |
r = ws2.updatePrepare("test"); |
|
578 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
579 |
|
|
580 |
// assertTrue(false); |
|
581 |
// Actualizamos (update) la tabla "test" en el workspace2 |
|
582 |
// comprobamos que falla |
|
583 |
r = ws2.update("test"); |
|
584 |
assertEquals("ws2.update-1 status", ERR_UPDATE_NEED_MERGE, r); |
|
585 |
|
|
586 |
// // Actualizamos (merge) la tabla "test" en el workspace2 |
|
587 |
// // comprobamos que no falla |
|
588 |
// r = ws2.merge("test"); |
|
589 |
// assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
590 |
//Seleccionar el cambio conflictivo id=4 |
|
591 |
utils().test_selectRemoteChange(ws2, true, 3, "CC1", ws1); |
|
592 |
|
|
593 |
//update y comprobar que funciona y no se ha insertado la feature conflictiva |
|
594 |
r = ws2.update("test"); |
|
595 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
596 |
|
|
597 |
store2 = ws2.openFeatureStore("test",false); |
|
598 |
assertEquals("ws2-update sizes", 3, store2.size64()); |
|
599 |
features = store2.getFeatures((Expression) null, "id", true); |
|
600 |
|
|
601 |
utils().test_check(features, 0, 1, "AAA"); |
|
602 |
utils().test_check(features, 1, 2, "BBB"); |
|
603 |
utils().test_check(features, 2, 3, "CC1"); |
|
604 |
|
|
605 |
//Comprobar que en la tabla de cambios locales no hay nada |
|
606 |
FeatureStore changes = ws2.getFeatureStore(WorkspaceChangesTable.TABLE_NAME); |
|
607 |
assertEquals("ws2-changes size", 0, changes.size64()); |
|
608 |
DisposeUtils.disposeQuietly(changes); |
|
609 |
} finally { |
|
610 |
server.stop(); |
|
611 |
} |
|
612 |
|
|
613 |
} |
|
614 |
|
|
615 |
public void testOneCommitAndMergeOverDeleted() throws Exception { |
|
616 |
try { |
|
617 |
|
|
618 |
VCSGisWorkspace[] wss = initTest(); |
|
619 |
VCSGisWorkspace ws1 = wss[0]; |
|
620 |
VCSGisWorkspace ws2 = wss[1]; |
|
621 |
List<Feature> features; |
|
622 |
|
|
623 |
int r; |
|
624 |
Feature f; |
|
625 |
EditableFeature ef; |
|
626 |
FeatureStore store1; |
|
627 |
FeatureStore store2; |
|
628 |
|
|
629 |
// Modificamos en workspace1 una feature con una id concreta y la commitamos |
|
630 |
store1 = ws1.openFeatureStore("test",false); |
|
631 |
store1.edit(); |
|
632 |
utils().test_update(store1, 3, "CC1"); |
|
633 |
|
|
634 |
store1.finishEditing(); |
|
635 |
DisposeUtils.disposeQuietly(store1); |
|
636 |
|
|
637 |
r = ws1.commit(); |
|
638 |
assertEquals("ws1.commit-1 status", ERR_NO_ERROR, r); |
|
639 |
|
|
640 |
// Borramos en el workspace2 la feature con la misma id |
|
641 |
store2 = ws2.openFeatureStore("test",false); |
|
642 |
store2.edit(); |
|
643 |
utils().test_delete(store2, 3, "CCC"); |
|
644 |
|
|
645 |
store2.finishEditing(); |
|
646 |
DisposeUtils.disposeQuietly(store2); |
|
647 |
|
|
648 |
// ------------------------------------------------------------ |
|
649 |
// Preparamos la actualización de (updatePrepare) la tabla "test" en el workspace2 |
|
650 |
// comprobamos que funciona y que tiene lo que toca. |
|
651 |
r = ws2.updatePrepare("test"); |
|
652 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
653 |
|
|
654 |
// assertTrue(false); |
|
655 |
// Actualizamos (update) la tabla "test" en el workspace2 |
|
656 |
// comprobamos que falla |
|
657 |
// r = ws2.update("test"); |
|
658 |
// assertEquals("ws2.update-1 status", ERR_UPDATE_NEED_MERGE, r); |
|
659 |
// Actualizamos (merge) la tabla "test" en el workspace2 |
|
660 |
// comprobamos que no falla |
|
661 |
r = ws2.merge("test"); |
|
662 |
assertEquals("ws2.update-1 status", ERR_NO_ERROR, r); |
|
663 |
|
|
664 |
//Comprobamos que en workspace2 hay lo que toca |
|
665 |
store2 = ws2.openFeatureStore("test",false); |
|
666 |
assertEquals("ws2-update sizes", 2, store2.size64()); |
|
667 |
features = store2.getFeatures((Expression) null, "id", true); |
|
668 |
|
|
669 |
utils().test_check(features, 0, 1, "AAA"); |
|
670 |
utils().test_check(features, 1, 2, "BBB"); |
|
671 |
// check(features, 2, 3, "CC1"); |
|
672 |
|
|
673 |
//Comprobar que en la tabla de cambios locales permanece el cambio |
|
674 |
FeatureStore changes = ws2.getFeatureStore(WorkspaceChangesTable.TABLE_NAME); |
|
675 |
assertEquals("ws2-changes size", 1, changes.size64()); |
|
676 |
DisposeUtils.disposeQuietly(changes); |
|
677 |
} finally { |
|
678 |
server.stop(); |
|
679 |
} |
|
680 |
|
|
681 |
} |
|
682 |
|
|
683 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/src/test/java/org/gvsig/vcsgis/app/server/TestSrv02Entities.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.server; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URL; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Locale; |
|
7 |
import junit.framework.TestCase; |
|
8 |
import static junit.framework.TestCase.assertEquals; |
|
9 |
import org.apache.commons.io.FileUtils; |
|
10 |
import org.eclipse.jetty.server.Server; |
|
11 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
13 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
14 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
15 |
import static org.gvsig.vcsgis.app.server.TestServerUtils.createServer; |
|
16 |
import static org.gvsig.vcsgis.app.server.TestServerUtils.utils; |
|
17 |
import static org.gvsig.vcsgis.app.server.VCSGisJettyServerUtils.SERVER_PORT; |
|
18 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
19 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
|
20 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
|
21 |
import org.gvsig.vcsgis.lib.repository.VCSGisRepository; |
|
22 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
23 |
import org.slf4j.Logger; |
|
24 |
import org.slf4j.LoggerFactory; |
|
25 |
|
|
26 |
public class TestSrv02Entities extends TestCase { |
|
27 |
|
|
28 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestSrv02Entities.class); |
|
29 |
|
|
30 |
static{ |
|
31 |
Locale.setDefault(Locale.forLanguageTag("es-ES")); |
|
32 |
} |
|
33 |
|
|
34 |
public TestSrv02Entities(String testName) { |
|
35 |
super(testName); |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
protected void setUp() throws Exception { |
|
40 |
super.setUp(); |
|
41 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
protected void tearDown() throws Exception { |
|
46 |
super.tearDown(); |
|
47 |
} |
|
48 |
|
|
49 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
50 |
// public void testHello() {} |
|
51 |
public void testEntities() throws Exception { |
|
52 |
final String testid = "ServerAddCommit"; |
|
53 |
final URL serverUrl = new URL("http://localhost:" + SERVER_PORT + "/"); |
|
54 |
|
|
55 |
VCSGisManager vcsgismanager = VCSGisLocator.getVCSGisManager(); |
|
56 |
JDBCServerExplorerParameters explorerParams = utils().getRepositoryServerExplorerParameters("srv-" + testid); |
|
57 |
File wsfile = utils().getFile(FileUtils.getFile("test-dbs", "ws-" + testid)); |
|
58 |
|
|
59 |
// --------------------------------------------------------- |
|
60 |
// Creamos el server y obtenemos el repositorio del server |
|
61 |
int r = vcsgismanager.initRepository(explorerParams, null); |
|
62 |
assertEquals("srv-init status", 0, r); |
|
63 |
|
|
64 |
Server server = createServer(utils(),explorerParams); |
|
65 |
try { |
|
66 |
server.start(); |
|
67 |
|
|
68 |
VCSGisRepository repositoryRemote = vcsgismanager.openRepository(serverUrl); |
|
69 |
|
|
70 |
// --------------------------------------------------------- |
|
71 |
// Creamos un workspace y preparamos los datos en el para hacer un commit |
|
72 |
r = vcsgismanager.initWorkspace(wsfile, repositoryRemote, "Test add and commit", null); |
|
73 |
assertEquals("ws-init status", 0, r); |
|
74 |
|
|
75 |
VCSGisWorkspace ws = vcsgismanager.openWorkspace(wsfile); |
|
76 |
utils().info_workspace(ws); |
|
77 |
|
|
78 |
FeatureStore sourceStore = utils().openSourceStore1(); |
|
79 |
long expectedRows = sourceStore.getFeatureCount(); |
|
80 |
|
|
81 |
r = ws.add("sourceStore1", sourceStore, "ID"); |
|
82 |
assertEquals("ws-add status", 0, r); |
|
83 |
|
|
84 |
DisposeUtils.disposeQuietly(sourceStore); |
|
85 |
|
|
86 |
r = ws.commit(); |
|
87 |
assertEquals("ws-commit status", 0, r); |
|
88 |
|
|
89 |
// --------------------------------------------------------- |
|
90 |
// Comprobamos que en el server esta la tabla que acabamos de adicionar |
|
91 |
ws.updateEntitiesFromRepository(null); |
|
92 |
List<VCSGisEntity> rentities = ws.getRepositoryEntities(); |
|
93 |
assertEquals("Num entities in server", 1, rentities.size()); |
|
94 |
assertEquals("Name of the entity in server", "sourceStore1", rentities.get(0).getEntityName()); |
|
95 |
} finally { |
|
96 |
server.stop(); |
|
97 |
} |
|
98 |
} |
|
99 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.50/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.server/src/test/java/org/gvsig/vcsgis/app/server/TestSrv05Update.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.server; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URL; |
|
5 |
import java.sql.Timestamp; |
|
6 |
import java.util.List; |
|
7 |
import java.util.Locale; |
|
8 |
import junit.framework.TestCase; |
|
9 |
import static junit.framework.TestCase.assertEquals; |
|
10 |
import static junit.framework.TestCase.assertNotNull; |
|
11 |
import org.apache.commons.io.FileUtils; |
|
12 |
import org.eclipse.jetty.server.Server; |
|
13 |
import org.gvsig.expressionevaluator.Expression; |
|
14 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
15 |
import org.gvsig.fmap.dal.feature.Feature; |
|
16 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
17 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
18 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
19 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
20 |
import static org.gvsig.vcsgis.app.server.TestServerUtils.createServer; |
|
21 |
import static org.gvsig.vcsgis.app.server.TestServerUtils.utils; |
|
22 |
import static org.gvsig.vcsgis.app.server.VCSGisJettyServerUtils.SERVER_PORT; |
|
23 |
import org.gvsig.vcsgis.lib.SequentialCodeGenerator; |
|
24 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
25 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
|
26 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
|
27 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_NO_ERROR; |
|
28 |
import org.gvsig.vcsgis.lib.repository.VCSGisRepository; |
|
29 |
import org.gvsig.vcsgis.lib.repository.localdb.VCSGisRepositoryLocaldbImpl; |
|
30 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
31 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
|
32 |
import org.slf4j.Logger; |
|
33 |
import org.slf4j.LoggerFactory; |
|
34 |
|
|
35 |
public class TestSrv05Update extends TestCase { |
|
36 |
|
|
37 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestSrv05Update.class); |
|
38 |
|
|
39 |
static{ |
|
40 |
Locale.setDefault(Locale.forLanguageTag("es-ES")); |
|
41 |
} |
|
42 |
|
|
43 |
public TestSrv05Update(String testName) { |
|
44 |
super(testName); |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
protected void setUp() throws Exception { |
|
49 |
super.setUp(); |
|
50 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
protected void tearDown() throws Exception { |
|
55 |
super.tearDown(); |
|
56 |
} |
Also available in: Unified diff