Revision 13423
trunk/applications/appgvSIG/src-test/com/iver/cit/gvsig/AllTests.java | ||
---|---|---|
7 | 7 |
import com.iver.cit.gvsig.project.ProjectTest; |
8 | 8 |
import com.iver.cit.gvsig.project.TableTest; |
9 | 9 |
import com.iver.cit.gvsig.sqlQueryValidation.TestSQLQueryValidation; |
10 |
import com.iver.cit.gvsig.test.Persistence; |
|
10 | 11 |
|
11 | 12 |
public class AllTests { |
12 | 13 |
|
13 | 14 |
public static Test suite() { |
14 | 15 |
TestSuite suite = new TestSuite("Test for com.iver.cit.gvsig"); |
15 | 16 |
//$JUnit-BEGIN$ |
17 |
suite.addTestSuite(Persistence.class); |
|
18 |
suite.addTestSuite(ProjectTest.class); |
|
16 | 19 |
suite.addTestSuite(TableTest.class); |
17 |
suite.addTestSuite(ProjectTest.class); |
|
18 | 20 |
suite.addTestSuite(TestFilterExpressionFromWhereIsEmpty_Method.class); |
19 | 21 |
suite.addTestSuite(TestSQLQueryValidation.class); |
20 | 22 |
|
trunk/applications/appgvSIG/src-test/com/iver/cit/gvsig/test/Persistence.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.test; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.io.File; |
|
5 |
|
|
6 |
import junit.framework.TestCase; |
|
7 |
|
|
8 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
|
9 |
import com.iver.cit.gvsig.ProjectExtension; |
|
10 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
11 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
12 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
|
13 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
|
14 |
import com.iver.cit.gvsig.fmap.edition.EditableAdapter; |
|
15 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
16 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
|
17 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
|
18 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
|
19 |
import com.iver.cit.gvsig.project.Project; |
|
20 |
import com.iver.cit.gvsig.project.ProjectFactory; |
|
21 |
import com.iver.cit.gvsig.project.documents.table.ProjectTable; |
|
22 |
import com.iver.cit.gvsig.project.documents.table.ProjectTableFactory; |
|
23 |
import com.iver.cit.gvsig.project.documents.view.ProjectView; |
|
24 |
|
|
25 |
/** |
|
26 |
* @author Fernando Gonz?lez Cort?s |
|
27 |
*/ |
|
28 |
public class Persistence extends TestCase { |
|
29 |
private ProjectExtension pe; |
|
30 |
|
|
31 |
/* |
|
32 |
* @see TestCase#setUp() |
|
33 |
*/ |
|
34 |
protected void setUp() throws Exception { |
|
35 |
pe = new ProjectExtension(); |
|
36 |
// pe.inicializar(); |
|
37 |
LayerFactory.setDriversPath( |
|
38 |
"/root/workspace/Andami/gvSIG/extensiones/com.iver.cit.gvsig/drivers"); |
|
39 |
|
|
40 |
LayerFactory.getDataSourceFactory().addFileDataSource("gdbms dbf driver", "prueba", |
|
41 |
"test/cities.dbf"); |
|
42 |
|
|
43 |
} |
|
44 |
|
|
45 |
public void testPersist() throws Throwable { |
|
46 |
Project p = new Project(); |
|
47 |
|
|
48 |
/* |
|
49 |
* A?adimos una vista con una capa |
|
50 |
*/ |
|
51 |
ProjectView v = new ProjectView(); |
|
52 |
ViewPort vp = new ViewPort( CRSFactory.getCRS("EPSG:23030")); |
|
53 |
vp.setImageSize(new Dimension(500, 500)); |
|
54 |
|
|
55 |
MapContext fmap = new MapContext(vp); |
|
56 |
v.setMapContext(fmap); |
|
57 |
FLayer l = LayerFactory.createLayer("Vias", |
|
58 |
(VectorialFileDriver) LayerFactory.getDM().getDriver("gvSIG shp driver"), |
|
59 |
new File("test/cities.shp"), |
|
60 |
CRSFactory.getCRS("EPSG:23030")); |
|
61 |
fmap.getLayers().addLayer(l); |
|
62 |
|
|
63 |
/* |
|
64 |
* A?adimos la tabla del tema anterior |
|
65 |
*/ |
|
66 |
SelectableDataSource sds1 = ((AlphanumericData) l).getRecordset(); |
|
67 |
EditableAdapter ea1 = new EditableAdapter(); |
|
68 |
ea1.setOriginalDataSource(sds1); |
|
69 |
|
|
70 |
ProjectTable pt1 = ProjectFactory.createTable("tabla", ea1); |
|
71 |
p.addDocument(pt1); |
|
72 |
|
|
73 |
/* |
|
74 |
* A?adimos otra tabla |
|
75 |
*/ |
|
76 |
SelectableDataSource sds2 = new SelectableDataSource(LayerFactory.getDataSourceFactory().createRandomDataSource("prueba", DataSourceFactory.MANUAL_OPENING)); |
|
77 |
EditableAdapter ea2 = new EditableAdapter(); |
|
78 |
ea2.setOriginalDataSource(sds2); |
|
79 |
ProjectTable pt2 = ProjectFactory.createTable("tabla2", ea2); |
|
80 |
p.addTable(pt2); |
|
81 |
|
|
82 |
/* |
|
83 |
* Creamos un join |
|
84 |
*/ |
|
85 |
String sql = "custom com_iver_cit_gvsig_arcjoin tables '"+ |
|
86 |
sds1.getName()+"', '"+sds1.getName()+"' values(NAME,NAME);"; |
|
87 |
|
|
88 |
SelectableDataSource result = new SelectableDataSource( |
|
89 |
LayerFactory.getDataSourceFactory() |
|
90 |
.executeSQL(sql, DataSourceFactory.MANUAL_OPENING)); |
|
91 |
EditableAdapter auxea=new EditableAdapter(); |
|
92 |
auxea.setOriginalDataSource(result); |
|
93 |
|
|
94 |
pt1.replaceDataSource(auxea); |
|
95 |
|
|
96 |
/* |
|
97 |
* Guardamos y cargamos |
|
98 |
*/ |
|
99 |
File temp = File.createTempFile("junit-", ".gvp"); |
|
100 |
temp.deleteOnExit(); |
|
101 |
pe.writeProject(temp, p); |
|
102 |
|
|
103 |
Project p2 = pe.readProject(temp); |
|
104 |
|
|
105 |
/* |
|
106 |
* Comprobamos que las dos tablas son id?nticas |
|
107 |
*/ |
|
108 |
assertTrue(((ProjectTable)p2.getDocumentsByType(ProjectTableFactory.registerName).get(0)).getModelo().getRecordset().getAsString().equals(((ProjectTable)p.getTables().get(0)).getModelo().getRecordset().getAsString())); |
|
109 |
assertTrue(((ProjectTable)p2.getDocumentsByType(ProjectTableFactory.registerName).get(1)).getModelo().getRecordset().getAsString().equals(((ProjectTable)p.getTables().get(1)).getModelo().getRecordset().getAsString())); |
|
110 |
} |
|
111 |
} |
|
0 | 112 |
trunk/applications/appgvSIG/build.xml | ||
---|---|---|
7 | 7 |
|
8 | 8 |
<!-- |
9 | 9 |
============================================ |
10 |
Properties for build of the appgvSIG proyect
|
|
10 |
Properties for build of the appgvSIG project
|
|
11 | 11 |
============================================ |
12 | 12 |
--> |
13 | 13 |
<property name="version" value="1.2 ${eclipse.startTime}"/> |
14 | 14 |
<property name="src" location="src"/> |
15 | 15 |
<property name="build" location="bin"/> |
16 |
<property name="src-test" location="src-test"/> |
|
17 |
<property name="build-test" location="bin-test"/> |
|
16 | 18 |
<property name="dist" location="dist"/> |
17 | 19 |
<property name="lib" location="lib"/> |
18 | 20 |
<property name="plugin" value="com.iver.cit.gvsig"/> |
... | ... | |
49 | 51 |
|
50 | 52 |
<!-- |
51 | 53 |
============================================ |
52 |
Targets for build of the appgvSIG proyect
|
|
54 |
Targets for build of the appgvSIG project
|
|
53 | 55 |
============================================ |
54 | 56 |
--> |
55 | 57 |
|
... | ... | |
78 | 80 |
<!-- Compile the Java code from ${src} to ${build} --> |
79 | 81 |
<loadEclipseClasspath project="${basedir}"/> |
80 | 82 |
<gvSIG-javac |
81 |
classpath="${eclipseClasspath}" |
|
82 |
excludes="com/iver/cit/gvsig/test/**"/> |
|
83 |
classpath="${eclipseClasspath}"/> |
|
83 | 84 |
|
84 | 85 |
</target> |
85 | 86 |
|
... | ... | |
134 | 135 |
<delete dir="${build}"/> |
135 | 136 |
<!--<delete dir="${dist}"/> --> |
136 | 137 |
</target> |
137 |
|
|
138 |
<target name="run-tests"> |
|
138 |
|
|
139 |
<target name="run-tests" depends="batch-build,compile-tests">
|
|
139 | 140 |
<antcall target="generic-run-tests"> |
140 | 141 |
<param name="TestSuite.Name" value="com.iver.cit.gvsig.AllTests"/> |
141 | 142 |
</antcall> |
... | ... | |
244 | 245 |
<target name="clean-all-projects" |
245 | 246 |
description="cleans the base components of gvSIG: appgvSIG + libs"> |
246 | 247 |
<!-- Delete the ${build} and ${dist} directory trees --> |
247 |
<foreach list="${gvSIG_projects}" delimiter="," target="clean-proyect" param="c-proyect.name"/>
|
|
248 |
<foreach list="${gvSIG_projects}" delimiter="," target="clean-project" param="c-project.name"/>
|
|
248 | 249 |
</target> |
249 | 250 |
|
250 | 251 |
<target name="install-all" |
... | ... | |
296 | 297 |
</target> |
297 | 298 |
|
298 | 299 |
|
299 |
<target name="clean-proyect">
|
|
300 |
<property name="c-proyect.dir" location="../${c-proyect.name}"/>
|
|
300 |
<target name="clean-project">
|
|
301 |
<property name="c-project.dir" location="../${c-project.name}"/>
|
|
301 | 302 |
<if> |
302 |
<available file="${c-proyect.dir}" type="dir"/>
|
|
303 |
<available file="${c-project.dir}" type="dir"/>
|
|
303 | 304 |
<then> |
304 | 305 |
<echo> |
305 |
Clean ${c-proyect.name}
|
|
306 |
Clean ${c-project.name}
|
|
306 | 307 |
</echo> |
307 |
<ant dir="${c-proyect.dir}" target="clean" inheritAll="false"/>
|
|
308 |
<ant dir="${c-project.dir}" target="clean" inheritAll="false"/>
|
|
308 | 309 |
</then> |
309 | 310 |
<else> |
310 | 311 |
<if> |
311 |
<contains string="${mandatoryProjets}" substring="${c-proyect.name}"/>
|
|
312 |
<contains string="${mandatoryProjets}" substring="${c-project.name}"/>
|
|
312 | 313 |
<then> |
313 |
<fail message="The required project is missing for Clean: ${c-proyect.name}"/>
|
|
314 |
<fail message="The required project is missing for Clean: ${c-project.name}"/>
|
|
314 | 315 |
</then> |
315 | 316 |
<else> |
316 | 317 |
<echo> |
317 |
Skip ${c-proyect.name} project from Clean
|
|
318 |
Skip ${c-project.name} project from Clean
|
|
318 | 319 |
</echo> |
319 | 320 |
</else> |
320 | 321 |
</if> |
... | ... | |
404 | 405 |
<move file="${JUnitGlobalResultsFile}" |
405 | 406 |
tofile="${JUnitGlobalResults}.old" |
406 | 407 |
failonerror="false" /> |
407 |
|
|
408 |
<var name="gvSIG_projects" value="_fwAndami,appgvSIG,libInternationalization,libRaster,libDXF,libCorePlugin" /> |
|
408 |
<property file="build.number"/> |
|
409 |
<!-- <property name="gvSIG_projects" value="libInternationalization,libIverUtiles,libUIComponent,libExceptions,_fwAndami,libCorePlugin,libProjection,libRaster,libDXF,libDriverManager,libRemoteServices,libGDBMS,libFMap,appgvSIG,libJCRS,extJCRS,libDwg,extDwg,extRasterTools-SE,extAddEventTheme,appCatalogAndGazetteerClient,extCatalogAndGazetteer,extDataLocator,extJDBC,extCAD,extGeoProcessing,extGeoprocessingExtensions,extGeoreferencing,extOracleSpatial,extSDE,extScripting,extAnnotations,extExpresionField,extWCS,extWFS2,extWMS,extCenterViewToPoint,libArcIMS,extArcims,binaries"/>--> |
|
410 |
<var name="gvSIG_projects" value="libInternationalization,_fwAndami,libCorePlugin,libRaster,libDXF,libFMap,appgvSIG" /> |
|
409 | 411 |
<foreach list="${gvSIG_projects}" |
410 | 412 |
delimiter="," |
411 | 413 |
target="run-one-test" |
... | ... | |
419 | 421 |
<if> |
420 | 422 |
<available file="${FlagTestError}" type="file"/> |
421 | 423 |
<then> |
424 |
<echo file="${JUnitGlobalResultsFile}.tmp"> === Global JUnit Results: FAILURE.${line.separator}${line.separator}</echo> |
|
425 |
<concat destfile="${JUnitGlobalResultsFile}.tmp2" |
|
426 |
binary="true"> |
|
427 |
<fileset file="${JUnitGlobalResultsFile}.tmp"/> |
|
428 |
<fileset file="${JUnitGlobalResultsFile}"/> |
|
429 |
</concat> |
|
430 |
<move file="${JUnitGlobalResultsFile}.tmp2" tofile="${JUnitGlobalResultsFile}"/> |
|
431 |
<delete file="${JUnitGlobalResultsFile}.tmp"/> |
|
422 | 432 |
<echo level="error">JUnitTests: FAILURE. |
423 | 433 |
See ${JUnitGlobalResultsFile} file for details. |
424 | 434 |
</echo> |
425 | 435 |
</then> |
426 | 436 |
<else> |
437 |
<echo file="${JUnitGlobalResultsFile}.tmp"> === Global JUnit Results: SUCCESS.${line.separator}${line.separator}</echo> |
|
438 |
<concat destfile="${JUnitGlobalResultsFile}.tmp2" |
|
439 |
binary="true"> |
|
440 |
<fileset file="${JUnitGlobalResultsFile}.tmp"/> |
|
441 |
<fileset file="${JUnitGlobalResultsFile}"/> |
|
442 |
</concat> |
|
443 |
<move file="${JUnitGlobalResultsFile}.tmp2" tofile="${JUnitGlobalResultsFile}"/> |
|
444 |
<delete file="${22JUnitGlobalResultsFile}.tmp"/> |
|
427 | 445 |
<echo>JUnitTests: SUCCESS. |
428 | 446 |
See ${JUnitGlobalResultsFile} file for details. |
429 | 447 |
</echo> |
Also available in: Unified diff