jixture :: core

jixture - fixture loader

License

License

Categories

Categories

Net
GroupId

GroupId

net.cpollet.jixture
ArtifactId

ArtifactId

jixture-core
Last Version

Last Version

1.0.0.rc3
Release Date

Release Date

Type

Type

jar
Description

Description

jixture :: core
jixture - fixture loader
Source Code Management

Source Code Management

https://github.com/cpollet/jixture

Download jixture-core

How to add to project

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

Dependencies

compile (6)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.6.1
commons-beanutils : commons-beanutils Optional jar 1.9.2
uk.com.robust-it : cloning Optional jar 1.9.0
joda-time : joda-time Optional jar 2.3
org.hamcrest : hamcrest-core Optional jar 1.3
org.apache.poi : poi-ooxml Optional jar 3.9

provided (2)

Group / Artifact Type Version
org.springframework : spring-context jar 3.0.0.RELEASE
org.springframework : spring-orm jar 3.0.0.RELEASE

runtime (2)

Group / Artifact Type Version
org.slf4j : jcl-over-slf4j Optional jar 1.7.7
ch.qos.logback : logback-classic Optional jar 1.1.2

test (2)

Group / Artifact Type Version
net.cpollet.jixture : jixture-test-support jar 1.0.0.rc2
com.h2database : h2 jar 1.3.174

Project Modules

There are no modules declared in this project.

# jixture

Build Status Maven Central Coverage Status

jixture is an open source (Apache 2 licensed) spring/hibernate based java fixtures loading framework.

It can load data from varous sources, such as:

  • DbUnit-like XML files (but without the DTD);
  • Plain SQL files;
  • Entities instances build from code, Spring context or generated automatically;
  • Excel files (both XLS and XLSX).

Is is possible to write you own loader as well to load, for instance, CSV or other formats.

Resources

Maven commands.

Sample

A full sample using jixture-hibernate3 is available under sample/hibernate3.

Loading XML file

First, we need to det an instance of a DatabaseTestSupport. The following Soring context will do the trick. It only supposes that you have

<!-- import jixture context -->
<alias name="transactionManager" alias="jixture.core.transactionManager"/>
<import resource="classpath:/spring/jixture-core-context.xml"/>

<!-- create test support bean -->
<bean id="commitDatabaseTestSupport" class="net.cpollet.jixture.support.CommitDatabaseTestSupport" />

This creates an instance of CommitDatabaseTestSupport that you can use to load data:

commitDatabaseTestSupport
	.addFixtures(new XmlFileFixture("/path/to/file.xml")) //
	.loadFixtures();

Dependencies

You must provide at least the following dependencies to use jixture-core:

<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-context</artifactId>
	<version>3.0.0.RELEASE</version>
</dependency>
<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-orm</artifactId>
	<version>3.0.0.RELEASE</version>
</dependency>

If you plan using jixture-hibernate3 (which brings jixture-core), you have to provide the following dependencies as well:

<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-core</artifactId>
	<version>3.5.0-Final</version>
</dependency>
<dependency>
	<groupId>org.hibernate.javax.persistence</groupId>
	<artifactId>hibernate-jpa-2.0-api</artifactId>
	<version>1.0.0.Final</version>
</dependency>

Some other dependencies are optional. Keep reading to know when they are needed.

TemplateGenerator

If you want to the the TemplateGenerator as an entity generator for an GeneratedFixture, you have to include following libs:

For instance:

SomeModel template = new SomeModel().setAttribute(value);
TemplateGenerator fixture = GeneratedFixture.from(template);

Requies Maven dependencies:

<dependency>
	<groupId>commons-beanutils</groupId>
	<artifactId>commons-beanutils</artifactId>
	<version>1.9.2</version>
</dependency>
<dependency>
	<groupId>uk.com.robust-it</groupId>
	<artifactId>cloning</artifactId>
	<version>1.9.0</version>
</dependency>

DateSequence

If you want to use a DateSequence field generator inside an TemplateGenerator fixture generator, you have to include Joda-Time in your dependencies.

For instance:

DateTime start;
DateTime stop;

SomeModel template = new SomeModel().setAttribute(value);

Fixture fixture = GeneratedFixture.from(template)
	.addFieldGenerator("insertionDate", FieldGenerators.sequence(start, stop));

Requires Maven dependency:

<dependency>
	<groupId>joda-time</groupId>
	<artifactId>joda-time</artifactId>
	<version>2.3</version>
</dependency>

XlsFileFixture and XlsxFileFixture

If you want to load fixtures from Excel files, you have to include Apache POI in your dependencies.

For XLSX, you need:

<dependency>
	<groupId>org.apache.poi</groupId>
	<artifactId>poi-ooxml</artifactId>
	<version>3.9</version>
</dependency>

For XLS, you need:

<dependency>
	<groupId>org.apache.poi</groupId>
	<artifactId>poi</artifactId>
	<version>3.9</version>
</dependency>

ExtractorMatcher

If you want to be able to extract entities from fixtures implenting ExtractionCapableFixture (such as GeneratedFixture or MappingFixture), you have to include hamcrest in your dependencies.

hamcrest is required when you want to use the in fixtures implenting .

For instance:

Matcher someHamcrestMarcher;

MappingFixture fixture = new MappingFixture(entity1, entity2)
	.addExtractorMatcher(ExtractionMatcher.create(someHamcrestMatcher));

Requires Maven dependency:

<dependency>
	<groupId>org.hamcrest</groupId>
	<artifactId>hamcrest-core</artifactId>
	<version>1.3</version>
</dependency>

Versions

Version
1.0.0.rc3
1.0.0.rc2
1.0.0.rc1