openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dick <michael.d.d...@gmail.com>
Subject Re: How to run database specific test
Date Tue, 31 Mar 2009 20:00:03 GMT
I've always viewed the @DatabasePlatform annotation as a way to test
something very specific to the database, say something that takes advantage
of the various DB2 specific locks. It shouldn't be used to limit the
testcase to only the platforms that happen to work at this moment.

That being said it's great for database specific tests like the Oracle
sequence issue.

-mike

On Tue, Mar 31, 2009 at 10:59 AM, Pinaki Poddar <ppoddar@apache.org> wrote:

>
> Hi,
>  If you are running the tests with OpenJPA test harness, then you may
> consider annotating the test case with the following:
> // Specifies that the test runs only if the driver is available in the
> execution classpath
> @DatabasePlatform("org.apache.derby.jdbc.EmbeddedDriver")
>
> The annotation is recognized by OpenJPA test harness and few examples can
> be found in org.apache.openjpa.persistence.jdbc.oracle.TestAutoIncrement
>
>
> package org.apache.openjpa.persistence.test;
>
> /**
>  * Annotates a test to run only if the specified driver classes are
> available in
>  * the current classpath.
>  *
>  * Specify comma-separated list of fully-qualified JDBC driver class names.
>  *
>  * @author Pinaki Poddar
>  *
>  */
> @Target({TYPE})
> @Retention(RUNTIME)
> public @interface DatabasePlatform {
>    String value();
> }
>
>
> Thanks a lot, Michael.So basically we manually run the cases for specific
> database in local environment right?
>
>
> Thanks,
> Amy
> 2009/3/31 Michael Dick <michael.d.dick@gmail.com>
>
> > Hi Amy,
> >
> > There are a few options. You could create a separate persistence-unit for
> > your database and specify the connection information in the persistence
> > unit
> > (this is better for embeddable dbs like Derby). If it's not something you
> > can assume other devs have you'll probably want to go with another route.
> >
> > The junit test suite picks up the database configuration from jvm
> arguments
> > that you pass in on the command line or through a maven profile. To use
> one
> > of the built in profiles you could do something like this :
> > $ mvn -Ptest-derby -Dtest=${specific testcase name} test
> > $ mvn -Ptest-mysql -Dtest=${specific testcase name} test
> >
> > Insert the testcase name for ${specific testcase name} and these examples
> > will run one specific test against derby or mysql respectively. Note that
> > you'll need to set a few other properties to indicate the location of
> your
> > mysql database, but it should get you started.
> >
> > If we don't have a built in profile (check
> openjpa-persistence-jdbc/pom.xml
> > for the list) then you'll have to create one or set the properties
> > manually.
> > For example (using oracle)  :
> > mvn test -Dtest=TestPersistence -Ptest-custom
> >
> > -Dopenjpa.custom.driverjar=$(pwd)/drivers/jdbc-oracle-10_2_0_1_0.jar
> >          -Dopenjpa.custom.driverclass=oracle.jdbc.driver.OracleDriver
> >          -Dopenjpa.custom.url=jdbc:oracle:thin:@HOST:PORT:DBNAME
> >          -Dopenjpa.custom.username=USERNAME
> >          -Dopenjpa.custom.password=PASSWORD
> >
> > The example runs the TestPersistence testcase against whatever database
> you
> > indicate in the openjpa-custom.xxx properties.
> >
> > Hope this helps,
> > -mike
> >
> >
> >
> > On Mon, Mar 30, 2009 at 8:20 PM, Amy Yang <milotty@gmail.com> wrote:
> >
> > > Hi All,I found a Database specific problem recently.
> > > To run test for the fix, I think it would be good to run our test cases
> > on
> > > a
> > > specific Database.
> > > Does anyone know if Oracle is available in Teamcity? Is it possible to
> > > target one test of the entire run to a specific database?
> > >
> > >
> > > Thanks,
> > > Amy
> > >
> >
>
>
>
>
> -----
> Pinaki Poddar                      http://ppoddar.blogspot.com/
>
> http://www.linkedin.com/in/pinakipoddar
> OpenJPA PMC Member/Committer
> JPA Expert Group Member
> --
> View this message in context:
> http://n2.nabble.com/How-to-run-database-specific-test-tp2560633p2563834.html
> Sent from the OpenJPA Developers mailing list archive at Nabble.com.
>
>

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