dbsock-parent

Expresses the data as Spockly!

License

License

Categories

Categories

Spock Application Testing & Monitoring
GroupId

GroupId

com.yo1000
ArtifactId

ArtifactId

dbspock-parent
Last Version

Last Version

2.3.0.RELEASE
Release Date

Release Date

Type

Type

pom
Description

Description

dbsock-parent
Expresses the data as Spockly!
Project URL

Project URL

https://github.com/yo1000/dbspock
Source Code Management

Source Code Management

https://github.com/yo1000/dbspock

Download dbspock-parent

How to add to project

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

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

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