List of usage examples for org.apache.commons.configuration ConfigurationException printStackTrace
public void printStackTrace()
From source file:jdbc.pool.JDBCPoolOracleConnectionTest.java
/** * Tests the get methods of CPoolAttribute for pools ORACLE and MYSQL. * *//* www.jav a 2 s. c om*/ public void testCPoolAttributeGET() { System.out.println("testCPoolAttributeGET Started"); testGetInstanceNull(); CConnectionPoolManager manager = null; try { manager = create(); CPoolAttribute attribOraclePool = CConnectionPoolManager.getInstance().getPoolAttributes("ORACLE"); CPoolAttribute attribMySqlPool = CConnectionPoolManager.getInstance().getPoolAttributes("MYSQL"); assertEquals("Capacity Increament", 1, attribOraclePool.getCapacityIncreament()); assertEquals("Capacity Increament", 2, attribMySqlPool.getCapacityIncreament()); assertEquals("Connection Idle Timeout", 3, attribOraclePool.getConnectionIdleTimeout()); assertEquals("Connection Idle Timeout", 5, attribMySqlPool.getConnectionIdleTimeout()); assertEquals("Driver", "oracle.jdbc.driver.OracleDriver", attribOraclePool.getDriver()); assertEquals("Driver", "com.mysql.jdbc.Driver", attribMySqlPool.getDriver()); assertEquals("Initial Pool Size", 1, attribOraclePool.getInitialPoolSize()); assertEquals("Initial Pool Size", 3, attribMySqlPool.getInitialPoolSize()); assertEquals("Maximum Capacity", 5, attribOraclePool.getMaximumCapacity()); assertEquals("Maximum Capacity", 50, attribMySqlPool.getMaximumCapacity()); assertNotNull("Password not null", attribOraclePool.getPassword()); assertNotNull("Password not null", attribMySqlPool.getPassword()); assertEquals("Pool Name", "ORACLE", attribOraclePool.getPoolName()); assertEquals("Pool Name", "MYSQL", attribMySqlPool.getPoolName()); assertEquals("Shrink Pool Interval", 1, attribOraclePool.getShrinkPoolInterval()); assertEquals("Shrink Pool Interval", 1, attribMySqlPool.getShrinkPoolInterval()); assertEquals("URL", "jdbc:oracle:thin:@192.100.192.114:1521:SUN2DB1", attribOraclePool.getURL()); assertEquals("URL", "jdbc:mysql://localhost/newpre", attribMySqlPool.getURL()); assertEquals("USER", "rendev", attribOraclePool.getUser()); assertEquals("USER", "root", attribMySqlPool.getUser()); assertEquals("VENDOR", "ORACLE", attribOraclePool.getVendor()); assertEquals("VENDOR", "MySQL", attribMySqlPool.getVendor()); assertEquals("Critical Operation Time Limit", 1000, attribOraclePool.getCriticalOperationTimeLimit()); assertEquals("Critical Operation Time Limit", 10000, attribMySqlPool.getCriticalOperationTimeLimit()); assertEquals("In Use Wait Time", 7, attribOraclePool.getInUseWaitTime()); assertEquals("In Use Wait Time", 10, attribMySqlPool.getInUseWaitTime()); assertEquals("Load On Startup", false, attribOraclePool.isLoadOnStartup()); assertEquals("Load On Startup", true, attribMySqlPool.isLoadOnStartup()); assertEquals("Maximum Capacity", 4, attribOraclePool.getMaxUsagePerJDBCConnection()); assertEquals("Maximum Capacity", -1, attribMySqlPool.getMaxUsagePerJDBCConnection()); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } finally { manager.destroy(true); } System.out.println("testCPoolAttributeGET Ended"); }
From source file:jdbc.pool.JDBCPoolOracleConnectionTest.java
/** * Tests Inactive Timeout for -1 or 0 value. * This pool has different set of parameters as compared to MYSQL pool and this forces the behaviour changes * in the pool. The connections will not be pooled and therefore the connections will be closed upon release. *///from w ww . ja v a 2 s. com public void testTIT() { System.out.println("testTIT Start."); testGetInstanceNull(); CConnectionPoolManager manager = null; try { manager = create(); CPoolAttribute attrib = manager.getPoolAttributes("TIT"); assertEquals("Driver", "com.mysql.jdbc.Driver", attrib.getDriver()); assertEquals("Vendor", "MySQL", attrib.getVendor()); assertEquals("URL", "jdbc:mysql://localhost/newpre", attrib.getURL()); assertEquals("User", "root", attrib.getUser()); assertEquals("Password", "=?UTF-8?B?cm9vdA==?=", attrib.getPassword()); assertEquals("Initial Pool Size", 3, attrib.getInitialPoolSize()); assertEquals("Capacity Increament", 2, attrib.getCapacityIncreament()); assertEquals("Maximum Capacity", 50, attrib.getMaximumCapacity()); assertEquals("Connection Idle Timeout", -1, attrib.getConnectionIdleTimeout()); assertEquals("Shrink Pool Interval", 1, attrib.getShrinkPoolInterval()); assertEquals("Critical Operation Timelimit", 10000, attrib.getCriticalOperationTimeLimit()); assertEquals("In Use wait time", 10, attrib.getInUseWaitTime()); assertFalse("load-on-startup", attrib.isLoadOnStartup()); Connection conOra1 = manager.getConnection("TIT"); Connection realCon = null; if (conOra1 instanceof ConnectionWrapper) { ConnectionWrapper wrapper = (ConnectionWrapper) conOra1; realCon = wrapper.realConnection(); } else { fail("Connection returned is not an instance of ConnectionWrapper"); } conOra1.close(); assertTrue("Connection must get closed as the inactive-time-out <= 0", realCon.isClosed()); attrib = manager.getPoolAttributes("TIT"); assertEquals("Driver", "com.mysql.jdbc.Driver", attrib.getDriver()); assertEquals("Vendor", "MySQL", attrib.getVendor()); assertEquals("URL", "jdbc:mysql://localhost/newpre", attrib.getURL()); assertEquals("User", "root", attrib.getUser()); assertEquals("Password", "=?UTF-8?B?cm9vdA==?=", attrib.getPassword()); assertEquals("Initial Pool Size", 0, attrib.getInitialPoolSize()); assertEquals("Capacity Increament", 1, attrib.getCapacityIncreament()); assertEquals("Maximum Capacity", 50, attrib.getMaximumCapacity()); assertEquals("Connection Idle Timeout", -1, attrib.getConnectionIdleTimeout()); assertEquals("Shrink Pool Interval", -1, attrib.getShrinkPoolInterval()); assertEquals("Critical Operation Timelimit", 10000, attrib.getCriticalOperationTimeLimit()); assertEquals("In Use wait time", 10, attrib.getInUseWaitTime()); assertFalse("load-on-startup", attrib.isLoadOnStartup()); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } finally { manager.destroy(true); } System.out.println("testTIT end."); }
From source file:jdbc.pool.JDBCPoolOracleConnectionTest.java
/** * Test case for ResultSet leak./*from www .j ava2 s .c o m*/ */ public void testResultSetLeak() { System.out.println("testResultSetLeak Start."); testGetInstanceNull(); CConnectionPoolManager manager = null; Connection con = null; //It has 3 iniital connections. PreparedStatement st; try { manager = create(); con = manager.getConnection("ORACLE"); st = con.prepareStatement("SELECT 'A' FROM DUAL UNION SELECT 'B' FROM DUAL"); ResultSet rs = st.executeQuery(); while (rs.next()) { //do nothing } st.close(); CPoolStatisticsBean bean = manager.getPoolStatistics("ORACLE"); assertEquals("Pool Name", "ORACLE", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 1, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 0, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 1, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 1, bean.getLeakedResultSetCount()); st = con.prepareStatement("SELECT 'A' FROM DUAL UNION SELECT 'B' FROM DUAL"); rs = st.executeQuery(); while (rs.next()) { //do nothing } st.close(); bean = manager.getPoolStatistics("ORACLE"); assertEquals("Pool Name", "ORACLE", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 1, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 0, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 1, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 2, bean.getLeakedResultSetCount()); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } finally { if (con != null) { try { con.close(); } catch (SQLException e) { e.printStackTrace(); } } if (manager != null) { manager.destroy(true); } } System.out.println("testStatementCaching End."); }
From source file:jdbc.pool.JDBCPoolOracleConnectionTest.java
/** * Tests the capacity increament of the pool. * /*from w ww. ja va 2 s . c o m*/ */ public void testCapacityIncreament() { System.out.println("testCapacityIncreament Start"); testGetInstanceNull(); try { CConnectionPoolManager manager = create(); // capacity increament Oracle 1 Connection conOracle1 = manager.getConnection("ORACLE"); CPoolStatisticsBean bean = manager.getPoolStatistics("ORACLE"); assertEquals("Pool Name", "ORACLE", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 1, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 0, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 1, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); Connection conOracle2 = manager.getConnection("ORACLE"); bean = manager.getPoolStatistics("ORACLE"); assertEquals("Pool Name", "ORACLE", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 2, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 0, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 2, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); conOracle2.close(); conOracle1.close(); // capacity increament MySQL 2 Connection conMysql1 = manager.getConnection("MYSQL"); Connection conMysql2 = manager.getConnection("MYSQL"); Connection conMysql3 = manager.getConnection("MYSQL"); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 3, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 0, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 3, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); Connection conMysql4 = manager.getConnection("MYSQL"); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 4, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 1, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 4, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); conMysql1.close(); conMysql2.close(); conMysql3.close(); conMysql4.close(); manager.destroy(true); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } System.out.println("testCapacityIncreament end."); }
From source file:muvis.Environment.java
private Environment() { //Loading the main configuration ConfigurationFactory factory = new ConfigurationFactory("config.xml"); try {/* w w w . j av a 2 s . co m*/ configuration = factory.getConfiguration(); } catch (ConfigurationException ex) { System.out.println("Couldn't not load the configuration file! Possible reason: " + ex.toString()); } initializeDataFolders(); //initialize all the elements in the workspace audioPlayer = new MuVisAudioPlayer(); snippetManager = new AudioSnippetPlayerManager(audioPlayer); userPlaylist = new BasePlaylist(); configFile = new Properties(); viewManager = new ViewManager(); desk = new DockingDesktop(); ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); scheduler.scheduleAtFixedRate(new MemoryCollector(), 300, 300, TimeUnit.SECONDS); nbtreesManager = new NBTreeManager(); try { String dataFolder = configuration.getString("muvis.data_folder"); String nbtreeMainFolder = configuration.getString("muvis.nbtree_folder"); String nbtreeFullfolder = dataFolder + Util.getOSEscapeSequence() + nbtreeMainFolder + Util.getOSEscapeSequence(); nbtreesManager.addNBTree(Elements.TRACKS_NBTREE, new NBTree(Elements.TRACKS_NBTREE, nbtreeFullfolder)); nbtreesManager.addNBTree(Elements.ALBUMS_NBTREE, new NBTree(Elements.ALBUMS_NBTREE, nbtreeFullfolder)); nbtreesManager.addNBTree(Elements.ARTISTS_NBTREE, new NBTree(Elements.ARTISTS_NBTREE, nbtreeFullfolder)); } catch (NBTreeException ex) { ex.printStackTrace(); System.out.println("An error occured when trying to initialize the nbtreemanager!"); } initConfigFile(); }
From source file:jdbc.pool.JDBCPoolOracleConnectionTest.java
public synchronized void testGetConnection() { System.out.println("testGetConnection Start."); testGetInstanceNull();/* w w w . ja v a2s.co m*/ CConnectionPoolManager manager = null; try { manager = create(); CPoolStatisticsBean bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 0, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 3, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 0, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); Connection con = manager.getConnection("MYSQL"); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 1, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 2, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 1, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); con.close(); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 1, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 3, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 0, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); Connection con1 = manager.getConnection("MYSQL"); Connection con2 = manager.getConnection("MYSQL"); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 2, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 1, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 2, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); con1.close(); con2.close(); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 2, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 3, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 0, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); manager.destroy(true); testGetInstanceNull(); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } finally { if (manager != null) manager.destroy(true); testGetInstanceNull(); } System.out.println("testGetConnection end."); }
From source file:es.bsc.demiurge.core.configuration.Config.java
/** * Returns a properties file that contains the configuration parameters for the VM Manager. * * @return the properties file/*from w ww. j av a 2s.c o m*/ */ private Configuration getPropertiesObjectFromConfigFile() { Logger log = LogManager.getLogger(Config.class); try { Configuration embeddedConfig = null; URL embeddedConfigURL = Configuration.class.getResource(DEFAULT_CONF_CLASSPATH_LOCATION); if (embeddedConfigURL != null) { try { embeddedConfig = new PropertiesConfiguration(embeddedConfigURL); } catch (ConfigurationException e) { log.warn("Error processing embedded config file", e); } } // TO ALLOW COMPATIBILITY WITH OLDER VERSIONS OF VMM (Ascetic_exclusive) // If there is a config file in the newest default location, looks for it // if not, it looks in the old Ascetic default location String defaultFileName = OLD_ASCETIC_DEFAULT_CONF_FILE_LOCATION; if (new File(DEFAULT_CONF_FILE_LOCATION).exists()) { defaultFileName = DEFAULT_CONF_FILE_LOCATION; } configurationFileName = System.getProperty(PROPNAME_CONF_FILE, defaultFileName); log.debug("Loading configuration file: " + configurationFileName); Configuration fileConfig = null; if (new File(configurationFileName).exists()) { fileConfig = new PropertiesConfiguration(configurationFileName); } if (embeddedConfig == null) { if (fileConfig == null) { throw new IllegalStateException("No configuration found at " + configurationFileName); } return fileConfig; } else { CompositeConfiguration compositeConfiguration = new CompositeConfiguration(); if (fileConfig != null) { compositeConfiguration.addConfiguration(fileConfig); } compositeConfiguration.addConfiguration(embeddedConfig); return compositeConfiguration; } } catch (ConfigurationException e) { log.error("Error loading properties file", e); e.printStackTrace(); } return null; }
From source file:jdbc.pool.JDBCPoolMySQLTest.java
public void testDestroy() { logger.debug("testDestroy Start."); try {// ww w .ja v a 2s.c o m CConnectionPoolManager manager = null; manager = create(); manager.destroy(true); // testGetInstanceNull(); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); logger.debug(e.getMessage()); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } logger.debug("testDestroy end."); }
From source file:jdbc.pool.JDBCPoolMySQLTest.java
public void testGetInstanceStringFile() { logger.debug("testGetInstanceStringFile Start"); try {// w ww . ja v a 2 s. c o m CConnectionPoolManager manager = null; manager = create(); assertNotNull("check manager for not null", manager); assertNotNull("check CConnectionPoolManager.getInstance() for not null", CConnectionPoolManager.getInstance()); assertTrue("check manager == CConnectionPoolManager.getInstance()", manager.hashCode() == CConnectionPoolManager.getInstance().hashCode()); manager.destroy(true); testGetInstanceNull(); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } logger.debug("testGetInstanceStringFile End"); }
From source file:jdbc.pool.JDBCPoolMySQLTest.java
/** * Validates whether the connection received from the pool is as per the * JDBC driver specified in the configuration file. * //from w ww . j a va 2s. c o m */ public void testValidateConnectionForJDBCDriver() { testGetInstanceNull(); logger.debug("validateConnectionForJDBCDriver Start"); try { CConnectionPoolManager manager = create(); Connection con = manager.getConnection("MYSQL2"); // if (con instanceof ConnectionWrapper) { // ConnectionWrapper wrapper = (ConnectionWrapper) con; // assertTrue("real connection from MYSQL2 pool is of MYSQL2", wrapper.realConnection() instanceof oracle.jdbc.OracleConnection); // } else { // fail("Connection returned is not an instance of ConnectionWrapper"); // } con.close(); con = manager.getConnection("MYSQL"); if (con instanceof ConnectionWrapper) { ConnectionWrapper wrapper = (ConnectionWrapper) con; assertTrue("real connection from MYSQL pool is of MySQL", wrapper.realConnection() instanceof com.mysql.jdbc.Connection); } else { fail("Connection returned is not an instance of ConnectionWrapper"); } con.close(); manager.destroy(true); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } logger.debug("validateConnectionForJDBCDriver end"); }