Revision 40435
trunk/org.gvsig.desktop/README.txt | ||
---|---|---|
1 |
|
|
2 |
Como compilar |
|
3 |
================ |
|
4 |
|
|
5 |
Para compilar la aplicacion gvSIG es necesario disponer de: |
|
6 |
|
|
7 |
- maven instalado en el sistema, recomenado maven 3 (aunque podria compilar |
|
8 |
con maven 2). |
|
9 |
|
|
10 |
- Acceso a internet para acceder a los repositorios de maven de la aplicacion. |
|
11 |
|
|
12 |
- Configurar la variable MAVEN_OPTS con el valor adecuado (ver "notas de compilacion"). |
|
13 |
|
|
14 |
- Descargar la carpeta org.gvsig.desktop y ejecutar "mvn clean install". |
|
15 |
|
|
16 |
Esto, por defecto, desplegara en la carpeta target/product la instalacion de gvSIG. |
|
17 |
|
|
18 |
Notas de compilacion |
|
19 |
======================== |
|
20 |
|
|
21 |
MAVEN_OPTS |
|
22 |
------------ |
|
23 |
|
|
24 |
Para que compile correctamente gvsig precisaremos especificar en la variable |
|
25 |
MAVEN_OPTS una serie de valores para reserbar memoria para el compilador. |
|
26 |
|
|
27 |
Valores adecuados para la compilacion del proyecto "org.gvsig.desktop" son:: |
|
28 |
|
|
29 |
-Xms256m -Xmx512m -XX:PerenmSize=64m -XX:MaxPermSize=128m |
|
30 |
|
|
31 |
Para asignar estos valores en linux puede hacerlo ejecutando la siguiente |
|
32 |
instruccion en la linea de comandos desde la que vaya a compilar:: |
|
33 |
|
|
34 |
export MAVEN_OPTS="-Xms256m -Xmx512m -XX:PerenmSize=64m -XX:MaxPermSize=128m" |
|
35 |
|
|
36 |
En windows .... ¿? FIXME |
|
37 |
|
|
38 |
|
|
39 |
Si esta compilando desde eclipse, precisara tener instalado el plugin maven2e |
|
40 |
y para configurarlo especifique en .... ¿? FIXME |
|
41 |
|
|
42 |
Cuando no especifica correctamente estos valores pueden aparecerle errores como: |
|
43 |
|
|
44 |
|
|
45 |
- Error "Compilation failure...":: |
|
46 |
|
|
47 |
[ERROR] BUILD FAILURE |
|
48 |
[INFO] ------------------------------------------------------------------------ |
|
49 |
[INFO] Compilation failure |
|
50 |
Failure executing javac, but could not parse the error: |
|
51 |
|
|
52 |
|
|
53 |
The system is out of resources. |
|
54 |
Consult the following stack trace for details. |
|
55 |
java.lang.OutOfMemoryError: PermGen space |
|
56 |
|
|
57 |
|
|
58 |
- Error "Error while executing forked tests...":: |
|
59 |
|
|
60 |
[ERROR] BUILD ERROR |
|
61 |
[INFO] ------------------------------------------------------------------------ |
|
62 |
[INFO] Error while executing forked tests.; nested exception is org.apache.maven.surefire.booter.shade.org.codehaus.plexus.util.cli.CommandLineException: Error setting up environmental variables |
|
63 |
|
|
64 |
java.io.IOException: error=12, Cannot allocate memory |
|
65 |
|
|
66 |
gvsig-devel.properties |
|
67 |
------------------------------ |
|
68 |
|
|
69 |
Por defecto al ejecutar "mvn install" sobre org.gvsig.desktop la aplicacion se desplegara |
|
70 |
en la carpeta target/product de ese mismo directorio. Una vez ejecutado ese primer |
|
71 |
comando maven sobre la carpeta org.gvsig.desktop debera editar el fichero |
|
72 |
".gvsig-devel.properties" de la carpeta del usuario si desea cambiarlo. |
|
73 |
|
|
74 |
Si tiene varios espacios de trabajo y desea que cada uno despliegue sobre una carpeta distinta |
|
75 |
puede copiar el fichero de su carpeta de usuario a la carpeta raiz de org.gvsig.desktop con el |
|
76 |
nombre "gvsig-devel.properties" y cambiar en el sobre donde quiere hacer el despliegue, asi puede |
|
77 |
tener varias "instancias" del desarrollo de gvSIG desplegandose sobre sitios distintos. |
|
78 |
|
|
79 |
Si ejecuta "mvn install" desde algun subproyecto de org.gvsig.desktop tenga en cuenta que solo |
|
80 |
se utilizara el fichero ".gvsig-devel.properties" que hay en su carpeta de usuario y no el del |
|
81 |
que se encuentre en org.gvsig.desktop . |
|
82 |
|
|
83 |
Notas pendientes |
|
84 |
================= |
|
85 |
|
|
86 |
Puede ser interesante mirar el plugin |
|
87 |
|
|
88 |
http://mojo.codehaus.org/versions-maven-plugin/ |
|
89 |
|
|
90 |
|
|
91 |
Importantes |
|
92 |
------------- |
|
93 |
|
|
94 |
- El plugin org.gvsig.mkmvnproject.app.mainplugin no se empaquete correctamente, no |
|
95 |
se descarga los fuentes de las plantillas, no se por que no lo hace aunque en el poms |
|
96 |
parece decirselo. |
|
97 |
|
|
98 |
- En el pom de org.gvsig.desktop.installer hay una variable que falta por |
|
99 |
definir. No tengo nada claro que valor a de tener. |
|
100 |
|
|
101 |
- No se estan generando los indices para los paquetes del administrador de complementos. |
|
102 |
|
|
103 |
- Hay que añadir la gestion de alias de paquetes del administrador de complementos. |
|
104 |
|
|
105 |
- Andami se lleva ahora muchas mas dependencias que antes, entre otras el api de la libreria |
|
106 |
de proyecciones (se lo lleva org.gvsig.ui) pero como no se lleva una implementacion |
|
107 |
peta en la inicializacion. De momento he puesto un exclude de org.gvsig.projection en el assembly. |
|
108 |
|
|
109 |
A tener en cuenta |
|
110 |
-------------------- |
|
111 |
|
|
112 |
- Los snappers que hay en appgvsig dependen de jts. |
|
113 |
Habria que ver de cambiar su implementacion para que usen el API |
|
114 |
de la libreria de geometrias y eliminar la dependencia de compilacion |
|
115 |
de appgvsig hacia jts del pom. |
|
116 |
|
|
117 |
- TangentPointSnapper |
|
118 |
- PixelSnapper |
|
119 |
- MediumPointSnapper |
|
120 |
- PerpendicularPointSnapper |
|
121 |
- NearestPointSnapper |
|
122 |
|
|
123 |
- La clase Line2DOffset en org.gvsig.symbology.lib.impl hace uso intensivo de JTS. |
|
124 |
Ver si es viable crear una operacion sobre la geometria que haga lo que hace esa clase. |
|
125 |
|
|
126 |
- En org.gvsig.symbology.swing se hace uso de funcionalidades de andami. |
|
127 |
|
|
128 |
- Hay que repasar la asignacion de iconos a las capas. Ver la extension |
|
129 |
de extDWG, pero puede afectar a otras. |
|
130 |
|
|
131 |
- Ver que pasa con las clases de DAL FeatureQueryOrder y DefaultFeatureComparator. |
|
132 |
De momento he hecho una chapuza y he incrustado DefaultFeatureComparator dentro |
|
133 |
de FeatureQueryOrder en el API. |
|
134 |
|
|
135 |
- En la libreria de geometrias, la operacion Equals y el metodo equals de Geometry hacen |
|
136 |
cosas distintas. En mapcontext, EqualsGeometryEvaluator, he sustituido la llamada a |
|
137 |
la operacion por el metodo. |
|
138 |
|
|
139 |
- El proyecto org.gvsig.new.layer.lib.impl tiene una dependencia con org.gvsig.projection.cresques.ui |
|
140 |
|
|
141 |
- En PluginServices, en el metodo getPluginHomeFolder, habria que hacer que si es nuevo copie los |
|
142 |
contenidos de los AlternativeNames a el. De esta forma seguira funcionanado con la configuracion |
|
143 |
que tuviese el usuario aunque se renombre un plugin. |
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
0 | 148 |
trunk/org.gvsig.desktop/maven-howto.rst | ||
---|---|---|
1 |
|
|
2 |
- How to reduce the process of "install" to run as fast as possible. |
|
3 |
Can reduce install execution skiping test execution and compilation, |
|
4 |
javadoc generation and test signature checking. |
|
5 |
|
|
6 |
mvn -Dmaven.test.skip=true -DskipTests -Dmaven.javadoc.skip=true -Danimal.sniffer.skip=true install |
|
7 |
|
|
8 |
- How to skip test compile from command line:: |
|
9 |
|
|
10 |
mvn -Dmaven.test.skip=true install |
|
11 |
|
|
12 |
- How to skip test execution from command line:: |
|
13 |
|
|
14 |
mvn -DskipTests install |
|
15 |
|
|
16 |
- How to skip javadoc generation from command line:: |
|
17 |
|
|
18 |
mvn -Dmaven.javadoc.skip=true install |
|
19 |
|
|
20 |
- How to skip test signature cheks from command line:: |
|
21 |
|
|
22 |
mvn -Danimal.sniffer.skip=true install |
|
23 |
|
|
24 |
- How to install a project without install submodules |
|
25 |
|
|
26 |
mvn --non-recursive install |
|
27 |
|
|
28 |
- How to skip test compilation:: |
|
29 |
|
|
30 |
<build> |
|
31 |
<plugins> |
|
32 |
... |
|
33 |
<plugin> |
|
34 |
<!-- Skip compilation tests --> |
|
35 |
<groupId>org.apache.maven.plugins</groupId> |
|
36 |
<artifactId>maven-compiler-plugin</artifactId> |
|
37 |
<executions> |
|
38 |
<execution> |
|
39 |
<id>default-testCompile</id> |
|
40 |
<phase>process-test-sources</phase> |
|
41 |
<goals> |
|
42 |
<goal>testCompile</goal> |
|
43 |
</goals> |
|
44 |
<configuration> |
|
45 |
<skip>true</skip> |
|
46 |
</configuration> |
|
47 |
</execution> |
|
48 |
</executions> |
|
49 |
</plugin> |
|
50 |
... |
|
51 |
</plugins> |
|
52 |
</build> |
|
53 |
|
|
54 |
- Skip test execution:: |
|
55 |
|
|
56 |
<build> |
|
57 |
<plugins> |
|
58 |
... |
|
59 |
<plugin> |
|
60 |
<!-- Skip test execution --> |
|
61 |
<groupId>org.apache.maven.plugins</groupId> |
|
62 |
<artifactId>maven-surefire-plugin</artifactId> |
|
63 |
<configuration> |
|
64 |
<skipTests>true</skipTests> |
|
65 |
</configuration> |
|
66 |
</plugin> |
|
67 |
... |
|
68 |
</plugins> |
|
69 |
</build> |
|
70 |
|
|
71 |
- Continue on test failure :: |
|
72 |
|
|
73 |
<build> |
|
74 |
<plugins> |
|
75 |
... |
|
76 |
<plugin> |
|
77 |
<!-- Continue on test failure --> |
|
78 |
<groupId>org.apache.maven.plugins</groupId> |
|
79 |
<artifactId>maven-surefire-plugin</artifactId> |
|
80 |
<configuration> |
|
81 |
<testFailureIgnore>true</testFailureIgnore> |
|
82 |
</configuration> |
|
83 |
</plugin> |
|
84 |
... |
|
85 |
</plugins> |
|
86 |
</build> |
|
87 |
|
|
88 |
|
|
89 |
- Set java compatibility:: |
|
90 |
|
|
91 |
<build> |
|
92 |
<plugins> |
|
93 |
... |
|
94 |
<plugin> |
|
95 |
<!-- Set java compatibility --> |
|
96 |
<groupId>org.apache.maven.plugins</groupId> |
|
97 |
<artifactId>maven-compiler-plugin</artifactId> |
|
98 |
<configuration> |
|
99 |
<source>1.5</source> |
|
100 |
<target>1.5</target> |
|
101 |
<encoding>ISO-8859-1</encoding> |
|
102 |
</configuration> |
|
103 |
</plugin> |
|
104 |
... |
|
105 |
</plugins> |
|
106 |
</build> |
|
107 |
|
|
108 |
- Packaging tests in jar |
|
109 |
|
|
110 |
Test classes do not packaging in jar by default. |
|
111 |
To packing add to pom:: |
|
112 |
|
|
113 |
<build> |
|
114 |
<plugins> |
|
115 |
... |
|
116 |
<plugin> |
|
117 |
<!-- Packaging tests in jar --> |
|
118 |
<groupId>org.apache.maven.plugins</groupId> |
|
119 |
<artifactId>maven-jar-plugin</artifactId> |
|
120 |
<executions> |
|
121 |
<!-- Generates a jar file only with the test classes --> |
|
122 |
<execution> |
|
123 |
<goals> |
|
124 |
<goal>test-jar</goal> |
|
125 |
</goals> |
|
126 |
<configuration> |
|
127 |
<includes> |
|
128 |
<include>**/**</include> |
|
129 |
</includes> |
|
130 |
</configuration> |
|
131 |
</execution> |
|
132 |
</executions> |
|
133 |
</plugin> |
|
134 |
... |
|
135 |
</plugins> |
|
136 |
</build> |
|
137 |
|
|
138 |
- How to set a dependency with tests jar:: |
|
139 |
|
|
140 |
<dependency> |
|
141 |
<groupId>...</groupId> |
|
142 |
<artifactId>...</artifactId> |
|
143 |
<type>test-jar</type> |
|
144 |
<scope>test</scope> |
|
145 |
</dependency> |
|
146 |
|
|
147 |
- How use ant in maven:: |
|
148 |
|
|
149 |
<plugin> |
|
150 |
<artifactId>maven-antrun-plugin</artifactId> |
|
151 |
<version>1.7</version> |
|
152 |
<executions> |
|
153 |
<execution> |
|
154 |
<phase>generate-sources</phase> |
|
155 |
<configuration> |
|
156 |
<target> |
|
157 |
<echo>Hello world!</echo> |
|
158 |
</target> |
|
159 |
</configuration> |
|
160 |
<goals> |
|
161 |
<goal>run</goal> |
|
162 |
</goals> |
|
163 |
</execution> |
|
164 |
</executions> |
|
165 |
</plugin> |
|
166 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.gvsig.desktop.library</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.m2e.core.maven2Builder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
</buildSpec> |
|
14 |
<natures> |
|
15 |
<nature>org.eclipse.m2e.core.maven2Nature</nature> |
|
16 |
</natures> |
|
17 |
</projectDescription> |
|
0 | 18 |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.utils/.classpath | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="src" output="target/classes" path="src/main/java"/> |
|
4 |
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> |
|
5 |
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/> |
|
6 |
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/> |
|
7 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> |
|
8 |
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/> |
|
9 |
<classpathentry kind="output" path="target/classes"/> |
|
10 |
</classpath> |
|
0 | 11 |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.utils/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.gvsig.utils</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
<buildCommand> |
|
14 |
<name>org.eclipse.m2e.core.maven2Builder</name> |
|
15 |
<arguments> |
|
16 |
</arguments> |
|
17 |
</buildCommand> |
|
18 |
</buildSpec> |
|
19 |
<natures> |
|
20 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
21 |
<nature>org.eclipse.m2e.core.maven2Nature</nature> |
|
22 |
</natures> |
|
23 |
</projectDescription> |
|
0 | 24 |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.utils/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
5 |
|
|
6 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
7 |
<layout class="org.apache.log4j.PatternLayout"> |
|
8 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
9 |
</layout> |
|
10 |
</appender> |
|
11 |
|
|
12 |
<category name="org.gvsig.tools"> |
|
13 |
<priority value="DEBUG" /> |
|
14 |
</category> |
|
15 |
|
|
16 |
<category name="org.gvsig.utils"> |
|
17 |
<priority value="DEBUG" /> |
|
18 |
</category> |
|
19 |
|
|
20 |
<root> |
|
21 |
<priority value="INFO" /> |
|
22 |
<appender-ref ref="CONSOLE" /> |
|
23 |
</root> |
|
24 |
</log4j:configuration> |
|
0 | 25 |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/TestXMLEntity.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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 Ib??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 |
|
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id: TestXMLEntity.java 30754 2009-09-09 06:42:28Z cordinyana $ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.7 2007-03-05 11:15:43 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.6 2007/03/05 10:03:12 jaume |
|
50 |
* *** empty log message *** |
|
51 |
* |
|
52 |
* Revision 1.5 2007/03/05 09:00:11 jaume |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* Revision 1.4 2007/03/02 13:35:56 jaume |
|
56 |
* *** empty log message *** |
|
57 |
* |
|
58 |
* Revision 1.3 2007/03/02 13:27:32 jaume |
|
59 |
* *** empty log message *** |
|
60 |
* |
|
61 |
* Revision 1.2 2007/03/02 13:24:53 jaume |
|
62 |
* *** empty log message *** |
|
63 |
* |
|
64 |
* Revision 1.1 2007/03/02 13:23:50 jaume |
|
65 |
* *** empty log message *** |
|
66 |
* |
|
67 |
* Revision 1.1 2006/08/29 06:18:17 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* |
|
71 |
*/ |
|
72 |
package org.gvsig.utils; |
|
73 |
|
|
74 |
import java.io.File; |
|
75 |
import java.io.FileReader; |
|
76 |
|
|
77 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
78 |
import org.gvsig.utils.xmlEntity.generate.XmlTag; |
|
79 |
|
|
80 |
|
|
81 |
public class TestXMLEntity extends AbstractLibraryAutoInitTestCase { |
|
82 |
private XMLEntity x1, x2, x3, x4; |
|
83 |
private XMLEntity gvp1; |
|
84 |
private XMLEntity gvp2; |
|
85 |
|
|
86 |
@Override |
|
87 |
protected void doSetUp() throws Exception { |
|
88 |
|
|
89 |
x1 = new XMLEntity(); |
|
90 |
x2 = new XMLEntity(); |
|
91 |
x3 = new XMLEntity(); |
|
92 |
|
|
93 |
|
|
94 |
final Object obj1 = new XMLEntity(); |
|
95 |
final Object obj2 = new XMLEntity(); |
|
96 |
final Object obj3 = "StringClass"; |
|
97 |
|
|
98 |
|
|
99 |
x1.putProperty("boolean1", false); |
|
100 |
x1.putProperty("boolean2", true); |
|
101 |
|
|
102 |
x1.putProperty("integer1", Integer.parseInt("123")); |
|
103 |
x1.putProperty("integer2", Integer.parseInt("321")); |
|
104 |
|
|
105 |
x1.putProperty("long1", Long.parseLong("123123")); |
|
106 |
x1.putProperty("long2", Long.parseLong("321321")); |
|
107 |
|
|
108 |
x1.putProperty("float1", Float.parseFloat("1234.1234")); |
|
109 |
x1.putProperty("float2", Float.parseFloat("4321.4321")); |
|
110 |
|
|
111 |
x1.putProperty("double1", Double.parseDouble("12341234.12341234")); |
|
112 |
x1.putProperty("double2", Double.parseDouble("43214321.43214321")); |
|
113 |
|
|
114 |
x1.putProperty("string1", "String1"); |
|
115 |
x1.putProperty("string2", "String2"); |
|
116 |
|
|
117 |
x1.putProperty("object1", obj1); |
|
118 |
x1.putProperty("object2", obj2); |
|
119 |
|
|
120 |
|
|
121 |
//----- x1 == x2 |
|
122 |
x2.putProperty("boolean1", false); |
|
123 |
x2.putProperty("boolean2", true); |
|
124 |
|
|
125 |
x2.putProperty("integer1", Integer.parseInt("123")); |
|
126 |
x2.putProperty("integer2", Integer.parseInt("321")); |
|
127 |
|
|
128 |
x2.putProperty("long1", Long.parseLong("123123")); |
|
129 |
x2.putProperty("long2", Long.parseLong("321321")); |
|
130 |
|
|
131 |
x2.putProperty("float1", Float.parseFloat("1234.1234")); |
|
132 |
x2.putProperty("float2", Float.parseFloat("4321.4321")); |
|
133 |
|
|
134 |
x2.putProperty("double1", Double.parseDouble("12341234.12341234")); |
|
135 |
x2.putProperty("double2", Double.parseDouble("43214321.43214321")); |
|
136 |
|
|
137 |
x2.putProperty("string1", "String1"); |
|
138 |
x2.putProperty("string2", "String2"); |
|
139 |
|
|
140 |
x2.putProperty("object1", obj1); |
|
141 |
x2.putProperty("object2", obj2); |
|
142 |
|
|
143 |
|
|
144 |
//----- x1 != x3 |
|
145 |
|
|
146 |
x3.putProperty("boolean1", false); |
|
147 |
x3.putProperty("boolean2", true); |
|
148 |
|
|
149 |
x3.putProperty("integer1", Integer.parseInt("123")); |
|
150 |
x3.putProperty("integer2", Integer.parseInt("321")); |
|
151 |
|
|
152 |
x3.putProperty("long1", Long.parseLong("123123")); |
|
153 |
x3.putProperty("long2", Long.parseLong("321321")); |
|
154 |
|
|
155 |
x3.putProperty("float1", Float.parseFloat("1234.1234")); |
|
156 |
x3.putProperty("float2", Float.parseFloat("4321.4321")); |
|
157 |
|
|
158 |
x3.putProperty("double1", Double.parseDouble("12341234.12341234")); |
|
159 |
x3.putProperty("double2", Double.parseDouble("43214321.43214324")); |
|
160 |
|
|
161 |
x3.putProperty("string1", "String1"); |
|
162 |
x3.putProperty("string2", "String2"); |
|
163 |
|
|
164 |
x3.putProperty("object1", obj1); |
|
165 |
x3.putProperty("object2", obj3); |
|
166 |
|
|
167 |
|
|
168 |
XmlTag tag; |
|
169 |
try { |
|
170 |
tag = (XmlTag) XmlTag.unmarshal( |
|
171 |
new FileReader(new File("testdata/sample.gvp"))); |
|
172 |
gvp1 = new XMLEntity(tag); |
|
173 |
|
|
174 |
tag = (XmlTag) XmlTag.unmarshal( |
|
175 |
new FileReader(new File("testdata/sample2.gvp"))); |
|
176 |
gvp2 = new XMLEntity(tag); |
|
177 |
} catch (Exception e) { |
|
178 |
// TODO Auto-generated catch block |
|
179 |
e.printStackTrace(); |
|
180 |
} |
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
} |
|
185 |
|
|
186 |
public void testEquality() { |
|
187 |
assertEquals(x1, x2); |
|
188 |
|
|
189 |
assertFalse(x1.equals(x3)); |
|
190 |
assertFalse(x2.equals(x3)); |
|
191 |
} |
|
192 |
|
|
193 |
|
|
194 |
public void testHash() { |
|
195 |
final long x1Hash = x1.hash(); |
|
196 |
final long x2Hash = x2.hash(); |
|
197 |
final long x3Hash = x3.hash(); |
|
198 |
|
|
199 |
assertTrue("x1 should be equals to x2", x1Hash == x2Hash); |
|
200 |
assertTrue("x1 should be distinct to x3", x1Hash != x3Hash); |
|
201 |
} |
|
202 |
|
|
203 |
|
|
204 |
public void testSkippedProperties() { |
|
205 |
x1.putProperty("skipped1", true, false); |
|
206 |
x1.putProperty("skipped2", 1, false); |
|
207 |
x1.putProperty("skipped3", 1D, false); |
|
208 |
x1.putProperty("skipped4", 1F, false); |
|
209 |
x1.putProperty("skipped5", 1L, false); |
|
210 |
x1.putProperty("skipped6", "bla bla", false); |
|
211 |
|
|
212 |
x2.putProperty("skipped1", false, false); |
|
213 |
x2.putProperty("skipped2", 2, false); |
|
214 |
x2.putProperty("skipped3", 2D, false); |
|
215 |
x2.putProperty("skipped4", 2F, false); |
|
216 |
x2.putProperty("skipped5", 2L, false); |
|
217 |
x2.putProperty("skipped6", "bla bla bleitor", false); |
|
218 |
|
|
219 |
x3.putProperty("skipped1", false, false); |
|
220 |
x3.putProperty("skipped2", 2, false); |
|
221 |
x3.putProperty("skipped3", 2D, false); |
|
222 |
x3.putProperty("skipped4", 2F, false); |
|
223 |
x3.putProperty("skipped5", 2L, false); |
|
224 |
x3.putProperty("skipped6", "bla bla bleitor", false); |
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
final long x1Hash = x1.hash(); |
|
229 |
final long x2Hash = x2.hash(); |
|
230 |
final long x3Hash = x3.hash(); |
|
231 |
|
|
232 |
assertTrue("x1 should be equals to x2", x1Hash == x2Hash); |
|
233 |
assertTrue("x1 should be distinct to x3", x1Hash != x3Hash); |
|
234 |
assertTrue("x2 should be distinct to x3", x2Hash != x3Hash); |
|
235 |
|
|
236 |
x1.remove("skipped1"); |
|
237 |
x1.remove("skipped2"); |
|
238 |
x1.remove("skipped3"); |
|
239 |
x1.remove("skipped4"); |
|
240 |
x1.remove("skipped5"); |
|
241 |
x1.remove("skipped6"); |
|
242 |
|
|
243 |
x2.remove("skipped1"); |
|
244 |
x2.remove("skipped2"); |
|
245 |
x2.remove("skipped3"); |
|
246 |
x2.remove("skipped4"); |
|
247 |
x2.remove("skipped5"); |
|
248 |
x2.remove("skipped6"); |
|
249 |
|
|
250 |
x3.remove("skipped1"); |
|
251 |
x3.remove("skipped2"); |
|
252 |
x3.remove("skipped3"); |
|
253 |
x3.remove("skipped4"); |
|
254 |
x3.remove("skipped5"); |
|
255 |
x3.remove("skipped6"); |
|
256 |
} |
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
public void testNonSkippedProperties() { |
|
261 |
x1.putProperty("non_skipped1", true, true); |
|
262 |
x1.putProperty("non_skipped2", 1, true); |
|
263 |
x1.putProperty("non_skipped3", 1D, true); |
|
264 |
x1.putProperty("non_skipped4", 1F, true); |
|
265 |
x1.putProperty("non_skipped5", 1L, true); |
|
266 |
x1.putProperty("non_skipped6", "bla bla", true); |
|
267 |
|
|
268 |
x3.putProperty("non_skipped1", false, true); |
|
269 |
x3.putProperty("non_skipped2", 2, true); |
|
270 |
x3.putProperty("non_skipped3", 2D, true); |
|
271 |
x3.putProperty("non_skipped4", 2F, true); |
|
272 |
x3.putProperty("non_skipped5", 2L, true); |
|
273 |
x3.putProperty("non_skipped6", "bla bla bleitor", true); |
|
274 |
|
|
275 |
x2.putProperty("non_skipped1", false, true); |
|
276 |
x2.putProperty("non_skipped2", 2, true); |
|
277 |
x2.putProperty("non_skipped3", 2D, true); |
|
278 |
x2.putProperty("non_skipped4", 2F, true); |
|
279 |
x2.putProperty("non_skipped5", 2L, true); |
|
280 |
x2.putProperty("non_skipped6", "bla bla bleitor", true); |
|
281 |
|
|
282 |
final long x1Hash = x1.hash(); |
|
283 |
final long x2Hash = x2.hash(); |
|
284 |
final long x3Hash = x3.hash(); |
|
285 |
|
|
286 |
assertFalse("x1 should be distinct to x2", x1Hash == x2Hash); |
|
287 |
assertFalse("x1 should be distinct to x3", x1Hash == x3Hash); |
|
288 |
assertFalse("x2 should be distinct to x3", x2Hash == x3Hash); |
|
289 |
|
|
290 |
|
|
291 |
// restore the XMEntities to the initial state and ensure that |
|
292 |
// passes the tests again |
|
293 |
x1.remove("non_skipped1"); |
|
294 |
x1.remove("non_skipped2"); |
|
295 |
x1.remove("non_skipped3"); |
|
296 |
x1.remove("non_skipped4"); |
|
297 |
x1.remove("non_skipped5"); |
|
298 |
x1.remove("non_skipped6"); |
|
299 |
|
|
300 |
x2.remove("non_skipped1"); |
|
301 |
x2.remove("non_skipped2"); |
|
302 |
x2.remove("non_skipped3"); |
|
303 |
x2.remove("non_skipped4"); |
|
304 |
x2.remove("non_skipped5"); |
|
305 |
x2.remove("non_skipped6"); |
|
306 |
|
|
307 |
x3.remove("non_skipped1"); |
|
308 |
x3.remove("non_skipped2"); |
|
309 |
x3.remove("non_skipped3"); |
|
310 |
x3.remove("non_skipped4"); |
|
311 |
x3.remove("non_skipped5"); |
|
312 |
x3.remove("non_skipped6"); |
|
313 |
|
|
314 |
testHash(); |
|
315 |
testEquality(); |
|
316 |
} |
|
317 |
|
|
318 |
|
|
319 |
public void testEquivalentProjects() { |
|
320 |
final long x1Hash = gvp1.hash(); |
|
321 |
final long x2Hash = gvp2.hash(); |
|
322 |
|
|
323 |
assertTrue("x1 should be equals to x2", x1Hash == x2Hash); |
|
324 |
} |
|
325 |
|
|
326 |
public void testBenchMark() { |
|
327 |
long t_ini, t_unmarshal, t_buildXMLEntity, t_computeHash ; |
|
328 |
t_ini = System.currentTimeMillis(); |
|
329 |
XmlTag tag; |
|
330 |
try { |
|
331 |
File f= new File("testdata/big.gvp"); |
|
332 |
tag = (XmlTag) XmlTag.unmarshal( |
|
333 |
new FileReader(f)); |
|
334 |
t_unmarshal = System.currentTimeMillis() - t_ini; |
|
335 |
|
|
336 |
gvp1 = new XMLEntity(tag); |
|
337 |
t_buildXMLEntity = System.currentTimeMillis() - t_unmarshal- t_ini; |
|
338 |
|
|
339 |
long hash = gvp1.hash(); |
|
340 |
t_computeHash = System.currentTimeMillis() - t_buildXMLEntity- t_ini; |
|
341 |
|
|
342 |
assertTrue("BenchMark ("+f.getAbsolutePath()+" "+f.length()/1024+"Kb):" + |
|
343 |
"\t-unmarshal time: "+t_unmarshal+" milliseconds\n" + |
|
344 |
"\t-build XMLEntity time: "+t_buildXMLEntity+" milliseconds\n" + |
|
345 |
"\t-compute hash time: "+t_computeHash+" milliseconds",t_computeHash < 500); |
|
346 |
|
|
347 |
} catch (Exception e) { |
|
348 |
// TODO Auto-generated catch block |
|
349 |
e.printStackTrace(); |
|
350 |
} |
|
351 |
|
|
352 |
} |
|
353 |
} |
|
0 | 354 |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/TestStringComparator.java | ||
---|---|---|
1 |
package org.gvsig.utils; |
|
2 |
|
|
3 |
import java.text.Collator; |
|
4 |
import java.util.Collections; |
|
5 |
import java.util.Locale; |
|
6 |
import java.util.Vector; |
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
import org.gvsig.utils.StringComparator; |
|
10 |
|
|
11 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
12 |
* |
|
13 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
14 |
* |
|
15 |
* This program is free software; you can redistribute it and/or |
|
16 |
* modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 2 |
|
18 |
* of the License, or (at your option) any later version. |
|
19 |
* |
|
20 |
* This program is distributed in the hope that it will be useful, |
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
* GNU General Public License for more details. |
|
24 |
* |
|
25 |
* You should have received a copy of the GNU General Public License |
|
26 |
* along with this program; if not, write to the Free Software |
|
27 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
28 |
* |
|
29 |
* For more information, contact: |
|
30 |
* |
|
31 |
* Generalitat Valenciana |
|
32 |
* Conselleria d'Infraestructures i Transport |
|
33 |
* Av. Blasco Ib??ez, 50 |
|
34 |
* 46010 VALENCIA |
|
35 |
* SPAIN |
|
36 |
* |
|
37 |
* +34 963862235 |
|
38 |
* gvsig@gva.es |
|
39 |
* www.gvsig.gva.es |
|
40 |
* |
|
41 |
* or |
|
42 |
* |
|
43 |
* IVER T.I. S.A |
|
44 |
* Salamanca 50 |
|
45 |
* 46005 Valencia |
|
46 |
* Spain |
|
47 |
* |
|
48 |
* +34 963163400 |
|
49 |
* dac@iver.es |
|
50 |
*/ |
|
51 |
|
|
52 |
/** |
|
53 |
* Tests the methods of the class <i>StringComparator</i> |
|
54 |
* |
|
55 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com) |
|
56 |
*/ |
|
57 |
public class TestStringComparator { |
|
58 |
/** |
|
59 |
* Test method for the TestMathExtension class |
|
60 |
* |
|
61 |
* @param args |
|
62 |
*/ |
|
63 |
public static void main(String[] args) |
|
64 |
{ |
|
65 |
StringComparator stringComparator = new StringComparator(); |
|
66 |
|
|
67 |
// Initialize the vector of Strings (for test methods with the parameter Comparator) |
|
68 |
Vector v = new Vector(); |
|
69 |
v.add("extWMS"); |
|
70 |
v.add("libUI"); |
|
71 |
v.add("extWMS"); |
|
72 |
v.add("libRemoteServices"); |
|
73 |
v.add("extWFS2"); |
|
74 |
v.add("libNomenclatorIGN"); |
|
75 |
v.add("libNomenclatorIGN_GUI"); |
|
76 |
v.add("libIverUtiles"); |
|
77 |
v.add("extWFS2"); |
|
78 |
v.add("EXTWFS2"); |
|
79 |
v.add("extWFS2"); |
|
80 |
v.add("libGDBMS"); |
|
81 |
v.add("libInternationalization"); |
|
82 |
v.add("libFMap"); |
|
83 |
v.add("6"); |
|
84 |
v.add("4"); |
|
85 |
v.add("3"); |
|
86 |
v.add("5"); |
|
87 |
v.add("2"); |
|
88 |
v.add("1"); |
|
89 |
v.add("extWFS2"); |
|
90 |
v.add("libExceptions"); |
|
91 |
v.add("libDriverManager"); |
|
92 |
v.add("libCq CMS for java"); |
|
93 |
v.add("libCorePlugin"); |
|
94 |
v.add("extWFS2"); |
|
95 |
v.add("extAddIDEELayers"); |
|
96 |
v.add("extAlertCClient"); |
|
97 |
v.add("extCAD"); |
|
98 |
v.add("extWFS2"); |
|
99 |
v.add("?and?"); |
|
100 |
v.add("?and?"); |
|
101 |
v.add("extJDBC"); |
|
102 |
v.add("extMyPlugin"); |
|
103 |
v.add("extRasterTools"); |
|
104 |
v.add("extScripting"); |
|
105 |
v.add("extWCS"); |
|
106 |
v.add("extWFS2"); |
|
107 |
v.add("extwfs2"); // If both are null -> true |
|
108 |
v.add("extWMS"); |
|
109 |
v.add("extWMS"); |
|
110 |
v.add("extWCS"); |
|
111 |
v.add("7"); |
|
112 |
v.add("9"); |
|
113 |
v.add("8"); |
|
114 |
v.add("0"); |
|
115 |
v.add("EXTWCS"); |
|
116 |
v.add("?and?"); |
|
117 |
v.add("extensi?n"); |
|
118 |
v.add("?AND?"); |
|
119 |
v.add("_fwAndami"); |
|
120 |
v.add("abcdefghijklmn?opqrstuvwxyz"); |
|
121 |
v.add("?"); |
|
122 |
v.add("appgvSIG"); |
|
123 |
v.add("la casa"); |
|
124 |
v.add("la monta?a"); |
|
125 |
v.add("la colina"); |
|
126 |
v.add("las abejas"); |
|
127 |
v.add("las nutrias"); |
|
128 |
v.add("las ballenas"); |
|
129 |
v.add("lasa?a"); |
|
130 |
v.add("Vector"); |
|
131 |
v.add("avi?n"); |
|
132 |
v.add("cami?n"); |
|
133 |
v.add("autob?s"); |
|
134 |
|
|
135 |
// Show the original vector |
|
136 |
System.out.println("Vector original: " + v.toString() + "\n"); |
|
137 |
|
|
138 |
// First kind of sort |
|
139 |
stringComparator.setCaseSensitive(true); |
|
140 |
List list = v.subList(0, v.size()); |
|
141 |
Collections.sort(list, stringComparator); |
|
142 |
System.out.println("Ordenaci?n normal con case-sensitive:" + list.toString() + "\n"); |
|
143 |
|
|
144 |
// Second kind of sort |
|
145 |
stringComparator.setCaseSensitive(false); |
|
146 |
list = v.subList(0, v.size()); |
|
147 |
Collections.sort(list, stringComparator); |
|
148 |
System.out.println("Ordenaci?n normal sin case-sensitive:" + list.toString() + "\n"); |
|
149 |
|
|
150 |
|
|
151 |
Collator collator = Collator.getInstance(new Locale("es_ES")); |
|
152 |
stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator)); |
|
153 |
|
|
154 |
// Third kind of sort |
|
155 |
stringComparator.setCaseSensitive(true); |
|
156 |
list = v.subList(0, v.size()); |
|
157 |
Collections.sort(list, stringComparator); |
|
158 |
System.out.println("Ordenaci?n con reglas locales y con case-sensitive:" + list.toString() + "\n"); |
|
159 |
|
|
160 |
// Fourth kind of sort |
|
161 |
stringComparator.setCaseSensitive(false); |
|
162 |
list = v.subList(0, v.size()); |
|
163 |
Collections.sort(list, stringComparator); |
|
164 |
System.out.println("Ordenaci?n con reglas locales y sin case-sensitive:" + list.toString() + "\n"); |
|
165 |
|
|
166 |
|
|
167 |
stringComparator.getLocaleRules().setUseLocaleRules(false); |
|
168 |
|
|
169 |
// Fifth kind of sort |
|
170 |
stringComparator.setCaseSensitive(true); |
|
171 |
list = v.subList(0, v.size()); |
|
172 |
Collections.sort(list, stringComparator); |
|
173 |
System.out.println("Ordenaci?n normal con case-sensitive:" + list.toString() + "\n"); |
|
174 |
|
|
175 |
// Sixth kind of sort |
|
176 |
stringComparator.setCaseSensitive(false); |
|
177 |
list = v.subList(0, v.size()); |
|
178 |
Collections.sort(list, stringComparator); |
|
179 |
System.out.println("Ordenaci?n normal sin case-sensitive:" + list.toString() + "\n"); |
|
180 |
} |
|
181 |
} |
|
0 | 182 |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/vectorUtilities/TestVectorUtilities.java | ||
---|---|---|
1 |
package org.gvsig.utils.vectorUtilities; |
|
2 |
|
|
3 |
import java.text.Collator; |
|
4 |
import java.util.Locale; |
|
5 |
import java.util.Vector; |
|
6 |
|
|
7 |
import org.gvsig.utils.StringComparator; |
|
8 |
import org.gvsig.utils.vectorUtilities.VectorUtilities; |
|
9 |
|
|
10 |
|
|
11 |
import junit.framework.TestCase; |
|
12 |
|
|
13 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
14 |
* |
|
15 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
16 |
* |
|
17 |
* This program is free software; you can redistribute it and/or |
|
18 |
* modify it under the terms of the GNU General Public License |
|
19 |
* as published by the Free Software Foundation; either version 2 |
|
20 |
* of the License, or (at your option) any later version. |
|
21 |
* |
|
22 |
* This program is distributed in the hope that it will be useful, |
|
23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
25 |
* GNU General Public License for more details. |
|
26 |
* |
|
27 |
* You should have received a copy of the GNU General Public License |
|
28 |
* along with this program; if not, write to the Free Software |
|
29 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
30 |
* |
|
31 |
* For more information, contact: |
|
32 |
* |
|
33 |
* Generalitat Valenciana |
|
34 |
* Conselleria d'Infraestructures i Transport |
|
35 |
* Av. Blasco Ib??ez, 50 |
|
36 |
* 46010 VALENCIA |
|
37 |
* SPAIN |
|
38 |
* |
|
39 |
* +34 963862235 |
|
40 |
* gvsig@gva.es |
|
41 |
* www.gvsig.gva.es |
|
42 |
* |
|
43 |
* or |
|
44 |
* |
|
45 |
* IVER T.I. S.A |
|
46 |
* Salamanca 50 |
|
47 |
* 46005 Valencia |
|
48 |
* Spain |
|
49 |
* |
|
50 |
* +34 963163400 |
|
51 |
* dac@iver.es |
|
52 |
*/ |
|
53 |
|
|
54 |
/** |
|
55 |
* Tests the methods of {@link VectorUtilities} |
|
56 |
* |
|
57 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com) |
|
58 |
*/ |
|
59 |
public class TestVectorUtilities extends TestCase { |
|
60 |
private static String obj; |
|
61 |
private static Vector v1 = new Vector(); |
|
62 |
private static Vector v2 = new Vector(); |
|
63 |
private static StringComparator stringComparator; |
|
64 |
|
|
65 |
/* |
|
66 |
* (non-Javadoc) |
|
67 |
* @see junit.framework.TestCase#setUp() |
|
68 |
*/ |
|
69 |
protected void setUp() throws Exception { |
|
70 |
super.setUp(); |
|
71 |
|
|
72 |
// Initialize the StringComparator |
|
73 |
stringComparator = new StringComparator(); |
|
74 |
|
|
75 |
// Set spanish rules and with case sensitive |
|
76 |
Collator collator = Collator.getInstance(new Locale("es_ES")); |
|
77 |
stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator)); |
|
78 |
stringComparator.setCaseSensitive(false); |
|
79 |
} |
|
80 |
|
|
81 |
/* |
|
82 |
* (non-Javadoc) |
|
83 |
* @see junit.framework.TestCase#tearDown() |
|
84 |
*/ |
|
85 |
protected void tearDown() throws Exception { |
|
86 |
super.tearDown(); |
|
87 |
} |
|
88 |
|
|
89 |
///// TEST OPERATION: addAlphabeticallyOrdered(Vector, Object) ///// |
|
90 |
|
|
91 |
/** |
|
92 |
* A test |
|
93 |
*/ |
|
94 |
public void test1() { |
|
95 |
try { |
|
96 |
// Insert at the beginning |
|
97 |
obj = new String("First"); |
|
98 |
|
|
99 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
|
100 |
|
|
101 |
System.out.println("Test 1:\nObj: " + obj + "\nResults: " + v1); |
|
102 |
} catch (Exception e) { |
|
103 |
e.printStackTrace(); |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* A test |
|
109 |
*/ |
|
110 |
public void test2() { |
|
111 |
try { |
|
112 |
// Insert at the end |
|
113 |
obj = new String("ZZ????"); |
|
114 |
|
|
115 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
|
116 |
|
|
117 |
System.out.println("Test 2:\nObj: " + obj + "\nResults: " + v1); |
|
118 |
} catch (Exception e) { |
|
119 |
e.printStackTrace(); |
|
120 |
} |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* A test |
|
125 |
*/ |
|
126 |
public void test3() { |
|
127 |
try { |
|
128 |
// An insertion |
|
129 |
obj = new String("?and?"); |
|
130 |
|
|
131 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
|
132 |
|
|
133 |
System.out.println("Test 3:\nObj: " + obj + "\nResults: " + v1); |
|
134 |
} catch (Exception e) { |
|
135 |
e.printStackTrace(); |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* A test |
|
141 |
*/ |
|
142 |
public void test4() { |
|
143 |
try { |
|
144 |
// An insertion |
|
145 |
obj = new String("?AND?"); |
|
146 |
|
|
147 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
|
148 |
|
|
149 |
System.out.println("Test 4:\nObj: " + obj + "\nResults: " + v1); |
|
150 |
} catch (Exception e) { |
|
151 |
e.printStackTrace(); |
|
152 |
} |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* A test |
|
157 |
*/ |
|
158 |
public void test5() { |
|
159 |
try { |
|
160 |
// An insertion |
|
161 |
obj = new String("appgvSIG"); |
|
162 |
|
|
163 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
|
164 |
|
|
165 |
System.out.println("Test 5:\nObj: " + obj + "\nResults: " + v1); |
|
166 |
} catch (Exception e) { |
|
167 |
e.printStackTrace(); |
|
168 |
} |
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* A test |
|
173 |
*/ |
|
174 |
public void test6() { |
|
175 |
try { |
|
176 |
// An insertion |
|
177 |
obj = new String("libIverUtiles"); |
|
178 |
|
|
179 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
|
180 |
|
|
181 |
System.out.println("Test 6:\nObj: " + obj + "\nResults: " + v1); |
|
182 |
} catch (Exception e) { |
|
183 |
e.printStackTrace(); |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
/** |
|
188 |
* A test |
|
189 |
*/ |
|
190 |
public void test7() { |
|
191 |
try { |
|
192 |
// An insertion |
|
193 |
obj = new String("libUI"); |
|
194 |
|
|
195 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
|
196 |
|
|
197 |
System.out.println("Test 7:\nObj: " + obj + "\nResults: " + v1); |
|
198 |
} catch (Exception e) { |
|
199 |
e.printStackTrace(); |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* A test |
|
205 |
*/ |
|
206 |
public void test8() { |
|
207 |
try { |
|
208 |
// An insertion |
|
209 |
obj = new String("libIverUtiles"); |
|
210 |
|
|
211 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
|
212 |
|
|
213 |
System.out.println("Test 8:\nObj: " + obj + "\nResults: " + v1); |
|
214 |
} catch (Exception e) { |
|
215 |
e.printStackTrace(); |
|
216 |
} |
|
217 |
} |
|
218 |
|
|
219 |
/** |
|
220 |
* A test |
|
221 |
*/ |
|
222 |
public void test9() { |
|
223 |
try { |
|
224 |
// An insertion |
|
225 |
obj = new String("extWFS"); |
|
226 |
|
|
227 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
|
228 |
|
|
229 |
System.out.println("Test 9:\nObj: " + obj + "\nResults: " + v1); |
|
230 |
} catch (Exception e) { |
|
231 |
e.printStackTrace(); |
|
232 |
} |
|
233 |
} |
|
234 |
///// END TEST OPERATION: addAlphabeticallyOrdered(Vector, Object) ///// |
|
235 |
|
|
236 |
///// TEST OPERATION: addAlphabeticallyOrdered(Vector, Object, Comparator) ///// |
|
237 |
|
|
238 |
/** |
|
239 |
* A test |
|
240 |
*/ |
|
241 |
public void test11() { |
|
242 |
try { |
|
243 |
// Insert at the beginning |
|
244 |
obj = new String("First"); |
|
245 |
|
|
246 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
|
247 |
|
|
248 |
System.out.println("Test 11:\nObj: " + obj + "\nResults: " + v2); |
|
249 |
} catch (Exception e) { |
|
250 |
e.printStackTrace(); |
|
251 |
} |
|
252 |
} |
|
253 |
|
|
254 |
/** |
|
255 |
* A test |
|
256 |
*/ |
|
257 |
public void test12() { |
|
258 |
try { |
|
259 |
// Insert at the end |
|
260 |
obj = new String("ZZ????"); |
|
261 |
|
|
262 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
|
263 |
|
|
264 |
System.out.println("Test 12:\nObj: " + obj + "\nResults: " + v2); |
|
265 |
} catch (Exception e) { |
|
266 |
e.printStackTrace(); |
|
267 |
} |
|
268 |
} |
|
269 |
|
|
270 |
/** |
|
271 |
* A test |
|
272 |
*/ |
|
273 |
public void test13() { |
|
274 |
try { |
|
275 |
// An insertion |
|
276 |
obj = new String("?and?"); |
|
277 |
|
|
278 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
|
279 |
|
|
280 |
System.out.println("Test 13:\nObj: " + obj + "\nResults: " + v2); |
|
281 |
} catch (Exception e) { |
|
282 |
e.printStackTrace(); |
|
283 |
} |
|
284 |
} |
|
285 |
|
|
286 |
/** |
|
287 |
* A test |
|
288 |
*/ |
|
289 |
public void test14() { |
|
290 |
try { |
|
291 |
// An insertion |
|
292 |
obj = new String("?AND?"); |
|
293 |
|
|
294 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
|
295 |
|
|
296 |
System.out.println("Test 14:\nObj: " + obj + "\nResults: " + v2); |
|
297 |
} catch (Exception e) { |
|
298 |
e.printStackTrace(); |
|
299 |
} |
|
300 |
} |
|
301 |
|
|
302 |
/** |
|
303 |
* A test |
|
304 |
*/ |
|
305 |
public void test15() { |
|
306 |
try { |
|
307 |
// An insertion |
|
308 |
obj = new String("appgvSIG"); |
|
309 |
|
|
310 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
|
311 |
|
|
312 |
System.out.println("Test 15:\nObj: " + obj + "\nResults: " + v2); |
|
313 |
} catch (Exception e) { |
|
314 |
e.printStackTrace(); |
|
315 |
} |
|
316 |
} |
|
317 |
|
|
318 |
/** |
|
319 |
* A test |
|
320 |
*/ |
|
321 |
public void test16() { |
|
322 |
try { |
|
323 |
// An insertion |
|
324 |
obj = new String("libIverUtiles"); |
|
325 |
|
|
326 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
|
327 |
|
|
328 |
System.out.println("Test 16:\nObj: " + obj + "\nResults: " + v2); |
|
329 |
} catch (Exception e) { |
|
330 |
e.printStackTrace(); |
|
331 |
} |
|
332 |
} |
|
333 |
|
|
334 |
/** |
|
335 |
* A test |
|
336 |
*/ |
|
337 |
public void test17() { |
|
338 |
try { |
|
339 |
// An insertion |
|
340 |
obj = new String("libUI"); |
|
341 |
|
|
342 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
|
343 |
|
|
344 |
System.out.println("Test 17:\nObj: " + obj + "\nResults: " + v2); |
|
345 |
} catch (Exception e) { |
|
346 |
e.printStackTrace(); |
|
347 |
} |
|
348 |
} |
|
349 |
|
|
350 |
/** |
|
351 |
* A test |
|
352 |
*/ |
|
353 |
public void test18() { |
|
354 |
try { |
|
355 |
// An insertion |
|
356 |
obj = new String("libIverUtiles"); |
|
357 |
|
|
358 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
|
359 |
|
|
360 |
System.out.println("Test 18:\nObj: " + obj + "\nResults: " + v2); |
|
361 |
} catch (Exception e) { |
|
362 |
e.printStackTrace(); |
|
363 |
} |
|
364 |
} |
|
365 |
|
|
366 |
/** |
|
367 |
* A test |
|
368 |
*/ |
|
369 |
public void test19() { |
|
370 |
try { |
|
371 |
// An insertion |
|
372 |
obj = new String("extWFS"); |
|
373 |
|
|
374 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
|
375 |
|
|
376 |
System.out.println("Test 19:\nObj: " + obj + "\nResults: " + v2); |
|
377 |
} catch (Exception e) { |
|
378 |
e.printStackTrace(); |
|
379 |
} |
|
380 |
} |
|
381 |
|
|
382 |
///// END TEST OPERATION: addAlphabeticallyOrdered(Vector, Object, Comparator) ///// |
|
383 |
} |
|
0 | 384 |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/TestStringUtilities.java | ||
---|---|---|
1 |
package org.gvsig.utils; |
|
2 |
|
|
3 |
import org.gvsig.utils.StringUtilities; |
|
4 |
|
|
5 |
import junit.framework.TestCase; |
|
6 |
|
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
8 |
* |
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
10 |
* |
|
11 |
* This program is free software; you can redistribute it and/or |
|
12 |
* modify it under the terms of the GNU General Public License |
|
13 |
* as published by the Free Software Foundation; either version 2 |
|
14 |
* of the License, or (at your option) any later version. |
|
15 |
* |
|
16 |
* This program is distributed in the hope that it will be useful, |
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
* GNU General Public License for more details. |
|
20 |
* |
|
21 |
* You should have received a copy of the GNU General Public License |
|
22 |
* along with this program; if not, write to the Free Software |
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
24 |
* |
|
25 |
* For more information, contact: |
|
26 |
* |
|
27 |
* Generalitat Valenciana |
|
28 |
* Conselleria d'Infraestructures i Transport |
|
29 |
* Av. Blasco Ib??ez, 50 |
|
30 |
* 46010 VALENCIA |
|
31 |
* SPAIN |
|
32 |
* |
|
33 |
* +34 963862235 |
|
34 |
* gvsig@gva.es |
|
35 |
* www.gvsig.gva.es |
|
36 |
* |
|
37 |
* or |
|
38 |
* |
|
39 |
* IVER T.I. S.A |
|
40 |
* Salamanca 50 |
|
41 |
* 46005 Valencia |
|
42 |
* Spain |
|
43 |
* |
|
44 |
* +34 963163400 |
|
45 |
* dac@iver.es |
|
46 |
*/ |
|
47 |
|
|
48 |
/** |
|
49 |
* This class tests some methods of the 'StringUtilities' class |
|
50 |
* (Now only tests the methods 'numberOfOccurrencesOfSubStringInString' and 'numberOfOccurrencesOfSubStringInStringUpToPosition') |
|
51 |
* |
|
52 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com) |
|
53 |
*/ |
|
54 |
public class TestStringUtilities extends TestCase{ |
|
55 |
private String word_String; |
|
56 |
private String word_subString; |
|
57 |
private boolean case_Sensitive; |
|
58 |
private int start_position; |
|
59 |
private int end_position; |
|
60 |
|
|
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* @see junit.framework.TestCase#setUp() |
|
64 |
*/ |
|
65 |
protected void setUp() throws Exception { |
|
66 |
super.setUp(); |
|
67 |
word_String = new String(); |
|
68 |
word_subString = new String(); |
|
69 |
case_Sensitive = true; // By default, case sensitive |
|
70 |
} |
|
71 |
|
|
72 |
/* |
|
73 |
* (non-Javadoc) |
|
74 |
* @see junit.framework.TestCase#tearDown() |
|
75 |
*/ |
|
76 |
protected void tearDown() throws Exception { |
|
77 |
super.tearDown(); |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* A test |
|
82 |
*/ |
|
83 |
public void test1() { |
|
84 |
word_String = "la casa es grande"; |
|
85 |
word_subString = "a"; |
|
86 |
case_Sensitive = true; |
|
87 |
|
|
88 |
System.out.print("Test1: El n?mero de ocurrencias"); |
|
89 |
|
|
90 |
if (case_Sensitive) |
|
91 |
System.out.print(" con distinci?n min?sculas/may?sculas "); |
|
92 |
else |
|
93 |
System.out.print(" sin distinci?n min?sculas/may?sculas "); |
|
94 |
|
|
95 |
System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive)); |
|
96 |
} |
|
97 |
|
|
98 |
/** |
Also available in: Unified diff