[jboss-svn-commits] JBL Code SVN: r5387 - in labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb: . connection
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Aug 1 16:32:20 EDT 2006
Author: mohit309
Date: 2006-08-01 16:32:19 -0400 (Tue, 01 Aug 2006)
New Revision: 5387
Added:
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/TestConnectionPool.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/TestPasswordDecoder.java
Log:
Connection Pool Test Cases
Added: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/TestConnectionPool.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/TestConnectionPool.java 2006-08-01 20:28:58 UTC (rev 5386)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/TestConnectionPool.java 2006-08-01 20:32:19 UTC (rev 5387)
@@ -0,0 +1,104 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.connection;
+
+import junit.framework.TestCase;
+import org.jboss.soa.esb.connection.ConnectionProperties;
+import org.jboss.soa.esb.connection.PoolDataSource;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+/**
+ * TODO
+ * User: MohitK
+ * Date: Jul 22, 2006
+ */
+public class TestConnectionPool extends TestCase {
+
+ Properties properties = new Properties();
+
+ protected void setUp() throws Exception {
+ properties.put(ConnectionProperties.DRIVER_CLASSNAME, "oracle.jdbc.driver.OracleDriver");
+ properties.put(ConnectionProperties.CONNECTION_URL, "jdbc:oracle:thin:@localhost:1521:EMS");
+ properties.put(ConnectionProperties.USERNAME, "CLEARSTORY");
+ properties.put(ConnectionProperties.PASSWORD, "password");
+ properties.put(ConnectionProperties.ABANDONED_CONNECTION_CHECK_INTERVAL, "30000");
+ }
+
+
+ public void testConnectionPool() {
+ PoolDataSource ds = new PoolDataSource();
+ ds.setConnectionProperties(properties);
+ Connection con1 = null;
+ Connection con2 = null;
+ Connection con3 = null;
+ Connection con4 = null;
+ Connection con5 = null;
+ Connection con6 = null;
+ Connection con7 = null;
+ Connection con8 = null;
+ Connection con9 = null;
+ Connection con10 = null;
+ Statement stat = null;
+ try {
+ con1 = ds.getConnection();
+ con2 = ds.getConnection();
+ stat = con1.createStatement();
+ ResultSet rs = stat.executeQuery("select count(*) from WM_SERVER");
+ while (rs.next()) {
+ int count = rs.getInt(1);
+ System.out.println("count = " + count);
+ }
+ try {
+ if (stat != null) {
+ stat.close();
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ con3 = ds.getConnection();
+ con4 = ds.getConnection();
+ con5 = ds.getConnection();
+ con6 = ds.getConnection();
+ con7 = ds.getConnection();
+ con8 = ds.getConnection();
+ con9 = ds.getConnection();
+ try {
+ Thread.sleep(35000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ stat = con3.createStatement();
+ stat.executeQuery("select count(*) from WM_SERVER");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+
+
+}
Added: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/TestPasswordDecoder.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/TestPasswordDecoder.java 2006-08-01 20:28:58 UTC (rev 5386)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/TestPasswordDecoder.java 2006-08-01 20:32:19 UTC (rev 5387)
@@ -0,0 +1,90 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.connection;
+
+import junit.framework.TestCase;
+import org.jboss.soa.esb.connection.ConnectionProperties;
+import org.jboss.soa.esb.connection.PoolDataSource;
+import org.jboss.soa.esb.connection.HashPasswordDecoder;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+/**
+ * TODO
+ * User: MohitK
+ * Date: Aug 1, 2006
+ */
+public class TestPasswordDecoder extends TestCase {
+
+ Properties properties = new Properties();
+
+ protected void setUp() throws Exception {
+ properties.put(ConnectionProperties.DRIVER_CLASSNAME, "oracle.jdbc.driver.OracleDriver");
+ properties.put(ConnectionProperties.CONNECTION_URL, "jdbc:oracle:thin:@localhost:1521:EMS");
+ properties.put(ConnectionProperties.USERNAME, "CLEARSTORY");
+ properties.put(ConnectionProperties.PASSWORD, "password");
+ properties.setProperty(ConnectionProperties.PASSWORD_DECODER, HashPasswordDecoder.class.getName());
+ }
+
+ public void testPasswordDecoder() {
+
+ PoolDataSource ds = new PoolDataSource();
+ ds.setConnectionProperties(properties);
+ Connection con1 = null;
+ Statement stat = null;
+ try {
+ con1 = ds.getConnection();
+ stat = con1.createStatement();
+ ResultSet rs = stat.executeQuery("select count(*) from WM_SERVER");
+ while (rs.next()) {
+ int count = rs.getInt(1);
+ System.out.println("count = " + count);
+ }
+
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail();
+ } finally {
+ if (stat != null) {
+ try {
+ stat.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+ if (con1 != null) {
+ try {
+ con1.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list