1 package org.apache.maven.hibernate;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import junit.framework.TestCase;
21
22 /**
23 * Test cases for the {@link HibernateEntityResolver}. Based heavily
24 * on J2EEEntityResolver.
25 *
26 * @author <a href="mailto:epugh@opnesourceconnections.com">Eric Pugh</a>
27 * @version $Id: HibernateEntityResolverTest.java 170200 2005-05-15 06:24:19Z brett $
28 */
29 public class HibernateEntityResolverTest extends TestCase
30 {
31
32 /** instance for unit testing */
33 private HibernateEntityResolver instance;
34 /**
35 * Creates a new instance of J2EEEntityResolverTest
36 * @param testName the name of the test
37 */
38 public HibernateEntityResolverTest(String testName)
39 {
40 super(testName);
41 }
42
43 /**
44 * Initialize per test data
45 * @throws Exception when there is an unexpected problem
46 */
47 public void setUp() throws Exception
48 {
49 instance = new HibernateEntityResolver();
50 }
51
52 /**
53 * Test that all public ids are available and being found
54 */
55 public void testAllAvailable()
56 {
57 assertNotNull("id to resource map not available", instance.getIdToResource());
58 int numDTDs = HibernateEntityResolver.HIBERNATE_DTDS.length;
59 assertEquals("wrong number of entries", numDTDs, instance.getIdToResource().size());
60 for (int i = 0; i < numDTDs; i++)
61 {
62 assertNotNull("Can't find resource for publicId",
63 instance.getIdToResource().get(HibernateEntityResolver.HIBERNATE_DTDS[i]));
64 }
65 }
66
67 /**
68 * Test that the resolver is getting resources locally
69 */
70 public void testResolvingLocally() throws Exception
71 {
72 int numDTDs = HibernateEntityResolver.HIBERNATE_DTDS.length;
73 for (int i = 0; i < numDTDs; i++)
74 {
75 String publicId = HibernateEntityResolver.HIBERNATE_DTDS[i];
76 assertNotNull("Can't find resource for publicId " + publicId,
77 instance.resolveEntity(publicId, null));
78 }
79 }
80 }