tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Gallimore <jonathan.gallim...@gmail.com>
Subject Re: How to examine database when testing entity beans?
Date Tue, 26 May 2009 19:49:23 GMT
Hi Siegfried,

This test uses a HSQLDB in-memory database running embedded in the JVM, so
(as far as I'm aware) you can't connect to it with a client.

You could however, run an instance of HSQLDB as a server, and you can hook
up SQuirreL to that:

You can run the server from the console by running:

java -cp lib/hsqldb-1.8.0.7.jar org.hsqldb.Server -database.0 file:movies
-dbname.0 movies

And then change the properties at the top of the test to look like this:

        Properties p = new Properties();
        p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
        p.put("movieDatabase", "new://Resource?type=DataSource");
        p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
        p.put("movieDatabase.JdbcUrl",
"jdbc:hsqldb:hsql://localhost/movies");

        p.put("movieDatabaseUnmanaged", "new://Resource?type=DataSource");
        p.put("movieDatabaseUnmanaged.JdbcDriver", "org.hsqldb.jdbcDriver");
        p.put("movieDatabaseUnmanaged.JdbcUrl",
"jdbc:hsqldb:hsql://localhost/movies");
        p.put("movieDatabaseUnmanaged.JtaManaged", "false");

You'll then be able to connect to the database using this JDBC URL:
jdbc:hsqldb:hsql://localhost/movies

Hope that helps.

Jon

On Tue, May 26, 2009 at 9:07 AM, siegfried <siegfried@heintze.com> wrote:

> I'm studying
>
> c:\dev\sandboxes\EJB\openejb\examples\apache\openejb-examples-3.1\simple-cmp
> 2\src\test\java\org\superbiz\cmp2\MoviesTest.java
>
>
> Who is cleaning up the database? I thought it was using dbunit was doing it
> but I see MoviesTest.java is deleting it. Hmmmm.... Could this example have
> been done more efficiently with dbunit?
>
> How can I pause the execution of the test so I can see the data in the HSQL
> database using a client like squirrel to look at the data?
>
> Thanks,
> Siegfried
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message