Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWFS2 / src-test / com / iver / cit / gvsig / wfs / filters / FilterEncodingTest.java @ 27070

History | View | Annotate | Download (3.51 KB)

1
package com.iver.cit.gvsig.wfs.filters;
2

    
3
import junit.framework.TestCase;
4

    
5
import org.gvsig.remoteClient.wfs.filters.FilterEncoding;
6

    
7
import com.iver.cit.gvsig.fmap.drivers.wfs.filters.SQLExpressionFormat;
8
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
9
 *
10
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
11
 *
12
 * This program is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU General Public License
14
 * as published by the Free Software Foundation; either version 2
15
 * of the License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
25
 *
26
 * For more information, contact:
27
 *
28
 *  Generalitat Valenciana
29
 *   Conselleria d'Infraestructures i Transport
30
 *   Av. Blasco Ib??ez, 50
31
 *   46010 VALENCIA
32
 *   SPAIN
33
 *
34
 *      +34 963862235
35
 *   gvsig@gva.es
36
 *      www.gvsig.gva.es
37
 *
38
 *    or
39
 *
40
 *   IVER T.I. S.A
41
 *   Salamanca 50
42
 *   46005 Valencia
43
 *   Spain
44
 *
45
 *   +34 963163400
46
 *   dac@iver.es
47
 */
48
/* CVS MESSAGES:
49
 *
50
 * $Id: FilterEncodingTest.java 12328 2007-06-26 07:50:20Z jorpiell $
51
 * $Log$
52
 * Revision 1.1.2.3  2007-06-26 07:50:20  jorpiell
53
 * Test updated
54
 *
55
 * Revision 1.1.2.2  2006/11/17 11:28:45  ppiqueras
56
 * Corregidos bugs y a?adida nueva funcionalidad.
57
 *
58
 * Revision 1.1  2006/10/05 10:26:26  jorpiell
59
 * A?adidas las clases para obtener los filtros
60
 *
61
 *
62
 */
63
/**
64
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
65
 */
66
public class FilterEncodingTest extends TestCase {
67
        String query1 = "nombre='pepe' and apellidos='sanchez' or edad < 3"; 
68
        String filter1 = "<Filter><Or><And><PropertyIsEqualTo><PropertyName>nombre</PropertyName><Literal>pepe</Literal></PropertyIsEqualTo><PropertyIsEqualTo><PropertyName>apellidos</PropertyName><Literal>sanchez</Literal></PropertyIsEqualTo></And><PropertyIsLessThan><PropertyName>edad</PropertyName><Literal>3</Literal></PropertyIsLessThan></Or></Filter>";
69
        String query2 = "nombre='pepe' or apellidos='sanchez' and edad < 3"; 
70
        String filter2 = "<Filter><Or><PropertyIsEqualTo><PropertyName>nombre</PropertyName><Literal>pepe</Literal></PropertyIsEqualTo><And><PropertyIsEqualTo><PropertyName>apellidos</PropertyName><Literal>sanchez</Literal></PropertyIsEqualTo><PropertyIsLessThan><PropertyName>edad</PropertyName><Literal>3</Literal></PropertyIsLessThan></And></Or></Filter>";
71
        String query3 = "nombre='pepe' or apellidos='sanchez' or edad < 3"; 
72
        String filter3 = "<Filter><Or><PropertyIsEqualTo><PropertyName>nombre</PropertyName><Literal>pepe</Literal></PropertyIsEqualTo><Or><PropertyIsEqualTo><PropertyName>apellidos</PropertyName><Literal>sanchez</Literal></PropertyIsEqualTo><PropertyIsLessThan><PropertyName>edad</PropertyName><Literal>3</Literal></PropertyIsLessThan></Or></Or></Filter>";
73
        
74
//        public void test1(){
75
//                parseQuery(query1,filter1);
76
//        }
77
//        
78
//        public void test2(){
79
//                parseQuery(query2,filter2);
80
//        }
81
        
82
        public void test3(){
83
                parseQuery(query3,filter3);
84
        }
85
        
86
        private void parseQuery(String query, String filter){
87
                FilterEncoding fe = new FilterEncoding(new SQLExpressionFormat());
88
                fe.setQuery(query);
89
                System.out.println(fe.toString());
90
                assertEquals(fe.toString(), filter);
91
        }
92
}