comparison geo-backend/src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java @ 132:5a583cff97ea

Implementation of the Datainfrastructure for fetching Data from different DataStores. geo-backend/trunk@12 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 04 Sep 2009 08:11:30 +0000
parents
children 56655046194f
comparison
equal deleted inserted replaced
131:d8ff739b9f3b 132:5a583cff97ea
1 /**
2 *
3 */
4 package de.intevation.gnv.geobackend.base.query;
5
6 import java.io.FileInputStream;
7 import java.io.InputStream;
8 import java.util.Collection;
9 import java.util.Iterator;
10 import java.util.Properties;
11
12 import org.apache.log4j.BasicConfigurator;
13 import org.apache.log4j.Logger;
14
15 import de.intevation.gnv.geobackend.base.Result;
16 import de.intevation.gnv.geobackend.base.ResultDescriptor;
17 import de.intevation.gnv.geobackend.base.connectionpool.ConnectionPoolFactory;
18 import de.intevation.gnv.geobackend.base.query.container.QueryContainerFactory;
19 import de.intevation.gnv.geobackend.base.query.exception.QueryException;
20 import junit.framework.TestCase;
21
22 /**
23 * TestCase for the QueryExecutor interface
24 * @author Tim Englich <tim.englich@intevation.de>
25 *
26 */
27 public class QueryExecutorTestCase extends TestCase {
28
29
30 /**
31 * the logger, used to log exceptions and additonaly information
32 */
33 private static Logger log = null;
34
35 static{
36 BasicConfigurator.configure();
37 log = Logger.getLogger(QueryExecutorTestCase.class);
38 }
39
40 /**
41 * Constructor
42 * @param name
43 */
44 public QueryExecutorTestCase(String name) {
45 super(name);
46 }
47
48 /**
49 * Tests if the Databaseconnection can be established and
50 * Data could be read from the Database
51 */
52 public void testQueryExecutor(){
53
54 try {
55 QueryExecutor queryExecutor = QueryExecutorFactory.getInstance().getQueryExecutor();
56 Collection<Result> results = queryExecutor.executeQuery("mesh", null);
57 if (results == null || results.size() == 0){
58 log.error("Keine Daten erhalten");
59 fail();
60 }else {
61 log.debug("Datem erhalten");
62 Iterator<Result> it = results.iterator();
63 while (it.hasNext()){
64 Result tmpResult = it.next();
65 ResultDescriptor resultDescriptor = tmpResult.getResultDescriptor();
66 int columns = resultDescriptor.getColumnCount();
67 for (int i = 0; i < columns; i++){
68 String columnName = resultDescriptor.getColumnName(i);
69 Object value = tmpResult.getObject(columnName);
70 log.debug(columnName + " ==> "+value.toString());
71 }
72 }
73 }
74 } catch (QueryException e) {
75 log.error(e,e);
76 fail();
77 }
78 }
79
80
81 /**
82 * @see junit.framework.TestCase#setUp()
83 */
84 @Override
85 protected void setUp() throws Exception {
86
87 super.setUp();
88 InputStream inputStream = new FileInputStream("src/test/ressources/ArcSDEConnectionPoolTestCase.properties");
89 Properties properties = new Properties();
90 properties.load(inputStream);
91
92 ConnectionPoolFactory cpf = ConnectionPoolFactory.getInstance();
93 cpf.initializeConnectionPool(properties);
94
95
96 inputStream = new FileInputStream("src/test/ressources/QueryExecutorTestCase.properties");
97 properties = new Properties();
98 properties.load(inputStream);
99
100 QueryContainerFactory qcf = QueryContainerFactory.getInstance();
101 qcf.initializeQueryContainer(properties);
102 }
103
104 }

http://dive4elements.wald.intevation.org