changeset 133:56655046194f

Fix Bug setting the Filtervalues into the Statement. Further Testcases implemented. geo-backend/trunk@14 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 04 Sep 2009 08:49:50 +0000 (2009-09-04)
parents 5a583cff97ea
children 488db510c517
files geo-backend/Changelog geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorBase.java geo-backend/src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java geo-backend/src/test/ressources/QueryExecutorTestCase.properties
diffstat 4 files changed, 37 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/geo-backend/Changelog	Fri Sep 04 08:11:30 2009 +0000
+++ b/geo-backend/Changelog	Fri Sep 04 08:49:50 2009 +0000
@@ -1,3 +1,12 @@
+2009-09-04  Tim Englich  <tim.englich@intevation.de>
+
+    * src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorBase.java (setFilterValues): Edited
+    Fixed Bug using replaceFirst an ?. You hav to put a ? in [].
+    * src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java (testQueryExecutor): Edited
+    Further TestCase using a where clause implemented. More asserts testimg the number of Results integrated
+     * src/test/ressources/QueryExecutorTestCase.properties: Edited
+      Statement Fetching only one Mesh integrated.
+      
 2009-09-04  Tim Englich  <tim.englich@intevation.de>
     
     * src/test/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnectionPoolTestCase.java: Edited
--- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorBase.java	Fri Sep 04 08:11:30 2009 +0000
+++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorBase.java	Fri Sep 04 08:49:50 2009 +0000
@@ -39,7 +39,7 @@
     protected String setFilterValues(String queryString, String[] filter){
         String returnValue = queryString;
         for (int i = 0; i < filter.length; i++){
-            returnValue = returnValue.replaceFirst("?", filter[i]);
+            returnValue = returnValue.replaceFirst("[?]", filter[i]);
         }
         return returnValue;
     }
--- a/geo-backend/src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java	Fri Sep 04 08:11:30 2009 +0000
+++ b/geo-backend/src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java	Fri Sep 04 08:49:50 2009 +0000
@@ -58,7 +58,8 @@
                 log.error("Keine Daten erhalten");
                 fail();
             }else {
-                log.debug("Datem erhalten");
+                assertEquals(6, results.size());
+                log.debug("6 Datens�tze erhalten");
                 Iterator<Result> it = results.iterator();
                 while (it.hasNext()){
                     Result tmpResult = it.next();
@@ -71,6 +72,29 @@
                     }
                 }
             }
+            
+            // Quering Data with where clause
+            results = queryExecutor.executeQuery("mesh_id", new String[]{"5"});
+            if (results == null || results.size() == 0){
+                log.error("Keine Daten erhalten");
+                fail();
+            }else {
+                assertEquals(1, results.size());
+                log.debug("1 Datensatz erhalten");
+                log.debug("Daten erhalten");
+                Iterator<Result> it = results.iterator();
+                while (it.hasNext()){
+                    Result tmpResult = it.next();
+                    ResultDescriptor resultDescriptor = tmpResult.getResultDescriptor();
+                    int columns = resultDescriptor.getColumnCount();
+                    for (int i = 0; i < columns; i++){
+                        String columnName = resultDescriptor.getColumnName(i);
+                        Object value = tmpResult.getObject(columnName);
+                        log.debug(columnName + " ==> "+value.toString());
+                    }
+                }
+            }
+            
         } catch (QueryException e) {
             log.error(e,e);
             fail();
--- a/geo-backend/src/test/ressources/QueryExecutorTestCase.properties	Fri Sep 04 08:11:30 2009 +0000
+++ b/geo-backend/src/test/ressources/QueryExecutorTestCase.properties	Fri Sep 04 08:49:50 2009 +0000
@@ -1,1 +1,2 @@
-mesh=Select MESHID, NAME from MEDIAN.MESH
\ No newline at end of file
+mesh=Select MESHID, NAME from MEDIAN.MESH
+mesh_id=Select MESHID, NAME from MEDIAN.MESH where MESHID = ?
\ No newline at end of file

http://dive4elements.wald.intevation.org