dbspock core

Expresses the data as Spockly!

License

License

Categories

Categories

Spock Application Testing & Monitoring
GroupId

GroupId

com.yo1000
ArtifactId

ArtifactId

dbspock-core
Last Version

Last Version

2.3.0.RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

dbspock core
Expresses the data as Spockly!
Source Code Management

Source Code Management

https://github.com/yo1000/dbspock

Download dbspock-core

How to add to project

<!-- https://jarcasting.com/artifacts/com.yo1000/dbspock-core/ -->
<dependency>
    <groupId>com.yo1000</groupId>
    <artifactId>dbspock-core</artifactId>
    <version>2.3.0.RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/com.yo1000/dbspock-core/
implementation 'com.yo1000:dbspock-core:2.3.0.RELEASE'
// https://jarcasting.com/artifacts/com.yo1000/dbspock-core/
implementation ("com.yo1000:dbspock-core:2.3.0.RELEASE")
'com.yo1000:dbspock-core:jar:2.3.0.RELEASE'
<dependency org="com.yo1000" name="dbspock-core" rev="2.3.0.RELEASE">
  <artifact name="dbspock-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.yo1000', module='dbspock-core', version='2.3.0.RELEASE')
)
libraryDependencies += "com.yo1000" % "dbspock-core" % "2.3.0.RELEASE"
[com.yo1000/dbspock-core "2.3.0.RELEASE"]

Dependencies

compile (3)

Group / Artifact Type Version
org.codehaus.groovy : groovy jar 2.4.7
junit : junit jar 4.12
org.spockframework : spock-core jar 1.1-groovy-2.4-rc-2

Project Modules

There are no modules declared in this project.

dbspock

Expresses the data as Spockly!

Usage

Can be used in DbSetup or DBUnit

for DbSetup

Dependency

<dependencies>
    <dependency>
        <groupId>com.yo1000</groupId>
        <artifactId>dbspock-core</artifactId>
        <version>2.3.0.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.yo1000</groupId>
        <artifactId>dbspock-dbsetup</artifactId>
        <version>2.3.0.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.yo1000</groupId>
        <artifactId>dbspock-jdbc</artifactId>
        <version>2.3.0.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.ninja-squad</groupId>
        <artifactId>DbSetup</artifactId>
        <version>2.1.0</version>
        <scope>test</scope>
    </dependency>
</dependencies>

Setup in spec

setup:
def insertOps = DbspockOperations.insertInto {
    test_table {
        test_int | test_str | test_date
        100      | 'test1'  | '2016-09-26 23:20:01.0'
        200      | 'test2'  | '2016-09-26 23:20:02.0'
        300      | 'test3'  | '2016-09-26 23:20:03.0'
    }
}

def destination = new DriverManagerDestination(URL, USERNAME, PASSWORD)
new DbSetup(destination,
        Operations.sequenceOf(
                Operations.truncate('test_table'),
                insertOps
        )
).launch()

When using a rotate support

setup:
def insertOps = DbspockOperations.insertIntoWithRotate {
    test_table {
        test_int  | 100                     | 200                     | 300
        test_str  | 'test1'                 | 'test2'                 | 'test3'
        test_date | '2016-09-26 23:20:01.0' | '2016-09-26 23:20:02.0' | '2016-09-26 23:20:03.0'
    }
}

def destination = new DriverManagerDestination(URL, USERNAME, PASSWORD)
new DbSetup(destination,
        Operations.sequenceOf(
                Operations.truncate('test_table'),
                insertOps
        )
).launch()

When using a expectation support

setup:
def insertOps = DbspockOperations.insertInto {
    test_table {
        test_int | test_str | test_date
        100      | 'test1'  | '2016-09-26 23:20:01.0'
        200      | 'test2'  | '2016-09-26 23:20:02.0'
        300      | 'test3'  | '2016-09-26 23:20:03.0'
    }
}

def destination = new DriverManagerDestination(URL, USERNAME, PASSWORD)
new DbSetup(destination,
        Operations.sequenceOf(
                Operations.truncate('test_table'),
                insertOps
        )
).launch()

expect:
DbspockExpectations.matches(destination.connection, {
    test_table {
        test_int | test_str | test_date
        100      | 'test1'  | '2016-09-26 23:20:01.0'
        200      | 'test2'  | '2016-09-26 23:20:02.0'
        300      | 'test3'  | '2016-09-26 23:20:03.0'
    }
})

