jixture :: hibernate3

jixture - fixture loader

Лицензия

Лицензия

Категории

Категории

Сеть Hibernate Данные ORM
Группа

Группа

net.cpollet.jixture
Идентификатор

Идентификатор

jixture-hibernate3
Последняя версия

Последняя версия

1.0.0.rc1
Дата

Дата

Тип

Тип

jar
Описание

Описание

jixture :: hibernate3
jixture - fixture loader
Система контроля версий

Система контроля версий

https://github.com/cpollet/jixture

Скачать jixture-hibernate3

Как подключить последнюю версию

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

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
net.cpollet.jixture : jixture-core jar 1.0.0.rc2
org.slf4j : slf4j-api jar 1.6.1

provided (4)

Идентификатор библиотеки Тип Версия
org.springframework : spring-context jar 3.0.0.RELEASE
org.springframework : spring-orm jar 3.0.0.RELEASE
org.hibernate : hibernate-core jar 3.5.0-Final
org.hibernate.javax.persistence : hibernate-jpa-2.0-api jar 1.0.0.Final

runtime (2)

Идентификатор библиотеки Тип Версия
org.slf4j : jcl-over-slf4j Необязательный jar 1.7.7
ch.qos.logback : logback-classic Необязательный jar 1.1.2

test (2)

Идентификатор библиотеки Тип Версия
net.cpollet.jixture : jixture-test-support jar 1.0.0.rc2
com.h2database : h2 jar 1.3.174

Модули Проекта

Данный проект не имеет модулей.

# 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>

Версии библиотеки

Версия
1.0.0.rc1