[jboss-cvs] JBossAS SVN: r111651 - in projects/jboss-jca/trunk/adapters/src/test: java/org/jboss/jca/adapters/jdbc/unit/support and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 22 12:58:38 EDT 2011
Author: jesper.pedersen
Date: 2011-06-22 12:58:38 -0400 (Wed, 22 Jun 2011)
New Revision: 111651
Added:
projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/ConnectionDefinitionTestCase.java
projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/
projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/TestConnection.java
projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/TestDriver.java
projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/package.html
projects/jboss-jca/trunk/adapters/src/test/resources/connection-definition-ds.xml
Log:
<connection-definition> test case
Added: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/ConnectionDefinitionTestCase.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/ConnectionDefinitionTestCase.java (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/ConnectionDefinitionTestCase.java 2011-06-22 16:58:38 UTC (rev 111651)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.adapters.jdbc.unit;
+
+import org.jboss.jca.adapters.ArquillianJCATestUtils;
+import org.jboss.jca.adapters.jdbc.WrappedConnection;
+import org.jboss.jca.adapters.jdbc.unit.support.TestConnection;
+import org.jboss.jca.embedded.dsl.InputStreamDescriptor;
+
+import java.sql.Connection;
+
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptor;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test cases for connection definition
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class ConnectionDefinitionTestCase
+{
+
+ //-------------------------------------------------------------------------------------||
+ //---------------------- GIVEN --------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Define the deployment
+ * @return The deployment archive
+ * @throws Exception in case of errors
+ */
+ @Deployment(order = 1)
+ public static ResourceAdapterArchive createArchive() throws Exception
+ {
+ return ArquillianJCATestUtils.buildShrinkwrapJdbcLocal();
+ }
+
+ /**
+ * Define the -ds.xml
+ * @return The deployment archive
+ * @throws Exception in case of errors
+ */
+ @Deployment(order = 2)
+ public static Descriptor createDescriptor() throws Exception
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ InputStreamDescriptor isd = new InputStreamDescriptor("connection-definition-ds.xml",
+ cl.getResourceAsStream("connection-definition-ds.xml"));
+ return isd;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ //---------------------- WHEN --------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+ //
+ @Resource(mappedName = "java:/ConDefDS")
+ private DataSource ds;
+
+ //-------------------------------------------------------------------------------------||
+ //---------------------- THEN --------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Test connection definitions
+ * @exception Throwable Thrown if case of an error
+ */
+ @Test
+ public void test() throws Throwable
+ {
+ assertNotNull(ds);
+ Connection c = ds.getConnection();
+ assertNotNull(c);
+ assertTrue(c instanceof WrappedConnection);
+
+ WrappedConnection wc = (WrappedConnection)c;
+
+ TestConnection tc = (TestConnection)wc.getUnderlyingConnection();
+ assertNotNull(tc);
+
+ assertTrue("test".equals(tc.getUser()));
+ assertTrue("test".equals(tc.getPassword()));
+
+ assertTrue("test".equals(tc.getStringProperty()));
+
+ c.close();
+ }
+}
Added: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/TestConnection.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/TestConnection.java (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/TestConnection.java 2011-06-22 16:58:38 UTC (rev 111651)
@@ -0,0 +1,484 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.adapters.jdbc.unit.support;
+
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Test connection.
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class TestConnection implements Connection
+{
+ private boolean closed;
+ private String user;
+ private String password;
+
+ private String stringProperty;
+
+ /**
+ * Constructor
+ * @param info The properties
+ */
+ public TestConnection(Properties info)
+ {
+ if (info != null)
+ {
+ user = info.getProperty("user");
+ password = info.getProperty("password");
+
+ stringProperty = info.getProperty("StringProperty");
+ }
+
+ this.closed = false;
+ }
+
+ /**
+ * Get the user
+ * @return The value
+ */
+ public String getUser()
+ {
+ return user;
+ }
+
+ /**
+ * Get the password
+ * @return The value
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ /**
+ * Get the StringProperty
+ * @return The value
+ */
+ public String getStringProperty()
+ {
+ return stringProperty;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setReadOnly(boolean readOnly) throws SQLException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isReadOnly() throws SQLException
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void close() throws SQLException
+ {
+ closed = true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isClosed() throws SQLException
+ {
+ return closed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Statement createStatement() throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PreparedStatement prepareStatement(String sql) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
+ throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public CallableStatement prepareCall(String sql) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String nativeSQL(String sql) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setAutoCommit(boolean autocommit) throws SQLException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean getAutoCommit() throws SQLException
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void commit() throws SQLException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rollback() throws SQLException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rollback(Savepoint savepoint) throws SQLException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public DatabaseMetaData getMetaData() throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setCatalog(String catalog) throws SQLException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getCatalog() throws SQLException
+ {
+ return "";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setTransactionIsolation(int isolationLevel) throws SQLException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getTransactionIsolation() throws SQLException
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public SQLWarning getWarnings() throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void clearWarnings() throws SQLException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public Map<String, Class<?>> getTypeMap() throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public void setTypeMap(Map<String, Class<?>> typeMap) throws SQLException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setHoldability(int holdability) throws SQLException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getHoldability() throws SQLException
+ {
+ return -1;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Savepoint setSavepoint() throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Savepoint setSavepoint(String name) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void releaseSavepoint(Savepoint savepoint) throws SQLException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Array createArrayOf(String typeName, Object[] elements) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Blob createBlob() throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Clob createClob() throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public NClob createNClob() throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public SQLXML createSQLXML() throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Struct createStruct(String typeName, Object[] attributes) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Properties getClientInfo() throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getClientInfo(String name) throws SQLException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isValid(int timeout) throws SQLException
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setClientInfo(Properties properties) throws SQLClientInfoException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setClientInfo(String name, String value) throws SQLClientInfoException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isWrapperFor(Class<?> iface)
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public <T> T unwrap(Class<T> iface)
+ {
+ return null;
+ }
+}
Added: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/TestDriver.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/TestDriver.java (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/TestDriver.java 2011-06-22 16:58:38 UTC (rev 111651)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.adapters.jdbc.unit.support;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.util.Properties;
+
+/**
+ * Test JDBC driver
+ */
+public class TestDriver implements Driver
+{
+ /**
+ * {@inheritDoc}
+ */
+ public Connection connect(String url, Properties info) throws SQLException
+ {
+ return new TestConnection(info);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean acceptsURL(String url) throws SQLException
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
+ {
+ Driver driver = DriverManager.getDriver(url);
+ return driver.getPropertyInfo(url, info);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMajorVersion()
+ {
+ return 1;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMinorVersion()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean jdbcCompliant()
+ {
+ return false;
+ }
+}
Added: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/package.html
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/package.html (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/support/package.html 2011-06-22 16:58:38 UTC (rev 111651)
@@ -0,0 +1,3 @@
+<body>
+This package contains support classes for JDBC based test cases.
+</body>
Added: projects/jboss-jca/trunk/adapters/src/test/resources/connection-definition-ds.xml
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/resources/connection-definition-ds.xml (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/resources/connection-definition-ds.xml 2011-06-22 16:58:38 UTC (rev 111651)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://www.jboss.org/jee/schema/ironjacamar/datasources_1_0.xsd">
+
+ <datasource jndi-name="java:/ConDefDS" pool-name="ConDefDS">
+ <connection-url>jdbc:test:test</connection-url>
+ <driver-class>org.jboss.jca.adapters.jdbc.unit.support.TestDriver</driver-class>
+ <connection-property name="StringProperty">test</connection-property>
+ <security>
+ <user-name>test</user-name>
+ <password>test</password>
+ </security>
+ </datasource>
+
+</datasources>
More information about the jboss-cvs-commits
mailing list