DBUnit hanging on DatabaseOperation.CLEAN_INSERT

View: New views
3 Messages — Rating Filter:   Alert me  

DBUnit hanging on DatabaseOperation.CLEAN_INSERT

by Furtado, Murray :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

DBUnit hanging on DatabaseOperation.CLEAN_INSERT

I'm trying to integrate DbUnit with the Spring transactional test class AbstractTransactionalJUnit4SpringContextTests.

The idea is that dbunit sets up the test data in the same transaction as Spring creates, the test is then run and the transaction then rolls back.

Here is my test class:

import org.springframework.jdbc.datasource.DataSourceUtils;
import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.dbunit.dataset.xml.XmlDataSet;
import java.sql.Connection;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/config/dev_config.xml" })
@Transactional
public class TestSettlementBatchProcessor extends AbstractTransactionalJUnit4SpringContextTests {

        @Autowired
        protected DataSource dataSource;

        @Before
        public void onSetUpInTransaction() throws Exception {
                Connection con = DataSourceUtils.getConnection(dataSource);
                IDatabaseConnection dbUnitCon = new DatabaseConnection(con);
                IDataSet dataSet = new XmlDataSet(new FileInputStream("src/test/testdata/dataset.xml"));
                try {
                        DatabaseOperation.CLEAN_INSERT.execute(dbUnitCon, dataSet);
                } catch (Exception e) {
                        e.printStackTrace();
                } finally {
                        DataSourceUtils.releaseConnection(con, getDataSource());
                }
        }

        @Test
        public void testSomething() {
                // test
        }
}

The problem is that the DatabaseOperation.CLEAN_INSERT.execute() call hangs with no exception thrown, so I have no idea as to what has happened.

The XmlDataSet is created without problem, and there are no identity columns in the table being populated.

Can anyone enlighten me?

Many thanks,

Murray

==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer: 

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
dbunit-user mailing list
dbunit-user@...
https://lists.sourceforge.net/lists/listinfo/dbunit-user

Re: DBUnit hanging on DatabaseOperation.CLEAN_INSERT

by Furtado, Murray :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

DBUnit hanging on DatabaseOperation.CLEAN_INSERT
OK, I've resolved this problem, which was due to read locking on the table preventing my test from executing, so I killed the blocking SPIDs. However, I now get the following error:
 

com.sybase.jdbc3.jdbc.SybSQLException: The 'CREATE TABLE' command is not allowed within a multi-statement transaction in the 'tempdb' database.

at com.sybase.jdbc3.tds.Tds.a(Unknown Source)

at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)

at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(Unknown Source)

at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)

at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)

at com.sybase.jdbc3.jdbc.SybStatement.queryLoop(Unknown Source)

at com.sybase.jdbc3.jdbc.SybCallableStatement.executeQuery(Unknown Source)

at com.sybase.jdbc3.jdbc.SybDatabaseMetaData.if(Unknown Source)

at com.sybase.jdbc3.jdbc.SybDatabaseMetaData.getColumns(Unknown Source)

at org.dbunit.database.DatabaseTableMetaData.getColumns(DatabaseTableMetaData.java:219)

at org.dbunit.operation.AbstractOperation.getOperationMetaData(AbstractOperation.java:74)

at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:152)

at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:78)

at test.dit.ops.caps.warehouse.settlement.loop.TestSettlementBatchProcessor.onSetUpInTransaction

This is bizarre, as I don't understand why Sybase should be issuing a CREATE_TABLE command in response to a call to getColumns() to retrieve metadata.

I'm running against Sybase, using the jconn3.jar sybase driver and Sybase v12.5.3.

Someone else has been encountering the same problem on the Spring forum: http://forum.springframework.org/showthread.php?p=150617

Anyone have any ideas what the issue is?

Many thanks,

Murray



From: dbunit-user-bounces@... [mailto:dbunit-user-bounces@...] On Behalf Of Furtado, Murray
Sent: 02 May 2008 10:35
To: dbunit-user@...
Subject: [dbunit-user] DBUnit hanging on DatabaseOperation.CLEAN_INSERT

I'm trying to integrate DbUnit with the Spring transactional test class AbstractTransactionalJUnit4SpringContextTests.

The idea is that dbunit sets up the test data in the same transaction as Spring creates, the test is then run and the transaction then rolls back.

Here is my test class:

import org.springframework.jdbc.datasource.DataSourceUtils;
import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.dbunit.dataset.xml.XmlDataSet;
import java.sql.Connection;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/config/dev_config.xml" })
@Transactional
public class TestSettlementBatchProcessor extends AbstractTransactionalJUnit4SpringContextTests {

        @Autowired
        protected DataSource dataSource;

        @Before
        public void onSetUpInTransaction() throws Exception {
                Connection con = DataSourceUtils.getConnection(dataSource);
                IDatabaseConnection dbUnitCon = new DatabaseConnection(con);
                IDataSet dataSet = new XmlDataSet(new FileInputStream("src/test/testdata/dataset.xml"));
                try {
                        DatabaseOperation.CLEAN_INSERT.execute(dbUnitCon, dataSet);
                } catch (Exception e) {
                        e.printStackTrace();
                } finally {
                        DataSourceUtils.releaseConnection(con, getDataSource());
                }
        }

        @Test
        public void testSomething() {
                // test
        }
}

