Just in case people are unsure how much research has gone in, here are similar references (unresolved directly for dbunit usage):
http://old.nabble.com/Externalize-db-access-data-for-junit-testing-td18940819.html#a18968443 http://old.nabble.com/How-to-examine-database-when-testing-entity-beans--td23718486.html#a23718486 http://old.nabble.com/Nuking-tables-on-tearDown()-for-CRUD-tests-td14655064.html#a14703735 http://old.nabble.com/Unit-testing-code-containing-DirContext-resource-injection-td24101774.html#a24107795 http://old.nabble.com/Local-testing%3A-programmatic-reinitialization-of-container-supplied--EMF--td24961501.html#a24961501 https://blogs.apache.org/openejb/entry/user_blog_restarting_the_embedded (dead link) http://openejb.apache.org/faq.html http://nasvel.wordpress.com/2008/06/18/unit-test-ejb3/ http://markmail.org/message/jtsazyhehbnfs6jf (explicitly defines a new database connection that may or may not be different than the datasource used for openejb). The most common answer I've seen from examples has been a re-definition of the datasource for use with dbunit, opposed to re-using the existing openejb datasource. Is there a way to re-use the existing openejb datasource for use with dbunit? -D dhartfrd wrote: > > I'm trying to use openejb for unit testing with dbunit, but having some > issues making it 'easy/clean' -- > > private Context ctx; > private String datasourceName = "jdbc/MyDS"; > > public void setUp() throws Exception { > Properties props = new Properties(); > props.setProperty(Context.INITIAL_CONTEXT_FACTORY, > "org.apache.openejb.client.LocalInitialContextFactory"); > props.put(datasourceName, "new://Resource?type=DataSource"); > props.put(datasourceName + ".JtaManaged", "false"); > props.put(datasourceName + ".JdbcDriver", "org.h2.Driver"); > props.put(datasourceName + ".JdbcUrl","jdbc:h2:mem:testdb"); > ctx = new InitialContext(props); > > IDatabaseConnection connection = new > DatabaseDataSourceConnection((InitialContext) ctx, datasourceName); > > } > > Unfortunately, when it tries to get the datasource connection for dbunit > it throws NameNotFound exceptions. > > Is there an elegant way to resolve this? > > openejb 3.1.1, dbunit 2.4.6 > > Thanks! > -D > -- View this message in context: http://old.nabble.com/dbunit-usage-tp26713592p26727585.html Sent from the OpenEJB User mailing list archive at Nabble.com.
