KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > test > setup > sl > HibernateSchemaLoaderTestCase


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.test.setup.sl;
10
11 import org.jboss.portal.setup.impl.sl.dbloader.hibernate.HibernateSchemaLoaderConfigImpl;
12 import org.jboss.portal.setup.impl.sl.dbloader.hibernate.HibernateSchemaLoader;
13 import org.jboss.portal.setup.sl.SchemaLoadType;
14 import org.jboss.portal.setup.PortalSetupException;
15
16 import org.jboss.portal.test.setup.PortalSetupBaseTestCase;
17
18 import java.util.List JavaDoc;
19 import java.util.ArrayList JavaDoc;
20
21 /**
22  * @author <a HREF="mailto:palber@novell.com">Polina Alber</a>
23  * Date: Apr 13, 2005; Time: 1:29:11 PM
24  * @since JBoss portal 2.0
25  * Class org.jboss.portal.test.setup.sl.HibernateSchemaLoaderTestCase
26  */

27 public class HibernateSchemaLoaderTestCase extends PortalSetupBaseTestCase
28 {
29
30    private HibernateSchemaLoader m_schLoader = null;
31    HibernateSchemaLoaderConfigImpl m_config = null;
32
33
34    public HibernateSchemaLoaderTestCase(String JavaDoc name)
35    {
36       super(name);
37    }
38
39    public void setUp() throws Exception JavaDoc
40    {
41       try
42       {
43          super.setUp();
44          setupSchemaLoaderConfig();
45          processURIs();
46          m_schLoader = new HibernateSchemaLoader();
47          m_schLoader.setSchemaLoaderConfig(m_config);
48       }
49       catch (PortalSetupException pse)
50       {
51          pse.printStackTrace();
52          assertTrue(false);
53       }
54
55    }
56
57    public void testLoadSchema() throws Exception JavaDoc
58    {
59       boolean schemaExists = m_schLoader.isSchemaExists();
60       if (schemaExists)
61       {
62          assertTrue(m_schLoader.destroySchema());
63          assertTrue(m_schLoader.isSchemaExists() == false);
64       }
65       m_schLoader.loadSchema();
66       schemaExists = m_schLoader.isSchemaExists();
67       assertTrue(schemaExists);
68    }
69
70    public void tearDown() throws Exception JavaDoc
71    {
72       m_schLoader.destroy();
73       m_schLoader = null;
74       super.tearDown();
75    }
76
77    protected void setupSchemaLoaderConfig() throws PortalSetupException
78    {
79
80       m_config = new HibernateSchemaLoaderConfigImpl();
81       m_config.setSchemaLoadRule(SchemaLoadType.ALWAYS.toString());
82       m_config.setSchemaQueryString("SELECT * FROM JBP_USERS");
83       m_config.setSchemaLoaderClass(HibernateSchemaLoader.class.getName());
84       m_config.setHibernateConfig(m_hbConfig);
85
86    }
87
88    protected void processURIs() throws PortalSetupException
89    {
90       m_config.addSchemaLoadURI("org/jboss/portal/core/impl/user/UserImpl.hbm.xml");
91       m_config.addSchemaLoadURI("org/jboss/portal/core/impl/role/RoleImpl.hbm.xml");
92       m_config.addSchemaLoadURI("org/jboss/portal/core/impl/user/UserPref.hbm.xml");
93       m_config.addSchemaLoadURI("org/jboss/portal/core/impl/user/UserPrefSet.hbm.xml");
94       m_config.addSchemaLoadURI("org/jboss/portal/core/impl/preferences/MappedPreference.hbm.xml");
95       m_config.addSchemaLoadURI("org/jboss/portal/core/impl/preferences/MappedPreferenceSet.hbm.xml");
96    }
97
98    protected List JavaDoc getClassList() throws PortalSetupException
99    {
100       return new ArrayList JavaDoc(0);
101    }
102 }
103
Popular Tags