The problem is that the DatabaseOperation.CLEAN_INSERT.execute() call hangs with no exception thrown, so I have no idea as to what has happened.

The XmlDataSet is created without problem, and there are no identity columns in the table being populated.

Can anyone enlighten me?

Many thanks,

Murray

==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer: 

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================

==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer: 

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
dbunit-user mailing list
dbunit-user@...
https://lists.sourceforge.net/lists/listinfo/dbunit-user

Re: DBUnit hanging on DatabaseOperation.CLEAN_INSERT

by lfbarragan () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Murray,

I am working with an Oracle database and I'm having the same problem, the application is hanging after excecuting DatabaseOperation.REFRESH.execute(connection, dataSet),it seems that I wasn't closing the connection to the database, I fixed it usgin the following code:

  private void setUpDatabase() throws Exception {
    // initialize your database connection here
    super.setUp();
    Class driverClass = Class.forName(DRIVER_CLASS);
    Connection jdbcConnection = DriverManager.getConnection(
        CONNECTION_URL, DBUNIT_USERNAME, DBUNIT_PASSWORD);
    IDatabaseConnection connection = new DatabaseConnection(jdbcConnection,DBUNIT_SCHEMA);

    // initialize your dataset here
    IDataSet dataSet = new XmlDataSet(new FileInputStream(originalXmlPath));

    try {
      DatabaseOperation.REFRESH.execute(connection, dataSet);
    }
    finally {
      connection.close();
    }
  }

Hope it helps

--
Luis Barragan



Furtado, Murray wrote:
OK, I've resolved this problem, which was due to read locking on the
table preventing my test from executing, so I killed the blocking SPIDs.
However, I now get the following error:
 
com.sybase.jdbc3.jdbc.SybSQLException: The 'CREATE TABLE' command is not
allowed within a multi-statement transaction in the 'tempdb' database.

at com.sybase.jdbc3.tds.Tds.a(Unknown Source)

at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)

at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(Unknown Source)

at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)

at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)

at com.sybase.jdbc3.jdbc.SybStatement.queryLoop(Unknown Source)

at com.sybase.jdbc3.jdbc.SybCallableStatement.executeQuery(Unknown
Source)

at com.sybase.jdbc3.jdbc.SybDatabaseMetaData.if(Unknown Source)

at com.sybase.jdbc3.jdbc.SybDatabaseMetaData.getColumns(Unknown Source)

at
org.dbunit.database.DatabaseTableMetaData.getColumns(DatabaseTableMetaDa
ta.java:219)

at
org.dbunit.operation.AbstractOperation.getOperationMetaData(AbstractOper
ation.java:74)

at
org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperati
on.java:152)

at
org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:
78)

at
test.dit.ops.caps.warehouse.settlement.loop.TestSettlementBatchProcessor
.onSetUpInTransaction

This is bizarre, as I don't understand why Sybase should be issuing a
CREATE_TABLE command in response to a call to getColumns() to retrieve
metadata.

I'm running against Sybase, using the jconn3.jar sybase driver and
Sybase v12.5.3.

Someone else has been encountering the same problem on the Spring forum:
http://forum.springframework.org/showthread.php?p=150617

Anyone have any ideas what the issue is?

Many thanks,

Murray


________________________________

From: dbunit-user-bounces@lists.sourceforge.net
[mailto:dbunit-user-bounces@lists.sourceforge.net] On Behalf Of Furtado,
Murray
Sent: 02 May 2008 10:35
To: dbunit-user@lists.sourceforge.net
Subject: [dbunit-user] DBUnit hanging on DatabaseOperation.CLEAN_INSERT



I'm trying to integrate DbUnit with the Spring transactional test class
AbstractTransactionalJUnit4SpringContextTests.

The idea is that dbunit sets up the test data in the same transaction as
Spring creates, the test is then run and the transaction then rolls
back.

Here is my test class:

import org.springframework.jdbc.datasource.DataSourceUtils;
import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.dbunit.dataset.xml.XmlDataSet;
import java.sql.Connection;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/config/dev_config.xml" })
@Transactional
public class TestSettlementBatchProcessor extends
AbstractTransactionalJUnit4SpringContextTests {

        @Autowired
        protected DataSource dataSource;

        @Before
        public void onSetUpInTransaction() throws Exception {
                Connection con =
DataSourceUtils.getConnection(dataSource);
                IDatabaseConnection dbUnitCon = new
DatabaseConnection(con);
                IDataSet dataSet = new XmlDataSet(new
FileInputStream("src/test/testdata/dataset.xml"));
                try {
 
DatabaseOperation.CLEAN_INSERT.execute(dbUnitCon, dataSet);
                } catch (Exception e) {
                        e.printStackTrace();
                } finally {
                        DataSourceUtils.releaseConnection(con,
getDataSource());
                }
        }

        @Test
        public void testSomething() {
                // test
        }
}

The problem is that the DatabaseOperation.CLEAN_INSERT.execute() call
hangs with no exception thrown, so I have no idea as to what has
happened.

The XmlDataSet is created without problem, and there are no identity
columns in the table being populated.

Can anyone enlighten me?

Many thanks,

Murray

========================================================================
======
Please access the attached hyperlink for an important electronic
communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
========================================================================
======


==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
dbunit-user mailing list
dbunit-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dbunit-user
LightInTheBox - Buy quality products at wholesale price!