001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata groupware may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: AdminTestCase.java,v $
031: * Revision 1.4 2005/10/11 18:53:07 colinmacleod
032: * Fixed some checkstyle and javadoc issues.
033: *
034: * Revision 1.3 2005/09/15 10:23:23 colinmacleod
035: * Upgraded Maven to 1.1 (beta-2).
036: * Upgraded Hibernate to 3.0.5.
037: *
038: * Revision 1.2 2005/04/09 17:19:11 colinmacleod
039: * Changed copyright text to GPL v2 explicitly.
040: *
041: * Revision 1.1.1.1 2005/03/10 17:50:14 colinmacleod
042: * Restructured ivata op around Hibernate/PicoContainer.
043: * Renamed ivata groupware.
044: *
045: * Revision 1.1 2004/07/13 19:41:17 colinmacleod
046: * Moved project to POJOs from EJBs.
047: * Applied PicoContainer to services layer (replacing session EJBs).
048: * Applied Hibernate to persistence layer (replacing entity EJBs).
049: * -----------------------------------------------------------------------------
050: */
051: package com.ivata.groupware.admin;
052:
053: import java.io.File;
054: import java.util.Properties;
055:
056: import org.hibernate.cfg.Configuration;
057:
058: import com.ivata.groupware.GroupwareTestCase;
059:
060: /**
061: * Generalizes preparation required for several admin test cases.
062: *
063: * @author Colin MacLeod
064: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
065: * @since ivata groupware 0.10 (Jun 7, 2004)
066: * @version $Revision: 1.4 $
067: */
068: public abstract class AdminTestCase extends GroupwareTestCase {
069: /**
070: * Constructor.
071: *
072: * @param arg0 {@inheritDoc}
073: */
074: public AdminTestCase(final String arg0) {
075: super (getHibernateConfiguration(), arg0);
076: }
077:
078: /**
079: * <p>
080: * Helper called by the constructor to create a valid Hibernate
081: * configuration for all the address book's functionality.
082: * </p>
083: *
084: * @return valid Hibernate configuration.
085: */
086: private static Configuration getHibernateConfiguration() {
087: Configuration hibernateConfiguration = new Configuration();
088: hibernateConfiguration.addFile(new File(
089: "../hibernate/target/xdoclet/hibernatedoclet/com/ivata/"
090: + "groupware/admin/setting/SettingDO.hbm.xml"));
091: hibernateConfiguration
092: .addFile(new File(
093: "../hibernate/target/xdoclet/hibernatedoclet/com/ivata/"
094: + "groupware/admin/security/user/UserDO.hbm.xml"));
095: hibernateConfiguration
096: .addFile(new File(
097: "../hibernate/target/xdoclet/hibernatedoclet/com/ivata/"
098: + "groupware/business/addressbook/address/AddressDO.hbm.xml"));
099: hibernateConfiguration
100: .addFile(new File(
101: "../hibernate/target/xdoclet/hibernatedoclet/com/ivata/"
102: + "groupware/business/addressbook/address/country/"
103: + "CountryDO.hbm.xml"));
104: hibernateConfiguration
105: .addFile(new File(
106: "../hibernate/target/xdoclet/hibernatedoclet/com/ivata/"
107: + "groupware/business/addressbook/person/PersonDO.hbm.xml"));
108: hibernateConfiguration
109: .addFile(new File(
110: "../hibernate/target/xdoclet/hibernatedoclet/com/ivata/"
111: + "groupware/business/addressbook/person/group/right/"
112: + "RightDO.hbm.xml"));
113: hibernateConfiguration
114: .addFile(new File(
115: "../hibernate/target/xdoclet/hibernatedoclet/com/ivata/"
116: + "groupware/business/addressbook/person/group/right/detail/"
117: + "RightDetailDO.hbm.xml"));
118: hibernateConfiguration
119: .addFile(new File(
120: "../hibernate/target/xdoclet/hibernatedoclet/com/ivata/"
121: + "groupware/business/addressbook/person/group/"
122: + "GroupDO.hbm.xml"));
123: hibernateConfiguration
124: .addFile(new File(
125: "../hibernate/target/xdoclet/hibernatedoclet/com/ivata/"
126: + "groupware/business/addressbook/person/employee/"
127: + "EmployeeDO.hbm.xml"));
128: hibernateConfiguration
129: .addFile(new File(
130: "../hibernate/target/xdoclet/hibernatedoclet/com/ivata/"
131: + "groupware/business/addressbook/telecomaddress/"
132: + "TelecomAddressDO.hbm.xml"));
133: hibernateConfiguration.addFile(new File(
134: "../hibernate/target/xdoclet/hibernatedoclet/com/ivata/"
135: + "groupware/navigation/menu/MenuDO.hbm.xml"));
136: hibernateConfiguration
137: .addFile(new File(
138: "../hibernate/target/xdoclet/hibernatedoclet/com/ivata/"
139: + "groupware/navigation/menu/item/MenuItemDO.hbm.xml"));
140:
141: Properties hibernateProperties = new Properties();
142: hibernateProperties.setProperty(
143: "hibernate.connection.driver_class",
144: "org.postgresql.Driver");
145: hibernateProperties.setProperty("hibernate.connection.URL",
146: "jdbc:postgresql://localhost:5432/portal");
147: hibernateProperties.setProperty(
148: "hibernate.connection.username", "postgres");
149: hibernateProperties.setProperty(
150: "hibernate.connection.password", "");
151: hibernateProperties.setProperty("hibernate.dialect",
152: "org.hibernate.dialect.PostgreSQLDialect");
153: hibernateProperties.setProperty("hibernate.show_sql", "true");
154: hibernateConfiguration.setProperties(hibernateProperties);
155:
156: return hibernateConfiguration;
157: }
158: }
|