DbUnit SQL

SQL dataset support for "DbUnit" and "spring-test-dbunit"

License

License

GroupId

GroupId

fr.pinguet62
ArtifactId

ArtifactId

dbunit-sql
Last Version

Last Version

2.0
Release Date

Release Date

Type

Type

jar
Description

Description

DbUnit SQL
SQL dataset support for "DbUnit" and "spring-test-dbunit"
Project URL

Project URL

https://github.com/pinguet62/dbunit-sql
Source Code Management

Source Code Management

https://github.com/pinguet62/dbunit-sql

Download dbunit-sql

How to add to project

<!-- https://jarcasting.com/artifacts/fr.pinguet62/dbunit-sql/ -->
<dependency>
    <groupId>fr.pinguet62</groupId>
    <artifactId>dbunit-sql</artifactId>
    <version>2.0</version>
</dependency>
// https://jarcasting.com/artifacts/fr.pinguet62/dbunit-sql/
implementation 'fr.pinguet62:dbunit-sql:2.0'
// https://jarcasting.com/artifacts/fr.pinguet62/dbunit-sql/
implementation ("fr.pinguet62:dbunit-sql:2.0")
'fr.pinguet62:dbunit-sql:jar:2.0'
<dependency org="fr.pinguet62" name="dbunit-sql" rev="2.0">
  <artifact name="dbunit-sql" type="jar" />
</dependency>
@Grapes(
@Grab(group='fr.pinguet62', module='dbunit-sql', version='2.0')
)
libraryDependencies += "fr.pinguet62" % "dbunit-sql" % "2.0"
[fr.pinguet62/dbunit-sql "2.0"]

Dependencies

compile (2)

Group / Artifact Type Version
commons-io : commons-io jar 2.8.0
com.github.jsqlparser : jsqlparser jar 3.2

provided (3)

Group / Artifact Type Version
org.dbunit : dbunit jar 2.7.0
com.github.springtestdbunit : spring-test-dbunit jar 1.3.0
org.springframework : spring-beans jar 5.3.1

test (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 2.4.0
org.springframework.boot : spring-boot-starter-jdbc jar 2.4.0
org.hsqldb : hsqldb jar 2.5.1

Project Modules

There are no modules declared in this project.

DbUnit SQL

Maintained

Libraries.io dependency status for GitHub repo Snyk Vulnerabilities for GitHub Repo

Codacy Badge codecov

GitHub Actions

Maven Central Javadocs

SQL dataset support for DbUnit and spring-test-dbunit extension for Spring test.

Description

Are equivalents:

  • SQL dataset:

     insert into profile (id, key) values ('1st', 'first');
     insert into user (id, email, profile_id) values (1, '[email protected]', '1st');
  • XML dataset:

     <dataset>
     	<profile id="1st" key="first">
     	<user id="1" email="[email protected]" profile_id="1st">
     </dataset>

Dependencies

To use SQL support, add this dependency to your pom.xml:

<dependency>
	<groupId>fr.pinguet62</groupId>
	<artifactId>dbunit-sql</artifactId>
	<version>...</version>
</dependency>

It's necessary to add DbUnit and/or spring-test-dbunit dependencies, because this project use provided scope.

Usage

DbUnit (native)

From Getting Started:

// [...]
import fr.pinguet62.dbunit.sql.ext.SqlDataSet;

public class SqlTest extends DBTestCase {
	// [...]

	@Override
	protected IDataSet getDataSet() throws Exception {
		return new SqlDataSet(getClass().getResourceAsStream("/dataset.sql"));
		// return new SqlDataSet(getClass().getResourceAsStream("insert into profile (id, key) values ('1st', 'first');"));
	}
}

spring-test-dbunit (extension)

// [...]
import fr.pinguet62.dbunit.sql.springtest.SqlDataSetLoader;

// [...]
@TestExecutionListeners({ /*...,*/ TransactionDbUnitTestExecutionListener.class })
@DbUnitConfiguration(dataSetLoader = SqlDataSetLoader.class)
@DatabaseSetup("/dataset.sql")
public class SqlTest {
	// [...]
}

Versions

Version
2.0
1.1
1.0