Reputation: 49097
I am using a standard Maven project and I have one persistence.xml in the java resources folder and another persistence.xml in the test folder. How can I use the persistence.xml from the test folder in the arquillian test? Or isn't that a normal thing to do?
Upvotes: 3
Views: 3723
Reputation: 4934
It should also be possible to add it like this:
.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
Upvotes: 2
Reputation: 76719
How can I use the persistence.xml from the test folder in the arquillian test?
You can construct a ShrinkWrap deployment for your test that packages the persistence.xml file of your test resources, instead of the main resource. You may reference it as such, in your @Deployment method:
addAsManifestResource("persistence.xml", new File("src/test/resources/persistence.xml"))
Or isn't that a normal thing to do?
Its an acceptable thing to do. But, with the Arquillian Persistence Extension, you should be able to use the persistence.xml file of your main resource, since the persistence unit will be managed by the container and the underlying datasource would be available to the JPA provider at runtime.
Using a test-only persistence.xml is usually done for instances where you want a persistence unit of transaction type RESOURCE_LOCAL instead of JTA, to enable testing of the persistence-unit outside the container.
Upvotes: 3
Reputation: 3691
there is a line in your code where you define what persistence file you are using. find it (using C-f on most platforms) and change it.
Upvotes: 1