01: /*
02: * User: Michael Rettig
03: * Date: Aug 17, 2002
04: * Time: 3:05:39 PM
05: */
06: package net.sourceforge.jaxor.example.tests;
07:
08: import junit.textui.TestRunner;
09: import net.sourceforge.jaxor.MetaRow;
10: import net.sourceforge.jaxor.example.domain.AddressFinder;
11: import net.sourceforge.jaxor.example.domain.AddressMetaRow;
12: import net.sourceforge.jaxor.example.domain.ObjectFactory;
13:
14: public class PerfTest extends TableTestCase {
15:
16: protected MetaRow getRow() {
17: return new AddressMetaRow();
18: }
19:
20: /**
21: * This should take a couple seconds. If not, something is wrong.
22: */
23: public void testLargeInsertSet() {
24: int max = 10000;
25: for (int i = 0; i < max; i++)
26: ObjectFactory.createAddress(new Long(i));
27: commit();
28: assertEquals(max, AddressFinder.selectAll().size());
29: }
30:
31: /**
32: * Should hit the cache for pk selects, so this should be quick.
33: */
34: public void testPrimaryKeyCache() {
35: int max = 1000;
36: for (int i = 0; i < max; i++)
37: ObjectFactory.createAddress(new Long(i));
38: commit();
39: for (int i = 0; i < 100000; i++)
40: AddressFinder.selectByPrimaryKey(new Long(i % 1000));
41: }
42:
43: public static void main(String[] args) {
44: TestRunner.run(PerfTest.class);
45: }
46:
47: }
|