|
Mantis - Resin
|
|||||
| Viewing Issue Advanced Details | |||||
|
|
|||||
| ID: | Category: | Severity: | Reproducibility: | Date Submitted: | Last Update: |
| 4163 | feature | always | 08-04-10 16:24 | 10-04-11 10:38 | |
|
|
|||||
| Reporter: | reza | Platform: | |||
| Assigned To: | ferg | OS: | |||
| Priority: | normal | OS Version: | |||
| Status: | closed | Product Version: | 4.0.10 | ||
| Product Build: | Resolution: | no change required | |||
| Projection: | none | ||||
| ETA: | none | Fixed in Version: | |||
|
|
|||||
| Summary: | 0004163: Add the ability to specify alternative persistence.xml in ResinBeanContainerRunner | ||||
| Description: |
It should be possible to specify alternative persistence.xml files per unit test like this: @RunWith(ResinBeanContainerRunner.class) @ResinBeanConfiguration(beansXml = { "classpath:META-INF/beans.xml", "classpath:beans-test.xml" } persistenceXml = { "classpath:META-INF/persistence-test.xml" }) public class AccountServiceTest { @Inject private AccountService accountService; @Test public void testAddAccount() { Account account = new Account(); account.setNumber("1111"); account.setCustomer("NRahman"); account.setBalance(1000.00); accountService.addAccount(account); } @Test public void testGetAccount() { Account account = accountService.getAccount("NRahman"); assertNotNull(account); } @Test public void testUpdateAccount() { Account account = accountService.getAccount("NRahman"); account.setBalance(1001.50); accountService.updateAccount(account); } @Test public void testDeleteAccount() { Account account = accountService.getAccount("NRahman"); accountService.deleteAccount(account); } @Test public void testTransfer() { accountService.transfer("MegaBank", "3434", "AcmeBank", "1111", 100.00); } } The alternative persistence.xml would enable different data sources, logging levels, provider configuration and so on. This could be an example alternative persistence.xml: <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" [^] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" [^] xsi:schemaLocation="http://java.sun.com/xml/ns/persistence [^] http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> [^] <persistence-unit name="acme-bank-db" transaction-type="JTA"> <jta-data-source>jdbc/AcmeBankTestDB</jta-data-source> <validation-mode>AUTO</validation-mode> <properties> <property name="eclipselink.ddl-generation" value="drop-create-tables" /> <property name="eclipselink.logging.level" value="FINEST" /> </properties> </persistence-unit> </persistence> While the production version would look like this: <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" [^] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" [^] xsi:schemaLocation="http://java.sun.com/xml/ns/persistence [^] http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> [^] <persistence-unit name="acme-bank-db" transaction-type="JTA"> <jta-data-source>jdbc/AcmeBankDB</jta-data-source> <validation-mode>AUTO</validation-mode> <properties> <property name="eclipselink.logging.level" value="WARNING" /> </properties> </persistence-unit> </persistence> |
||||
| Steps To Reproduce: | |||||
| Additional Information: | |||||
| Relationships | |||||
| Attached Files: | |||||
| There are no notes attached to this issue. |