[jboss-svn-commits] JBL Code SVN: r5497 - 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
Sat Aug 5 12:15:49 EDT 2006
Author: mohit309
Date: 2006-08-05 12:15:48 -0400 (Sat, 05 Aug 2006)
New Revision: 5497
Added:
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/AbandonedConnectionFuncTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/ConnectionPoolFuncTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/PasswordDecoderFuncTest.java
labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/PasswordDecoderTestImpl.java
Log:
Added latest unit test cases
Added: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/AbandonedConnectionFuncTest.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/AbandonedConnectionFuncTest.java 2006-08-05 16:14:59 UTC (rev 5496)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/AbandonedConnectionFuncTest.java 2006-08-05 16:15:48 UTC (rev 5497)
@@ -0,0 +1,71 @@
+/*
+* 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 java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+/**
+ * TODO
+ * User: MohitK
+ * Date: Aug 3, 2006
+ */
+public class AbandonedConnectionFuncTest extends TestCase {
+
+ Properties properties = new Properties();
+
+ protected void setUp() throws Exception {
+ properties.put(ConnectionProperties.DRIVER_CLASSNAME, "com.mysql.jdbc.Driver");
+ properties.put(ConnectionProperties.CONNECTION_URL, "jdbc:mysql://localhost/rosetta");
+ properties.put(ConnectionProperties.USERNAME, "rosetta");
+ properties.put(ConnectionProperties.PASSWORD, "rosetta");
+ properties.put(ConnectionProperties.ABANDONED_CONNECTION_CHECK_INTERVAL, "30000");
+ }
+
+
+ public void testAbandonedConnections() {
+ PoolDataSource ds = new PoolDataSource();
+ ds.setConnectionProperties(properties);
+ Connection con1 = null;
+ Connection con2 = null;
+ Connection con3 = null;
+ try {
+ con1 = ds.getConnection();
+ con2 = ds.getConnection();
+ try {
+ Thread.sleep(70000);
+ } catch (InterruptedException e) {
+ //Do nothing
+ }
+ con1.createStatement();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ assertTrue(true);
+ }
+ }
+
+}
Added: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/ConnectionPoolFuncTest.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/ConnectionPoolFuncTest.java 2006-08-05 16:14:59 UTC (rev 5496)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/ConnectionPoolFuncTest.java 2006-08-05 16:15:48 UTC (rev 5497)
@@ -0,0 +1,84 @@
+/*
+* 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
+ * @author MohitK
+ * Date: Jul 22, 2006
+ */
+public class ConnectionPoolFuncTest extends TestCase {
+
+ Properties properties = new Properties();
+
+ protected void setUp() throws Exception {
+ properties.put(ConnectionProperties.DRIVER_CLASSNAME, "com.mysql.jdbc.Driver");
+ properties.put(ConnectionProperties.CONNECTION_URL, "jdbc:mysql://localhost/rosetta");
+ properties.put(ConnectionProperties.USERNAME, "rosetta");
+ properties.put(ConnectionProperties.PASSWORD, "rosetta");
+ }
+
+
+ public void testConnectionPool() {
+ PoolDataSource ds = new PoolDataSource();
+ ds.setConnectionProperties(properties);
+ Connection con = null;
+ Statement stat = null;
+ try {
+ con = ds.getConnection();
+ stat = con.createStatement();
+ ResultSet rs = stat.executeQuery("SELECT count(*) FROM uid_table");
+ while (rs.next()) {
+ int count = rs.getInt(1);
+ System.out.println("count = " + count);
+ }
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail();
+ }finally{
+ try {
+ if (stat != null) {
+ stat.close();
+ }
+ if(con!=null){
+ con.close();
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+
+}
Added: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/PasswordDecoderFuncTest.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/PasswordDecoderFuncTest.java 2006-08-05 16:14:59 UTC (rev 5496)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/PasswordDecoderFuncTest.java 2006-08-05 16:15:48 UTC (rev 5497)
@@ -0,0 +1,87 @@
+/*
+* 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 java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+/**
+ * TODO
+ *
+ * @author MohitK
+ * Date: Aug 1, 2006
+ */
+public class PasswordDecoderFuncTest extends TestCase {
+
+ Properties properties = new Properties();
+
+ protected void setUp() throws Exception {
+ properties.put(ConnectionProperties.DRIVER_CLASSNAME, "com.mysql.jdbc.Driver");
+ properties.put(ConnectionProperties.CONNECTION_URL, "jdbc:mysql://localhost/rosetta");
+ properties.put(ConnectionProperties.USERNAME, "rosetta");
+ properties.setProperty(ConnectionProperties.PASSWORD_DECODER, PasswordDecoderTestImpl.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 uid_table");
+ 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();
+ }
+ }
+ }
+ }
+}
Added: labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/PasswordDecoderTestImpl.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/PasswordDecoderTestImpl.java 2006-08-05 16:14:59 UTC (rev 5496)
+++ labs/jbossesb/branches/refactor/product/core/common/tests/src/org/jboss/soa/esb/connection/PasswordDecoderTestImpl.java 2006-08-05 16:15:48 UTC (rev 5497)
@@ -0,0 +1,36 @@
+/*
+* 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 org.jboss.soa.esb.connection.PasswordDecoder;
+
+/**
+ * TODO
+ * @author MohitK
+ * Date: Aug 1, 2006
+ */
+public class PasswordDecoderTestImpl implements PasswordDecoder {
+
+ public String decode(String encodedPassword) {
+ return "rosetta";
+ }
+}
More information about the jboss-svn-commits
mailing list