Mercurial > dive4elements > gnv-client
comparison geo-backend/src/test/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnectionPoolTestCase.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 | e4eacd613356 |
children | 1c3efbd2fc5a |
comparison
equal
deleted
inserted
replaced
131:d8ff739b9f3b | 132:5a583cff97ea |
---|---|
25 * @author Tim Englich <tim.englich@intevation.de> | 25 * @author Tim Englich <tim.englich@intevation.de> |
26 * | 26 * |
27 */ | 27 */ |
28 public class ArcSDEConnectionPoolTestCase extends TestCase { | 28 public class ArcSDEConnectionPoolTestCase extends TestCase { |
29 | 29 |
30 /** | 30 /** |
31 * the logger, used to log exceptions and additonaly information | 31 * the logger, used to log exceptions and additonaly information |
32 */ | 32 */ |
33 private static Logger log = null; | 33 private static Logger log = null; |
34 | 34 |
35 static { | 35 static { |
36 BasicConfigurator.configure(); | 36 BasicConfigurator.configure(); |
37 log = Logger.getLogger(ArcSDEPoolableObjectFactory.class); | 37 log = Logger.getLogger(ArcSDEPoolableObjectFactory.class); |
38 } | 38 } |
39 | 39 /** |
40 | 40 * |
41 | 41 */ |
42 /** | 42 public ArcSDEConnectionPoolTestCase() { |
43 * | 43 super(); |
44 */ | 44 } |
45 public ArcSDEConnectionPoolTestCase() { | 45 |
46 super(); | 46 /** |
47 } | 47 * |
48 | 48 * @param name |
49 /** | 49 */ |
50 * | 50 public ArcSDEConnectionPoolTestCase(String name) { |
51 * @param name | 51 super(name); |
52 */ | 52 } |
53 public ArcSDEConnectionPoolTestCase(String name) { | 53 |
54 super(name); | 54 /** |
55 } | 55 * Test if the ArcSDEConnectionPool can be established |
56 | 56 * and if a Request could be done. |
57 public void testArcSDEConnectionPool(){ | 57 */ |
58 log.debug("ArcSDEConnectionPoolTestCase.testArcSDEConnectionPool"); | 58 public void testArcSDEConnectionPool(){ |
59 try { | 59 log.debug("ArcSDEConnectionPoolTestCase.testArcSDEConnectionPool"); |
60 InputStream inputStream = new FileInputStream("src/test/ressources/ArcSDEConnectionPoolTestCase.properties"); | 60 try { |
61 Properties properties = new Properties(); | 61 InputStream inputStream = new FileInputStream("src/test/ressources/ArcSDEConnectionPoolTestCase.properties"); |
62 properties.load(inputStream); | 62 Properties properties = new Properties(); |
63 | 63 properties.load(inputStream); |
64 ConnectionPoolFactory cpf = ConnectionPoolFactory.getInstance(); | 64 |
65 cpf.initializeConnectionPool(properties); | 65 ConnectionPoolFactory cpf = ConnectionPoolFactory.getInstance(); |
66 | 66 cpf.initializeConnectionPool(properties); |
67 assertTrue(cpf.isInitialized()); | 67 |
68 log.debug("ConnectionPoolFactory ist initialisiert."); | 68 assertTrue(cpf.isInitialized()); |
69 | 69 log.debug("ConnectionPoolFactory ist initialisiert."); |
70 ConnectionPool cp = cpf.getConnectionPool(); | 70 |
71 assertNotNull(cp); | 71 ConnectionPool cp = cpf.getConnectionPool(); |
72 log.debug("ConnectionPool ist initialisiert."); | 72 assertNotNull(cp); |
73 | 73 log.debug("ConnectionPool ist initialisiert."); |
74 Connection connection = null; | 74 |
75 try{ | 75 Connection connection = null; |
76 try { | 76 try{ |
77 connection = cp.getConnection("N/N"); | 77 try { |
78 assertNotNull(connection); | 78 connection = cp.getConnection("N/N"); |
79 log.debug("Connection ist initialisiert."); | 79 assertNotNull(connection); |
80 } catch (ConnectionException e) { | 80 log.debug("Connection ist initialisiert."); |
81 log.error("Es traten Probleme bei der Verbinung zur Datenbank auf."); | 81 } catch (ConnectionException e) { |
82 fail(); | 82 log.error("Es traten Probleme bei der Verbinung zur Datenbank auf."); |
83 } | 83 fail(); |
84 | 84 } |
85 | 85 |
86 try { | 86 |
87 Statement stmt = connection.createStatement(); | 87 try { |
88 ResultSet rs = stmt.executeQuery("Select MESHID, NAME from MEDIAN.MESH"); | 88 Statement stmt = connection.createStatement(); |
89 | 89 ResultSet rs = stmt.executeQuery("Select MESHID, NAME from MEDIAN.MESH"); |
90 while (rs.next()){ | 90 |
91 log.debug(rs.getInt(1)); | 91 while (rs.next()){ |
92 log.debug(rs.getString(2)); | 92 log.debug(rs.getInt(1)); |
93 | 93 log.debug(rs.getString(2)); |
94 log.debug(rs.getInt("MESHID")); | 94 |
95 log.debug(rs.getString("NAME")); | 95 log.debug(rs.getInt("MESHID")); |
96 } | 96 log.debug(rs.getString("NAME")); |
97 | 97 } |
98 } catch (SQLException e) { | 98 |
99 log.error(e,e); | 99 } catch (SQLException e) { |
100 } | 100 log.error(e,e); |
101 }finally{ | 101 } |
102 if (connection != null){ | 102 }finally{ |
103 try { | 103 if (connection != null){ |
104 connection.close(); | 104 try { |
105 connection.close(); | |
105 } catch (SQLException e) { | 106 } catch (SQLException e) { |
106 log.error(e,e); | 107 log.error(e,e); |
107 fail(); | 108 fail(); |
108 } | 109 } |
109 } | 110 } |
110 } | 111 } |
111 | 112 } catch (FileNotFoundException e) { |
112 | 113 log.error(e,e); |
113 | 114 fail(); |
114 } catch (FileNotFoundException e) { | 115 } catch (IOException e) { |
115 log.error(e,e); | 116 log.error(e,e); |
116 fail(); | 117 fail(); |
117 } catch (IOException e) { | 118 } |
118 log.error(e,e); | 119 } |
119 fail(); | |
120 } | |
121 } | |
122 | |
123 } | 120 } |