Index: TestOptimizer.java
===================================================================
--- TestOptimizer.java	(revision 44643)
+++ TestOptimizer.java	(revision 44644)
@@ -1,29 +1,16 @@
 package org.gvsig.expresionevaluator.impl;
 
-import static junit.framework.Assert.assertEquals;
 import org.gvsig.expressionevaluator.impl.SQLLexicalAnalyzer;
-import org.gvsig.expressionevaluator.impl.DefaultCompiler;
 import junit.framework.TestCase;
-import org.cresques.cts.IProjection;
 import org.gvsig.expressionevaluator.LexicalAnalyzer;
 import org.gvsig.expressionevaluator.Compiler;
 import org.gvsig.expressionevaluator.Code;
 import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionUtils;
 import org.gvsig.expressionevaluator.Interpreter;
 import org.gvsig.expressionevaluator.MutableSymbolTable;
 import org.gvsig.expressionevaluator.Optimizer;
 import org.gvsig.expressionevaluator.SymbolTable;
-import org.gvsig.expressionevaluator.impl.DefaultExpressionBuilder;
-import org.gvsig.expressionevaluator.impl.DefaultInterpreter;
-import org.gvsig.expressionevaluator.impl.DefaultOptimizer;
-import org.gvsig.expressionevaluator.impl.DefaultSymbolTable;
-import org.gvsig.fmap.crs.CRSFactory;
-import org.gvsig.fmap.geom.Geometry;
-import org.gvsig.fmap.geom.GeometryLocator;
-import org.gvsig.fmap.geom.GeometryManager;
-import org.gvsig.fmap.geom.exception.CreateGeometryException;
-import org.gvsig.fmap.geom.primitive.Point;
-import org.gvsig.fmap.geom.primitive.Polygon;
 import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
 
 public class TestOptimizer extends TestCase {
@@ -51,31 +38,32 @@
     }
 
     protected Compiler createCompiler() {
-        Compiler compiler = new DefaultCompiler();
+        Compiler compiler = ExpressionUtils.createCompiler();
         compiler.setLexicalAnalyzer(createLexicalAnalyzer());
         return compiler;
     }
 
     protected Interpreter createInterpreter(SymbolTable symbolTable) {
-        Interpreter interpreter = new DefaultInterpreter();
+        Interpreter interpreter = ExpressionUtils.createInterpreter();
         interpreter.setSymbolTable(symbolTable);
         return interpreter;
     }
 
     protected Optimizer createOptimizer(SymbolTable symbolTable) {
-        Optimizer optimizer = new DefaultOptimizer(symbolTable);
+        Optimizer optimizer = ExpressionUtils.createOptimizer();
+        optimizer.setSymbolTable(symbolTable);
         return optimizer;
     }
 
     protected MutableSymbolTable createSymbolTable() {
-        DefaultSymbolTable symbolTable = new DefaultSymbolTable();
+        MutableSymbolTable symbolTable = ExpressionUtils.createSymbolTable();
         symbolTable.setVar("precio", 200);
         symbolTable.setVar("1990", 0.168873933773767);
         return symbolTable;
     }
 
     private String createExpr1() {
-        ExpressionBuilder builder = new DefaultExpressionBuilder();
+        ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder();
 
         ExpressionBuilder.Value expr1 = builder.gt(
                 builder.column("campo1"),
@@ -89,29 +77,7 @@
         return expr1.toString();
     }
 
-    private Polygon createPolygon() throws CreateGeometryException {
-        GeometryManager geometryManager = GeometryLocator.getGeometryManager();
-        IProjection proj = CRSFactory.getCRS("EPSG:4326");
 
-        Polygon polygon = geometryManager.createPolygon(Geometry.SUBTYPES.GEOM2D);
-        polygon.addVertex(0, 0);
-        polygon.addVertex(0, 100);
-        polygon.addVertex(100, 100);
-        polygon.addVertex(100, 0);
-        polygon.addVertex(0, 0);
-
-        polygon.setProjection(proj);
-        return polygon;
-    }
-
-    private Geometry createPoint(double x, double y) throws CreateGeometryException {
-        GeometryManager geometryManager = GeometryLocator.getGeometryManager();
-        IProjection proj = CRSFactory.getCRS("EPSG:4326");
-        Point point = geometryManager.createPoint(x, y, Geometry.SUBTYPES.GEOM2D);
-        point.setProjection(proj);
-        return point;
-    }
-
     public void testIdentifier1() {
         String source = "precio";
 
@@ -449,54 +415,4 @@
         assertEquals("'hola'->length()", code2.toString());
     }
 
-    public void testSpatialExpression1() throws Exception {
-        IProjection proj = CRSFactory.getCRS("EPSG:4326");
-        ExpressionBuilder builder = new DefaultExpressionBuilder();
-        builder.geometry_support_type(ExpressionBuilder.GeometrySupportType.WKB);
-
-        String source = builder.and(
-                builder.custom(this.createExpr1()),
-                builder.ST_Intersects(
-                        builder.geometry(createPolygon()),
-                        builder.column("GEOMETRY")
-                )
-        ).toString();
-
-        MutableSymbolTable symbolTable = createSymbolTable();
-        symbolTable.setVar("campo1", 11);
-        symbolTable.setVar("GEOMETRY", createPoint(50, 50));
-
-        Interpreter interpreter = createInterpreter(symbolTable);
-        Compiler compiler = createCompiler();
-        Code code = compiler.compileExpression(source);
-        System.out.println(code.toString());
-        assertEquals(
-                "((\"campo1\" > 10) AND ST_Intersects(ST_GeomFromWKB(DECODE('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000', 'hex'), 4326), \"GEOMETRY\"))",
-                code.toString()
-        );
-
-//        long t1 = System.currentTimeMillis();
-//        for (int i = 0; i < 1000; i++) {
-//            interpreter.run(code);
-//        }
-//        System.out.println("Sin optimizar: " + (System.currentTimeMillis() - t1));
-
-//        t1 = System.currentTimeMillis();
-        Optimizer optimizer = createOptimizer(symbolTable);
-        Code code2 = optimizer.optimize(code);
-//        System.out.println("Tiempo de optimizacion: " + (System.currentTimeMillis() - t1));
-        System.out.println(code2.toString());
-        assertEquals(
-                "((\"campo1\" > 10) AND ST_Intersects('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))'::geometry, \"GEOMETRY\"))",
-                code2.toString()
-        );
-
-//        t1 = System.currentTimeMillis();
-//        for (int i = 0; i < 1000; i++) {
-//            interpreter.run(code2);
-//        }
-//        System.out.println("Optimizado: " + (System.currentTimeMillis() - t1));
-
-    }
-
 }
