|
1 |
/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
|
|
2 |
*
|
|
3 |
* Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana.
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or
|
|
6 |
* modify it under the terms of the GNU General Public License
|
|
7 |
* as published by the Free Software Foundation; either version 2
|
|
8 |
* of the License, or (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
|
18 |
*
|
|
19 |
* For more information, contact:
|
|
20 |
*
|
|
21 |
* Generalitat Valenciana
|
|
22 |
* Conselleria d'Infraestructures i Transport
|
|
23 |
* Av. Blasco Ibañez, 50
|
|
24 |
* 46010 VALENCIA
|
|
25 |
* SPAIN
|
|
26 |
*
|
|
27 |
* +34 963862235
|
|
28 |
* gvsig@gva.es
|
|
29 |
* www.gvsig.gva.es
|
|
30 |
*
|
|
31 |
* or
|
|
32 |
*
|
|
33 |
* IVER T.I. S.A
|
|
34 |
* Salamanca 50
|
|
35 |
* 46005 Valencia
|
|
36 |
* Spain
|
|
37 |
*
|
|
38 |
* +34 963163400
|
|
39 |
* dac@iver.es
|
|
40 |
*/
|
|
41 |
package org.gvsig.publish.geoserver.config;
|
|
42 |
|
|
43 |
import java.io.File;
|
|
44 |
|
|
45 |
import org.gvsig.publish.geoserver.config.CatalogPOSTGIS;
|
|
46 |
import org.gvsig.publish.geoserver.config.CatalogSHAPE;
|
|
47 |
import org.gvsig.publish.geoserver.config.InfoPOSTGIS;
|
|
48 |
import org.gvsig.publish.geoserver.config.InfoSHAPE;
|
|
49 |
|
|
50 |
import junit.framework.TestCase;
|
|
51 |
|
|
52 |
public class Test_GenerateConf extends TestCase {
|
|
53 |
/**
|
|
54 |
* Creates the Geoserver DATA_DIR
|
|
55 |
*
|
|
56 |
*/
|
|
57 |
protected void setUp() throws Exception {
|
|
58 |
File f = new File("test");
|
|
59 |
f.mkdir();
|
|
60 |
System.out.println("GEOSERVER_DATA_DIR: " + f.getAbsolutePath());
|
|
61 |
}
|
|
62 |
|
|
63 |
protected void tearDown() throws Exception {
|
|
64 |
}
|
|
65 |
|
|
66 |
public static String hostURL = "http://localhost:8080/geoserver";
|
|
67 |
public static String layer = "autopistas";
|
|
68 |
public static String dataStoreId = "cv300";
|
|
69 |
public static String confDir = "/home/jvhigon/test";
|
|
70 |
|
|
71 |
public static void testSHAPE(){
|
|
72 |
InfoSHAPE i=new InfoSHAPE(confDir,"/featureTypes/"+dataStoreId+"_"+layer+"/"
|
|
73 |
,dataStoreId,layer,"23030","/","8","false"
|
|
74 |
,"line","false","",-1.55,37.82,0.43,40.61);
|
|
75 |
|
|
76 |
CatalogSHAPE g=new CatalogSHAPE(confDir
|
|
77 |
,"topp","namespace",dataStoreId
|
|
78 |
,"file:data/"+dataStoreId+"/"+layer+".shp","true");
|
|
79 |
i.toXML();
|
|
80 |
i.close();
|
|
81 |
g.toXML();
|
|
82 |
g.close();
|
|
83 |
System.out.println("notificando cambios a geoserver ...");
|
|
84 |
g.update(hostURL, "admin","geoserver");
|
|
85 |
System.out.println("hecho.");
|
|
86 |
|
|
87 |
|
|
88 |
}
|
|
89 |
|
|
90 |
public static void testPOSTGIS(){
|
|
91 |
|
|
92 |
InfoPOSTGIS i=new InfoPOSTGIS(confDir,"/featureTypes/"+dataStoreId+"_"+layer+"/"
|
|
93 |
,dataStoreId,layer,"23030","/","8","false"
|
|
94 |
,"line","false","",-1.55,37.82,0.43,40.61);
|
|
95 |
CatalogPOSTGIS g=new CatalogPOSTGIS(confDir
|
|
96 |
,"topp","namespace",dataStoreId,"true",
|
|
97 |
"autopistas gv","true","david","chkdsk","true","localhost","public",
|
|
98 |
"5432","betel","postgis");
|
|
99 |
i.toXML();
|
|
100 |
i.close();
|
|
101 |
g.toXML();
|
|
102 |
g.close();
|
|
103 |
System.out.println("notificando cambios a geoserver ...");
|
|
104 |
g.update(hostURL, "admin","geoserver");
|
|
105 |
System.out.println("hecho.");
|
|
106 |
}
|
|
107 |
|
|
108 |
|
|
109 |
}
|