You can provide a map to 
javax.persistence.Persistence#createEntityManagerFactory(String pu, Map 
properties);
That way you can define the Driver, jdbc user + pwc, url, etc

That way you don't need anything in your persistence.xml.

If you use CDI you can create a producer for it or use the one from DeltaSpike.
Or you use TomEE where you can do the same. You can pass a property map to 
DeltaSpike CdiCtrl boot(Map):
https://github.com/apache/deltaspike/blob/master/deltaspike/cdictrl/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainer.java#L58

LieGrue,
strub

> Am 13.02.2019 um 17:10 schrieb Francesco Chicchiriccò <ilgro...@apache.org>:
> 
> On 13/02/19 15:04, Matthew Broadhead wrote:
>> i am trying to test some business logic that depends heavily on the results 
>> of calls to entitymanager.  i would like to keep the persistence.xml exactly 
>> as it is in the main project but basically load in a different database 
>> underneath.  is there a way to initialise the entitymanager and point it to 
>> a development database for the duration of the tests?
> 
> Hi Matthew,
> I normally do as you require above, but with some Spring ORM support, not 
> sure it fits with your scenario; if so, I can point you to some working 
> samples.
> 
> Regards.
> 
> -- 
> Francesco Chicchiriccò
> 
> Tirasa - Open Source Excellence
> http://www.tirasa.net/
> 
> Member at The Apache Software Foundation
> Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
> http://home.apache.org/~ilgrosso/
> 

Reply via email to