You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Michelle Caisse <Mi...@Sun.COM> on 2005/09/22 01:42:02 UTC
Cleanup in models.fieldtypes.Test*.java
Hi,
I've noticed that the fieldtypes tests, all created on the same pattern,
delete the persistent instance that they create at the end of the test.
(For example,
http://svn.apache.org/viewcvs.cgi/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveboolean.java?view=markup)
Now that we use the new cleanup mechanism (addTearDownClass(Class)),
there doesn't seem to be any point to deleting the instance. Also, the
new maven option jdo.tck.cleanupaftertest cannot override this cleanup,
so you can never see the database contents for debugging. Therefore, I
think we should remove the line that deletes the persistent instance.
What about the finally block in these tests?
finally {
if ((tx != null) && tx.isActive())
tx.rollback();
}
We don't do this in our sample test
(http://wiki.apache.org/jdo/SampleTest), which is supposed to be a model
of excellence. Is it a good idea or not?
-- Michelle
Re: Cleanup in models.fieldtypes.Test*.java
Posted by Craig Russell <Cr...@Sun.COM>.
Hi,
On Sep 22, 2005, at 2:58 AM, Michael Watzek wrote:
> Hi Michelle,
>
> the query tests implement the same strategy: They call method
> 'QueryTest.cleanupDatabaseInternal' which calls
> 'pm.deletePersistent'. Thus, TCK property
> 'jdo.tck.cleanupaftertest' does not apply for those tests. We have
> to adapt them also.
Agree.
>
> The finally block below is fine.
Actually, I took the finally block out of the sample because it
duplicates code in the tearDown method in JDO_Test.
If there is only one test method in the test case, it's clearly not
needed. Where it can still be useful is in cases where even if one of
the tests fails, you still want to run the rest of the test methods
and the cleanup allows other test methods to run. But the test class
has already failed so it might not be so useful.
Craig
>
> Regards,
> Michael
>
>
>> Hi,
>> I've noticed that the fieldtypes tests, all created on the same
>> pattern, delete the persistent instance that they create at the
>> end of the test. (For example, http://svn.apache.org/viewcvs.cgi/
>> incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/
>> fieldtypes/TestFieldsOfPrimitiveboolean.java?view=markup) Now that
>> we use the new cleanup mechanism (addTearDownClass(Class)), there
>> doesn't seem to be any point to deleting the instance. Also, the
>> new maven option jdo.tck.cleanupaftertest cannot override this
>> cleanup, so you can never see the database contents for
>> debugging. Therefore, I think we should remove the line that
>> deletes the persistent instance.
>> What about the finally block in these tests?
>> finally {
>> if ((tx != null) && tx.isActive())
>> tx.rollback();
>> }
>> We don't do this in our sample test (http://wiki.apache.org/jdo/
>> SampleTest), which is supposed to be a model of excellence. Is it
>> a good idea or not?
>> -- Michelle
>>
>
>
> --
> -------------------------------------------------------------------
> Michael Watzek Tech@Spree Engineering GmbH
> mailto:mwa.tech@spree.de Buelowstr. 66
> Tel.: ++49/30/235 520 36 10783 Berlin - Germany
> Fax.: ++49/30/217 520 12 http://www.spree.de/
> -------------------------------------------------------------------
>
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!
Re: Cleanup in models.fieldtypes.Test*.java
Posted by Michael Watzek <mw...@spree.de>.
Hi Michelle,
the query tests implement the same strategy: They call method
'QueryTest.cleanupDatabaseInternal' which calls 'pm.deletePersistent'.
Thus, TCK property 'jdo.tck.cleanupaftertest' does not apply for those
tests. We have to adapt them also.
The finally block below is fine.
Regards,
Michael
> Hi,
>
> I've noticed that the fieldtypes tests, all created on the same pattern,
> delete the persistent instance that they create at the end of the test.
> (For example,
> http://svn.apache.org/viewcvs.cgi/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveboolean.java?view=markup)
> Now that we use the new cleanup mechanism (addTearDownClass(Class)),
> there doesn't seem to be any point to deleting the instance. Also, the
> new maven option jdo.tck.cleanupaftertest cannot override this cleanup,
> so you can never see the database contents for debugging. Therefore, I
> think we should remove the line that deletes the persistent instance.
>
> What about the finally block in these tests?
> finally {
> if ((tx != null) && tx.isActive())
> tx.rollback();
> }
> We don't do this in our sample test
> (http://wiki.apache.org/jdo/SampleTest), which is supposed to be a model
> of excellence. Is it a good idea or not?
>
> -- Michelle
--
-------------------------------------------------------------------
Michael Watzek Tech@Spree Engineering GmbH
mailto:mwa.tech@spree.de Buelowstr. 66
Tel.: ++49/30/235 520 36 10783 Berlin - Germany
Fax.: ++49/30/217 520 12 http://www.spree.de/
-------------------------------------------------------------------
Re: Cleanup in models.fieldtypes.Test*.java
Posted by Karan Malhi <ka...@gmail.com>.
Hi Michelle,
I agree. jdo.tck.cleanupaftertest is not effective in this case.
On 9/21/05, Michelle Caisse <Mi...@sun.com> wrote:
>
> Hi,
>
> I've noticed that the fieldtypes tests, all created on the same pattern,
> delete the persistent instance that they create at the end of the test.
> (For example,
>
> http://svn.apache.org/viewcvs.cgi/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveboolean.java?view=markup)
> Now that we use the new cleanup mechanism (addTearDownClass(Class)),
> there doesn't seem to be any point to deleting the instance. Also, the
> new maven option jdo.tck.cleanupaftertest cannot override this cleanup,
> so you can never see the database contents for debugging. Therefore, I
> think we should remove the line that deletes the persistent instance.
>
> What about the finally block in these tests?
> finally {
> if ((tx != null) && tx.isActive())
> tx.rollback();
> }
> We don't do this in our sample test
> (http://wiki.apache.org/jdo/SampleTest), which is supposed to be a model
> of excellence. Is it a good idea or not?
>
> -- Michelle
>
--
Karan Malhi