Author: lisbor
Date: 2008-12-18 06:53:51 -0500 (Thu, 18 Dec 2008)
New Revision: 691
Added:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcConnection.java
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java
trunk/extensions/dna-connector-jdbc-metadata/src/test/data/
trunk/extensions/dna-connector-jdbc-metadata/src/test/data/insert.xml
trunk/extensions/dna-connector-jdbc-metadata/src/test/data/testdb/
trunk/extensions/dna-connector-jdbc-metadata/src/test/data/testdb/db.properties
trunk/extensions/dna-connector-jdbc-metadata/src/test/data/testdb/db.script
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/jdbc/
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/jdbc/DatabaseBasicTest.java
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/log4j.xml
Modified:
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/TableTypeBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java
trunk/extensions/dna-connector-jdbc-metadata/pom.xml
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.java
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositorySource.java
trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.properties
Log:
DNA-37 Federate schema information from relational sources
https://jira.jboss.org/jira/browse/DNA-37
JdbcRepositorySource, JdbcConnection, and simple test
Modified:
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/TableTypeBean.java
===================================================================
---
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/TableTypeBean.java 2008-12-17
15:54:36 UTC (rev 690)
+++
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/TableTypeBean.java 2008-12-18
11:53:51 UTC (rev 691)
@@ -35,8 +35,7 @@
*/
public class TableTypeBean extends DatabaseNamedObjectBean implements TableType {
private static final long serialVersionUID = -5095835769360603900L;
- private String tableTypeName;
-
+
/**
* Default constructor
*/
Modified:
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java
===================================================================
---
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java 2008-12-17
15:54:36 UTC (rev 690)
+++
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java 2008-12-18
11:53:51 UTC (rev 691)
@@ -21,6 +21,8 @@
*/
package org.jboss.dna.common.jdbc.util;
+import java.lang.reflect.Method;
+import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
@@ -3464,4 +3466,27 @@
superTableName));
}
}
+
+ /**
+ * Get simple database metadata for the getter method (no input parameters)
+ * @param <T> the return type
+ * @param instance the instance of database metadata implementation
+ * @param methodName the full name of a getter method to execute
+ * @param traceLog the log
+ * @return simple database metadata for the getter method
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T getDatabaseMetadataProperty (DatabaseMetaData instance,
String methodName, Logger traceLog) {
+ try {
+ // acces to the instance's RTTI
+ Method m = instance.getClass().getDeclaredMethod (methodName);
+ // trying to execute method without parameters
+ return (T) m.invoke(instance);
+ } catch (Exception e) {
+ traceLog.debug(String.format ("Unable to execute getDatabaseMetadata for
the '%1$s' method - %2$s: %3$s",
+ methodName, e.getClass().getName(),
e.getMessage()));
+ // default is null
+ return null;
+ }
+ }
}
Modified: trunk/extensions/dna-connector-jdbc-metadata/pom.xml
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/pom.xml 2008-12-17 15:54:36 UTC (rev
690)
+++ trunk/extensions/dna-connector-jdbc-metadata/pom.xml 2008-12-18 11:53:51 UTC (rev
691)
@@ -49,5 +49,46 @@
<version>4.4</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.7</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.dbunit</groupId>
+ <artifactId>dbunit</artifactId>
+ <version>2.4.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
+ <properties>
+ <jdbc.driverClassName>org.hsqldb.jdbcDriver</jdbc.driverClassName>
+ <jdbc.username>sa</jdbc.username>
+ <jdbc.password />
+ <jdbc.url>jdbc:hsqldb:file:${basedir}/target/testdb/db</jdbc.url>
+ </properties>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ <testResource>
+ <directory>src/test/data</directory>
+ <filtering>true</filtering>
+ <targetPath>../</targetPath>
+ </testResource>
+ <testResource>
+ <directory>src/it/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+ </build>
</project>
\ No newline at end of file
Added:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcConnection.java
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcConnection.java
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcConnection.java 2008-12-18
11:53:51 UTC (rev 691)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.dna.connector.jdbc;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.UUID;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+import javax.transaction.xa.XAResource;
+import javax.sql.XAConnection;
+
+import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.cache.CachePolicy;
+import org.jboss.dna.graph.connectors.RepositoryConnection;
+import org.jboss.dna.graph.connectors.RepositorySourceException;
+import org.jboss.dna.graph.connectors.RepositorySourceListener;
+import org.jboss.dna.graph.requests.Request;
+import org.jboss.dna.graph.requests.processor.RequestProcessor;
+
+/**
+ * JDBC connection wrapper
+ *
+ * @author <a href="mailto:litsenko_sergey@yahoo.com">Sergiy
Litsenko</a>
+ */
+public class JdbcConnection implements RepositoryConnection {
+ /**
+ * Logging for this instance
+ */
+ protected Logger log = Logger.getLogger(getClass());
+
+ private final String name;
+ private final CachePolicy cachePolicy;
+ private final CopyOnWriteArrayList<RepositorySourceListener> listeners = new
CopyOnWriteArrayList<RepositorySourceListener>();
+ private final Connection connection;
+ private final UUID rootNodeUuid;
+
+ /*package*/JdbcConnection( String sourceName,
+ CachePolicy cachePolicy,
+ Connection connection,
+ UUID rootNodeUuid) {
+ assert sourceName != null;
+ assert connection != null;
+ assert rootNodeUuid != null;
+ this.name = sourceName;
+ this.cachePolicy = cachePolicy; // may be null
+ this.connection = connection;
+ this.rootNodeUuid = rootNodeUuid;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connectors.RepositoryConnection#getSourceName()
+ */
+ public String getSourceName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.graph.connectors.RepositoryConnection#setListener(org.jboss.dna.graph.connectors.RepositorySourceListener)
+ */
+ public void setListener( RepositorySourceListener listener ) {
+ if (listener != null) {
+ listeners.addIfAbsent(listener);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connectors.RepositoryConnection#getDefaultCachePolicy()
+ */
+ public CachePolicy getDefaultCachePolicy() {
+ return cachePolicy;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connectors.RepositoryConnection#getXAResource()
+ */
+ public XAResource getXAResource() {
+ // if implemented by JDBC driver
+ if (connection instanceof XAConnection) {
+ try {
+ return ((XAConnection)connection).getXAResource();
+ } catch (SQLException e) {
+ // handle an exception silently so far and write it to the log
+ log.error(e, JdbcMetadataI18n.unableToGetXAResource, getSourceName());
+ return null;
+ }
+ }
+ // default
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connectors.RepositoryConnection#ping(long,
java.util.concurrent.TimeUnit)
+ */
+ public boolean ping( long time,
+ TimeUnit unit ) {
+ try {
+ // JDBC 4 has a method to check validity of a connection
(connection.isValid(timeout))
+ // but many drivers didn't get updated with latest spec
+ return connection != null && ! connection.isClosed();
+ } catch (SQLException e) {
+ // debug
+ if (log.isDebugEnabled()) {
+ log.debug(e, "{0}: Unable to check database connection due to
error.", getSourceName());
+ }
+ return false;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.graph.connectors.RepositoryConnection#execute(org.jboss.dna.graph.ExecutionContext,
+ * org.jboss.dna.graph.requests.Request)
+ */
+ public void execute( ExecutionContext context,
+ Request request ) throws RepositorySourceException {
+ // create processor and delegate handling
+ RequestProcessor proc = new JdbcRequestProcesor(getSourceName(),context,
connection);
+ try {
+ proc.process(request);
+ } finally {
+ proc.close();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connectors.RepositoryConnection#close()
+ */
+ public void close() {
+ try {
+ // release the JDBC connection resource
+ if (connection != null && ! connection.isClosed()) {
+ connection.close();
+ }
+ } catch (Exception e) {
+ // handle exception silently so far
+ if (log.isDebugEnabled()) {
+ log.debug(e, "{0}: Unable to close database connection due to
error.", getSourceName());
+ }
+ }
+ }
+
+}
Property changes on:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.java
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.java 2008-12-17
15:54:36 UTC (rev 690)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.java 2008-12-18
11:53:51 UTC (rev 691)
@@ -34,9 +34,13 @@
public static I18n nodeDoesNotExist;
public static I18n nodeTypeIsNotSupported;
public static I18n propertyIsRequired;
+ public static I18n oneOfPropertiesIsRequired;
public static I18n errorSerializingCachePolicyInSource;
public static I18n locationInRequestMustHavePath;
public static I18n sourceIsReadOnly;
+ public static I18n unableToGetConnectionUsingDriver;
+ public static I18n unableToGetConnectionUsingDataSource;
+ public static I18n unableToGetXAResource;
static {
try {
Modified:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositorySource.java
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositorySource.java 2008-12-17
15:54:36 UTC (rev 690)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositorySource.java 2008-12-18
11:53:51 UTC (rev 691)
@@ -30,6 +30,7 @@
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
+import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import javax.naming.BinaryRefAddr;
@@ -39,8 +40,13 @@
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.naming.spi.ObjectFactory;
+
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.i18n.I18n;
+import org.jboss.dna.common.jdbc.provider.DataSourceDatabaseMetadataProvider;
+import org.jboss.dna.common.jdbc.provider.DefaultDataSourceDatabaseMetadataProvider;
+import org.jboss.dna.common.jdbc.provider.DefaultDriverDatabaseMetadataProvider;
+import org.jboss.dna.common.jdbc.provider.DriverDatabaseMetadataProvider;
import org.jboss.dna.graph.cache.CachePolicy;
import org.jboss.dna.graph.connectors.RepositoryConnection;
import org.jboss.dna.graph.connectors.RepositoryContext;
@@ -54,7 +60,8 @@
* @author <a href="mailto:litsenko_sergey@yahoo.com">Sergiy
Litsenko</a>
*/
public class JdbcRepositorySource implements RepositorySource, ObjectFactory {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 3380130639143030018L;
+
/**
* The default limit is {@value} for retrying {@link RepositoryConnection connection}
calls to the underlying source.
*/
@@ -65,6 +72,10 @@
* read-only or updateable}.
*/
public static final boolean DEFAULT_SUPPORTS_UPDATES = true;
+ /**
+ * The default UUID that is used for root nodes in a JDBC connector.
+ */
+ public static final String DEFAULT_ROOT_NODE_UUID =
"9f9a52c8-0a4d-40d0-ac58-7c77b24b3155";
/**
* This source supports events.
@@ -80,14 +91,47 @@
protected final Capabilities capabilities = new Capabilities();
protected transient RepositoryContext repositoryContext;
protected CachePolicy defaultCachePolicy;
-
+ protected transient DriverDatabaseMetadataProvider driverProvider;
+ protected transient DataSourceDatabaseMetadataProvider dataSourceProvider;
+ protected transient UUID rootUuid = UUID.fromString(DEFAULT_ROOT_NODE_UUID);
+
protected static final String SOURCE_NAME = "sourceName";
+ protected static final String ROOT_NODE_UUID = "rootNodeUuid";
protected static final String DEFAULT_CACHE_POLICY = "defaultCachePolicy";
- protected static final String REPO_JNDI_NAME = "jndiName";
- protected static final String REPO_FACTORY_JNDI_NAME = "factoryJndiName";
+ protected static final String DATA_SOURCE_JNDI_NAME =
"dataSourceJndiName";
+ protected static final String USERNAME = "username";
+ protected static final String PASSWORD = "password";
+ protected static final String URL = "url";
+ protected static final String DRIVER_CLASS_NAME = "driverClassName";
protected static final String RETRY_LIMIT = "retryLimit";
/**
+ * Get and optionally create driver based provider
+ * @param create create provider
+ * @return driverProvider
+ */
+ protected DriverDatabaseMetadataProvider getDriverProvider(boolean create) {
+ // lazy creation
+ if (driverProvider == null) {
+ driverProvider = new DefaultDriverDatabaseMetadataProvider();
+ }
+ return driverProvider;
+ }
+
+ /**
+ * Get and optionally create data source based provider
+ * @param create create provider
+ * @return dataSourceProvider
+ */
+ protected DataSourceDatabaseMetadataProvider getDataSourceProvider(boolean create) {
+ // lazy creation
+ if (dataSourceProvider == null && create) {
+ dataSourceProvider = new DefaultDataSourceDatabaseMetadataProvider();
+ }
+ return dataSourceProvider;
+ }
+
+ /**
* default constructor
*/
public JdbcRepositorySource() {
@@ -108,8 +152,44 @@
* @see org.jboss.dna.graph.connectors.RepositorySource#getConnection()
*/
public RepositoryConnection getConnection() throws RepositorySourceException {
- // TODO create Jdbc connection
- return null;
+ String errMsg = null;
+ // check name
+ if (getName() == null) {
+ errMsg = JdbcMetadataI18n.propertyIsRequired.text("name");
+ throw new RepositorySourceException(errMsg);
+ }
+
+ // create Jdbc connection using data source first
+ try {
+ if (dataSourceProvider != null) {
+ // create wrapper for Jdbc connection
+ return new JdbcConnection(getName(),
+ getDefaultCachePolicy(),
+ dataSourceProvider.getConnection(),
+ rootUuid);
+ }
+ } catch (Exception e) {
+ errMsg = JdbcMetadataI18n.unableToGetConnectionUsingDriver.text(getName(),
getDriverClassName(), getDatabaseUrl());
+ throw new RepositorySourceException(errMsg, e);
+ }
+
+ // create Jdbc connection using driver and database URL
+ try {
+ if (driverProvider != null) {
+ // create wrapper for Jdbc connection
+ return new JdbcConnection(getName(),
+ getDefaultCachePolicy(),
+ driverProvider.getConnection(),
+ rootUuid);
+ }
+ } catch (Exception e) {
+ errMsg =
JdbcMetadataI18n.unableToGetConnectionUsingDataSource.text(getName(),
getDataSourceName());
+ throw new RepositorySourceException(errMsg, e);
+ }
+
+ // Either data source name or JDBC driver connection properties must be defined
+ errMsg = JdbcMetadataI18n.oneOfPropertiesIsRequired.text(getName());
+ throw new RepositorySourceException(errMsg);
}
/**
@@ -193,6 +273,22 @@
}
/**
+ * @return rootNodeUuid
+ */
+ public String getRootNodeUuid() {
+ return rootUuid != null? rootUuid.toString() : null;
+ }
+
+ /**
+ * @param rootNodeUuid Sets rootNodeUuid to the specified value.
+ * @throws IllegalArgumentException if the string value cannot be converted to UUID
+ */
+ public void setRootNodeUuid( String rootNodeUuid ) {
+ if (rootNodeUuid != null && rootNodeUuid.trim().length() == 0)
rootNodeUuid = DEFAULT_ROOT_NODE_UUID;
+ this.rootUuid = UUID.fromString(rootNodeUuid);
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -211,6 +307,140 @@
}
/**
+ * Gets JDBC driver class name
+ *
+ * @return the JDBC driver class name if any
+ */
+ public String getDriverClassName() {
+ // get provider
+ DriverDatabaseMetadataProvider provider = getDriverProvider(false);
+ // return
+ return (provider != null)? provider.getDriverClassName() : null;
+ }
+
+ /**
+ * Sets JDBC driver class name
+ *
+ * @param driverClassName the JDBC driver class name
+ */
+ public void setDriverClassName( String driverClassName ) {
+ if (driverClassName == null) {
+ driverProvider = null;
+ } else {
+ // get/create provider
+ DriverDatabaseMetadataProvider provider = getDriverProvider(true);
+ // set
+ provider.setDriverClassName(driverClassName);
+ }
+ }
+
+ /**
+ * Gets database URL as string
+ *
+ * @return database URL as string
+ */
+ public String getDatabaseUrl() {
+ // get provider
+ DriverDatabaseMetadataProvider provider = getDriverProvider(false);
+ // return
+ return (provider != null)? provider.getDatabaseUrl() : null;
+ }
+
+ /**
+ * Sets the database URL as string
+ *
+ * @param databaseUrl the database URL as string
+ */
+ public void setDatabaseUrl( String databaseUrl ) {
+ if (databaseUrl == null) {
+ driverProvider = null;
+ } else {
+ // get/create provider
+ DriverDatabaseMetadataProvider provider = getDriverProvider(true);
+ // set
+ provider.setDatabaseUrl(databaseUrl);
+ }
+ }
+
+ /**
+ * Gets the user name
+ *
+ * @return the user name
+ */
+ public String getUserName() {
+ // get provider
+ DriverDatabaseMetadataProvider provider = getDriverProvider(false);
+ return (provider != null)? provider.getUserName() : null;
+ }
+
+ /**
+ * Sets the user name
+ *
+ * @param userName the user name
+ */
+ public void setUserName( String userName ) {
+ if (userName == null) {
+ driverProvider = null;
+ } else {
+ // get provider
+ DriverDatabaseMetadataProvider provider = getDriverProvider(true);
+ provider.setUserName(userName);
+ }
+ }
+
+ /**
+ * Get user's password
+ *
+ * @return user's password
+ */
+ public String getPassword() {
+ // get provider
+ DriverDatabaseMetadataProvider provider = getDriverProvider(false);
+ return (provider != null)? provider.getPassword() : null;
+ }
+
+ /**
+ * Sets the user's password
+ *
+ * @param password the user's password
+ */
+ public void setPassword( String password ) {
+ if (password == null) {
+ driverProvider = null;
+ } else {
+ // get provider
+ DriverDatabaseMetadataProvider provider = getDriverProvider(true);
+ provider.setPassword(password);
+ }
+ }
+
+ /**
+ * Sets data source JNDI name
+ *
+ * @return data source JNDI name
+ */
+ public String getDataSourceName() {
+ // get provider
+ DataSourceDatabaseMetadataProvider provider = getDataSourceProvider(false);
+ return (provider != null)? provider.getDataSourceName() : null;
+ }
+
+ /**
+ * Sets data source JNDI name
+ *
+ * @param dataSourceName the data source JNDI name
+ */
+ public void setDataSourceName( String dataSourceName ) {
+ if (dataSourceName == null) {
+ dataSourceProvider = null;
+ } else {
+ // get provider
+ DataSourceDatabaseMetadataProvider provider = getDataSourceProvider(true);
+ provider.setDataSourceName(dataSourceName);
+ }
+ }
+
+ /**
* {@inheritDoc}
*
* @see javax.naming.Referenceable#getReference()
@@ -223,6 +453,29 @@
if (getName() != null) {
ref.add(new StringRefAddr(SOURCE_NAME, getName()));
}
+
+ if (getRootNodeUuid() != null) {
+ ref.add(new StringRefAddr(ROOT_NODE_UUID, getRootNodeUuid()));
+ }
+ if (getDataSourceName() != null) {
+ ref.add(new StringRefAddr(DATA_SOURCE_JNDI_NAME, getDataSourceName()));
+ }
+
+ if (getUserName() != null) {
+ ref.add(new StringRefAddr(USERNAME, getUserName()));
+ }
+
+ if (getPassword() != null) {
+ ref.add(new StringRefAddr(PASSWORD, getPassword()));
+ }
+
+ if (getDatabaseUrl() != null) {
+ ref.add(new StringRefAddr(URL, getDatabaseUrl()));
+ }
+ if (getDriverClassName() != null) {
+ ref.add(new StringRefAddr(DRIVER_CLASS_NAME, getDriverClassName()));
+ }
+
if (getDefaultCachePolicy() != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
CachePolicy policy = getDefaultCachePolicy();
@@ -272,13 +525,27 @@
}
}
}
+ // get individual properties
String sourceName = (String)values.get(SOURCE_NAME);
+ String rootNodeUuid = (String)values.get(ROOT_NODE_UUID);
+ String dataSourceJndiName = (String)values.get(DATA_SOURCE_JNDI_NAME);
+ String userName = (String)values.get(USERNAME);
+ String password = (String)values.get(PASSWORD);
+ String url = (String)values.get(URL);
+ String driverClassName = (String)values.get(DRIVER_CLASS_NAME);
+
Object defaultCachePolicy = values.get(DEFAULT_CACHE_POLICY);
String retryLimit = (String)values.get(RETRY_LIMIT);
// Create the source instance ...
JdbcRepositorySource source = new JdbcRepositorySource();
if (sourceName != null) source.setName(sourceName);
+ if (rootNodeUuid != null) source.setRootNodeUuid(rootNodeUuid);
+ if (dataSourceJndiName != null)
source.setDataSourceName(dataSourceJndiName);
+ if (userName != null) source.setUserName(userName);
+ if (password != null) source.setPassword(password);
+ if (url != null) source.setDatabaseUrl(url);
+ if (driverClassName != null) source.setDriverClassName(driverClassName);
if (defaultCachePolicy instanceof CachePolicy) {
source.setDefaultCachePolicy((CachePolicy)defaultCachePolicy);
}
Added:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java 2008-12-18
11:53:51 UTC (rev 691)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.dna.connector.jdbc;
+
+import java.sql.Connection;
+import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.properties.DateTime;
+import org.jboss.dna.graph.requests.CopyBranchRequest;
+import org.jboss.dna.graph.requests.CreateNodeRequest;
+import org.jboss.dna.graph.requests.DeleteBranchRequest;
+import org.jboss.dna.graph.requests.MoveBranchRequest;
+import org.jboss.dna.graph.requests.ReadAllChildrenRequest;
+import org.jboss.dna.graph.requests.ReadAllPropertiesRequest;
+import org.jboss.dna.graph.requests.UpdatePropertiesRequest;
+import org.jboss.dna.graph.requests.processor.RequestProcessor;
+
+/**
+ * JDBC request processor
+ *
+ * @author <a href="mailto:litsenko_sergey@yahoo.com">Sergiy
Litsenko</a>
+ *
+ */
+public class JdbcRequestProcesor extends RequestProcessor {
+ protected Connection connection;
+
+ /**
+ * Logging for this instance
+ */
+ protected Logger log = Logger.getLogger(getClass());
+
+ /**
+ * @param sourceName
+ * @param context
+ * @param connection
+ */
+ public JdbcRequestProcesor( String sourceName,
+ ExecutionContext context,
+ Connection connection) {
+ super(sourceName, context);
+ this.connection = connection;
+ }
+
+ /**
+ * @param sourceName
+ * @param context
+ * @param connection
+ * @param now
+ */
+ public JdbcRequestProcesor( String sourceName,
+ ExecutionContext context,
+ Connection connection,
+ DateTime now ) {
+ super(sourceName, context, now);
+ this.connection = connection;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.CopyBranchRequest)
+ */
+ @Override
+ public void process( CopyBranchRequest request ) {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.CreateNodeRequest)
+ */
+ @Override
+ public void process( CreateNodeRequest request ) {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.DeleteBranchRequest)
+ */
+ @Override
+ public void process( DeleteBranchRequest request ) {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.MoveBranchRequest)
+ */
+ @Override
+ public void process( MoveBranchRequest request ) {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.ReadAllChildrenRequest)
+ */
+ @Override
+ public void process( ReadAllChildrenRequest request ) {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.ReadAllPropertiesRequest)
+ */
+ @Override
+ public void process( ReadAllPropertiesRequest request ) {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.UpdatePropertiesRequest)
+ */
+ @Override
+ public void process( UpdatePropertiesRequest request ) {
+ }
+}
Property changes on:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.properties
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.properties 2008-12-17
15:54:36 UTC (rev 690)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.properties 2008-12-18
11:53:51 UTC (rev 691)
@@ -25,5 +25,9 @@
nodeTypeIsNotSupported= The {0} node type is not supported
locationInRequestMustHavePath = Location must have a path {0}
propertyIsRequired = The {0} property is required but has no value
+oneOfPropertiesIsRequired={0}: Either data source name or JDBC driver connection
properties must be defined
errorSerializingCachePolicyInSource = Error serializing a {0} instance owned by the {1}
JdbcRepositorySource
-sourceIsReadOnly = {0} is a read-only source; no updates are allowed
\ No newline at end of file
+sourceIsReadOnly = {0} is a read-only source; no updates are allowed
+unableToGetConnectionUsingDriver = {0}: Unable to get connection using following driver:
{1} ; and URL: {2}
+unableToGetConnectionUsingDataSource = {0}: Unable to get connection using following data
source: {1}
+unableToGetXAResource = {0}: Unable to get XA Resource for JDBC connection
\ No newline at end of file
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/data/insert.xml
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/data/insert.xml
(rev 0)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/test/data/insert.xml 2008-12-18
11:53:51 UTC (rev 691)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<dataset>
+ <TEST ID="1" NAME="1(a)hotmail.com" DESCRIPTION="This is
1"/>
+ <TEST ID="2" NAME="2(a)hotmail.com" DESCRIPTION="This is
2"/>
+ <TEST ID="3" NAME="3(a)hotmail.com" DESCRIPTION="This is
3"/>
+ <TEST ID="4" NAME="4(a)hotmail.com" DESCRIPTION="This is
4"/>
+ <TEST ID="5" NAME="5(a)hotmail.com" DESCRIPTION="This is
5"/>
+ <TEST ID="6" NAME="6(a)hotmail.com" DESCRIPTION="This is
6"/>
+ <TEST ID="7" NAME="7(a)hotmail.com" DESCRIPTION="This is
7"/>
+ <TEST ID="8" NAME="8(a)hotmail.com" DESCRIPTION="This is
8"/>
+ <TEST ID="9" NAME="9(a)hotmail.com" DESCRIPTION="This is
9"/>
+ <TEST ID="10" NAME="10(a)hotmail.com" DESCRIPTION="This is
10"/>
+
+ <SALGRADE GRADE="1" LOSAL="700" HISAL="1200"/>
+ <SALGRADE GRADE="2" LOSAL="1201" HISAL="1400"/>
+ <SALGRADE GRADE="3" LOSAL="1401" HISAL="2000"/>
+ <SALGRADE GRADE="4" LOSAL="2001" HISAL="3000"/>
+ <SALGRADE GRADE="5" LOSAL="3001" HISAL="9999"/>
+
+ <DEPT DEPTNO="10" DNAME="ACCOUNTING" LOC="NEW
YORK"/>
+ <DEPT DEPTNO="20" DNAME="RESEARCH"
LOC="DALLAS"/>
+ <DEPT DEPTNO="30" DNAME="SALES"
LOC="CHICAGO"/>
+ <DEPT DEPTNO="40" DNAME="OPERATIONS"
LOC="BOSTON"/>
+
+ <EMP EMPNO="7839" ENAME="KING" JOB="PRESIDENT"
HIREDATE="1981-11-17 00:00:00" SAL="5000"
DEPTNO="10"/>
+ <EMP EMPNO="7566" ENAME="JONES" JOB="MANAGER"
MGR="7839" HIREDATE="1981-04-02 00:00:00" SAL="2975"
DEPTNO="20"/>
+ <EMP EMPNO="7902" ENAME="FORD" JOB="ANALYST"
MGR="7566" HIREDATE="1981-12-03 00:00:00" SAL="3000"
DEPTNO="20"/>
+ <EMP EMPNO="7369" ENAME="SMITH" JOB="CLERK"
MGR="7902" HIREDATE="1980-12-17 00:00:00" SAL="800"
DEPTNO="20"/>
+ <EMP EMPNO="7698" ENAME="BLAKE" JOB="MANAGER"
MGR="7839" HIREDATE="1981-05-01 00:00:00" SAL="2850"
DEPTNO="30"/>
+ <EMP EMPNO="7499" ENAME="ALLEN" JOB="SALESMAN"
MGR="7698" HIREDATE="1981-02-20 00:00:00" SAL="1600"
DEPTNO="30" COMM="300" />
+ <EMP EMPNO="7521" ENAME="WARD" JOB="SALESMAN"
MGR="7698" HIREDATE="1981-02-22 00:00:00" SAL="1250"
DEPTNO="30" COMM="500" />
+ <EMP EMPNO="7654" ENAME="MARTIN" JOB="SALESMAN"
MGR="7698" HIREDATE="1981-09-28 00:00:00" SAL="1250"
DEPTNO="30" COMM="1400"/>
+ <EMP EMPNO="7782" ENAME="CLARK" JOB="MANAGER"
MGR="7839" HIREDATE="1981-06-09 00:00:00" SAL="2450"
DEPTNO="10"/>
+ <EMP EMPNO="7788" ENAME="SCOTT" JOB="ANALYST"
MGR="7566" HIREDATE="1987-04-19 00:00:00" SAL="3000"
DEPTNO="20"/>
+ <EMP EMPNO="7844" ENAME="TURNER" JOB="SALESMAN"
MGR="7698" HIREDATE="1981-09-08 00:00:00" SAL="1500"
DEPTNO="30" COMM="0"/>
+ <EMP EMPNO="7876" ENAME="ADAMS" JOB="CLERK"
MGR="7788" HIREDATE="1987-05-23 00:00:00" SAL="1100"
DEPTNO="20"/>
+ <EMP EMPNO="7900" ENAME="JAMES" JOB="CLERK"
MGR="7698" HIREDATE="1981-12-03 00:00:00" SAL="950"
DEPTNO="30"/>
+ <EMP EMPNO="7934" ENAME="MILLER" JOB="CLERK"
MGR="7782" HIREDATE="1982-01-23 00:00:00" SAL="1300"
DEPTNO="10"/>
+</dataset>
Property changes on:
trunk/extensions/dna-connector-jdbc-metadata/src/test/data/insert.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/data/testdb/db.properties
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/data/testdb/db.properties
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/data/testdb/db.properties 2008-12-18
11:53:51 UTC (rev 691)
@@ -0,0 +1,15 @@
+hsqldb.script_format=0
+runtime.gc_interval=0
+sql.enforce_strict_size=false
+hsqldb.cache_size_scale=8
+readonly=false
+hsqldb.nio_data_file=true
+hsqldb.cache_scale=14
+version=1.8.0
+hsqldb.default_table_type=memory
+hsqldb.cache_file_scale=1
+hsqldb.log_size=200
+modified=yes
+hsqldb.cache_version=1.7.0
+hsqldb.original_version=1.8.0
+hsqldb.compatible_version=1.8.0
Property changes on:
trunk/extensions/dna-connector-jdbc-metadata/src/test/data/testdb/db.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/data/testdb/db.script
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/data/testdb/db.script
(rev 0)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/test/data/testdb/db.script 2008-12-18
11:53:51 UTC (rev 691)
@@ -0,0 +1,17 @@
+CREATE SCHEMA PUBLIC AUTHORIZATION DBA
+CREATE USER SA PASSWORD ""
+GRANT DBA TO SA
+SET WRITE_DELAY 10
+CREATE TABLE TEST (ID NUMERIC NOT NULL PRIMARY KEY, NAME VARCHAR(30) NOT NULL,
DESCRIPTION VARCHAR(255))
+CREATE TABLE BONUS (ENAME VARCHAR(10) NULL, JOB VARCHAR(9) NULL, SAL NUMERIC NULL, COMM
NUMERIC NULL)
+CREATE TABLE DEPT (DEPTNO NUMERIC(2,0) NOT NULL, DNAME VARCHAR(14) NULL, LOC VARCHAR(13)
NULL)
+ALTER TABLE DEPT ADD CONSTRAINT PK_DEPT PRIMARY KEY (DEPTNO)
+CREATE TABLE EMP (EMPNO NUMERIC(4,0) NOT NULL, ENAME VARCHAR(10) NULL, JOB VARCHAR(9)
NULL, MGR NUMERIC(4,0) NULL, HIREDATE DATE NULL, SAL NUMERIC(7,2) NULL, COMM NUMERIC(7,2)
NULL, DEPTNO NUMERIC(2,0) NULL)
+ALTER TABLE EMP ADD CONSTRAINT PK_EMP PRIMARY KEY (EMPNO)
+ALTER TABLE EMP ADD CONSTRAINT FK_DEPTNO FOREIGN KEY(DEPTNO) REFERENCES DEPT(DEPTNO) ON
DELETE CASCADE
+CREATE TABLE SALGRADE (GRADE NUMERIC NULL, LOSAL NUMERIC NULL, HISAL NUMERIC NULL)
+CREATE UNIQUE INDEX PK_DEPT ON DEPT(DEPTNO)
+CREATE UNIQUE INDEX PK_EMP ON EMP(EMPNO);
+
+
+
Added:
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/jdbc/DatabaseBasicTest.java
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/jdbc/DatabaseBasicTest.java
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/jdbc/DatabaseBasicTest.java 2008-12-18
11:53:51 UTC (rev 691)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.dna.connector.jdbc;
+
+import java.io.File;
+import java.io.IOException;
+import java.math.BigDecimal;
+import org.dbunit.IDatabaseTester;
+import org.dbunit.Assertion;
+import org.dbunit.JdbcDatabaseTester;
+import org.dbunit.dataset.DataSetException;
+import org.dbunit.dataset.IDataSet;
+import org.dbunit.dataset.ITable;
+import org.dbunit.dataset.xml.FlatXmlDataSet;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Basic test of the HSQLDB database with simple schema
+ *
+ * @author <a href="mailto:litsenko_sergey@yahoo.com">Sergiy
Litsenko</a>
+ */
+public class DatabaseBasicTest {
+ private IDatabaseTester dbTester;
+
+ private IDataSet getDataSet() throws IOException, DataSetException {
+ return new FlatXmlDataSet(new File("src/test/data/insert.xml"));
+ }
+
+ @Before
+ public void beforeEach() throws Exception {
+ dbTester = new JdbcDatabaseTester("org.hsqldb.jdbcDriver",
"jdbc:hsqldb:file:target/testdb/db", "sa", "");
+ dbTester.setDataSet(getDataSet());
+ dbTester.onSetup();
+ }
+
+ @After
+ public void afterEach() throws Exception {
+ dbTester.onTearDown();
+ }
+
+ @Test
+ public void testTableShallBeLoaded() throws Exception {
+ // Fetch live database data
+ IDataSet databaseDataSet = dbTester.getConnection().createDataSet();
+ ITable actualTable = databaseDataSet.getTable("TEST");
+ ITable expectedTable = getDataSet().getTable("TEST");
+ Assertion.assertEquals(expectedTable, actualTable);
+ }
+
+ @Test
+ public void testTableRecordsLoaded() throws Exception {
+ // Fetch live database data
+ Assert.assertEquals(10, dbTester.getConnection().getRowCount("TEST"));
+ }
+
+ @Test
+ public void testTableRandomRowColumnId() throws Exception {
+ // Fetch live database data
+ IDataSet databaseDataSet = dbTester.getConnection().createDataSet();
+ ITable actualTable = databaseDataSet.getTable("TEST");
+ // get 5th row, column: id
+ Object actualId = actualTable.getValue(4, "ID");
+ Assert.assertNotNull(actualId);
+
+ BigDecimal expectedId = new BigDecimal(5);
+ Assert.assertTrue(expectedId.equals(actualId));
+ }
+
+ @Test
+ public void testTableRandomRowColumnName() throws Exception {
+ // Fetch live database data
+ IDataSet databaseDataSet = dbTester.getConnection().createDataSet();
+ ITable actualTable = databaseDataSet.getTable("TEST");
+ // get 6th row, column: name
+ Assert.assertEquals("6(a)hotmail.com", actualTable.getValue(5,
"NAME"));
+ }
+
+ @Test
+ public void testTableRandomRowColumnDescription() throws Exception {
+ // Fetch live database data
+ IDataSet databaseDataSet = dbTester.getConnection().createDataSet();
+ ITable actualTable = databaseDataSet.getTable("TEST");
+ // get 7th row, column: description
+ Assert.assertEquals("This is 7", actualTable.getValue(6,
"DESCRIPTION"));
+ }
+
+ @Test
+ public void testDefaultDatabaseSchemaNameIsEmpty() throws Exception {
+ Assert.assertNull(dbTester.getConnection().getSchema());
+ }
+
+ @Test
+ public void salGradeTableShallBeLoaded() throws Exception {
+ // Fetch live database data
+ IDataSet databaseDataSet = dbTester.getConnection().createDataSet();
+ ITable actualTable = databaseDataSet.getTable("SALGRADE");
+ ITable expectedTable = getDataSet().getTable("SALGRADE");
+ Assertion.assertEquals(expectedTable, actualTable);
+ }
+
+ @Test
+ public void deptTableShallBeLoaded() throws Exception {
+ // Fetch live database data
+ IDataSet databaseDataSet = dbTester.getConnection().createDataSet();
+ ITable actualTable = databaseDataSet.getTable("DEPT");
+ ITable expectedTable = getDataSet().getTable("DEPT");
+ Assertion.assertEquals(expectedTable, actualTable);
+ }
+
+ @Test
+ public void empTableShallBeLoaded() throws Exception {
+ // Fetch live database data
+ IDataSet databaseDataSet = dbTester.getConnection().createDataSet();
+ ITable actualTable = databaseDataSet.getTable("EMP");
+ ITable expectedTable = getDataSet().getTable("EMP");
+ // Assertion.assertEquals(expectedTable, actualTable);
+ Assert.assertEquals(actualTable.getRowCount(), expectedTable.getRowCount());
+ }
+}
Property changes on:
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/jdbc/DatabaseBasicTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/log4j.xml
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/log4j.xml
(rev 0)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/log4j.xml 2008-12-18
11:53:51 UTC (rev 691)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
+ <appender name="CONSOLE"
class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p
%t [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="FILE"
class="org.apache.log4j.FileAppender">
+ <param name="Threshold" value="TRACE"/>
+ <param name="Append" value="false"/>
+ <param name="File" value="target/test.log"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p
%t [%c, %L] %m%n"/>
+ </layout>
+ </appender>
+
+
+ <category name="org.jboss.dna.connector.jdbc">
+ <priority value="TRACE"/>
+ </category>
+
+ <category name="org.dbunit">
+ <priority value="INFO"/>
+ </category>
+
+ <root>
+ <priority value="INFO"/>
+ <appender-ref ref="FILE"/>
+ </root>
+</log4j:configuration>
Property changes on:
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/log4j.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain