svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / test / java / org / gvsig / app / test / Persistence.java @ 40558
History | View | Annotate | Download (3.94 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.test; |
25 |
|
26 |
import junit.framework.TestCase; |
27 |
|
28 |
import org.gvsig.app.extension.ProjectExtension; |
29 |
|
30 |
/**
|
31 |
* @author Fernando Gonz?lez Cort?s
|
32 |
*/
|
33 |
//TODO comentado para que compile
|
34 |
public class Persistence extends TestCase { |
35 |
private ProjectExtension pe;
|
36 |
|
37 |
/*
|
38 |
* @see TestCase#setUp()
|
39 |
*/
|
40 |
protected void setUp() throws Exception { |
41 |
pe = new ProjectExtension();
|
42 |
// pe.inicializar();
|
43 |
// LayerFactory.setDriversPath(
|
44 |
// "/root/workspace/Andami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
|
45 |
//
|
46 |
// LayerFactory.getDataSourceFactory().addFileDataSource("gdbms dbf driver", "prueba",
|
47 |
// "test/cities.dbf");
|
48 |
|
49 |
} |
50 |
|
51 |
public void testPersist() throws Throwable { |
52 |
// Project p = new Project();
|
53 |
//
|
54 |
// /*
|
55 |
// * A?adimos una vista con una capa
|
56 |
// */
|
57 |
// ProjectView v = new ProjectView();
|
58 |
// ViewPort vp = new ViewPort( CRSFactory.getCRS("EPSG:23030"));
|
59 |
// vp.setImageSize(new Dimension(500, 500));
|
60 |
//
|
61 |
// MapContext fmap = new MapContext(vp);
|
62 |
// v.setMapContext(fmap);
|
63 |
// FLayer l = LayerFactory.createLayer("Vias",
|
64 |
// (VectorialFileDriver) LayerFactory.getDM().getDriver("gvSIG shp driver"),
|
65 |
// new File("test/cities.shp"),
|
66 |
// CRSFactory.getCRS("EPSG:23030"));
|
67 |
// fmap.getLayers().addLayer(l);
|
68 |
//
|
69 |
// /*
|
70 |
// * A?adimos la tabla del tema anterior
|
71 |
// */
|
72 |
// SelectableDataSource sds1 = ((FLyrVect) l).getRecordset();
|
73 |
// EditableAdapter ea1 = new EditableAdapter();
|
74 |
// ea1.setOriginalDataSource(sds1);
|
75 |
//
|
76 |
// ProjectTable pt1 = ProjectFactory.createTable("tabla", ea1);
|
77 |
// p.addDocument(pt1);
|
78 |
//
|
79 |
// /*
|
80 |
// * A?adimos otra tabla
|
81 |
// */
|
82 |
// SelectableDataSource sds2 = new SelectableDataSource(LayerFactory.getDataSourceFactory().createRandomDataSource("prueba", DataSourceFactory.MANUAL_OPENING));
|
83 |
// EditableAdapter ea2 = new EditableAdapter();
|
84 |
// ea2.setOriginalDataSource(sds2);
|
85 |
// ProjectTable pt2 = ProjectFactory.createTable("tabla2", ea2);
|
86 |
// p.addTable(pt2);
|
87 |
//
|
88 |
// /*
|
89 |
// * Creamos un join
|
90 |
// */
|
91 |
// String sql = "custom com_iver_cit_gvsig_arcjoin tables '"+
|
92 |
// sds1.getName()+"', '"+sds1.getName()+"' values(NAME,NAME);";
|
93 |
//
|
94 |
// SelectableDataSource result = new SelectableDataSource(
|
95 |
// LayerFactory.getDataSourceFactory()
|
96 |
// .executeSQL(sql, DataSourceFactory.MANUAL_OPENING));
|
97 |
// EditableAdapter auxea=new EditableAdapter();
|
98 |
// auxea.setOriginalDataSource(result);
|
99 |
//
|
100 |
// pt1.replaceDataSource(auxea);
|
101 |
//
|
102 |
// /*
|
103 |
// * Guardamos y cargamos
|
104 |
// */
|
105 |
// File temp = File.createTempFile("junit-", ".gvp");
|
106 |
// temp.deleteOnExit();
|
107 |
// pe.writeProject(temp, p);
|
108 |
//
|
109 |
// Project p2 = pe.readProject(temp);
|
110 |
//
|
111 |
// /*
|
112 |
// * Comprobamos que las dos tablas son id?nticas
|
113 |
// */
|
114 |
// assertTrue(((ProjectTable)p2.getDocumentsByType(ProjectTableFactory.registerName).get(0)).getModel().getRecordset().getAsString().equals(((ProjectTable)p.getTables().get(0)).getModel().getRecordset().getAsString()));
|
115 |
// assertTrue(((ProjectTable)p2.getDocumentsByType(ProjectTableFactory.registerName).get(1)).getModel().getRecordset().getAsString().equals(((ProjectTable)p.getTables().get(1)).getModel().getRecordset().getAsString()));
|
116 |
} |
117 |
} |