|
Home > Archive > Apache JDO Project > September 2005 > Writing TestCase for Sequence Assertions
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Writing TestCase for Sequence Assertions
|
|
| karan malhi 2005-09-14, 8:45 pm |
| 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?
2. Which .jdo file should i add the <sequence> element to?
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.
<sequence name="TestSequence" datastore-sequence="TEST_SEQ"
strategy="contiguous"/>
--------------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.
[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. 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
--
Karan Singh
| |
| Craig Russell 2005-09-15, 2:45 am |
| | |
| Andy Jefferson 2005-09-15, 7:45 am |
| > *** For factory sequences (not defined in the database) is the API
> sufficient to use the sequence in the three modes: nontransactional,
> contiguous, and noncontiguous? ***
Well, the implementation has to call factory.newInstance() to create the
sequence, but has no way of telling the factory whether it wants a
contiguous, noncontiguous, or nontransactional sequence.
Really depends whether the users sequence that is created by the factory will
typically be able to operate in all 3 strategies. I would guess that most
sequences would support one of the 3 strategies, so by saying that they want
to use a particular factory, then they are implicitly electing the strategy
that will be used.
If it is really necessary to allow a factory to create a sequence in any of
the 3 strategies then we could add a requirement on the factory of having a
static newInstance(int strategy) method, and the "strategy" value specified
in the metadata could be passed in. If the metadata has no value for strategy
then the newInstance() method is called.
> *** Does Derby support sequences? ***
No.
DB2, PostgreSQL, Oracle, Firebird, SAPDB, McKoi and maybe some others do.
The JDO impl can clearly generate a sequence using other means where there is
no native RDBMS support.
--
Andy
| |
| Michelle Caisse 2005-09-15, 5:45 pm |
| Hi Karan,
I have added a bit more information to the How To... section of
http://wiki.apache.org/jdo/TechnologyCompatibilityKit. I hope it helps
address some of the general issues you encountered.
-- Michelle
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?
> 2. Which .jdo file should i add the <sequence> element to?
> 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.
>
> <sequence name="TestSequence" datastore-sequence="TEST_SEQ"
> strategy="contiguous"/>
>
> --------------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.
> [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. 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
>
|
|
|
|
|