Revision 1023
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/postgresql.properties | ||
---|---|---|
1 |
PostgreSQLEnabled=false |
|
2 |
PostgreSQLHost=127.0.0.1 |
|
3 |
PostgreSQLPort=5532 |
|
4 |
PostgreSQLDbname=gvsigdb |
|
5 |
PostgreSQLSchema=public |
|
6 |
PostgreSQLUser=gvsig |
|
7 |
PostgreSQLPassword=gvsig |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/testCreateSource1.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=30;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) |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/tableIsEmpty.sql | ||
---|---|---|
1 |
|
|
2 |
-- Table is empty |
|
3 |
SELECT * FROM "dbtest"."public"."test" LIMIT 1; |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/performChanges.sql | ||
---|---|---|
1 |
|
|
2 |
-- Insert SQL |
|
3 |
INSERT INTO "dbtest"."public"."test" ( |
|
4 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
5 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", |
|
6 |
"Decimal", "Geometry" |
|
7 |
) VALUES ( |
|
8 |
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ST_GeomFromWKB((?), (?)) |
|
9 |
); |
|
10 |
|
|
11 |
-- Delete SQL |
|
12 |
DELETE FROM "dbtest"."public"."test" WHERE ( ("ID") = (?) ); |
|
13 |
|
|
14 |
-- Update SQL |
|
15 |
UPDATE "dbtest"."public"."test" |
|
16 |
SET |
|
17 |
"Byte" = ?, |
|
18 |
"Bool1" = ?, |
|
19 |
"Long" = ?, |
|
20 |
"Timestamp" = ?, |
|
21 |
"Date" = ?, |
|
22 |
"Time" = ?, |
|
23 |
"Bool2" = ?, |
|
24 |
"String" = ?, |
|
25 |
"Bool3" = ?, |
|
26 |
"Double" = ?, |
|
27 |
"Bool4" = ?, |
|
28 |
"Float" = ?, |
|
29 |
"Bool5" = ?, |
|
30 |
"Decimal" = ?, |
|
31 |
"Geometry" = ST_GeomFromWKB((?), (?)) |
|
32 |
WHERE |
|
33 |
( ("ID") = (?) ); |
|
34 |
|
|
35 |
|
|
36 |
-- Update Table SQL |
|
37 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Byte" TINYINT DEFAULT NULL NULL; |
|
38 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Bool1" BOOLEAN DEFAULT NULL NULL; |
|
39 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Long" BIGINT DEFAULT NULL NULL; |
|
40 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Timestamp" TIMESTAMP DEFAULT NULL NULL; |
|
41 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Date" DATE DEFAULT NULL NULL; |
|
42 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Time" TIME DEFAULT NULL NULL; |
|
43 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Bool2" BOOLEAN DEFAULT NULL NULL; |
|
44 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "String" VARCHAR(30) DEFAULT NULL NULL; |
|
45 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Bool3" BOOLEAN DEFAULT NULL NULL; |
|
46 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Double" DOUBLE PRECISION DEFAULT NULL NULL; |
|
47 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Bool4" BOOLEAN DEFAULT NULL NULL; |
|
48 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Float" REAL DEFAULT NULL NULL; |
|
49 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Bool5" BOOLEAN DEFAULT NULL NULL; |
|
50 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Decimal" NUMERIC(6,3) DEFAULT NULL NULL; |
|
51 |
ALTER TABLE "dbtest"."public"."test" ADD COLUMN "Geometry" TEXT DEFAULT NULL NULL; |
|
52 |
|
|
53 |
-- FIXME: El ALTER TABLE de una columna geometria no funciona |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/updateTableStatistics.sql | ||
---|---|---|
1 |
|
|
2 |
-- UpdateTableStatistics SQL |
|
3 |
ANALYZE "public"."test"; |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/testJsonValue.sql | ||
---|---|---|
1 |
|
|
2 |
-- test Json Value Function SQL |
|
3 |
|
|
4 |
-- JsonValueWhere |
|
5 |
SELECT "ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", "Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", ST_AsBinary("Geometry"), jsonb_path_query_first("String"::jsonb, '$.acc_cit') AS "JsonValue1" FROM "dbtest"."public"."test" WHERE (jsonb_path_query_first("String"::jsonb, '$.acc_cit') = 1) ORDER BY "ID" ASC NULLS LAST; |
|
6 |
|
|
7 |
-- Count |
|
8 |
|
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/append.sql | ||
---|---|---|
1 |
|
|
2 |
-- Previous SQLs |
|
3 |
|
|
4 |
-- Inser SQL |
|
5 |
|
|
6 |
INSERT INTO "dbtest"."public"."test" ( |
|
7 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
8 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", |
|
9 |
"Decimal", "Geometry" |
|
10 |
) VALUES ( |
|
11 |
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ST_GeomFromWKB((?), (?)) |
|
12 |
); |
|
13 |
|
|
14 |
-- Post SQLs |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/fetchFeatureType.sql | ||
---|---|---|
1 |
|
|
2 |
-- FetchFeatureType first row SQL |
|
3 |
SELECT * FROM "dbtest"."public"."test" LIMIT 1; |
|
4 |
|
|
5 |
-- FetchFeatureType get primery keys SQL |
|
6 |
SELECT |
|
7 |
"COLUMN_NAME", "CONSTRAINT_TYPE" |
|
8 |
FROM INFORMATION_SCHEMA.table_constraints t_cons |
|
9 |
inner join INFORMATION_SCHEMA.key_column_usage c |
|
10 |
on c.constraint_catalog = t_cons.constraint_catalog and |
|
11 |
c.table_schema = t_cons.table_schema and |
|
12 |
c.table_name = t_cons.table_name and |
|
13 |
c.constraint_name = t_cons.constraint_name |
|
14 |
WHERE ((( (c.TABLE_NAME) LIKE ('test') ) AND |
|
15 |
( (c.TABLE_SCHEMA) LIKE ('public') )) AND |
|
16 |
( ("CONSTRAINT_TYPE") = ('PRIMARY KEY') ) |
|
17 |
); |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/count.sql | ||
---|---|---|
1 |
|
|
2 |
-- Count SQL |
|
3 |
SELECT COUNT(*) FROM "dbtest"."public"."test"; |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/resultSetForSetProvider.sql | ||
---|---|---|
1 |
|
|
2 |
-- ResultSetForSetProvider SQL |
|
3 |
SELECT |
|
4 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
5 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
6 |
ST_AsBinary("Geometry") |
|
7 |
FROM "dbtest"."public"."test" ORDER BY "ID" ASC NULLS LAST; |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/fetchFeatureProviderByReference.sql | ||
---|---|---|
1 |
|
|
2 |
-- FetchFeatureProviderByReference SQL |
|
3 |
|
|
4 |
SELECT |
|
5 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", "Bool2", |
|
6 |
"String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
7 |
ST_AsBinary("Geometry") |
|
8 |
FROM "dbtest"."public"."test" |
|
9 |
WHERE ( ("ID") = (?) ) LIMIT 1; |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/calculateEnvelope.sql | ||
---|---|---|
1 |
|
|
2 |
-- Count SQL |
|
3 |
|
|
4 |
SELECT |
|
5 |
ST_AsBinary(ST_Extent("Geometry")) |
|
6 |
FROM "dbtest"."public"."test" |
|
7 |
WHERE ( ("Geometry") IS NOT NULL ); |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/createTable.sql | ||
---|---|---|
1 |
|
|
2 |
-- Se usa en TestCreateTable. |
|
3 |
-- Se corresponde con el fichero CSV "testCreateSource1.csv". |
|
4 |
|
|
5 |
CREATE TABLE "dbtest"."public"."test" ( |
|
6 |
"ID" INT NOT NULL PRIMARY KEY, |
|
7 |
"Byte" TINYINT DEFAULT NULL NULL, |
|
8 |
"Bool1" BOOLEAN DEFAULT NULL NULL, |
|
9 |
"Long" BIGINT DEFAULT NULL NULL, |
|
10 |
"Timestamp" TIMESTAMP DEFAULT NULL NULL, |
|
11 |
"Date" DATE DEFAULT NULL NULL, |
|
12 |
"Time" TIME DEFAULT NULL NULL, |
|
13 |
"Bool2" BOOLEAN DEFAULT NULL NULL, |
|
14 |
"String" VARCHAR(30) DEFAULT NULL NULL, |
|
15 |
"Bool3" BOOLEAN DEFAULT NULL NULL, |
|
16 |
"Double" DOUBLE PRECISION DEFAULT NULL NULL, |
|
17 |
"Bool4" BOOLEAN DEFAULT NULL NULL, |
|
18 |
"Float" REAL DEFAULT NULL NULL, |
|
19 |
"Bool5" BOOLEAN DEFAULT NULL NULL, |
|
20 |
"Decimal" NUMERIC(6,3) DEFAULT NULL NULL |
|
21 |
); |
|
22 |
|
|
23 |
SELECT AddGeometryColumn('public' , 'test' , 'Geometry', 4326 , 'POINT' , 2, TRUE); |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/dropTable.sql | ||
---|---|---|
1 |
|
|
2 |
-- Count SQL |
|
3 |
DROP TABLE "dbtest"."public"."test"; |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/usecases/arena2/testMultipleExpansionOfCalculatedField.sql | ||
---|---|---|
1 |
|
|
2 |
-- testToDoubleWithSpecialFunctions SQL |
|
3 |
|
|
4 |
-- Select |
|
5 |
SELECT "dbtest"."public"."ARENA2_CONDUCTORES"."LID_CONDUCTOR", "dbtest"."public"."ARENA2_CONDUCTORES"."ID_ACCIDENTE", |
|
6 |
"dbtest"."public"."ARENA2_CONDUCTORES"."LID_VEHICULO", "dbtest"."public"."ARENA2_CONDUCTORES"."ID_VEHICULO", |
|
7 |
"dbtest"."public"."ARENA2_CONDUCTORES"."POSIBLE_RESPONSABLE", "dbtest"."public"."ARENA2_CONDUCTORES"."FECHA_NACIMIENTO", |
|
8 |
"dbtest"."public"."ARENA2_CONDUCTORES"."SEXO", "dbtest"."public"."ARENA2_CONDUCTORES"."NACIONALIDAD", |
|
9 |
"dbtest"."public"."ARENA2_CONDUCTORES"."PAIS_RESIDENCIA", "dbtest"."public"."ARENA2_CONDUCTORES"."PROVINCIA_RESIDENCIA", |
|
10 |
"dbtest"."public"."ARENA2_CONDUCTORES"."MUNICIPIO_RESIDENCIA", "dbtest"."public"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA", |
|
11 |
"dbtest"."public"."ARENA2_CONDUCTORES"."INFLU_FACT_ATENCION", "dbtest"."public"."ARENA2_CONDUCTORES"."FACTORES_ATENCION", |
|
12 |
"dbtest"."public"."ARENA2_CONDUCTORES"."INFLU_PRES_ERROR", "dbtest"."public"."ARENA2_CONDUCTORES"."PRESUNTOS_ERRORES", |
|
13 |
"dbtest"."public"."ARENA2_CONDUCTORES"."CARACT_PERMISO", "dbtest"."public"."ARENA2_CONDUCTORES"."CLASE_PERMISO", |
|
14 |
"dbtest"."public"."ARENA2_CONDUCTORES"."FECHA_PERMISO", "dbtest"."public"."ARENA2_CONDUCTORES"."MOTIVO_DESPLAZAMIENTO", |
|
15 |
"dbtest"."public"."ARENA2_CONDUCTORES"."DESPLAZAMIENTO_PREVISTO", "dbtest"."public"."ARENA2_CONDUCTORES"."ACC_SEG_CINTURON", |
|
16 |
"dbtest"."public"."ARENA2_CONDUCTORES"."ACC_SEG_CASCO", "dbtest"."public"."ARENA2_CONDUCTORES"."ACC_SEG_BRAZOS", |
|
17 |
"dbtest"."public"."ARENA2_CONDUCTORES"."ACC_SEG_ESPALDA", "dbtest"."public"."ARENA2_CONDUCTORES"."ACC_SEG_TORSO", |
|
18 |
"dbtest"."public"."ARENA2_CONDUCTORES"."ACC_SEG_MANOS", "dbtest"."public"."ARENA2_CONDUCTORES"."ACC_SEG_PIERNAS", |
|
19 |
"dbtest"."public"."ARENA2_CONDUCTORES"."ACC_SEG_PIES", "dbtest"."public"."ARENA2_CONDUCTORES"."ACC_SEG_PRENDA_REF", |
|
20 |
"dbtest"."public"."ARENA2_CONDUCTORES"."INFLU_ALCOHOL", "dbtest"."public"."ARENA2_CONDUCTORES"."PRUEBA_ALCOHOLEMIA", |
|
21 |
"dbtest"."public"."ARENA2_CONDUCTORES"."TASA_ALCOHOLEMIA1", "dbtest"."public"."ARENA2_CONDUCTORES"."TASA_ALCOHOLEMIA2", |
|
22 |
"dbtest"."public"."ARENA2_CONDUCTORES"."PRUEBA_ALC_SANGRE", "dbtest"."public"."ARENA2_CONDUCTORES"."SIGNOS_INFLU_ALCOHOL", |
|
23 |
"dbtest"."public"."ARENA2_CONDUCTORES"."INFLU_DROGAS", "dbtest"."public"."ARENA2_CONDUCTORES"."PRUEBA_DROGAS", |
|
24 |
"dbtest"."public"."ARENA2_CONDUCTORES"."AMP", "dbtest"."public"."ARENA2_CONDUCTORES"."CONFIRMADO_AMP", |
|
25 |
"dbtest"."public"."ARENA2_CONDUCTORES"."BDZ", "dbtest"."public"."ARENA2_CONDUCTORES"."CONFIRMADO_BDZ", |
|
26 |
"dbtest"."public"."ARENA2_CONDUCTORES"."COC", "dbtest"."public"."ARENA2_CONDUCTORES"."CONFIRMADO_COC", "dbtest"."public"."ARENA2_CONDUCTORES"."THC", |
|
27 |
"dbtest"."public"."ARENA2_CONDUCTORES"."CONFIRMADO_THC", "dbtest"."public"."ARENA2_CONDUCTORES"."METH", |
|
28 |
"dbtest"."public"."ARENA2_CONDUCTORES"."CONFIRMADO_METH", "dbtest"."public"."ARENA2_CONDUCTORES"."OPI", "dbtest"."public"."ARENA2_CONDUCTORES"."CONFIRMADO_OPI", |
|
29 |
"dbtest"."public"."ARENA2_CONDUCTORES"."OTRAS", "dbtest"."public"."ARENA2_CONDUCTORES"."CONFIRMADO_OTRAS", |
|
30 |
"dbtest"."public"."ARENA2_CONDUCTORES"."SIGNOS_INFLU_DROGAS", "dbtest"."public"."ARENA2_CONDUCTORES"."INFLU_PRES_INFRAC_COND", |
|
31 |
"dbtest"."public"."ARENA2_CONDUCTORES"."PRES_INFRAC_COND", "dbtest"."public"."ARENA2_CONDUCTORES"."PRES_INFRAC_SIN_LUCES", |
|
32 |
"dbtest"."public"."ARENA2_CONDUCTORES"."PRES_INFRAC_SIN_TRIANGULO", "dbtest"."public"."ARENA2_CONDUCTORES"."INFLU_PRES_INFRAC_VEL", |
|
33 |
"dbtest"."public"."ARENA2_CONDUCTORES"."PRES_INFRAC_VEL_COND", "dbtest"."public"."ARENA2_CONDUCTORES"."INFLU_OTRA_INFRAC", |
|
34 |
"dbtest"."public"."ARENA2_CONDUCTORES"."OTRA_INFRAC_COND", "dbtest"."public"."ARENA2_CONDUCTORES"."EXTRA", |
|
35 |
"dbtest"."public"."ARENA2_ACCIDENTES"."KM" AS "AccKm0", |
|
36 |
("dbtest"."public"."ARENA2_ACCIDENTES"."KM" * 100) AS "AccKm1", |
|
37 |
("dbtest"."public"."ARENA2_ACCIDENTES"."KM" * 222) AS "AccKm2", |
|
38 |
"dbtest"."public"."ARENA2_ACCIDENTES"."KM" |
|
39 |
FROM "dbtest"."public"."ARENA2_CONDUCTORES" |
|
40 |
LEFT JOIN "dbtest"."public"."ARENA2_ACCIDENTES" ON ( ("dbtest"."public"."ARENA2_CONDUCTORES"."ID_ACCIDENTE") = ("dbtest"."public"."ARENA2_ACCIDENTES"."ID_ACCIDENTE") ) |
|
41 |
ORDER BY "LID_CONDUCTOR" ASC NULLS LAST LIMIT 15; |
|
42 |
|
|
43 |
-- Count |
|
44 |
SELECT COUNT(*) FROM "dbtest"."public"."ARENA2_CONDUCTORES"; |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/usecases/arena2/TestMultipleExpansionOfCalculatedField.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.usecases.arena2; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.store.jdbc2.AbstractTestUtils; |
|
4 |
import org.gvsig.fmap.dal.store.jdbc2.operations.usecases.arena2.AbstractTestMultipleExpansionOfCalculatedField; |
|
5 |
import org.gvsig.postgresql.dal.TestUtilsPostgreSQL; |
|
6 |
|
|
7 |
@SuppressWarnings("UseSpecificCatch") |
|
8 |
public class TestMultipleExpansionOfCalculatedField extends AbstractTestMultipleExpansionOfCalculatedField { |
|
9 |
|
|
10 |
public TestMultipleExpansionOfCalculatedField(String testName) { |
|
11 |
super(testName); |
|
12 |
} |
|
13 |
|
|
14 |
@Override |
|
15 |
protected AbstractTestUtils createUtils() { |
|
16 |
return new TestUtilsPostgreSQL(); |
|
17 |
} |
|
18 |
|
|
19 |
@Override |
|
20 |
public void testMultipleExpansionOfCalculatedField() throws Exception { |
|
21 |
super.testMultipleExpansionOfCalculatedField(); |
|
22 |
} |
|
23 |
|
|
24 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/sql/TestJsonValue.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.sql; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.store.jdbc2.AbstractTestJsonValue; |
|
4 |
import org.gvsig.fmap.dal.store.jdbc2.AbstractTestUtils; |
|
5 |
import org.gvsig.postgresql.dal.TestUtilsPostgreSQL; |
|
6 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
7 |
import org.slf4j.Logger; |
|
8 |
import org.slf4j.LoggerFactory; |
|
9 |
|
|
10 |
public class TestJsonValue extends AbstractTestJsonValue { |
|
11 |
|
|
12 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestJsonValue.class); |
|
13 |
|
|
14 |
public TestJsonValue(String testName) { |
|
15 |
super(testName); |
|
16 |
} |
|
17 |
|
|
18 |
@Override |
|
19 |
protected void setUp() throws Exception { |
|
20 |
super.setUp(); |
|
21 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
22 |
} |
|
23 |
|
|
24 |
@Override |
|
25 |
protected void tearDown() throws Exception { |
|
26 |
super.tearDown(); |
|
27 |
} |
|
28 |
|
|
29 |
@Override |
|
30 |
protected AbstractTestUtils createUtils() { |
|
31 |
return new TestUtilsPostgreSQL(); |
|
32 |
} |
|
33 |
|
|
34 |
public void testJsonValue() throws Exception { |
|
35 |
super.testJsonValue(); |
|
36 |
} |
|
37 |
|
|
38 |
|
|
39 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/sql/TestAppend.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.sql; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
import junit.framework.TestCase; |
|
6 |
import org.gvsig.fmap.dal.DataTypes; |
|
7 |
import org.gvsig.fmap.dal.feature.Feature; |
|
8 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
14 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
15 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.AppendOperation; |
|
16 |
import org.gvsig.postgresql.dal.TestUtils; |
|
17 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
18 |
import org.slf4j.Logger; |
|
19 |
import org.slf4j.LoggerFactory; |
|
20 |
|
|
21 |
public class TestAppend extends TestCase { |
|
22 |
|
|
23 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestAppend.class); |
|
24 |
|
|
25 |
public TestAppend(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 testAppend() throws Exception { |
|
44 |
JDBCHelper helper = TestUtils.getJDBCHelper(); |
|
45 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
46 |
OperationsFactory operations = helper.getOperations(); |
|
47 |
|
|
48 |
List<String> expectedSQLs = TestUtils.getSQLs("append.sql"); |
|
49 |
|
|
50 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
51 |
|
|
52 |
TableReference table = operations.createTableReference( |
|
53 |
"dbtest", |
|
54 |
sqlbuilder.default_schema(), |
|
55 |
"test", |
|
56 |
null |
|
57 |
); |
|
58 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
59 |
AppendOperation append = operations.createAppend( |
|
60 |
table, |
|
61 |
featureType |
|
62 |
); |
|
63 |
append.begin(); |
|
64 |
List<String> SQLs = new ArrayList<>(); |
|
65 |
SQLs.addAll(append.getPreviousSQLs()); |
|
66 |
SQLs.add( append.getSQL()); |
|
67 |
SQLs.addAll(append.getPostSQLs()); |
|
68 |
assertEquals("Append num SQLs", expectedSQLs.size(), SQLs.size()); |
|
69 |
for (int i = 0; i < expectedSQLs.size(); i++) { |
|
70 |
assertEquals("Append SQL "+i, expectedSQLs.get(i), SQLs.get(i)); |
|
71 |
} |
|
72 |
|
|
73 |
for (Feature sourceFeature : sourceStore.getFeatureSet()) { |
|
74 |
List<Object> parametersSQL = append.getSQLParameters(TestUtils.getFeatureProvider(sourceFeature)); |
|
75 |
List<Object> expectedParameters = this.getExpectedparameters(sourceFeature); |
|
76 |
assertEquals("Append num. parameters", parametersSQL.size(), expectedParameters.size()); |
|
77 |
for (int i = 0; i < expectedParameters.size(); i++) { |
|
78 |
assertEquals("Append parameter "+i, expectedParameters.get(i), parametersSQL.get(i)); |
|
79 |
} |
|
80 |
} |
|
81 |
append.end(); |
|
82 |
} |
|
83 |
|
|
84 |
private List<Object> getExpectedparameters(Feature sourceFeature) { |
|
85 |
FeatureType ft = sourceFeature.getType(); |
|
86 |
List<Object> values = new ArrayList<>(); |
|
87 |
for (FeatureAttributeDescriptor attr : ft) { |
|
88 |
Object v = sourceFeature.get(attr.getIndex()); |
|
89 |
values.add(v); |
|
90 |
if( attr.getType()==DataTypes.GEOMETRY ) { |
|
91 |
String srs = attr.getSRS().getAbrev(); |
|
92 |
values.add(Integer.parseInt(srs.split(":")[1])); |
|
93 |
} |
|
94 |
} |
|
95 |
return values; |
|
96 |
} |
|
97 |
|
|
98 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/sql/TestFetchFeatureType.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.sql; |
|
2 |
|
|
3 |
import java.util.Collections; |
|
4 |
import java.util.List; |
|
5 |
import junit.framework.TestCase; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
7 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation; |
|
13 |
import org.gvsig.postgresql.dal.TestUtils; |
|
14 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
15 |
import org.slf4j.Logger; |
|
16 |
import org.slf4j.LoggerFactory; |
|
17 |
|
|
18 |
public class TestFetchFeatureType extends TestCase { |
|
19 |
|
|
20 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestFetchFeatureType.class); |
|
21 |
|
|
22 |
public TestFetchFeatureType(String testName) { |
|
23 |
super(testName); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
protected void setUp() throws Exception { |
|
28 |
super.setUp(); |
|
29 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
protected void tearDown() throws Exception { |
|
34 |
super.tearDown(); |
|
35 |
} |
|
36 |
|
|
37 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
38 |
// public void testHello() {} |
|
39 |
|
|
40 |
public void testFetchFeatureType() throws Exception { |
|
41 |
JDBCHelper helper = TestUtils.getJDBCHelper(); |
|
42 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
43 |
OperationsFactory operations = helper.getOperations(); |
|
44 |
|
|
45 |
List<String> expectedSQLs = TestUtils.getSQLs("fetchFeatureType.sql"); |
|
46 |
|
|
47 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
48 |
|
|
49 |
TableReference table = operations.createTableReference( |
|
50 |
"dbtest", |
|
51 |
sqlbuilder.default_schema(), |
|
52 |
"test", |
|
53 |
null |
|
54 |
); |
|
55 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
56 |
FetchFeatureTypeOperation fetchFeatureType = operations.createFetchFeatureType( |
|
57 |
featureType.getEditable(), |
|
58 |
table, |
|
59 |
Collections.EMPTY_LIST, |
|
60 |
null, // "Geometry" |
|
61 |
featureType.getDefaultSRS() |
|
62 |
); |
|
63 |
|
|
64 |
|
|
65 |
String retrieveFirstRowOfTableSQL = fetchFeatureType.getSQLToRetrieveFirstRowOfTable(); |
|
66 |
String retrievePrimaryKeysFromInformationSchemaSQL = fetchFeatureType.getSQLToRetrievePrimaryKeysFromInformationSchema(); |
|
67 |
|
|
68 |
assertEquals("FetchFeatureType first row SQL", expectedSQLs.get(0), retrieveFirstRowOfTableSQL); |
|
69 |
assertEquals("FetchFeatureType get primery keys SQL", expectedSQLs.get(1), retrievePrimaryKeysFromInformationSchemaSQL); |
|
70 |
} |
|
71 |
|
|
72 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/sql/TestCount.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CountOperation; |
|
12 |
import org.gvsig.postgresql.dal.TestUtils; |
|
13 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
14 |
import org.slf4j.Logger; |
|
15 |
import org.slf4j.LoggerFactory; |
|
16 |
|
|
17 |
public class TestCount extends TestCase { |
|
18 |
|
|
19 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestCount.class); |
|
20 |
|
|
21 |
public TestCount(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 testCount() throws Exception { |
|
40 |
JDBCHelper helper = TestUtils.getJDBCHelper(); |
|
41 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
42 |
OperationsFactory operations = helper.getOperations(); |
|
43 |
|
|
44 |
List<String> expectedSQLs = TestUtils.getSQLs("count.sql"); |
|
45 |
|
|
46 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
47 |
|
|
48 |
TableReference table = operations.createTableReference( |
|
49 |
"dbtest", |
|
50 |
sqlbuilder.default_schema(), |
|
51 |
"test", |
|
52 |
null |
|
53 |
); |
|
54 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
55 |
CountOperation count = operations.createCount( |
|
56 |
featureType, |
|
57 |
table, |
|
58 |
null, null |
|
59 |
); |
|
60 |
|
|
61 |
String sql = count.getSQL(); |
|
62 |
assertEquals("Count SQL", expectedSQLs.get(0), sql); |
|
63 |
} |
|
64 |
|
|
65 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/sql/TestResultSetForSetProvider.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ResultSetForSetProviderOperation; |
|
12 |
import org.gvsig.postgresql.dal.TestUtils; |
|
13 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
14 |
import org.slf4j.Logger; |
|
15 |
import org.slf4j.LoggerFactory; |
|
16 |
|
|
17 |
public class TestResultSetForSetProvider extends TestCase { |
|
18 |
|
|
19 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestResultSetForSetProvider.class); |
|
20 |
|
|
21 |
public TestResultSetForSetProvider(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 testResultSetForSetProvider() throws Exception { |
|
40 |
JDBCHelper helper = TestUtils.getJDBCHelper(); |
|
41 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
42 |
OperationsFactory operations = helper.getOperations(); |
|
43 |
|
|
44 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
|
45 |
|
|
46 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
47 |
|
|
48 |
TableReference table = operations.createTableReference( |
|
49 |
"dbtest", |
|
50 |
sqlbuilder.default_schema(), |
|
51 |
"test", |
|
52 |
null |
|
53 |
); |
|
54 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
55 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
|
56 |
table, |
|
57 |
null, |
|
58 |
null, |
|
59 |
null, |
|
60 |
featureType, |
|
61 |
featureType, |
|
62 |
0, |
|
63 |
0, |
|
64 |
0 |
|
65 |
); |
|
66 |
String sql = resultSetForSetProvider.getSQL(); |
|
67 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(0), sql); |
|
68 |
} |
|
69 |
|
|
70 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/sql/TestFetchFeatureProviderByReference.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.Feature; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
7 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
8 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
9 |
import org.gvsig.fmap.dal.feature.impl.featurereference.FeatureReferenceFactory; |
|
10 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
14 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
15 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureProviderByReferenceOperation; |
|
16 |
import org.gvsig.postgresql.dal.TestUtils; |
|
17 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
18 |
import org.slf4j.Logger; |
|
19 |
import org.slf4j.LoggerFactory; |
|
20 |
|
|
21 |
public class TestFetchFeatureProviderByReference extends TestCase { |
|
22 |
|
|
23 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestFetchFeatureProviderByReference.class); |
|
24 |
|
|
25 |
public TestFetchFeatureProviderByReference(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 testFetchFeatureProviderByReference() throws Exception { |
|
44 |
JDBCHelper helper = TestUtils.getJDBCHelper(); |
|
45 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
46 |
OperationsFactory operations = helper.getOperations(); |
|
47 |
|
|
48 |
List<String> expectedSQLs = TestUtils.getSQLs("fetchFeatureProviderByReference.sql"); |
|
49 |
|
|
50 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
51 |
TableReference table = operations.createTableReference( |
|
52 |
"dbtest", |
|
53 |
sqlbuilder.default_schema(), |
|
54 |
"test", |
|
55 |
null |
|
56 |
); |
|
57 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
58 |
Feature feature = sourceStore.getFeatures().get(1); |
|
59 |
FeatureReference reference = FeatureReferenceFactory.createReferencePKFromFeature(feature); |
|
60 |
|
|
61 |
FetchFeatureProviderByReferenceOperation fetchFeatureProviderByReference = operations.createFetchFeatureProviderByReference( |
|
62 |
(FeatureReferenceProviderServices) reference, |
|
63 |
featureType, |
|
64 |
table |
|
65 |
); |
|
66 |
|
|
67 |
String sql = fetchFeatureProviderByReference.getSQL(); |
|
68 |
assertEquals("FetchFeatureProviderByReference SQL", expectedSQLs.get(0), sql); |
|
69 |
} |
|
70 |
|
|
71 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/sql/TestCalculateEnvelope.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CalculateEnvelopeOfColumnOperation; |
|
12 |
import org.gvsig.postgresql.dal.TestUtils; |
|
13 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
14 |
import org.slf4j.Logger; |
|
15 |
import org.slf4j.LoggerFactory; |
|
16 |
|
|
17 |
public class TestCalculateEnvelope extends TestCase { |
|
18 |
|
|
19 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestCalculateEnvelope.class); |
|
20 |
|
|
21 |
public TestCalculateEnvelope(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 testCalculateEnvelope() throws Exception { |
|
40 |
JDBCHelper helper = TestUtils.getJDBCHelper(); |
|
41 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
42 |
OperationsFactory operations = helper.getOperations(); |
|
43 |
|
|
44 |
List<String> expectedSQLs = TestUtils.getSQLs("calculateEnvelope.sql"); |
|
45 |
|
|
46 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
47 |
|
|
48 |
TableReference table = operations.createTableReference( |
|
49 |
"dbtest", |
|
50 |
sqlbuilder.default_schema(), |
|
51 |
"test", |
|
52 |
null |
|
53 |
); |
|
54 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
55 |
CalculateEnvelopeOfColumnOperation calculateEnvelope = operations.createCalculateEnvelopeOfColumn( |
|
56 |
featureType, |
|
57 |
table, |
|
58 |
"Geometry", |
|
59 |
null, |
|
60 |
null, |
|
61 |
featureType.getDefaultSRS() |
|
62 |
); |
|
63 |
|
|
64 |
String sql = calculateEnvelope.getSQL(); |
|
65 |
assertEquals("CalculateEnvelope SQL", expectedSQLs.get(0), sql); |
|
66 |
} |
|
67 |
|
|
68 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/sql/TestCreateTable.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CreateTableOperation; |
|
12 |
import org.gvsig.postgresql.dal.TestUtils; |
|
13 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
14 |
import org.slf4j.Logger; |
|
15 |
import org.slf4j.LoggerFactory; |
|
16 |
|
|
17 |
public class TestCreateTable extends TestCase { |
|
18 |
|
|
19 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestCreateTable.class); |
|
20 |
|
|
21 |
public TestCreateTable(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 testCreateTable() throws Exception { |
|
40 |
JDBCHelper helper = TestUtils.getJDBCHelper(); |
|
41 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
42 |
OperationsFactory operations = helper.getOperations(); |
|
43 |
|
|
44 |
List<String> expectedSQLs = TestUtils.getSQLs("createTable.sql"); |
|
45 |
|
|
46 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
47 |
|
|
48 |
TableReference table = operations.createTableReference( |
|
49 |
"dbtest", |
|
50 |
sqlbuilder.default_schema(), |
|
51 |
"test", |
|
52 |
null |
|
53 |
); |
|
54 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
55 |
CreateTableOperation createTable = operations.createTable( |
|
56 |
table, |
|
57 |
featureType, |
|
58 |
null, |
|
59 |
null |
|
60 |
); |
|
61 |
List<String> SQLs = createTable.getSQLs(); |
|
62 |
assertEquals("CreateTable num. SQLs", expectedSQLs.size(), SQLs.size()); |
|
63 |
for (int i = 0; i < expectedSQLs.size(); i++) { |
|
64 |
assertEquals("CreateTable SQL "+i, expectedSQLs.get(i), SQLs.get(i)); |
|
65 |
} |
|
66 |
|
|
67 |
} |
|
68 |
|
|
69 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/sql/TestDropTable.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
7 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.DropTableOperation; |
|
11 |
import org.gvsig.postgresql.dal.TestUtils; |
|
12 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
13 |
import org.slf4j.Logger; |
|
14 |
import org.slf4j.LoggerFactory; |
|
15 |
|
|
16 |
public class TestDropTable extends TestCase { |
|
17 |
|
|
18 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestDropTable.class); |
|
19 |
|
|
20 |
public TestDropTable(String testName) { |
|
21 |
super(testName); |
|
22 |
} |
|
23 |
|
|
24 |
@Override |
|
25 |
protected void setUp() throws Exception { |
|
26 |
super.setUp(); |
|
27 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
protected void tearDown() throws Exception { |
|
32 |
super.tearDown(); |
|
33 |
} |
|
34 |
|
|
35 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
36 |
// public void testHello() {} |
|
37 |
|
|
38 |
public void testDropTable() throws Exception { |
|
39 |
JDBCHelper helper = TestUtils.getJDBCHelper(); |
|
40 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
41 |
OperationsFactory operations = helper.getOperations(); |
|
42 |
|
|
43 |
List<String> expectedSQLs = TestUtils.getSQLs("dropTable.sql"); |
|
44 |
|
|
45 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
46 |
|
|
47 |
TableReference table = operations.createTableReference( |
|
48 |
"dbtest", |
|
49 |
sqlbuilder.default_schema(), |
|
50 |
"test", |
|
51 |
null |
|
52 |
); |
|
53 |
DropTableOperation dropTable = operations.createDropTable( |
|
54 |
table |
|
55 |
); |
|
56 |
List<String> SQLs = dropTable.getSQLs(); |
|
57 |
assertEquals("DropTable num. SQLs", expectedSQLs.size(), SQLs.size()); |
|
58 |
for (int i = 0; i < expectedSQLs.size(); i++) { |
|
59 |
assertEquals("DropTable SQL "+i, expectedSQLs.get(i), SQLs.get(i)); |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/sql/TestTableIsEmpty.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.TableIsEmptyOperation; |
|
12 |
import org.gvsig.postgresql.dal.TestUtils; |
|
13 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
14 |
import org.slf4j.Logger; |
|
15 |
import org.slf4j.LoggerFactory; |
|
16 |
|
|
17 |
public class TestTableIsEmpty extends TestCase { |
|
18 |
|
|
19 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestTableIsEmpty.class); |
|
20 |
|
|
21 |
public TestTableIsEmpty(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 testTableIsEmpty() throws Exception { |
|
40 |
JDBCHelper helper = TestUtils.getJDBCHelper(); |
|
41 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
42 |
OperationsFactory operations = helper.getOperations(); |
|
43 |
|
|
44 |
List<String> expectedSQLs = TestUtils.getSQLs("tableIsEmpty.sql"); |
|
45 |
|
|
46 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
47 |
|
|
48 |
TableReference table = operations.createTableReference( |
|
49 |
"dbtest", |
|
50 |
sqlbuilder.default_schema(), |
|
51 |
"test", |
|
52 |
null |
|
53 |
); |
|
54 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
55 |
TableIsEmptyOperation tableIsEmpty = operations.createTableIsEmpty( |
|
56 |
featureType, |
|
57 |
table, |
|
58 |
null, |
|
59 |
null |
|
60 |
); |
|
61 |
|
|
62 |
String sql = tableIsEmpty.getSQL(); |
|
63 |
assertEquals("TableIsEmpty SQL", expectedSQLs.get(0), sql); |
|
64 |
} |
|
65 |
|
|
66 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/sql/TestPerformChanges.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.sql; |
|
2 |
|
|
3 |
import java.util.Collections; |
|
4 |
import java.util.List; |
|
5 |
import junit.framework.TestCase; |
|
6 |
import org.gvsig.fmap.dal.DALLocator; |
|
7 |
import org.gvsig.fmap.dal.DataTypes; |
|
8 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
9 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
11 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
12 |
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
14 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
15 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
16 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
17 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.PerformChangesOperation; |
|
18 |
import org.gvsig.postgresql.dal.TestUtils; |
|
19 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
20 |
import org.slf4j.Logger; |
|
21 |
import org.slf4j.LoggerFactory; |
|
22 |
|
|
23 |
public class TestPerformChanges extends TestCase { |
|
24 |
|
|
25 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestPerformChanges.class); |
|
26 |
|
|
27 |
public TestPerformChanges(String testName) { |
|
28 |
super(testName); |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
protected void setUp() throws Exception { |
|
33 |
super.setUp(); |
|
34 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
protected void tearDown() throws Exception { |
|
39 |
super.tearDown(); |
|
40 |
} |
|
41 |
|
|
42 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
43 |
// public void testHello() {} |
|
44 |
|
|
45 |
public void testPerformChanges() throws Exception { |
|
46 |
JDBCHelper helper = TestUtils.getJDBCHelper(); |
|
47 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
48 |
OperationsFactory operations = helper.getOperations(); |
|
49 |
|
|
50 |
List<String> expectedSQLs = TestUtils.getSQLs("performChanges.sql"); |
|
51 |
|
|
52 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
53 |
|
|
54 |
TableReference table = operations.createTableReference( |
|
55 |
"dbtest", |
|
56 |
sqlbuilder.default_schema(), |
|
57 |
"test", |
|
58 |
null |
|
59 |
); |
|
60 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
61 |
|
|
62 |
|
|
63 |
FeatureTypeChanged featureTypeChanged = new FeatureTypeChanged() { |
|
64 |
@Override |
|
65 |
public FeatureType getSource() { |
|
66 |
EditableFeatureType ft = DALLocator.getDataManager().createFeatureType(); |
|
67 |
EditableFeatureAttributeDescriptor id = ft.add("ID", DataTypes.INT); |
|
68 |
id.copyFrom(featureType.getAttributeDescriptor("ID")); |
|
69 |
return ft; |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public FeatureType getTarget() { |
|
74 |
return featureType; |
|
75 |
} |
|
76 |
}; |
|
77 |
List<FeatureTypeChanged> featureTypesChangeds = Collections.singletonList(featureTypeChanged); |
|
78 |
|
|
79 |
PerformChangesOperation performChanges = operations.createPerformChanges( |
|
80 |
table, |
|
81 |
sourceStore.getDefaultFeatureType(), |
|
82 |
null, |
|
83 |
null, |
|
84 |
null, |
|
85 |
featureTypesChangeds.iterator() |
|
86 |
); |
|
87 |
String insertSQL = performChanges.getInsertSQL(); |
|
88 |
String deleteSQL = performChanges.getDeleteSQL(); |
|
89 |
String updateSQL = performChanges.getUpdateSQL(); |
|
90 |
List<String> updateTableSQLs = performChanges.getUpdateTableSQLs(); |
|
91 |
|
|
92 |
assertEquals("Insert SQL", expectedSQLs.get(0), insertSQL); |
|
93 |
assertEquals("Delete SQL", expectedSQLs.get(1), deleteSQL); |
|
94 |
assertEquals("Update SQL", expectedSQLs.get(2), updateSQL); |
|
95 |
assertEquals("UpdateTable num. SQLs", expectedSQLs.size()-3, updateTableSQLs.size()); |
|
96 |
for (int i = 0; i < updateTableSQLs.size(); i++) { |
|
97 |
assertEquals("UpdateTable SQL "+i, expectedSQLs.get(i+3), updateTableSQLs.get(i)); |
|
98 |
} |
|
99 |
|
|
100 |
// FIXME: El ALTER TABLE de una columna geometria no funciona |
|
101 |
} |
|
102 |
|
|
103 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/operations/sql/TestUpdateTableStatistics.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.UpdateTableStatisticsOperation; |
|
12 |
import org.gvsig.postgresql.dal.TestUtils; |
|
13 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
14 |
import org.slf4j.Logger; |
|
15 |
import org.slf4j.LoggerFactory; |
|
16 |
|
|
17 |
public class TestUpdateTableStatistics extends TestCase { |
|
18 |
|
|
19 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestUpdateTableStatistics.class); |
|
20 |
|
|
21 |
public TestUpdateTableStatistics(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 testUpdateTableStatistics() throws Exception { |
|
40 |
JDBCHelper helper = TestUtils.getJDBCHelper(); |
|
41 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
42 |
OperationsFactory operations = helper.getOperations(); |
|
43 |
|
|
44 |
List<String> expectedSQLs = TestUtils.getSQLs("updateTableStatistics.sql"); |
|
45 |
|
|
46 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
47 |
|
|
48 |
TableReference table = operations.createTableReference( |
|
49 |
"dbtest", |
|
50 |
sqlbuilder.default_schema(), |
|
51 |
"test", |
|
52 |
null |
|
53 |
); |
|
54 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
55 |
UpdateTableStatisticsOperation updateTableStatistics = operations.createUpdateTableStatistics( |
|
56 |
table |
|
57 |
); |
|
58 |
|
|
59 |
List<String> SQLs = updateTableStatistics.getSQLs(); |
|
60 |
assertEquals("UpdateTableStatistics num. SQLs", expectedSQLs.size(), SQLs.size()); |
|
61 |
for (int i = 0; i < expectedSQLs.size(); i++) { |
|
62 |
assertEquals("UpdateTableStatistics SQL "+i, expectedSQLs.get(i), SQLs.get(i)); |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/TestUtilsPostgreSQL.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal; |
|
2 |
|
|
3 |
import java.net.URL; |
|
4 |
import java.util.Properties; |
|
5 |
import org.gvsig.fmap.dal.DALLocator; |
|
6 |
import org.gvsig.fmap.dal.DataManager; |
|
7 |
import org.gvsig.fmap.dal.store.jdbc2.AbstractTestUtils; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.spi.FakeConnectionProvider; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* @author jjdelcerro |
|
14 |
*/ |
|
15 |
@SuppressWarnings("UseSpecificCatch") |
|
16 |
public class TestUtilsPostgreSQL extends AbstractTestUtils { |
|
17 |
|
|
18 |
@Override |
|
19 |
public String getProviderName() { |
|
20 |
return PostgreSQLLibrary.NAME; |
|
21 |
} |
|
22 |
|
|
23 |
@Override |
|
24 |
public String getExpectedsPath() { |
|
25 |
return "/org/gvsig/postgresql/dal"; |
|
26 |
} |
|
27 |
|
|
28 |
@Override |
|
29 |
protected Properties getProperties() { |
|
30 |
if (this.properties == null) { |
|
31 |
try { |
|
32 |
URL url = this.getClass().getResource("postgresql.properties"); |
|
33 |
Properties props = new Properties(); |
|
34 |
props.load(url.openStream()); |
|
35 |
String[] keys = new String[]{ |
|
36 |
"PostgreSQLEnabled", |
|
37 |
"PostgreSQLHost", |
|
38 |
"PostgreSQLPort", |
|
39 |
"PostgreSQLDbname", |
|
40 |
"PostgreSQLSchema", |
|
41 |
"PostgreSQLUser", |
|
42 |
"PostgreSQLPassword" |
|
43 |
}; |
|
44 |
for (String key : keys) { |
|
45 |
if (System.getenv().containsKey(key)) { |
|
46 |
props.setProperty(key, System.getenv(key)); |
|
47 |
} |
|
48 |
} |
|
49 |
this.properties = props; |
|
50 |
} catch (Exception ex) { |
|
51 |
throw new RuntimeException(ex); |
|
52 |
} |
|
53 |
} |
|
54 |
return this.properties; |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public boolean isTheDatabaseAvailable() { |
|
59 |
return this.getPropertyBoolean("PostgreSQLEnabled"); |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public JDBCHelper createJDBCHelper() throws Exception { |
|
64 |
PostgreSQLServerExplorerParameters params = this.getServerExplorerParameters("fake"); |
|
65 |
PostgreSQLHelper helper = new PostgreSQLHelper(params, new FakeConnectionProvider()); |
|
66 |
return helper; |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public PostgreSQLServerExplorerParameters getServerExplorerParameters(String dbname) throws Exception { |
|
71 |
DataManager dataManager = DALLocator.getDataManager(); |
|
72 |
PostgreSQLServerExplorerParameters conn = (PostgreSQLServerExplorerParameters) dataManager.createServerExplorerParameters(this.getProviderName()); |
|
73 |
conn.setHost(getProperty("PostgreSQLHost")); |
|
74 |
conn.setPort(getPropertyInt("PostgreSQLPort", 5432)); |
|
75 |
conn.setDBName(getProperty("PostgreSQLDbname")); |
|
76 |
conn.setSchema(getProperty("PostgreSQLSchema")); |
|
77 |
conn.setUser(getProperty("PostgreSQLUser")); |
|
78 |
conn.setPassword(getProperty("PostgreSQLPassword")); |
|
79 |
conn.setShowInformationDBTables(false); |
|
80 |
return conn; |
|
81 |
} |
|
82 |
|
|
83 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/TestComputedAttributes.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.store.jdbc2.AbstractTestComputedAttributes; |
|
4 |
import org.gvsig.fmap.dal.store.jdbc2.AbstractTestUtils; |
|
5 |
|
|
6 |
public class TestComputedAttributes extends AbstractTestComputedAttributes { |
|
7 |
|
|
8 |
public TestComputedAttributes(String testName) { |
|
9 |
super(testName); |
|
10 |
} |
|
11 |
|
|
12 |
@Override |
|
13 |
protected AbstractTestUtils createUtils() { |
|
14 |
return new TestUtilsPostgreSQL(); |
|
15 |
} |
|
16 |
|
|
17 |
@Override |
|
18 |
public void testComputed1() throws Exception { |
|
19 |
super.testComputed1(); |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 |
public void testComputed2() throws Exception { |
|
24 |
super.testComputed2(); |
|
25 |
} |
|
26 |
|
|
27 |
} |
tags/org.gvsig.postgresql-2.0.198/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/PostgreSQLBuilderTest.java | ||
---|---|---|
1 |
package org.gvsig.postgresql.dal; |
|
2 |
|
|
3 |
import junit.framework.TestCase; |
|
4 |
import org.apache.commons.lang3.ArrayUtils; |
|
5 |
import org.cresques.cts.IProjection; |
|
6 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
|
7 |
import org.gvsig.expressionevaluator.GeometryExpressionBuilder; |
|
8 |
import org.gvsig.fmap.crs.CRSFactory; |
|
9 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
10 |
import org.gvsig.fmap.dal.SQLBuilder.Privilege; |
|
11 |
import org.gvsig.fmap.dal.feature.spi.SQLBuilderBase; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.OperationsFactoryBase; |
|
14 |
import org.gvsig.fmap.geom.DataTypes; |
|
15 |
import org.gvsig.fmap.geom.Geometry; |
|
16 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
17 |
import org.gvsig.fmap.geom.GeometryManager; |
|
18 |
import org.gvsig.fmap.geom.primitive.Polygon; |
|
19 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
20 |
|
|
21 |
public class PostgreSQLBuilderTest extends TestCase { |
|
22 |
|
|
23 |
public PostgreSQLBuilderTest(String testName) { |
|
24 |
super(testName); |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
protected void setUp() throws Exception { |
|
29 |
super.setUp(); |
|
30 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
31 |
} |
|
32 |
|
|
33 |
@Override |
|
34 |
protected void tearDown() throws Exception { |
|
35 |
super.tearDown(); |
|
36 |
} |
|
37 |
|
|
38 |
private SQLBuilder createSQLBuilder() { |
|
39 |
return new PostgreSQLBuilder(new PostgreSQLHelper(new FakePostgreSQLConnectionParameters())); |
|
40 |
} |
|
41 |
|
|
42 |
public void testCalulateEnvelopeOfColumn() throws Exception { |
|
43 |
|
|
44 |
TableReference table = new OperationsFactoryBase.DefaultTableReference("master","dbo","test1", null); |
|
45 |
String columnName = "the_geom"; |
|
46 |
|
|
47 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
48 |
GeometryExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
49 |
|
|
50 |
sqlbuilder.select().column().value( |
|
51 |
expbuilder.as_geometry( |
|
52 |
expbuilder.ST_ExtentAggregate( |
|
53 |
expbuilder.column(columnName) |
|
54 |
) |
|
55 |
) |
|
56 |
); |
|
57 |
//sqlbuilder.select().group_by(expbuilder.column(columnName)); |
|
58 |
sqlbuilder.select().from().table() |
|
59 |
.database(table.getDatabase()) |
|
60 |
.schema(table.getSchema()) |
|
61 |
.name(table.getTable()); |
|
62 |
sqlbuilder.select().from().subquery(table.getSubquery()); |
|
63 |
|
|
64 |
sqlbuilder.select().where().and( |
|
65 |
expbuilder.not_is_null(expbuilder.column(columnName)) |
|
66 |
); |
|
67 |
|
|
68 |
System.out.println("# Test:: testCalulateEnvelopeOfColumn"); |
|
69 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
70 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
71 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
72 |
assertEquals( |
|
73 |
"SELECT ST_AsBinary(ST_Extent(\"the_geom\")) FROM \"master\".\"dbo\".\"test1\" WHERE ( (\"the_geom\") IS NOT NULL )", |
|
74 |
sqlbuilder.toString() |
|
75 |
); |
|
76 |
assertEquals( |
|
77 |
"[the_geom]", |
|
78 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
79 |
); |
|
80 |
assertEquals( |
|
81 |
"[]", |
|
82 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
83 |
); |
|
84 |
} |
|
85 |
|
|
86 |
public void testCalulateEnvelope() throws Exception { |
|
87 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
|
88 |
IProjection proj = CRSFactory.getCRS("EPSG:4326"); |
|
89 |
|
|
90 |
Polygon limit = geometryManager.createPolygon(Geometry.SUBTYPES.GEOM2D); |
|
91 |
limit.addVertex(0, 0); |
|
92 |
limit.addVertex(0, 100); |
|
93 |
limit.addVertex(100, 100); |
|
94 |
limit.addVertex(100, 0); |
|
95 |
limit.addVertex(0, 0); |
|
96 |
|
|
97 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
98 |
GeometryExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
99 |
|
|
100 |
sqlbuilder.select().column().value( |
|
101 |
expbuilder.as_geometry( |
|
102 |
expbuilder.ST_ExtentAggregate( |
|
103 |
expbuilder.column("the_geom") |
|
104 |
) |
|
105 |
) |
|
106 |
).as("envelope"); |
|
107 |
sqlbuilder.select().from().table().database("master").schema("dbo").name("test1"); |
|
108 |
sqlbuilder.select().where().set( |
|
109 |
expbuilder.ST_Intersects( |
|
110 |
expbuilder.ST_Envelope( |
|
111 |
expbuilder.column("the_geom") |
|
112 |
), |
|
113 |
expbuilder.geometry(limit, proj) |
|
114 |
) |
|
115 |
); |
|
116 |
sqlbuilder.select().where().and( |
|
117 |
expbuilder.custom("x = 27") |
|
118 |
); |
|
119 |
|
|
120 |
System.out.println("# Test:: testCalulateEnvelope"); |
|
121 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
122 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
123 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
124 |
assertEquals( |
|
125 |
"SELECT ST_AsBinary(ST_Extent(\"the_geom\")) AS \"envelope\" FROM \"master\".\"dbo\".\"test1\" WHERE (ST_Intersects((ST_Envelope(\"the_geom\")), (ST_GeomFromWKB(('\\x000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000'::bytea), (4326)))) AND x = 27)", |
|
126 |
sqlbuilder.toString() |
|
127 |
); |
|
128 |
assertEquals( |
|
129 |
"[the_geom]", |
|
130 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
131 |
); |
|
132 |
assertEquals( |
|
133 |
"[]", |
|
134 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
135 |
); |
Also available in: Unified diff