You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-21Lines changed: 19 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,13 @@
4
4
5
5
## Overview
6
6
This project implements a Groovy DSL that can be used to populate a database using JPA entities. Its indented use is testing but it could be used in other scenarios as well.
7
-
The DSL is implemented in Groovy but can be used from pure Java. Entities are modularly defined in separate .groovy files using the DSL syntax. Those entitiy definition files can then be loaded as needed using the `de.triology.blog.testdataloader.TestDataLoader`, which also provides access to loaded entities. Thus, the client code does not need to deal with any database or JPA specific concerns other than providing an initialized EntityManager.
7
+
The DSL is implemented in Groovy but can be used from pure Java. Entities are modularly defined in separate .groovy files using the DSL syntax. Those entity definition files can then be loaded as needed using the `de.triology.blog.testdata.loader.TestDataLoader`, which also provides access to loaded entities. Thus, the client code does not need to deal with any database or JPA specific concerns other than providing an initialized EntityManager.
8
8
9
9
This project was started while working on an article published in [Java aktuell](http://www.ijug.eu/java-aktuell/das-magazin.html) 03/2017:
10
10
[A Groovy DSL for the Creation of Test Data using JPA](https://www.triology.de/en/blog-entries/groovy-dsl-test-data).
11
-
The original article (🇩🇪) can be found here: [Eine Groovy-DSL zum Erzeugen von Testdaten über JPA](https://www.triology.de/wp-content/uploads/2017/09/Eine-Groovy-DSL-zum-Erzeugen-von-Testdaten-ueber-JPA.pdf).
11
+
The original article (🇩🇪) can be found here: [Eine Groovy-DSL zum Erzeugen von Testdaten über JPA](https://www.triology.de/wp-content/uploads/2017/09/Eine-Groovy-DSL-zum-Erzeugen-von-Testdaten-ueber-JPA.pdf).
12
+
13
+
Please note that from version 1.x the implementation as described in the article referenced above has changed. For more information about the changes, please refer to the release notes of each [release](https://github.com/triologygmbh/test-data-loader/releases).
12
14
13
15
## Configuration
14
16
You can use JitPack to configure the test-data-loader as a dependency in your project.<br/>
@@ -26,22 +28,21 @@ And the test-data-loader dependency:
26
28
<dependency>
27
29
<groupId>com.github.triologygmbh</groupId>
28
30
<artifactId>test-data-loader</artifactId>
29
-
<version>0.2.1</version>
31
+
<version>${version.test-data-loader}</version>
30
32
</dependency>
31
33
```
32
34
Current version is [](https://jitpack.io/#triologygmbh/test-data-loader).<br/>
33
35
For further details and options refer to the [JitPack website](https://jitpack.io/#triologygmbh/test-data-loader).
34
36
35
37
## Usage
36
-
An example entity definition can be found here: https://github.com/triologygmbh/test-data-loader/blob/master/src/test/resources/demo/testData.groovy
38
+
An example entity definition Groovy script file can be found here: https://github.com/triologygmbh/test-data-loader/blob/master/src/test/resources/tests/itTestData.groovy
37
39
38
-
And[`de.triology.blog.testdataloader.demo.Demo`](https://github.com/triologygmbh/test-data-loader/blob/master/src/test/java/de/triology/blog/testdataloader/demo/Demo.java) shows how to load that file. (Notice that `Demo` is a Java class.)
40
+
The[`de.triology.blog.testdata.loader.TestDataLoaderIT`](https://github.com/triologygmbh/test-data-loader/blob/master/src/test/java/de/triology/blog/testdata/loader/TestDataLoaderIT.java)integration test shows how to load that file.
39
41
40
42
### Entity Definitions
41
-
Use the following syntax in a separate .groovy file to define a `User` entity. The entitiy will be created, persisted and registered under the name "Peter" when the definition file is loaded. _**Note:** Entity definition files are expected to be UTF-8 encoded._
43
+
Use the following syntax in a separate .groovy file to define a `User` entity. The entity will be created, persisted and registered under the name "Peter" when the definition file is loaded. _**Note:** Entity definition files are expected to be UTF-8 encoded._
@@ -109,8 +107,8 @@ For now, we must work around this, by setting the field to `protected` or creati
109
107
See [this issue](https://github.com/triologygmbh/test-data-loader/issues/7).
110
108
111
109
### Loading entity definitions
112
-
Use the `de.triology.blog.testdataloader.TestDataLoader` to load entitiy definition files (from classpath or file system) and persist the defined entities.
113
-
The `TestDataLoader` requires a fully initialized, ready-to-use entitiy manager and can then be used to load entity definition files and access the persisted entities.
110
+
Use the `de.triology.blog.testdata.loader.TestDataLoader` to load entity definition files (from classpath or file system) and persist the defined entities.
111
+
The `TestDataLoader` requires a fully initialized, ready-to-use `EntityManager` and can then be used to load entity definition files and access the persisted entities.
To reset the database as well as the TestDataLoader to a clean state after a test case simply call `testDataLoader.clear()`. That will delete all created entites from the database and from TestDataLoader's entity cache.
125
+
To reset the database as well as the TestDataLoader to a clean state after a test case simply call `testDataLoader.clear()`. That will delete all created entities from the database and from TestDataLoader's entity cache.
128
126
129
127
## Tested with...
130
128
@@ -135,4 +133,4 @@ We have approved TestDataLoader in multiple projects and use cases including
135
133
* Integration tests with arquillian, IBM WebSphere Liberty Profile and IBM DB2
136
134
137
135
## Contributions
138
-
The test-data-loader has been derived and generalized from real world development projects but has yet to prove itself as standalone library. **Any feedback or contributions are highly welcome!**
136
+
The test-data-loader has been derived and generalized from real world development projects but has yet to prove itself as stand-alone library. **Any feedback or contributions are highly welcome!**
0 commit comments