labs-jpatest-core

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

License

License

GroupId

GroupId

org.openengsb.labs.jpatest
ArtifactId

ArtifactId

labs-jpatest-core
Last Version

Last Version

0.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

labs-jpatest-core
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Project URL

Project URL

http://maven.apache.org

Download labs-jpatest-core

How to add to project

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

Dependencies

compile (6)

Group / Artifact Type Version
junit : junit jar 4.11
org.apache.geronimo.specs : geronimo-jpa_2.0_spec jar 1.1
org.apache.openjpa : openjpa jar 2.2.1
org.slf4j : slf4j-api jar 1.7.2
org.slf4j : slf4j-log4j12 jar 1.7.2
com.h2database : h2 jar 1.3.170

Project Modules

There are no modules declared in this project.

JPA Test Helper

The purpose of this library is to provide an out-of-the box configuration for testing code that relies on JPA. While there are many other libraries for that purpuse the specific goals of this one are:

  • test the real persistence.xml instead of a separate one just for testing (so that they don't get out of sync)
  • Fast teardown of test-database (Only records are deleted, dbs are reused)
  • Out-of-the-box memory-db config that is easy to use

Build Status

How to build

  • Install JDK 7 or higher

You can install Oracle JDK or OpenJDK depending on the OS you use. Other JVM implementations should also work, but are untested.

Be sure to follow the provided installation instructions

  • configure JAVA_HOME and PATH environment variables

make sure the JAVA_HOME environment variable points to the path of your JDK installation and that both javac and mvn are available in your PATH-variable

  • Run mvn install from the project's root directory

That's it.

How to use

With maven add this dependency to your pom.xml:

<dependency>
  <groupId>org.openengsb.labs.jpatest</groupId>
  <artifactId>jpa-test-core</artifactId>
  <scope>test</scope>
  <version>LATEST_JPATEST_VERSION</version>
</dependency>

To use EntityManagers in your junit-tests include the Rule in your tests like this:

@Rule
public final TestPersistenceUnit testPersistenceUnit = new TestPersistenceUnit();

@Test
public void myTest throws Exception {
  EntityManager em = testPersistenceUnit.getPersistenceUnit("my-persistence-unit")
  // do stuff with our em
}

Limitations

Right now the library will only work testing with OpenJPA and H2Database. While this might sound as a no go for your project consider that most of your JPA tests will tackle if your queries are correct JPA provider and database independent. So, while this might not be a 100% match it will (in many cases) still provider ways better results than going without it.

org.openengsb.labs.jpatest

OpenEngSB Labs

Versions

Version
0.3.0
0.2.0
0.1.0