01: /*
02: * User: Michael Rettig
03: * Date: Sep 7, 2002
04: * Time: 12:49:02 PM
05: */
06: package net.sourceforge.jaxor.example.tests;
07:
08: import net.sourceforge.jaxor.example.domain.ObjectFactory;
09: import net.sourceforge.jaxor.example.simple.*;
10:
11: import java.util.ArrayList;
12: import java.util.List;
13:
14: public class ClassTableInheritanceTest extends MultiTableTestCase {
15:
16: protected List getRows() {
17: List all = new ArrayList();
18: all.add(new PlayerMetaRow());
19: all.add(new FootballerMetaRow());
20: all.add(new CricketerMetaRow());
21: all.add(new PlayerLookupMetaRow());
22: return all;
23: }
24:
25: public void testInheritance() {
26: FootballerEntity ent = FootballerFinder
27: .newInstance(new Long(1));
28: ent.setClub("club");
29: ent.setName("name");
30: ent.setTypeCode(FootballerBase.CODE);
31: commit();
32: PlayerEntity player = PlayerFinder.selectByPrimaryKey(new Long(
33: 1));
34: assertTrue(player.getPlayerImpl() instanceof FootballerEntity);
35: assertEquals("name", player.getName());
36: FootballerEntity footballer = FootballerFinder
37: .selectByPrimaryKey(new Long(1));
38: assertEquals("club", footballer.getClub());
39: assertEquals("name", footballer.getName());
40: }
41:
42: public void testConcreteInheritance() {
43: ObjectFactory.createCricketer(new Long(1));
44: commit();
45: Player player = CricketerFinder.selectByPrimaryKey(new Long(1));
46: assertTrue(player instanceof CricketerEntity);
47: assertEquals("name", player.getName());
48: player = PlayerLookupFinder.selectByPrimaryKey(new Long(1))
49: .getPlayer();
50: assertTrue((player instanceof CricketerEntity));
51: assertEquals("name", player.getName());
52: }
53:
54: }
|