db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig Russell <Craig.Russ...@Sun.COM>
Subject Re: Writing TestCase for Sequence Assertions
Date Thu, 15 Sep 2005 05:05:26 GMT

I've highlighted some questions below. Can anyone who has implemented  
sequences answer them?

Hi Karan,

On Sep 14, 2005, at 6:33 PM, karan malhi wrote:

> I am trying to follow Michelle's instructions and writing a test  
> case for Sequence Assertions. I have the following question:
> 1. What package should i put my Test Case in?

The first question is whether the test cases are their own group or  
fall into another category. Since you obtain a Sequence via  
pm.getSequence, you might argue the tests belong in  
org.apache.jdo.tck.api.persistencemanager. But most of the assertions  
regard the behavior of the sequence itself, which argues for  
org.apache.jdo.tck.api.sequence as the package. But how many  
independent test cases are there? If only a few, it might be just one  
test case in which case the api.persistencemanager package  
TestSequence.java would suffice.

> 2. Which .jdo file should i add the <sequence> element to?

Probably it belongs in the standard .orm files (mapping=0) for  
datastore sequences, and in the .jdo file for factory sequences.

> 3. I have specified my own .conf file, below are the contents of  
> that file:
> -------aaa.conf------------------------------------------
> jdo.tck.description = Run one test for debugging
> jdo.tck.testdata =
> jdo.tck.standarddata =
> jdo.tck.mapping = 0
> jdo.tck.classes = org.apache.jdo.tck.api.persistencemanager.Test #  
> Change the name of the class once the Test Case runs successfully
> --------------------------------------------------------------------
> As you can see from above, i was trying to run the Test Case so i  
> temporarily made a Test Case named "Test" and put it in package  
> org.apache.jdo.tck.api.persistencemanager. Then i  inserted the  
> <sequence> element in
> /test/applicationidentity/jdo/org/apache/jdo/tck/pc/company/ 
> package.jdo.

This probably belongs in the .orm file unless you are defining a  
factory sequence that you have implemented.

*** For factory sequences (not defined in the database) is the API  
sufficient to use the sequence in the three modes: nontransactional,  
contiguous, and noncontiguous? ***
>        <sequence name="TestSequence" datastore-sequence="TEST_SEQ"  
> strategy="contiguous"/>

This needs to be contained in a package element, presumably package  
name="org.apache.jdo.tck.pc.company". But you have named a datastore  
sequence, TEST_SEQ, that has to exist in the database. You need to  
define it in the schema file.

*** Does Derby support sequences? ***
> --------------Below is my test() method.---------------------
>   public void test() {
>        pm = getPM();
>        Transaction tx = pm.currentTransaction();
>        tx.begin();
>        Sequence seq = pm.getSequence 
> ("org.apache.jdo.tck.pc.company.TestSequence");
> //
> //            fail(ASSERTION_FAILED,
> //                     "Expected a sequence named  
> org.apache.jdo.tck.pc.company.ProductSequence but got null instead");
> //
>        tx.commit();
>        pm.close();
>        pm = null;
>        }
> ---------------------------------------------------------------
> When i run the test i get  the following error (I know i am testing  
> for this error if sequence not found, i just want to make sure i am  
> doing stuff properly):
>   [java] 1) test(org.apache.jdo.tck.api.persistencemanager.Test) 
> javax.jdo.JDOUserException: The requested sequence  
> "org.apache.jdo.tck.pc.company.ProductSequence" could not be found.  
> Please mak
> sure that it is specified in a valid Meta-Data file.

Maybe this is due to not putting the sequence inside a package  
element? Or because the TEST_SEQ database sequence is not defined?

>   [java]      at org.jpox.AbstractPersistenceManager.getSequence 
> (AbstractPersistenceManager.java:3133)
>   [java]      at org.apache.jdo.tck.api.persistencemanager.Test.test 
> (Test.java:65)
>   [java]      at sun.reflect.NativeMethodAccessorImpl.invoke0 
> (Native Method)
>   [java]      at sun.reflect.NativeMethodAccessorImpl.invoke 
> (NativeMethodAccessorImpl.java:39)
>   [java]      at sun.reflect.DelegatingMethodAccessorImpl.invoke 
> (DelegatingMethodAccessorImpl.java:25)
>   [java]      at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java: 
> 204)
>   [java]      at org.apache.jdo.tck.util.BatchTestRunner.start 
> (BatchTestRunner.java:115)
> Michelle: One issue here is that your instructions say that i  
> should invoke maven -Djdo.tck.cfglist=aaa.conf installSchema first.  
> If i do that with a mapping of jdo.tck.mapping=0, then it takes a  
> long time to install the schema.

You only need to do that if you change the schema file. Once defined,  
you don't do it again until you add more schema.

> Do we really need to installSchema everytime for the value 0. In my  
> case, i am simply trying to test pm.getSequence 
> ("org.apache.jdo.tck.pc.company.TestSequence"), can i simply put a  
> jdo.tck.mapping = 1 instead?
> An early response would be appreciated

I've copied the expert group who might be able to help with some of  
your questions.

> -- 
> Karan Singh

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!

View raw message