Source Code Cross Referenced for SettingsImplTest.java in  » Groupware » ivatagroupware » com » ivata » groupware » admin » setting » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » ivatagroupware » com.ivata.groupware.admin.setting 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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: SettingsImplTest.java,v $
031:         * Revision 1.5  2005/10/11 18:53:07  colinmacleod
032:         * Fixed some checkstyle and javadoc issues.
033:         *
034:         * Revision 1.4  2005/09/29 13:29:42  colinmacleod
035:         * Removed description field from setting.
036:         *
037:         * Revision 1.3  2005/09/15 10:23:23  colinmacleod
038:         * Upgraded Maven to 1.1 (beta-2).
039:         * Upgraded Hibernate to 3.0.5.
040:         *
041:         * Revision 1.2  2005/04/09 17:19:11  colinmacleod
042:         * Changed copyright text to GPL v2 explicitly.
043:         *
044:         * Revision 1.1.1.1  2005/03/10 17:50:14  colinmacleod
045:         * Restructured ivata op around Hibernate/PicoContainer.
046:         * Renamed ivata groupware.
047:         *
048:         * Revision 1.3  2004/11/12 18:17:25  colinmacleod
049:         * Ordered imports.
050:         *
051:         * Revision 1.2  2004/11/12 15:57:08  colinmacleod
052:         * Removed dependencies on SSLEXT.
053:         * Moved Persistence classes to ivata masks.
054:         *
055:         * Revision 1.1  2004/07/13 19:41:17  colinmacleod
056:         * Moved project to POJOs from EJBs.
057:         * Applied PicoContainer to services layer (replacing session EJBs).
058:         * Applied Hibernate to persistence layer (replacing entity EJBs).
059:         * -----------------------------------------------------------------------------
060:         */
061:        package com.ivata.groupware.admin.setting;
062:
063:        import java.util.ArrayList;
064:        import java.util.Iterator;
065:        import java.util.List;
066:
067:        import com.ivata.groupware.admin.AdminTestCase;
068:        import com.ivata.groupware.admin.security.server.SecuritySession;
069:        import com.ivata.groupware.admin.security.user.UserDO;
070:        import com.ivata.groupware.container.persistence.hibernate.HibernateManager;
071:        import com.ivata.groupware.container.persistence.hibernate.HibernateSession;
072:        import com.ivata.mask.util.SystemException;
073:
074:        /**
075:         * Tests <code>SettingsImpl</code>.
076:         *
077:         * @author Colin MacLeod
078:         * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
079:         * @since   Jun 7, 2004
080:         * @version $Revision: 1.5 $
081:         */
082:        public class SettingsImplTest extends AdminTestCase {
083:            /**
084:             * <p>
085:             * This is the implementation instance which will be tested.
086:             * </p>
087:             */
088:            private SettingsImpl settings;
089:
090:            /**
091:             * Stores settings we are testing.
092:             */
093:            private List testSettings = new ArrayList();
094:
095:            /**
096:             * Constructor for SettingsImplTest.
097:             *
098:             * @param arg0 {@inheritDoc}
099:             */
100:            public SettingsImplTest(final String arg0) {
101:                super (arg0);
102:            }
103:
104:            /**
105:             * Helper to create a simple test string setting.
106:             *
107:             * @param name The name of the test setting.
108:             * @return <code>SettingDO</code> instance with a setting of the given
109:             * name.
110:             * @throws SystemException Thrown by <code>HibernateManager.add</code>.
111:             */
112:            private SettingDO createStringSetting(final String name)
113:                    throws SystemException {
114:                HibernateManager hibernateManager = getHibernateManager();
115:                HibernateSession hibernateSession = getHibernateSession();
116:
117:                SettingDO setting = new SettingDO();
118:                setting.setEnabled(true);
119:                setting.setName("name");
120:                setting.setType(SettingConstants.DATA_TYPE_STRING);
121:                setting.setUser(null);
122:                setting = (SettingDO) hibernateManager.add(hibernateSession,
123:                        setting);
124:                assertNotNull(setting.getId());
125:                testSettings.add(setting);
126:                return setting;
127:            }
128:
129:            /**
130:             * {@inheritDoc}
131:             *
132:             * @throws Exception {@inheritDoc}
133:             */
134:            protected void setUp() throws Exception {
135:                super .setUp();
136:                //TODO        SecuritySession securitySession = getSecuritySession();
137:                settings = new SettingsImpl(getHibernateManager());
138:            }
139:
140:            /**
141:             * {@inheritDoc}
142:             *
143:             * @throws Exception {@inheritDoc}
144:             */
145:            protected void tearDown() throws Exception {
146:                super .tearDown();
147:                HibernateManager hibernateManager = getHibernateManager();
148:                HibernateSession hibernateSession = getHibernateSession();
149:
150:                Iterator testSettingIterator = testSettings.iterator();
151:                while (testSettingIterator.hasNext()) {
152:                    SettingDO setting = (SettingDO) testSettingIterator.next();
153:                    hibernateManager.remove(hibernateSession, setting);
154:                }
155:            }
156:
157:            /**
158:             * Tests {@link SettingsImpl#amendSetting SettingsImpl.amendSetting}.
159:             *
160:             * @throws SystemException
161:             * See {@link SettingsImpl#amendSetting SettingsImpl.amendSetting}.
162:             */
163:            public void testAmendSetting() throws SystemException {
164:                SecuritySession securitySession = getSecuritySession();
165:                HibernateManager hibernateManager = getHibernateManager();
166:                HibernateSession hibernateSession = getHibernateSession();
167:
168:                SettingDO setting = createStringSetting("amend_test");
169:                settings.amendSetting(securitySession, "amend_test",
170:                        "new_value", null);
171:                setting = (SettingDO) hibernateManager.findInstance(
172:                        hibernateSession, "adminSettingName",
173:                        new Object[] { setting.getName() });
174:                assertEquals("new_value", setting.getValue());
175:                UserDO user = securitySession.getUser();
176:                settings.amendSetting(securitySession, "amend_test",
177:                        "user_value", user);
178:                SettingDO userSetting = (SettingDO) hibernateManager
179:                        .findInstance(hibernateSession,
180:                                "adminSettingNameUserName", new Object[] {
181:                                        setting.getName(), user.getName() });
182:                setting = (SettingDO) hibernateManager.findInstance(
183:                        hibernateSession, "adminSettingName",
184:                        new Object[] { setting.getName() });
185:                // check the general setting hasn't changed!
186:                assertEquals("user_value", userSetting.getValue());
187:                // check the general setting hasn't changed!
188:                assertEquals("new_value", setting.getValue());
189:            }
190:
191:            /**
192:             * Tests {@link SettingsImpl#getBooleanSetting
193:             * SettingsImpl.getBooleanSetting}.
194:             *
195:             * @throws SystemException
196:             * See {@link SettingsImpl#getBooleanSetting
197:             * SettingsImpl.getBooleanSetting}.
198:             */
199:            public void testGetBooleanSetting() throws SystemException {
200:                SecuritySession securitySession = getSecuritySession();
201:                HibernateManager hibernateManager = getHibernateManager();
202:                HibernateSession hibernateSession = getHibernateSession();
203:
204:                SettingDO testSetting = createStringSetting("boolean_test");
205:                testSetting.setType(SettingConstants.DATA_TYPE_BOOLEAN);
206:                testSetting.setValue("false");
207:                hibernateManager.amend(hibernateSession, testSetting);
208:
209:                Boolean test = settings.getBooleanSetting(securitySession,
210:                        "boolean_test", null);
211:                assertFalse(test.booleanValue());
212:            }
213:
214:            /**
215:             * Tests {@link SettingsImpl#getIntegerSetting
216:             * SettingsImpl.getIntegerSetting}.
217:             *
218:             * @throws SystemException
219:             * See {@link SettingsImpl#getIntegerSetting
220:             * SettingsImpl.getIntegerSetting}.
221:             */
222:            public void testGetIntegerSetting() throws SystemException {
223:                SecuritySession securitySession = getSecuritySession();
224:                HibernateManager hibernateManager = getHibernateManager();
225:                HibernateSession hibernateSession = getHibernateSession();
226:
227:                SettingDO testSetting = createStringSetting("integer_test");
228:                testSetting.setType(SettingConstants.DATA_TYPE_BOOLEAN);
229:                testSetting.setValue("202");
230:                hibernateManager.amend(hibernateSession, testSetting);
231:
232:                Integer test = settings.getIntegerSetting(securitySession,
233:                        "integer_test", null);
234:                assertEquals(new Integer("202"), test);
235:            }
236:
237:            /**
238:             * Tests {@link SettingsImpl#getSetting
239:             * SettingsImpl.getSetting}.
240:             *
241:             * @throws SystemException
242:             * See {@link SettingsImpl#getSetting
243:             * SettingsImpl.getSetting}.
244:             */
245:            public void testGetSetting() throws SystemException {
246:                SecuritySession securitySession = getSecuritySession();
247:                HibernateManager hibernateManager = getHibernateManager();
248:                HibernateSession hibernateSession = getHibernateSession();
249:
250:                SettingDO testSetting = createStringSetting("get_test");
251:                testSetting.setValue("get_test_value");
252:                hibernateManager.amend(hibernateSession, testSetting);
253:
254:                Object test = settings.getSetting(securitySession, "get_test",
255:                        null);
256:                assertEquals("get_test_value", test);
257:            }
258:
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.