labs-jpatest-sample2

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-sample2
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

labs-jpatest-sample2
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-sample2

How to add to project

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

Dependencies

compile (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.apache.geronimo.specs : geronimo-jpa_2.0_spec jar 1.1

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.1.0