# HG changeset patch # User Tim Englich # Date 1252054190 0 # Node ID 56655046194f92f5a3ebeda55398b2a012b38e95 # Parent 5a583cff97eade3c825d8d414117811d5cb026e6 Fix Bug setting the Filtervalues into the Statement. Further Testcases implemented. geo-backend/trunk@14 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 5a583cff97ea -r 56655046194f geo-backend/Changelog --- 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 + + * 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 * src/test/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnectionPoolTestCase.java: Edited diff -r 5a583cff97ea -r 56655046194f geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorBase.java --- 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; } diff -r 5a583cff97ea -r 56655046194f geo-backend/src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java --- 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 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 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(); diff -r 5a583cff97ea -r 56655046194f geo-backend/src/test/ressources/QueryExecutorTestCase.properties --- 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