Revision 371
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/count.sql | ||
---|---|---|
1 |
|
|
2 |
-- Count SQL |
|
3 |
SELECT COUNT(*) FROM "public"."test"; |
|
4 |
|
|
5 |
-- Count SQL 1 |
|
6 |
SELECT COUNT(*) FROM "public"."test"; |
|
7 |
|
|
8 |
-- Count SQL 2 |
|
9 |
SELECT COUNT(*) FROM "dba"."test"; |
|
10 |
|
|
11 |
-- Count with group SQL |
|
12 |
SELECT COUNT(*) |
|
13 |
FROM ( |
|
14 |
SELECT COUNT(*) |
|
15 |
FROM "public"."test" |
|
16 |
GROUP BY "Long" |
|
17 |
ORDER BY "Long" ASC) |
|
18 |
"_subquery_alias_" ; |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/resultSetForSetProvider.sql | ||
---|---|---|
1 |
|
|
2 |
-- ResultSetForSetProvider SQL |
|
3 |
|
|
4 |
-- Simple |
|
5 |
SELECT |
|
6 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
7 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
8 |
NVL2(("Geometry"),("Geometry").Get_WKB(),NULL) |
|
9 |
FROM "public"."test"; |
|
10 |
|
|
11 |
-- Simple Group by |
|
12 |
SELECT MIN("test"."ID") "ID", MAX("test"."Byte") "Byte", NULL "Bool1", "Long", |
|
13 |
NULL "Timestamp", NULL "Date", NULL "Time", NULL "Bool2", |
|
14 |
NULL "String", NULL "Bool3", SUM("test"."Double") "Double", |
|
15 |
NULL "Bool4", NULL "Float", NULL "Bool5", NULL "Decimal", |
|
16 |
NULL "Geometry" |
|
17 |
FROM "public"."test" |
|
18 |
GROUP BY "test"."Long"; |
|
19 |
|
|
20 |
-- Subselect |
|
21 |
SELECT |
|
22 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
23 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
24 |
NVL2(("Geometry"),("Geometry").Get_WKB(),NULL), |
|
25 |
CASE WHEN ( |
|
26 |
EXISTS(( |
|
27 |
SELECT * |
|
28 |
FROM ( |
|
29 |
SELECT "ISO_A2" |
|
30 |
FROM "countries" |
|
31 |
WHERE ( (( ("test"."String") = ("countries"."CONTINENT") )) AND (( ("countries"."LASTCENSUS") < (0) )) ) |
|
32 |
) a WHERE ROWNUM <= 1 |
|
33 |
)) |
|
34 |
) |
|
35 |
THEN (1) |
|
36 |
ELSE (0) |
|
37 |
END "EXISTS62a964cd7bc24f409b97c03b9170408d" |
|
38 |
FROM "public"."test" |
|
39 |
WHERE |
|
40 |
EXISTS(( |
|
41 |
SELECT * |
|
42 |
FROM ( |
|
43 |
SELECT "ISO_A2" |
|
44 |
FROM "countries" |
|
45 |
WHERE ( (( ("test"."String") = ("countries"."CONTINENT") )) AND (( ("countries"."LASTCENSUS") < (0) )) ) |
|
46 |
) a |
|
47 |
WHERE ROWNUM <= 1 |
|
48 |
)); |
|
49 |
|
|
50 |
-- Group and Subselect |
|
51 |
SELECT |
|
52 |
MIN("test"."ID") "ID", MAX("test"."Byte") "Byte", NULL "Bool1", "Long", |
|
53 |
NULL "Timestamp", NULL "Date", NULL "Time", NULL "Bool2", |
|
54 |
NULL "String", NULL "Bool3", SUM("test"."Double") "Double", |
|
55 |
NULL "Bool4", NULL "Float", NULL "Bool5", NULL "Decimal", |
|
56 |
NULL "Geometry" |
|
57 |
FROM "public"."test" |
|
58 |
WHERE |
|
59 |
EXISTS(( |
|
60 |
SELECT * |
|
61 |
FROM ( |
|
62 |
SELECT "ISO_A2" |
|
63 |
FROM "countries" |
|
64 |
WHERE ( |
|
65 |
(( ("test"."String") = ("countries"."CONTINENT") )) |
|
66 |
AND |
|
67 |
(( ("countries"."LASTCENSUS") < (0) )) |
|
68 |
) |
|
69 |
) a |
|
70 |
WHERE ROWNUM <= 1 |
|
71 |
)) |
|
72 |
GROUP BY "test"."Long"; |
|
73 |
|
|
74 |
|
|
75 |
-- Constant Column Primary Key |
|
76 |
SELECT |
|
77 |
"Byte", "Bool1", "Long", "Timestamp", "Date", "Time", "Bool2", |
|
78 |
"String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
79 |
NVL2(("Geometry"),("Geometry").Get_WKB(),NULL), "ID" |
|
80 |
FROM "public"."test"; |
|
81 |
|
|
82 |
-- CLOB |
|
83 |
SELECT |
|
84 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", "Bool2", |
|
85 |
"String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
86 |
NVL2(("Geometry"),("Geometry").Get_WKB(),NULL) |
|
87 |
FROM "public"."test" |
|
88 |
WHERE dbms_lob.compare(("String"),('hola')) = 0; |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/testCreateSource1_es.csv | ||
---|---|---|
1 |
ID__Integer__set__size=0__set__precision=10__set__scale=0__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=true__set__automatic=false__set__isTime=false__set__locale=es__set__order=0__set__roundMode=4;Byte__Byte__set__size=0__set__precision=3__set__scale=0__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=10__set__roundMode=4;Bool1__Boolean__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=20__set__roundMode=4;Long__Long__set__size=0__set__precision=19__set__scale=0__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=30__set__roundMode=4;Timestamp__Timestamp__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=40__set__roundMode=4;Date__Date__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=50__set__roundMode=4;Time__Time__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=60__set__roundMode=4;Bool2__Boolean__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=70__set__roundMode=4;String__String__set__size=30__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=80__set__roundMode=4;Bool3__Boolean__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=90__set__roundMode=4;Double__Double__set__size=0__set__precision=16__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=100__set__roundMode=4;Bool4__Boolean__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=110__set__roundMode=4;Float__Float__set__size=0__set__precision=8__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=120__set__roundMode=4;Bool5__Boolean__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=130__set__roundMode=4;Decimal__Decimal__set__size=0__set__precision=6__set__scale=3__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=140__set__roundMode=4;Geometry__Geometry__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=150__set__roundMode=4__set__srs=EPSG:25830__set__geomtype=Point@2D |
|
2 |
0;;;;;;;; ;;;;;true;; |
|
3 |
1;10;true;1000;29-dic-2019 12:13:14;29 de diciembre de 2019;12:13:14 CET;true;Yo yo1;false;1234554321;true;12321;true;456,123;POINT (-3.8945156972987958 42.01053743584765) |
|
4 |
2;20;true;2000;29-nov-2019 12:13:14;29 de noviembre de 2019;13:13:14 CET;true;Yo yo2;false;1210054321;true;10021;true;456,123;POINT (-2.1079618220646115 41.983079082675474) |
|
5 |
3;30;true;3000;29-oct-2019 12:13:14;29 de octubre de 2019;14:13:14 CET;true;Yo yo3;false;1210154321;true;10121;true;456,123;POINT (-2.57249737803327 41.35372113353277) |
|
6 |
4;40;true;4000;29-sep-2019 12:13:14;29 de septiembre de 2019;15:13:14 CET;true;Yo yo4;false;1210254321;true;10221;true;456,123;POINT (-4.061822048036304 41.35877680235475) |
|
7 |
5;50;true;5000;29-ago-2019 12:13:14;29 de agosto de 2019;16:13:14 CET;true;Yo yo5;false;1210354321;true;10321;true;456,123;POINT (-3.974317066986988 40.78701209315094) |
|
8 |
6;60;true;6000;29-jul-2019 12:13:14;29 de julio de 2019;17:13:14 CET;true;Yo yo6;false;1210454321;true;10421;true;456,123;POINT (-2.510509736717547 40.69847453392384) |
|
9 |
7;70;true;7000;29-jun-2019 12:13:14;29 de junio de 2019;18:13:14 CET;true;Yo yo7;false;1210554321;true;10521;true;456,123;POINT (-0.5317736981843011 40.66396082637622) |
|
10 |
8;80;true;8000;29-may-2019 12:13:14;29 de mayo de 2019;19:13:14 CET;true;Yo yo8;false;1210654321;true;10621;true;456,123;POINT (-0.3626917259170671 41.13652386601604) |
|
11 |
9;90;true;9000;29-abr-2019 12:13:14;29 de abril de 2019;20:13:14 CET;true;Yo yo9;false;1210754321;true;10721;true;456,123;POINT (-1.2461823078608523 41.84950010180092) |
|
12 |
10;;true;1001;29-dic-2019 12:13:14;29 de diciembre de 2019;12:13:14 CET;true;Yo yo1;false;1234554321;true;12321;true;456,123;POINT (-1.2145405488596532 41.22158511004416) |
|
13 |
11;22;;2003;29-nov-2019 12:13:14;29 de noviembre de 2019;13:13:14 CET;true;Yo yo 2;false;1210054321;true;10021;true;456,123;POINT (-0.7699089544899235 41.630581204431756) |
|
14 |
12;33;true;;29-sep-2019 12:13:14;29 de octubre de 2019;14:13:14 CET;true;Yo yo3;false;1210154321;true;10121;true;456,123;POINT (0.4821915816701051 41.75970939133133) |
|
15 |
13;41;true;4001;;29 de septiembre de 2019;15:13:14 CET;true;Yo yo4;false;1210254321;true;10221;true;456,123;POINT (0.7912661147227479 41.919324620992036) |
|
16 |
14;52;true;5002;29-ago-2019 12:13:14;;16:13:14 CET;true;Yo yo5;false;1210354321;true;10321;true;456,123;POINT (1.052534629531243 41.493736996249545) |
|
17 |
15;63;true;6003;29-jul-2019 12:13:14;29 de julio de 2019;;true;Yo yo6;false;1210454321;true;10421;true;456,123;POINT (0.8097002367335026 41.0899480235613) |
|
18 |
16;74;true;7004;29-jun-2019 12:13:14;29 de junio de 2019;18:13:14 CET;true; ;false;1210554321;true;10521;true;456,123;POINT (-0.4883960310112362 41.17597288081971) |
|
19 |
17;85;true;8005;29-may-2019 12:13:14;29 de mayo de 2019;19:13:14 CET;true;Yo yo8;false;;true;10621;true;456,123;POINT (-0.6439030698437881 40.89530766155764) |
|
20 |
18;96;true;9006;29-abr-2019 12:13:14;29 de abril de 2019;20:13:14 CET;true;Yo yo9;false;1210754321;true;;true;;POINT (-1.3061826868199504 40.72372835570524) |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/fetchFeatureProviderByReference.sql | ||
---|---|---|
1 |
|
|
2 |
-- fetchFeatureProviderByReference SQL |
|
3 |
SELECT |
|
4 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
5 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
6 |
NVL2(("Geometry"),("Geometry").Get_WKB(),NULL) |
|
7 |
FROM "public"."test" |
|
8 |
WHERE ( ("ID") = (?) ) AND ROWNUM <= 1; |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/calculateEnvelope.sql | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
-- Count SQL |
|
5 |
--SELECT NVL2((SDO_AGGR_MBR("Geometry")),(SDO_AGGR_MBR("Geometry")).Get_WKB(),NULL) |
|
6 |
--FROM "public"."test" |
|
7 |
--WHERE ( ("Geometry") IS NOT NULL ); |
|
8 |
|
|
9 |
SELECT NVL2((SDO_AGGR_MBR("Geometry")),(SDO_AGGR_MBR("Geometry")).Get_WKB(),NULL) |
|
10 |
FROM "public"."test" |
|
11 |
WHERE ( ("Geometry") IS NOT NULL ); |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/testCreateSource_short.csv | ||
---|---|---|
1 |
Byte/Byte |
|
2 |
|
|
3 |
10 |
|
4 |
20 |
|
5 |
30 |
|
6 |
40 |
|
7 |
50 |
|
8 |
60 |
|
9 |
70 |
|
10 |
80 |
|
11 |
90 |
|
12 |
|
|
13 |
22 |
|
14 |
33 |
|
15 |
41 |
|
16 |
52 |
|
17 |
63 |
|
18 |
74 |
|
19 |
85 |
|
20 |
96 |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/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) |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/tableIsEmpty.sql | ||
---|---|---|
1 |
|
|
2 |
-- Table is empty |
|
3 |
SELECT * FROM "public"."test" WHERE ROWNUM <= 1; |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/performChanges.sql | ||
---|---|---|
1 |
|
|
2 |
-- Insert SQL |
|
3 |
INSERT INTO "public"."test" ( |
|
4 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
5 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", |
|
6 |
"Decimal", "Geometry" |
|
7 |
) VALUES ( |
|
8 |
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NVL2((?),SDO_GEOMETRY((?), (?)),NULL) |
|
9 |
); |
|
10 |
|
|
11 |
-- Delete SQL |
|
12 |
DELETE FROM "public"."test" WHERE ( ("ID") = (?) ); |
|
13 |
|
|
14 |
-- Update SQL |
|
15 |
UPDATE "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" = NVL2((?),SDO_GEOMETRY((?), (?)),NULL) |
|
32 |
WHERE |
|
33 |
( ("ID") = (?) ); |
|
34 |
|
|
35 |
|
|
36 |
-- Update Table SQL |
|
37 |
ALTER TABLE "public"."test" ADD "Byte" NUMBER(3,0) DEFAULT NULL NULL; |
|
38 |
ALTER TABLE "public"."test" ADD "Bool1" CHAR(1) DEFAULT NULL NULL; |
|
39 |
ALTER TABLE "public"."test" ADD "Long" NUMBER(18,0) DEFAULT NULL NULL; |
|
40 |
ALTER TABLE "public"."test" ADD "Timestamp" TIMESTAMP DEFAULT NULL NULL; |
|
41 |
ALTER TABLE "public"."test" ADD "Date" DATE DEFAULT NULL NULL; |
|
42 |
ALTER TABLE "public"."test" ADD "Time" TIMESTAMP DEFAULT NULL NULL; |
|
43 |
ALTER TABLE "public"."test" ADD "Bool2" CHAR(1) DEFAULT NULL NULL; |
|
44 |
ALTER TABLE "public"."test" ADD "String" NVARCHAR2(30) DEFAULT NULL NULL; |
|
45 |
ALTER TABLE "public"."test" ADD "Bool3" CHAR(1) DEFAULT NULL NULL; |
|
46 |
ALTER TABLE "public"."test" ADD "Double" BINARY_DOUBLE DEFAULT NULL NULL; |
|
47 |
ALTER TABLE "public"."test" ADD "Bool4" CHAR(1) DEFAULT NULL NULL; |
|
48 |
ALTER TABLE "public"."test" ADD "Float" BINARY_FLOAT DEFAULT NULL NULL; |
|
49 |
ALTER TABLE "public"."test" ADD "Bool5" CHAR(1) DEFAULT NULL NULL; |
|
50 |
ALTER TABLE "public"."test" ADD "Decimal" NUMBER(6,3) DEFAULT NULL NULL; |
|
51 |
ALTER TABLE "public"."test" ADD "Geometry" SDO_GEOMETRY DEFAULT NULL NULL; |
|
52 |
|
|
53 |
|
|
54 |
DELETE FROM MDSYS.OGIS_GEOMETRY_COLUMNS |
|
55 |
WHERE F_TABLE_SCHEMA = 'public' |
|
56 |
AND F_TABLE_NAME = 'test' |
|
57 |
AND F_GEOMETRY_COLUMN = 'Geometry'; |
|
58 |
|
|
59 |
|
|
60 |
INSERT INTO MDSYS.OGIS_GEOMETRY_COLUMNS ( |
|
61 |
F_TABLE_SCHEMA, F_TABLE_NAME, F_GEOMETRY_COLUMN, GEOMETRY_TYPE) |
|
62 |
VALUES ('public', 'test', 'Geometry', 1001); |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/updateTableStatistics.sql | ||
---|---|---|
1 |
|
|
2 |
-- UpdateTableStatistics SQL |
|
3 |
ANALYZE TABLE "public"."test" COMPUTE STATISTICS; |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/append.sql | ||
---|---|---|
1 |
INSERT INTO "public"."test" ( |
|
2 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
3 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", |
|
4 |
"Decimal", "Geometry" |
|
5 |
) VALUES ( |
|
6 |
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NVL2((?),SDO_GEOMETRY((?), (?)),NULL) ); |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/fetchFeatureType.sql | ||
---|---|---|
1 |
|
|
2 |
-- FetchFeatureType first row SQL |
|
3 |
SELECT * FROM "public"."test" WHERE ROWNUM <= 1; |
|
4 |
|
|
5 |
SELECT "USER_TAB_COLS"."COLUMN_NAME", "ALL_CONSTRAINTS"."CONSTRAINT_TYPE" |
|
6 |
FROM USER_TAB_COLS |
|
7 |
JOIN ALL_CONS_COLUMNS on (ALL_CONS_COLUMNS.TABLE_NAME = USER_TAB_COLS.TABLE_NAME and ALL_CONS_COLUMNS.COLUMN_NAME = USER_TAB_COLS.COLUMN_NAME) |
|
8 |
LEFT JOIN ALL_CONSTRAINTS on ALL_CONSTRAINTS.CONSTRAINT_NAME = ALL_CONS_COLUMNS.CONSTRAINT_NAME |
|
9 |
WHERE ( |
|
10 |
(( ("USER_TAB_COLS"."TABLE_NAME") LIKE ('test') )) |
|
11 |
AND |
|
12 |
(( ("ALL_CONSTRAINTS"."CONSTRAINT_TYPE") = ('P') )) |
|
13 |
); |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/createTable.sql | ||
---|---|---|
1 |
|
|
2 |
-- Se usa en TestCreateTable. |
|
3 |
-- Se corresponde con el fichero CSV "testCreateSource1.csv". |
|
4 |
|
|
5 |
CREATE TABLE "public"."TEST" ( |
|
6 |
"ID" NUMBER(9,0), |
|
7 |
"Byte" NUMBER(3,0) DEFAULT NULL, |
|
8 |
"Bool1" CHAR(1) DEFAULT NULL, |
|
9 |
"Long" NUMBER(18,0) DEFAULT NULL, |
|
10 |
"Timestamp" TIMESTAMP DEFAULT NULL, |
|
11 |
"Date" DATE DEFAULT NULL, |
|
12 |
"Time" TIMESTAMP DEFAULT NULL, |
|
13 |
"Bool2" CHAR(1) DEFAULT NULL, |
|
14 |
"String" NVARCHAR2(30) DEFAULT NULL, |
|
15 |
"Bool3" CHAR(1) DEFAULT NULL, |
|
16 |
"Double" BINARY_DOUBLE DEFAULT NULL, |
|
17 |
"Bool4" CHAR(1) DEFAULT NULL, |
|
18 |
"Float" BINARY_FLOAT DEFAULT NULL, |
|
19 |
"Bool5" CHAR(1) DEFAULT NULL, |
|
20 |
"Decimal" NUMBER(6,3) DEFAULT NULL, |
|
21 |
"GEOMETRY" SDO_GEOMETRY DEFAULT NULL |
|
22 |
); |
|
23 |
|
|
24 |
|
|
25 |
ALTER TABLE "public"."TEST" ADD PRIMARY KEY ("ID"); |
|
26 |
|
|
27 |
DELETE FROM MDSYS.OGIS_GEOMETRY_COLUMNS |
|
28 |
WHERE F_TABLE_SCHEMA = 'public' |
|
29 |
AND F_TABLE_NAME = 'TEST' |
|
30 |
AND F_GEOMETRY_COLUMN = 'GEOMETRY'; |
|
31 |
|
|
32 |
INSERT INTO MDSYS.OGIS_GEOMETRY_COLUMNS ( |
|
33 |
F_TABLE_SCHEMA, F_TABLE_NAME, F_GEOMETRY_COLUMN, GEOMETRY_TYPE) |
|
34 |
VALUES ('public', 'TEST', 'GEOMETRY', 1); |
|
35 |
|
|
36 |
-- Create table with CLOB |
|
37 |
|
|
38 |
CREATE TABLE "public"."TEST" ( |
|
39 |
"ID" NUMBER(9,0), |
|
40 |
"Byte" NUMBER(3,0) DEFAULT NULL, |
|
41 |
"Bool1" CHAR(1) DEFAULT NULL, |
|
42 |
"Long" NUMBER(18,0) DEFAULT NULL, |
|
43 |
"Timestamp" TIMESTAMP DEFAULT NULL, |
|
44 |
"Date" DATE DEFAULT NULL, |
|
45 |
"Time" TIMESTAMP DEFAULT NULL, |
|
46 |
"Bool2" CHAR(1) DEFAULT NULL, |
|
47 |
"String" NCLOB DEFAULT NULL, |
|
48 |
"Bool3" CHAR(1) DEFAULT NULL, |
|
49 |
"Double" BINARY_DOUBLE DEFAULT NULL, |
|
50 |
"Bool4" CHAR(1) DEFAULT NULL, |
|
51 |
"Float" BINARY_FLOAT DEFAULT NULL, |
|
52 |
"Bool5" CHAR(1) DEFAULT NULL, |
|
53 |
"Decimal" NUMBER(6,3) DEFAULT NULL, |
|
54 |
"GEOMETRY" SDO_GEOMETRY DEFAULT NULL |
|
55 |
); |
|
56 |
|
|
57 |
ALTER TABLE "public"."TEST" ADD PRIMARY KEY ("ID"); |
|
58 |
|
|
59 |
DELETE FROM MDSYS.OGIS_GEOMETRY_COLUMNS |
|
60 |
WHERE F_TABLE_SCHEMA = 'public' |
|
61 |
AND F_TABLE_NAME = 'TEST' |
|
62 |
AND F_GEOMETRY_COLUMN = 'GEOMETRY'; |
|
63 |
|
|
64 |
INSERT INTO MDSYS.OGIS_GEOMETRY_COLUMNS ( |
|
65 |
F_TABLE_SCHEMA, F_TABLE_NAME, F_GEOMETRY_COLUMN, GEOMETRY_TYPE) |
|
66 |
VALUES ('public', 'TEST', 'GEOMETRY', 1); |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/dropTable.sql | ||
---|---|---|
1 |
|
|
2 |
-- Drop table SQL |
|
3 |
DROP TABLE "public"."test"; |
|
4 |
|
|
5 |
DELETE FROM MDSYS.OGIS_GEOMETRY_COLUMNS WHERE F_TABLE_SCHEMA = 'public' AND F_TABLE_NAME = 'test'; |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/date.sql | ||
---|---|---|
1 |
|
|
2 |
-- Date SQL |
|
3 |
|
|
4 |
SELECT |
|
5 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", "Bool2", |
|
6 |
"String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
7 |
NVL2(("Geometry"),("Geometry").Get_WKB(),NULL) |
|
8 |
FROM "public"."test" |
|
9 |
WHERE ( |
|
10 |
(( |
|
11 |
(( ("Time") > (TIMESTAMP '1970-01-01 01:02:03') )) |
|
12 |
AND |
|
13 |
(( ("Time") < (TIMESTAMP '1970-01-01 20:52:55') )) |
|
14 |
)) |
|
15 |
OR |
|
16 |
(( |
|
17 |
(( ("Date") > (DATE '2019-02-17') )) |
|
18 |
AND |
|
19 |
(( ("Date") < (DATE '2020-02-23') )) |
|
20 |
)) |
|
21 |
); |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/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=DEBUG |
|
25 |
log4j.logger.org.gvsig.fmap.dal.store.jdbc2=DEBUG |
|
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=DEBUG |
|
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 |
# |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/java/org/gvsig/oracle/dal/TestUtils.java | ||
---|---|---|
1 |
package org.gvsig.oracle.dal; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.FileInputStream; |
|
5 |
import java.io.FileOutputStream; |
|
6 |
import java.net.URL; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.List; |
|
9 |
import java.util.Properties; |
|
10 |
import org.apache.commons.io.FileUtils; |
|
11 |
import org.apache.commons.io.FilenameUtils; |
|
12 |
import org.apache.commons.lang3.StringUtils; |
|
13 |
import org.gvsig.fmap.dal.DALLocator; |
|
14 |
import org.gvsig.fmap.dal.DataManager; |
|
15 |
import org.gvsig.fmap.dal.DataStore; |
|
16 |
import org.gvsig.fmap.dal.feature.Feature; |
|
17 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
18 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeature; |
|
19 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
|
20 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
21 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
22 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
|
23 |
import org.gvsig.fmap.dal.store.jdbc2.spi.FakeConnectionProvider; |
|
24 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
|
25 |
import org.slf4j.Logger; |
|
26 |
import org.slf4j.LoggerFactory; |
|
27 |
|
|
28 |
public class TestUtils { |
|
29 |
|
|
30 |
public static final Logger LOGGER = LoggerFactory.getLogger(TestUtils.class); |
|
31 |
|
|
32 |
public static final String PROVIDER_NAME = OracleLibrary.NAME; |
|
33 |
public static final String TEST_USER = "dba"; |
|
34 |
public static final String TEST_SCHEMA = "public"; |
|
35 |
public static final String TEST_DB_NAME = "dbtest"; |
|
36 |
|
|
37 |
public static OracleConnectionParameters buildDBConnection() throws Exception { |
|
38 |
DataManager dataManager = DALLocator.getDataManager(); |
|
39 |
OracleConnectionParameters conn = (OracleConnectionParameters) |
|
40 |
dataManager.createServerExplorerParameters(OracleLibrary.NAME); |
|
41 |
|
|
42 |
Properties p = new Properties(); |
|
43 |
File userDirectory = FileUtils.getUserDirectory(); |
|
44 |
String properties = FilenameUtils.concat( |
|
45 |
userDirectory.getCanonicalPath(), |
|
46 |
".gvSIG_Oracle_testDBConnection.properties"); |
|
47 |
File fileProperties = new File(properties); |
|
48 |
if(!fileProperties.exists()) { |
|
49 |
p.setProperty("host", "127.0.0.1"); |
|
50 |
p.setProperty("port", "1521"); |
|
51 |
p.setProperty("dbuser", TEST_USER); |
|
52 |
p.setProperty("schema", TEST_SCHEMA); |
|
53 |
p.setProperty("password", "PASSWD"); |
|
54 |
p.setProperty("dbname", TEST_DB_NAME); |
|
55 |
p.setProperty("mode", "service"); |
|
56 |
p.store(new FileOutputStream(properties), "Oracle test DB connection"); |
|
57 |
} else { |
|
58 |
FileInputStream fis = new FileInputStream(properties); |
|
59 |
p.load(fis); |
|
60 |
} |
|
61 |
|
|
62 |
conn.setDynValue("host", p.getProperty("host", null)); |
|
63 |
conn.setDynValue("port", p.getProperty("port", null)); |
|
64 |
conn.setDynValue("dbuser", p.getProperty("dbuser", null)); |
|
65 |
conn.setDynValue("schema", p.getProperty("schema", null)); |
|
66 |
conn.setDynValue("password", p.getProperty("password", null)); |
|
67 |
conn.setDynValue("dbname", p.getProperty("dbname", null)); |
|
68 |
conn.setDynValue("mode", p.getProperty("mode", null)); |
|
69 |
|
|
70 |
return conn; |
|
71 |
} |
|
72 |
|
|
73 |
public static JDBCServerExplorer openServerExplorer() throws Exception { |
|
74 |
DataManager dataManager = DALLocator.getDataManager(); |
|
75 |
OracleConnectionParameters conn = buildDBConnection(); |
|
76 |
JDBCServerExplorer explorer = (JDBCServerExplorer) dataManager.openServerExplorer( |
|
77 |
PROVIDER_NAME, conn |
|
78 |
); |
|
79 |
return explorer; |
|
80 |
} |
|
81 |
|
|
82 |
public static File getTargetFolder() throws Exception { |
|
83 |
URL url = TestUtils.class.getResource("/"); |
|
84 |
File x = new File(url.toURI()); |
|
85 |
File target = x.getParentFile(); |
|
86 |
return target; |
|
87 |
} |
|
88 |
|
|
89 |
public static File getResource(String name) throws Exception { |
|
90 |
File x = new File(getTargetFolder(), name); |
|
91 |
return x; |
|
92 |
} |
|
93 |
|
|
94 |
public static File getResourceAsFile(String pathname) throws Exception { |
|
95 |
URL url = TestUtils.class.getResource(pathname); |
|
96 |
File x = new File(url.toURI()); |
|
97 |
return x; |
|
98 |
} |
|
99 |
|
|
100 |
public static void removeDALResource(String tableName) throws Exception { |
|
101 |
// OracleConnectionParameters connection = buildDBConnection(dbname); |
|
102 |
// DatabaseWorkspaceManager workspace = DALLocator.getDataManager().createDatabaseWorkspaceManager( |
|
103 |
// (DataServerExplorerParameters) connection |
|
104 |
// ); |
|
105 |
|
|
106 |
JDBCServerExplorer explorer = openServerExplorer(); |
|
107 |
JDBCStoreParameters params = explorer.get(tableName); |
|
108 |
|
|
109 |
ResourcesStorage resources = explorer.getResourcesStorage(params); |
|
110 |
|
|
111 |
resources.remove("dal"); |
|
112 |
} |
|
113 |
|
|
114 |
public static FeatureStore openSourceStore1() throws Exception { |
|
115 |
DataManager dataManager = DALLocator.getDataManager(); |
|
116 |
File f = getResourceAsFile("/org/gvsig/oracle/dal/testCreateSource1.csv"); |
|
117 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
|
118 |
DataStore.CSV_PROVIDER_NAME, |
|
119 |
"file=",f, |
|
120 |
"automaticTypesDetection=", false, |
|
121 |
"locale=","en" |
|
122 |
); |
|
123 |
return store; |
|
124 |
} |
|
125 |
|
|
126 |
public static FeatureStore openSourceStoreShort() throws Exception { |
|
127 |
DataManager dataManager = DALLocator.getDataManager(); |
|
128 |
File f = getResourceAsFile("/org/gvsig/oracle/dal/testCreateSource_short.csv"); |
|
129 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
|
130 |
DataStore.CSV_PROVIDER_NAME, |
|
131 |
"file=",f, |
|
132 |
"automaticTypesDetection=", false, |
|
133 |
"locale=","en" |
|
134 |
); |
|
135 |
return store; |
|
136 |
} |
|
137 |
|
|
138 |
|
|
139 |
public static List<String> getSQLs(String name) throws Exception { |
|
140 |
File f = getResourceAsFile("/org/gvsig/oracle/dal/"+name); |
|
141 |
List<String> SQLs = new ArrayList<>(); |
|
142 |
List<String> lines = FileUtils.readLines(f); |
|
143 |
StringBuilder sb = new StringBuilder(); |
|
144 |
for (String line : lines) { |
|
145 |
line = StringUtils.stripStart(line, null); |
|
146 |
if( line.startsWith("--") ) { |
|
147 |
continue; |
|
148 |
} |
|
149 |
if( line.endsWith(";") ) { |
|
150 |
sb.append(line.substring(0, line.length()-1)); |
|
151 |
SQLs.add(sb.toString()); |
|
152 |
sb.setLength(0); |
|
153 |
} else { |
|
154 |
sb.append(line); |
|
155 |
} |
|
156 |
} |
|
157 |
return SQLs; |
|
158 |
} |
|
159 |
|
|
160 |
public static FeatureProvider getFeatureProvider(Feature feature) { |
|
161 |
return ((DefaultFeature)feature).getData(); |
|
162 |
} |
|
163 |
|
|
164 |
public static JDBCHelper getJDBCHelper() { |
|
165 |
return getJDBCHelper(TEST_SCHEMA, TEST_USER); |
|
166 |
} |
|
167 |
|
|
168 |
public static JDBCHelper getJDBCHelper(String schema, String user) { |
|
169 |
OracleExplorerParameters params = new OracleExplorerParameters(); |
|
170 |
params.setSchema(schema); |
|
171 |
params.setUser(user); |
|
172 |
params.setDBName(TEST_DB_NAME); |
|
173 |
OracleHelper helper = new OracleHelper(params, new FakeConnectionProvider(params)); |
|
174 |
return helper; |
|
175 |
} |
|
176 |
|
|
177 |
} |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/java/org/gvsig/oracle/dal/TestCreate.java | ||
---|---|---|
1 |
package org.gvsig.oracle.dal; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
import java.util.List; |
|
5 |
import junit.framework.TestCase; |
|
6 |
import static junit.framework.TestCase.assertEquals; |
|
7 |
import org.gvsig.fmap.dal.DALLocator; |
|
8 |
import org.gvsig.fmap.dal.DataManager; |
|
9 |
import org.gvsig.fmap.dal.DataTypes; |
|
10 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
11 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
12 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
13 |
import org.gvsig.fmap.dal.feature.Feature; |
|
14 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
15 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
16 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
17 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
18 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
19 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
|
20 |
import org.gvsig.fmap.geom.Geometry; |
|
21 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
22 |
import org.slf4j.Logger; |
|
23 |
import org.slf4j.LoggerFactory; |
|
24 |
|
|
25 |
public class TestCreate extends TestCase { |
|
26 |
|
|
27 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestCreate.class); |
|
28 |
|
|
29 |
public static final String DBNAME = "testCreate"; |
|
30 |
|
|
31 |
public static final int ZERO_DEFAULT_DISPLAY_SIZE = 0; |
|
32 |
public static final int BYTE_DEFAULT_DISPLAY_SIZE = 4; |
|
33 |
public static final int FLOAT_DEFAULT_DISPLAY_SIZE = 4; |
|
34 |
public static final int DOUBLE_DEFAULT_DISPLAY_SIZE = 8; |
|
35 |
|
|
36 |
public TestCreate(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 |
protected String getProviderName() { |
|
54 |
return OracleLibrary.NAME; |
|
55 |
} |
|
56 |
|
|
57 |
protected String getTargetName() { |
|
58 |
return "testCreateTarget6".toUpperCase(); |
|
59 |
} |
|
60 |
|
|
61 |
protected FeatureStore openTargetStore1(JDBCServerExplorer explorer) throws Exception { |
|
62 |
JDBCStoreParameters params = explorer.get(getTargetName()); |
|
63 |
|
|
64 |
DataManager dataManager = DALLocator.getDataManager(); |
|
65 |
FeatureStore store; |
|
66 |
try { |
|
67 |
store = (FeatureStore) dataManager.openStore( |
|
68 |
getProviderName(), |
|
69 |
params |
|
70 |
); |
|
71 |
} catch (ValidateDataParametersException ex) { |
|
72 |
LOGGER.warn(ex.getLocalizedMessageStack()); |
|
73 |
throw ex; |
|
74 |
} |
|
75 |
return store; |
|
76 |
} |
|
77 |
|
|
78 |
protected void createFrom(JDBCServerExplorer explorer, FeatureStore sourceStore) throws Exception { |
|
79 |
NewFeatureStoreParameters params = (NewFeatureStoreParameters) explorer.getAddParameters( |
|
80 |
getTargetName() |
|
81 |
); |
|
82 |
EditableFeatureType ft = params.getDefaultFeatureType(); |
|
83 |
ft.addAll(sourceStore.getDefaultFeatureType()); |
|
84 |
explorer.add(getProviderName(), params, true); |
|
85 |
} |
|
86 |
|
|
87 |
protected void checkTypes(JDBCServerExplorer explorer, FeatureType sourceFeatureType, boolean withDalResource) throws Exception { |
|
88 |
FeatureStore targetStore = openTargetStore1(explorer); |
|
89 |
FeatureType targetFeatureType = targetStore.getDefaultFeatureType(); |
|
90 |
|
|
91 |
assertEquals("Feature type size", sourceFeatureType.size(), targetFeatureType.size()); |
|
92 |
for (int i = 0; i < sourceFeatureType.size(); i++) { |
|
93 |
FeatureAttributeDescriptor sourceAttr = sourceFeatureType.get(i); |
|
94 |
FeatureAttributeDescriptor targetAttr = targetFeatureType.get(i); |
|
95 |
if (withDalResource) { |
|
96 |
if (sourceAttr.getType() == DataTypes.GEOMETRY) { |
|
97 |
assertEquals( |
|
98 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
99 |
sourceAttr.getName().toUpperCase(), |
|
100 |
targetAttr.getName() |
|
101 |
); |
|
102 |
} else { |
|
103 |
assertEquals( |
|
104 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
105 |
sourceAttr.getName(), |
|
106 |
targetAttr.getName() |
|
107 |
); |
|
108 |
} |
|
109 |
|
|
110 |
assertEquals( |
|
111 |
String.format("Field %s type mismatch", sourceAttr.getName()), |
|
112 |
sourceAttr.getDataTypeName(), |
|
113 |
targetAttr.getDataTypeName() |
|
114 |
); |
|
115 |
assertEquals( |
|
116 |
String.format("Field %s display size mismatch", sourceAttr.getName()), |
|
117 |
sourceAttr.getDisplaySize(), |
|
118 |
targetAttr.getDisplaySize() |
|
119 |
); |
|
120 |
assertEquals( |
|
121 |
String.format("Field %s size mismatch", sourceAttr.getName()), |
|
122 |
sourceAttr.getSize(), |
|
123 |
targetAttr.getSize() |
|
124 |
); |
|
125 |
assertEquals( |
|
126 |
String.format("Field %s precision mismatch", sourceAttr.getName()), |
|
127 |
sourceAttr.getPrecision(), |
|
128 |
targetAttr.getPrecision() |
|
129 |
); |
|
130 |
assertEquals( |
|
131 |
String.format("Field %s scale mismatch", sourceAttr.getName()), |
|
132 |
sourceAttr.getScale(), |
|
133 |
targetAttr.getScale() |
|
134 |
); |
|
135 |
|
|
136 |
if (sourceAttr.getType() == DataTypes.GEOMETRY) { |
|
137 |
assertEquals( |
|
138 |
String.format("Field %s geometry type mismatch", sourceAttr.getName()), |
|
139 |
sourceAttr.getGeomType().getName(), |
|
140 |
targetAttr.getGeomType().getName() |
|
141 |
); |
|
142 |
assertEquals( |
|
143 |
String.format("Field %s geometry SRS mismatch", sourceAttr.getName()), |
|
144 |
sourceAttr.getSRS().getAbrev(), |
|
145 |
targetAttr.getSRS().getAbrev() |
|
146 |
); |
|
147 |
|
|
148 |
} |
|
149 |
|
|
150 |
} else { |
|
151 |
switch (sourceAttr.getType()) { |
|
152 |
case DataTypes.BYTE: |
|
153 |
assertEquals( |
|
154 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
155 |
sourceAttr.getName(), |
|
156 |
targetAttr.getName() |
|
157 |
); |
|
158 |
assertEquals( |
|
159 |
String.format("Field %s type mismatch", sourceAttr.getName()), |
|
160 |
DataTypes.DECIMAL, |
|
161 |
targetAttr.getDataType().getType() |
|
162 |
); |
|
163 |
assertEquals( |
|
164 |
String.format("Field %s display size mismatch", sourceAttr.getName()), |
|
165 |
BYTE_DEFAULT_DISPLAY_SIZE, |
|
166 |
targetAttr.getDisplaySize() |
|
167 |
); |
|
168 |
assertEquals( |
|
169 |
String.format("Field %s size mismatch", sourceAttr.getName()), |
|
170 |
sourceAttr.getSize(), |
|
171 |
targetAttr.getSize() |
|
172 |
); |
|
173 |
assertEquals( |
|
174 |
String.format("Field %s precision mismatch", sourceAttr.getName()), |
|
175 |
sourceAttr.getPrecision(), |
|
176 |
targetAttr.getPrecision() |
|
177 |
); |
|
178 |
assertEquals( |
|
179 |
String.format("Field %s scale mismatch", sourceAttr.getName()), |
|
180 |
sourceAttr.getScale(), |
|
181 |
targetAttr.getScale() |
|
182 |
); |
|
183 |
break; |
|
184 |
case DataTypes.BOOLEAN: |
|
185 |
assertEquals( |
|
186 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
187 |
sourceAttr.getName(), |
|
188 |
targetAttr.getName() |
|
189 |
); |
|
190 |
assertEquals( |
|
191 |
String.format("Field %s type mismatch", sourceAttr.getName()), |
|
192 |
DataTypes.STRING_NAME, |
|
193 |
targetAttr.getDataTypeName() |
|
194 |
); |
|
195 |
assertEquals(String.format("Field %s display size mismatch", sourceAttr.getName()), |
|
196 |
ZERO_DEFAULT_DISPLAY_SIZE, |
|
197 |
targetAttr.getDisplaySize() |
|
198 |
); |
|
199 |
assertEquals(String.format("Field %s size mismatch", sourceAttr.getName()), |
|
200 |
OracleSQLBuilder.BOOLEAN_STRING_DEFAULT_LENGTH, |
|
201 |
targetAttr.getSize() |
|
202 |
); |
|
203 |
assertEquals( |
|
204 |
String.format("Field %s precision mismatch", sourceAttr.getName()), |
|
205 |
sourceAttr.getPrecision(), |
|
206 |
targetAttr.getPrecision() |
|
207 |
); |
|
208 |
assertEquals( |
|
209 |
String.format("Field %s scale mismatch", sourceAttr.getName()), |
|
210 |
sourceAttr.getScale(), |
|
211 |
targetAttr.getScale() |
|
212 |
); |
|
213 |
break; |
|
214 |
case DataTypes.STRING: |
|
215 |
assertEquals( |
|
216 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
217 |
sourceAttr.getName(), |
|
218 |
targetAttr.getName() |
|
219 |
); |
|
220 |
assertEquals( |
|
221 |
String.format("Field %s type mismatch", sourceAttr.getName()), |
|
222 |
sourceAttr.getDataTypeName(), |
|
223 |
targetAttr.getDataTypeName() |
|
224 |
); |
|
225 |
assertEquals(String.format("Field %s display size mismatch", sourceAttr.getName()), |
|
226 |
ZERO_DEFAULT_DISPLAY_SIZE, |
|
227 |
targetAttr.getDisplaySize() |
|
228 |
); |
|
229 |
assertEquals( |
|
230 |
String.format("Field %s size mismatch", sourceAttr.getName()), |
|
231 |
sourceAttr.getSize(), |
|
232 |
targetAttr.getSize() |
|
233 |
); |
|
234 |
assertEquals( |
|
235 |
String.format("Field %s precision mismatch", sourceAttr.getName()), |
|
236 |
sourceAttr.getPrecision(), |
|
237 |
targetAttr.getPrecision() |
|
238 |
); |
|
239 |
assertEquals( |
|
240 |
String.format("Field %s scale mismatch", sourceAttr.getName()), |
|
241 |
sourceAttr.getScale(), |
|
242 |
targetAttr.getScale() |
|
243 |
); |
|
244 |
break; |
|
245 |
case DataTypes.TIME: |
|
246 |
case DataTypes.DATE: |
|
247 |
assertEquals( |
|
248 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
249 |
sourceAttr.getName(), |
|
250 |
targetAttr.getName() |
|
251 |
); |
|
252 |
assertEquals( |
|
253 |
String.format("Field %s type mismatch", sourceAttr.getName()), |
|
254 |
DataTypes.TIMESTAMP_NAME, |
|
255 |
targetAttr.getDataTypeName() |
|
256 |
); |
|
257 |
assertEquals(String.format("Field %s display size mismatch", sourceAttr.getName()), |
|
258 |
ZERO_DEFAULT_DISPLAY_SIZE, |
|
259 |
targetAttr.getDisplaySize() |
|
260 |
); |
|
261 |
assertEquals( |
|
262 |
String.format("Field %s size mismatch", sourceAttr.getName()), |
|
263 |
sourceAttr.getSize(), |
|
264 |
targetAttr.getSize() |
|
265 |
); |
|
266 |
assertEquals( |
|
267 |
String.format("Field %s precision mismatch", sourceAttr.getName()), |
|
268 |
sourceAttr.getPrecision(), |
|
269 |
targetAttr.getPrecision() |
|
270 |
); |
|
271 |
assertEquals( |
|
272 |
String.format("Field %s scale mismatch", sourceAttr.getName()), |
|
273 |
sourceAttr.getScale(), |
|
274 |
targetAttr.getScale() |
|
275 |
); |
|
276 |
break; |
|
277 |
|
|
278 |
case DataTypes.DOUBLE: |
|
279 |
assertEquals( |
|
280 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
281 |
sourceAttr.getName(), |
|
282 |
targetAttr.getName() |
|
283 |
); |
|
284 |
assertEquals( |
|
285 |
String.format("Field %s type mismatch", sourceAttr.getName()), |
|
286 |
sourceAttr.getDataTypeName(), |
|
287 |
targetAttr.getDataTypeName() |
|
288 |
); |
|
289 |
assertEquals( |
|
290 |
String.format("Field %s display size mismatch", sourceAttr.getName()), |
|
291 |
DOUBLE_DEFAULT_DISPLAY_SIZE, |
|
292 |
targetAttr.getDisplaySize() |
|
293 |
); |
|
294 |
assertEquals( |
|
295 |
String.format("Field %s size mismatch", sourceAttr.getName()), |
|
296 |
sourceAttr.getSize(), |
|
297 |
targetAttr.getSize() |
|
298 |
); |
|
299 |
assertEquals( |
|
300 |
String.format("Field %s precision mismatch", sourceAttr.getName()), |
|
301 |
sourceAttr.getPrecision(), |
|
302 |
targetAttr.getPrecision() |
|
303 |
); |
|
304 |
assertEquals( |
|
305 |
String.format("Field %s scale mismatch", sourceAttr.getName()), |
|
306 |
sourceAttr.getScale(), |
|
307 |
targetAttr.getScale() |
|
308 |
); |
|
309 |
break; |
|
310 |
case DataTypes.FLOAT: |
|
311 |
assertEquals( |
|
312 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
313 |
sourceAttr.getName(), |
|
314 |
targetAttr.getName() |
|
315 |
); |
|
316 |
assertEquals( |
|
317 |
String.format("Field %s type mismatch", sourceAttr.getName()), |
|
318 |
sourceAttr.getDataTypeName(), |
|
319 |
targetAttr.getDataTypeName() |
|
320 |
); |
|
321 |
assertEquals( |
|
322 |
String.format("Field %s display size mismatch", sourceAttr.getName()), |
|
323 |
FLOAT_DEFAULT_DISPLAY_SIZE, |
|
324 |
targetAttr.getDisplaySize() |
|
325 |
); |
|
326 |
assertEquals( |
|
327 |
String.format("Field %s size mismatch", sourceAttr.getName()), |
|
328 |
sourceAttr.getSize(), |
|
329 |
targetAttr.getSize() |
|
330 |
); |
|
331 |
assertEquals( |
|
332 |
String.format("Field %s precision mismatch", sourceAttr.getName()), |
|
333 |
sourceAttr.getPrecision(), |
|
334 |
targetAttr.getPrecision() |
|
335 |
); |
|
336 |
assertEquals( |
|
337 |
String.format("Field %s scale mismatch", sourceAttr.getName()), |
|
338 |
sourceAttr.getScale(), |
|
339 |
targetAttr.getScale() |
|
340 |
); |
|
341 |
break; |
|
342 |
|
|
343 |
case DataTypes.INT: |
|
344 |
case DataTypes.LONG: |
|
345 |
case DataTypes.TIMESTAMP: |
|
346 |
assertEquals( |
|
347 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
348 |
sourceAttr.getName(), |
|
349 |
targetAttr.getName() |
|
350 |
); |
|
351 |
assertEquals( |
|
352 |
String.format("Field %s type mismatch", sourceAttr.getName()), |
|
353 |
sourceAttr.getDataType().getType(), |
|
354 |
targetAttr.getDataType().getType() |
|
355 |
); |
|
356 |
assertEquals(String.format("Field %s display size mismatch", sourceAttr.getName()), |
|
357 |
ZERO_DEFAULT_DISPLAY_SIZE, |
|
358 |
targetAttr.getDisplaySize() |
|
359 |
); |
|
360 |
assertEquals( |
|
361 |
String.format("Field %s size mismatch", sourceAttr.getName()), |
|
362 |
sourceAttr.getSize(), |
|
363 |
targetAttr.getSize() |
|
364 |
); |
|
365 |
assertEquals( |
|
366 |
String.format("Field %s precision mismatch", sourceAttr.getName()), |
|
367 |
sourceAttr.getPrecision(), |
|
368 |
targetAttr.getPrecision() |
|
369 |
); |
|
370 |
assertEquals( |
|
371 |
String.format("Field %s scale mismatch", sourceAttr.getName()), |
|
372 |
sourceAttr.getScale(), |
|
373 |
targetAttr.getScale() |
|
374 |
); |
|
375 |
break; |
|
376 |
|
|
377 |
case DataTypes.DECIMAL: |
|
378 |
assertEquals( |
|
379 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
380 |
sourceAttr.getName(), |
|
381 |
targetAttr.getName() |
|
382 |
); |
|
383 |
assertEquals( |
|
384 |
String.format("Field %s type mismatch", sourceAttr.getName()), |
|
385 |
sourceAttr.getDataTypeName(), |
|
386 |
targetAttr.getDataTypeName() |
|
387 |
); |
|
388 |
assertEquals( |
|
389 |
String.format("Field %s display size mismatch", sourceAttr.getName()), |
|
390 |
sourceAttr.getPrecision() + 2, //Precision plus sign and decimal separator |
|
391 |
targetAttr.getDisplaySize() |
|
392 |
); |
|
393 |
assertEquals( |
|
394 |
String.format("Field %s size mismatch", sourceAttr.getName()), |
|
395 |
sourceAttr.getSize(), |
|
396 |
targetAttr.getSize() |
|
397 |
); |
|
398 |
assertEquals( |
|
399 |
String.format("Field %s precision mismatch", sourceAttr.getName()), |
|
400 |
sourceAttr.getPrecision(), |
|
401 |
targetAttr.getPrecision() |
|
402 |
); |
|
403 |
assertEquals( |
|
404 |
String.format("Field %s scale mismatch", sourceAttr.getName()), |
|
405 |
sourceAttr.getScale(), |
|
406 |
targetAttr.getScale() |
|
407 |
); |
|
408 |
break; |
|
409 |
case DataTypes.GEOMETRY: |
|
410 |
assertEquals( |
|
411 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
412 |
sourceAttr.getName().toUpperCase(), |
|
413 |
targetAttr.getName() |
|
414 |
); |
|
415 |
assertEquals( |
|
416 |
String.format("Field %s type mismatch", sourceAttr.getName()), |
|
417 |
sourceAttr.getDataTypeName(), |
|
418 |
targetAttr.getDataTypeName() |
|
419 |
); |
|
420 |
assertEquals( |
|
421 |
String.format("Field %s geometry type mismatch", sourceAttr.getName()), |
|
422 |
sourceAttr.getGeomType().getName(), |
|
423 |
targetAttr.getGeomType().getName() |
|
424 |
); |
|
425 |
assertEquals( |
|
426 |
String.format("Field %s geometry SRS mismatch", sourceAttr.getName()), |
|
427 |
sourceAttr.getSRS().getAbrev(), |
|
428 |
targetAttr.getSRS().getAbrev() |
|
429 |
); |
|
430 |
assertEquals( |
|
431 |
String.format("Field %s size mismatch", sourceAttr.getName()), |
|
432 |
sourceAttr.getSize(), |
|
433 |
targetAttr.getSize() |
|
434 |
); |
|
435 |
assertEquals( |
|
436 |
String.format("Field %s precision mismatch", sourceAttr.getName()), |
|
437 |
sourceAttr.getPrecision(), |
|
438 |
targetAttr.getPrecision() |
|
439 |
); |
|
440 |
break; |
|
441 |
default: |
|
442 |
fail( |
|
443 |
String.format("Field %s type %d (%s) not supported.", |
|
444 |
targetAttr.getName(), |
|
445 |
targetAttr.getType(), |
|
446 |
targetAttr.getDataTypeName() |
|
447 |
) |
|
448 |
); |
|
449 |
} |
|
450 |
} |
|
451 |
} |
|
452 |
} |
|
453 |
|
|
454 |
protected void copyFrom(JDBCServerExplorer explorer, FeatureStore sourceStore, int mode) throws Exception { |
|
455 |
FeatureStore targetStore = openTargetStore1(explorer); |
|
456 |
targetStore.edit(mode); |
|
457 |
try { |
|
458 |
for (Feature sourceFeature : sourceStore.getFeatureSet()) { |
|
459 |
EditableFeature targetFeature = targetStore.createNewFeature(sourceFeature); |
|
460 |
targetStore.insert(targetFeature); |
|
461 |
} |
|
462 |
} finally { |
|
463 |
targetStore.finishEditing(); |
|
464 |
} |
|
465 |
} |
|
466 |
|
|
467 |
protected void checkData(JDBCServerExplorer explorer, FeatureStore sourceStore, boolean withDalResource) throws Exception { |
|
468 |
FeatureStore targetStore = openTargetStore1(explorer); |
|
469 |
|
|
470 |
List<Feature> sourceFeatures = sourceStore.getFeatures(); |
|
471 |
List<Feature> targetFeatures = targetStore.getFeatures(); |
|
472 |
assertEquals("Count features", sourceFeatures.size(), targetFeatures.size()); |
|
473 |
for (int i = 0; i < targetFeatures.size(); i++) { |
|
474 |
Feature sourceFeature = sourceFeatures.get(i); |
|
475 |
Feature targetFeature = targetFeatures.get(i); |
|
476 |
for (FeatureAttributeDescriptor sourceAttr : sourceStore.getDefaultFeatureType()) { |
|
477 |
switch (sourceAttr.getType()) { |
|
478 |
case DataTypes.BYTE: |
|
479 |
assertEquals( |
|
480 |
String.format("Feature %03d attribute %s", i, sourceAttr.getName()), |
|
481 |
sourceFeature.getInt(sourceAttr.getName()), |
|
482 |
targetFeature.getInt(sourceAttr.getName()) |
|
483 |
); |
|
484 |
break; |
|
485 |
case DataTypes.TIMESTAMP: |
|
486 |
Date sourceTimestamp = sourceFeature.getDate(sourceAttr.getName()); |
|
487 |
Date targetTimestamp = targetFeature.getDate(sourceAttr.getName()); |
|
488 |
assertEquals( |
|
489 |
String.format("Feature %03d attribute %s", i, sourceAttr.getName()), |
|
490 |
sourceTimestamp, |
|
491 |
targetTimestamp |
|
492 |
); |
|
493 |
break; |
|
494 |
case DataTypes.TIME: |
|
495 |
assertEquals( |
|
496 |
String.format("Feature %03d attribute %s", i, sourceAttr.getName()), |
|
497 |
sourceFeature.getDate(sourceAttr.getName()), |
|
498 |
targetFeature.getDate(sourceAttr.getName()) |
|
499 |
); |
|
500 |
break; |
|
501 |
case DataTypes.GEOMETRY: |
|
502 |
Geometry sourceGeometry = (Geometry) (sourceFeature.get(sourceAttr.getName())); |
|
503 |
Geometry targetGeometry = (Geometry) (targetFeature.get(sourceAttr.getName())); |
|
504 |
if (sourceGeometry == null) { |
|
505 |
assertNull(targetGeometry); |
|
506 |
} else { |
|
507 |
assertEquals( |
|
508 |
String.format("Feature %03d attribute %s", i, sourceAttr.getName()), |
|
509 |
sourceGeometry.getGeometryType(), |
|
510 |
targetGeometry.getGeometryType() |
|
511 |
); |
|
512 |
assertTrue(sourceGeometry.distance(targetGeometry) < 0.0000000000001); |
|
513 |
} |
|
514 |
|
|
515 |
break; |
|
516 |
|
|
517 |
case DataTypes.BOOLEAN: |
|
518 |
assertEquals( |
|
519 |
String.format("Feature %03d attribute %s", i, sourceAttr.getName()), |
|
520 |
sourceFeature.getBoolean(sourceAttr.getName()), |
|
521 |
targetFeature.getBoolean(sourceAttr.getName()) |
|
522 |
); |
|
523 |
break; |
|
524 |
case DataTypes.STRING: |
|
525 |
case DataTypes.INT: |
|
526 |
case DataTypes.LONG: |
|
527 |
case DataTypes.FLOAT: |
|
528 |
case DataTypes.DOUBLE: |
|
529 |
default: |
|
530 |
Object sourceValue = sourceFeature.get(sourceAttr.getName()); |
|
531 |
Object targetValue = targetFeature.get(sourceAttr.getName()); |
|
532 |
if (sourceValue == null) { |
|
533 |
LOGGER.info(String.format("Feature %03d attribute %s is null", i, sourceAttr.getName())); |
|
534 |
} |
|
535 |
assertEquals( |
|
536 |
String.format("Feature %03d attribute %s", i, sourceAttr.getName()), |
|
537 |
sourceValue, |
|
538 |
targetValue |
|
539 |
); |
|
540 |
} |
|
541 |
} |
|
542 |
} |
|
543 |
} |
|
544 |
|
|
545 |
public void testCreatePopulateAndCheckDataWithoutDalResource() throws Exception { |
|
546 |
// FeatureStore sourceStore = TestUtils.openSourceStoreShort(); |
|
547 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
548 |
JDBCServerExplorer explorer = TestUtils.openServerExplorer(); |
|
549 |
|
|
550 |
JDBCStoreParameters params = explorer.get(this.getTargetName()); |
|
551 |
if(params != null && explorer.exists(params) ){ |
|
552 |
explorer.remove(params); |
|
553 |
} |
|
554 |
|
|
555 |
createFrom(explorer, sourceStore); |
|
556 |
|
|
557 |
TestUtils.removeDALResource(this.getTargetName()); |
|
558 |
checkTypes(explorer, sourceStore.getDefaultFeatureType(), false); |
|
559 |
|
|
560 |
copyFrom(explorer, sourceStore, FeatureStore.MODE_APPEND); |
|
561 |
TestUtils.removeDALResource(this.getTargetName()); |
|
562 |
checkData(explorer, sourceStore, false); |
|
563 |
|
|
564 |
explorer.remove(params); |
|
565 |
|
|
566 |
createFrom(explorer, sourceStore); |
|
567 |
copyFrom(explorer, sourceStore, FeatureStore.MODE_FULLEDIT); |
|
568 |
TestUtils.removeDALResource(this.getTargetName()); |
|
569 |
checkData(explorer, sourceStore, false); |
|
570 |
|
|
571 |
explorer.remove(params); |
|
572 |
|
|
573 |
} |
|
574 |
|
|
575 |
public void testCreatePopulateAndCheckDataWithDalResource() throws Exception { |
|
576 |
// FeatureStore sourceStore = TestUtils.openSourceStoreShort(); |
|
577 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
578 |
JDBCServerExplorer explorer = TestUtils.openServerExplorer(); |
|
579 |
|
|
580 |
JDBCStoreParameters params = explorer.get(this.getTargetName()); |
|
581 |
if (params != null && explorer.exists(params)) { |
|
582 |
explorer.remove(params); |
|
583 |
} |
|
584 |
|
|
585 |
createFrom(explorer, sourceStore); |
|
586 |
|
|
587 |
checkTypes(explorer, sourceStore.getDefaultFeatureType(), true); |
|
588 |
|
|
589 |
copyFrom(explorer, sourceStore, FeatureStore.MODE_APPEND); |
|
590 |
checkData(explorer, sourceStore, true); |
|
591 |
|
|
592 |
explorer.remove(params); |
|
593 |
|
|
594 |
createFrom(explorer, sourceStore); |
|
595 |
copyFrom(explorer, sourceStore, FeatureStore.MODE_FULLEDIT); |
|
596 |
checkData(explorer, sourceStore, true); |
|
597 |
|
|
598 |
explorer.remove(params); |
|
599 |
|
|
600 |
} |
|
601 |
|
|
602 |
} |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/java/org/gvsig/oracle/dal/operations/sql/TestTableIsEmpty.java | ||
---|---|---|
1 |
package org.gvsig.oracle.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.oracle.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 |
} |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/java/org/gvsig/oracle/dal/operations/sql/TestPerformChanges.java | ||
---|---|---|
1 |
package org.gvsig.oracle.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.oracle.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 |
|
|
101 |
} |
|
102 |
|
|
103 |
} |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.53/org.gvsig.oracle.provider/src/test/java/org/gvsig/oracle/dal/operations/sql/TestUpdateTableStatistics.java | ||
---|---|---|
1 |
package org.gvsig.oracle.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.oracle.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 |
|
Also available in: Unified diff