Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would suggest placing a file named <code>jndi.properties</code> in <code>src/test/resources</code> for your OpenEJB configuration. This will then be available in the test classpath, you can then use the no-argument contructor of InitialContext to lookup datasources and ejbs. An example configuration looks like this, I'm using mysql for my datasource:</p> <pre><code>java.naming.factory.initial=org.apache.openejb.client.LocalInitialContextFactory myDS=new://Resource?type=DataSource myDS.JdbcDriver=com.mysql.jdbc.Driver myDS.JdbcUrl=jdbc:mysql://127.0.0.1:3306/test myDS.JtaManaged=true myDS.DefaultAutoCommit=false myDS.UserName=root myDS.Password=root </code></pre> <p>OpenEJB should then automatically replace the reference in persistence.xml with this datasource, if this is the only datasource then this should work even if the names are different.</p> <p><strong>Edit:</strong> Persistence unit settings</p> <p>According to the <a href="http://openejb.apache.org/3.0/configuring-persistenceunits-in-tests.html" rel="noreferrer">documentation you referenced</a> it should also be possible to configure persistence unit properties through jndi.properties:</p> <pre><code>abc.hibernate.hbm2ddl.auto=update abc.hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect </code></pre> <p>I haven't tested this myself since I'm using mysql for both tests and normal executions, only with different database names. Please let me know if this works, I've been thinking about replacing mysql in my testcases too.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload