Giter VIP home page Giter VIP logo

spock-dbunit's People

Contributors

janbols avatar mateuszstefek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

spock-dbunit's Issues

Single table inheritance: not common fields are not filled

Hi,
first, let me say thank you for this cool lib.
I tried to create different child entities of the same parent with annotations, but could not set non-common arguments.
So in my case, there is a User parent class, an EndUser and a ManagerUser children. I tried to make one EndUser and two ManagerUser instances. The latter would need some attributes filled which are not present in the first. So I am adding the attributes for the ManagerUser, but not for the EndUser. This way the attribute value is not set in the DB (it is null). If I only want to create ManagerUser instances I can add the attribute if I add to all of the created ones.
Is this a bug or am I doing something wrongly?
Your help is very much appreciated!

org.dbunit.dataset.NoSuchTableException: abc

I have below code in my spec file:
@dbunit(configure={ IDatabaseTester it ->
it.setUpOperation = InsertIdentityOperation.REFRESH
it.tearDownOperation = InsertIdentityOperation.DELETE
})
def content = {
abc(id:123, name:'test')
}

This working finr in MySql, but when I try to run for MSSQL it gives org.dbunit.dataset.NoSuchTableException : abc error.

I have verified the 'abc' table is already there in MSSSQL database.

While debugging I have found that connection.getSchema() return "".

So how I can pass schema 'dbo' to @dbunit extension?

I don't want to pass in every class @dbunit(schema='dbo', configure......) like this.

Instead is it possible to get schema from field like we get datasource.

Multiple @DbUnit for specific feature.

I have legacy db in which there are some tables without Primary key and some with PK, I know that for table with PK i can use DatabaseOperation.INSERT and tables without PK I can use DatabaseOperation.REFRESH, but for this I need to write 2 def conten{...}, but it's not allow to write, so what should I do?

In spec file how can I handle this scenario?

How to set IColumnFilter using @DbUnit

I have one of my table without primary key, So I want to set IColumnFilter as per given example in
So I have add below @dbunit annoation to one of my feature:

@dbunit(configure={ IDatabaseTester it ->
it.getConnection().getConfig().setProperty(
DatabaseConfig.PROPERTY_PRIMARY_KEY_FILTER,
new MyPrimaryKeyFilter(null))
it.setUpOperation = DatabaseOperation.REFRESH
it.tearDownOperation = DatabaseOperation.NONE
}, content = {
tableWitoutPK(no_key1:value1, no_key2:value2)
})
def "add value to table without pk"(){
.........
}

class MyPrimaryKeyFilter implements IColumnFilter{
.........
}

But it's failing with exception: org.dbunit.dataset.NoPrimaryKeyException: tableWitoutPK

When I have debug, found that while configuring IDatabaseTester in DbUnitInterceptor it's throwing exception "Failed to instantiate tester configurer in @dbunit".

I don't know this feature is present in current DbUnit extension or not.

Column sensing

It would be nice, if we could use the "column sensing" feature of DBUnit.

With this defining rows with null values wouldn't be so awkward.

Want to use schema from Connection

I have legacy test codebase , which working fine in MySql.

Now when I tried that code base with MSSQL, it required me to pass schema in each class which is cumbersome. Like

@DbUnit(schema = 'dbo', configure={
   .....
})

Is this possible to use schema from Connection class, in DbUnitInterceptor like this:

void interceptFeatureMethod(IMethodInvocation invocation) throws Throwable {
    ....
    def schema = dbUnitAnnotation.schema()
    if(schema == '' || schema == null){
         dataSource.getConnection().getSchema();
     }
     tester = new DataSourceDatabaseTester(dataSource, schema ) {
    ...
}

DB table ip field does not initialize value

@janbols

Hi!

I initialized the value in the ip field of the DB table as below, but it does not contain the value.

 @DbUnit(configure = { IDatabaseTester it ->
        it.setUpOperation = DatabaseOperation.CLEAN_INSERT
    })
def content = {
    User(name: 'test1', ip: '1.2.3.4')
    User(name: 'test2', ip: '127.0.0.1')
}

What should I do?

Please confirm.

Your help is very much appreciated!

Qualified names support (multiple schemas)

My project requires mocking data in multiple schemas (databases), so I am trying to us DbUnit's qualified table name feature. However, I am having problems with this so I am wondering if it has been tested before.

I am able to enable the feature with the configure closure:

@DbUnit(configure = {
    it.connection.config.setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, true)
})
def content = {
  'FOO.BAR'(id: 1)
}

But inserting fails with an unknown table:

    org.dbunit.dataset.NoSuchTableException: FOO.BAR

I have verified the tables exist with a simple SELECT * query.

Disregard this part below; this issue was related to jooq and are not present using groovy sql.

@DBUnit with @SingleExecution extension execution order not preserving

I'm trying to use @dbunit at field level, and @SingleExecution at method level.

Issue: @dbunit should be execute first and then @SingleExecution should be execute

For @SingleExecution - interceptIterationExecution() contain logic which every time first executed
For @dbunit - interceptFeatureMethod() contain logic which executed after @SingleExecution interceptIterationExecution method execute.

Currently they are executing in below order:

  1. @SingleExecution
  2. @dbunit
  3. My feature/spec execution

But I want to execute above annotation in following order:

  1. @dbunit -
  2. @SingleExecution
  3. My feature/spec execution

My code is as below:
@dbunit(configure={ IDatabaseTester it ->
it.setUpOperation = InsertIdentityOperation.REFRESH
it.tearDownOperation = InsertIdentityOperation.NONE
})
def content = {
table1(col1:value1, col2:value2)
}

@SingleExecution('getColumnWiseMap')
def "test data table with single execution"(){
.....
}

def getColumnWiseMap(){
return ....;
}

Problem with DB schema

Hi Jan,

I need to set the schema of an oracle database.
There is the posibility to do it with the configure closure like this

@DbUnit(configure = { IDatabaseTester dbTester -> dbTester.setSchema(config.getString("schema")) })

but this approach is deprecated in dbunit
since 2.4.3 Should not be used anymore. Every concrete IDatabaseTester implementation that needs a schema has the possibility to set it somehow in the constructor

Would it be possible that the annotation gets an extra field to specify a schema?

Configure a data type factory

When using an Oracle Database the following warning spams the log file:

WARN org.dbunit.dataset.AbstractTableMetaData - Potential problem found: The configured data type factory 'class org.dbunit.dataset.datatype.DefaultDataTypeFactory' might cause problems with the current database 'Oracle' (e.g. some datatypes may not be supported properly). In rare cases you might see this message because the list of supported database products is incomplete (list=[derby]). If so please request a java-class update via the forums.If you are using your own IDataTypeFactory extending DefaultDataTypeFactory, ensure that you override getValidDbProducts() to specify the supported database products.

It would be awesome when you could set the used database somehow

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.