DbspockExpectations.containsAll(destination.connection, {
    test_table {
        test_int | test_str | test_date
        100      | 'test1'  | '2016-09-26 23:20:01.0'
        300      | 'test3'  | '2016-09-26 23:20:03.0'
    }
})

DbspockExpectations.containsAny(destination.connection, {
    test_table {
        test_int | test_str | test_date
        100      | 'test1'  | '2016-09-26 23:20:01.0'
        900      | 'test9'  | '2020-09-26 23:20:03.0'
    }
})

DbspockExpectations.containsNone(destination.connection, {
    test_table {
        test_int | test_str | test_date
        900      | 'test9'  | '2020-09-26 23:20:03.0'
    }
})

for DBUnit

Dependency

<dependencies>
    <dependency>
        <groupId>com.yo1000</groupId>
        <artifactId>dbspock-core</artifactId>
        <version>2.3.0.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.yo1000</groupId>
        <artifactId>dbspock-dbunit</artifactId>
        <version>2.3.0.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.dbunit</groupId>
        <artifactId>dbunit</artifactId>
        <version>2.5.3</version>
        <scope>test</scope>
    </dependency>
</dependencies>

Setup in spec

setup:
def dataSet = DbspockLoaders.loadDataSet {
    test_table {
        test_int | test_str | test_date
        100      | 'test1'  | '2016-09-26 23:20:01.0'
        200      | 'test2'  | '2016-09-26 23:20:02.0'
        300      | 'test3'  | '2016-09-26 23:20:03.0'
    }
}

def databaseTester = new JdbcDatabaseTester(Driver.class.getName(), URL, USERNAME, PASSWORD)
databaseTester.setUpOperation = DatabaseOperation.CLEAN_INSERT

databaseTester.dataSet = dataSet
databaseTester.onSetup()

When using a rotate support

setup:
def dataSet = DbspockLoaders.loadDataSetWithRotate {
    test_table {
        test_int  | 100                     | 200                     | 300
        test_str  | 'test1'                 | 'test2'                 | 'test3'
        test_date | '2016-09-26 23:20:01.0' | '2016-09-26 23:20:02.0' | '2016-09-26 23:20:03.0'
    }
}

def databaseTester = new JdbcDatabaseTester(Driver.class.getName(), URL, USERNAME, PASSWORD)
databaseTester.setUpOperation = DatabaseOperation.CLEAN_INSERT

databaseTester.dataSet = dataSet
databaseTester.onSetup()

When using a expectation support

setup:
def dataSet = DbspockLoaders.loadDataSet {
    test_table {
        test_int | test_str | test_date
        100      | 'test1'  | '2016-09-26 23:20:01.0'
        200      | 'test2'  | '2016-09-26 23:20:02.0'
        300      | 'test3'  | '2016-09-26 23:20:03.0'
    }
}

def databaseTester = new JdbcDatabaseTester(Driver.class.getName(), URL, USERNAME, PASSWORD)
databaseTester.setUpOperation = DatabaseOperation.CLEAN_INSERT

databaseTester.dataSet = dataSet
databaseTester.onSetup()

expect:
DbspockExpectations.matches(databaseTester.connection, {
    test_table {
        test_int | test_str | test_date
        100      | 'test1'  | '2016-09-26 23:20:01.0'
        200      | 'test2'  | '2016-09-26 23:20:02.0'
        300      | 'test3'  | '2016-09-26 23:20:03.0'
    }
})

DbspockExpectations.containsAll(databaseTester.connection, {
    test_table {
        test_int | test_str | test_date
        100      | 'test1'  | '2016-09-26 23:20:01.0'
        300      | 'test3'  | '2016-09-26 23:20:03.0'
    }
})

DbspockExpectations.containsAny(databaseTester.connection, {
    test_table {
        test_int | test_str | test_date
        100      | 'test1'  | '2016-09-26 23:20:01.0'
        900      | 'test9'  | '2020-09-26 23:20:03.0'
    }
})

DbspockExpectations.containsNone(databaseTester.connection, {
    test_table {
        test_int | test_str | test_date
        900      | 'test9'  | '2020-09-26 23:20:03.0'
    }
})

Versions

Version
2.3.0.RELEASE
2.2.0.RELEASE
2.1.2.RELEASE
2.1.1.RELEASE
2.1.0.RELEASE