Source Code Cross Referenced for ResultPreferencesTest.java in  » J2EE » fleXive » com » flexive » tests » shared » 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 » J2EE » fleXive » com.flexive.tests.shared 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /***************************************************************
002:         *  This file is part of the [fleXive](R) project.
003:         *
004:         *  Copyright (c) 1999-2008
005:         *  UCS - unique computing solutions gmbh (http://www.ucs.at)
006:         *  All rights reserved
007:         *
008:         *  The [fleXive](R) project is free software; you can redistribute
009:         *  it and/or modify it under the terms of the GNU General Public
010:         *  License as published by the Free Software Foundation;
011:         *  either version 2 of the License, or (at your option) any
012:         *  later version.
013:         *
014:         *  The GNU General Public License can be found at
015:         *  http://www.gnu.org/copyleft/gpl.html.
016:         *  A copy is found in the textfile GPL.txt and important notices to the
017:         *  license from the author are found in LICENSE.txt distributed with
018:         *  these libraries.
019:         *
020:         *  This library is distributed in the hope that it will be useful,
021:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
022:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023:         *  GNU General Public License for more details.
024:         *
025:         *  For further information about UCS - unique computing solutions gmbh,
026:         *  please see the company website: http://www.ucs.at
027:         *
028:         *  For further information about [fleXive](R), please see the
029:         *  project website: http://www.flexive.org
030:         *
031:         *
032:         *  This copyright notice MUST APPEAR in all copies of the file!
033:         ***************************************************************/package com.flexive.tests.shared;
034:
035:        import com.flexive.shared.search.*;
036:        import org.testng.annotations.DataProvider;
037:        import org.testng.annotations.Test;
038:
039:        import java.util.Arrays;
040:        import java.util.List;
041:
042:        /**
043:         * Basic unit tests for the ResultPreferences class.
044:         *
045:         * @author Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
046:         * @version $Rev: 181 $
047:         */
048:        @Test(groups="shared")
049:        public class ResultPreferencesTest {
050:            private static final ResultColumnInfo[][] INFOS_EQUAL = {
051:                    { new ResultColumnInfo(Table.CONTENT, "type", ""),
052:                            new ResultColumnInfo(Table.CONTENT, "type", "") },
053:                    { new ResultColumnInfo(Table.CONTENT, "Type", ""),
054:                            new ResultColumnInfo(Table.CONTENT, "type", "") },
055:                    { new ResultColumnInfo(Table.CONTENT, "type", "name"),
056:                            new ResultColumnInfo(Table.CONTENT, "type", "name") },
057:                    { new ResultColumnInfo(Table.CONTENT, "type", "Name"),
058:                            new ResultColumnInfo(Table.CONTENT, "type", "name") },
059:                    { new ResultColumnInfo(Table.CONTENT, "type", null),
060:                            new ResultColumnInfo(Table.CONTENT, "type", null) }, };
061:            private static final ResultColumnInfo[][] INFOS_UNEQUAL = {
062:                    { new ResultColumnInfo(Table.CONTENT, "type", ""),
063:                            new ResultColumnInfo(Table.CONTENT, "type1", "") },
064:                    { new ResultColumnInfo(Table.CONTENT, "type", "name"),
065:                            new ResultColumnInfo(Table.CONTENT, "type", "") },
066:                    { new ResultColumnInfo(Table.CONTENT, "type", "name"),
067:                            new ResultColumnInfo(Table.CONTENT, "type", null) },
068:                    { new ResultColumnInfo(Table.CONTENT, "type", "name"),
069:                            new ResultColumnInfo(Table.CONTENT, "type", "id") }, };
070:            private static final ResultOrderByInfo[][] ORDERBY_EQUAL = {
071:                    {
072:                            new ResultOrderByInfo(Table.CONTENT, "type", "",
073:                                    SortDirection.ASCENDING),
074:                            new ResultOrderByInfo(Table.CONTENT, "type", "",
075:                                    SortDirection.ASCENDING) },
076:                    {
077:                            new ResultOrderByInfo(Table.CONTENT, "type", "",
078:                                    SortDirection.DESCENDING),
079:                            new ResultOrderByInfo(Table.CONTENT, "type", "",
080:                                    SortDirection.DESCENDING) } };
081:            private static final ResultOrderByInfo[][] ORDERBY_UNEQUAL = { {
082:                    new ResultOrderByInfo(Table.CONTENT, "type", "",
083:                            SortDirection.ASCENDING),
084:                    new ResultOrderByInfo(Table.CONTENT, "type", "",
085:                            SortDirection.DESCENDING) } };
086:
087:            @Test
088:            public void resultPreferencesDeepCopy() {
089:                ResultPreferences rp = new ResultPreferences();
090:                ResultPreferencesEdit rpe = rp.getEditObject();
091:
092:                // add a column info, check if base object remains unchanged
093:                assert rp.getSelectedColumns().size() == 0;
094:                assert rpe.getSelectedColumns().size() == 0;
095:                final ResultColumnInfo ci = INFOS_EQUAL[0][0];
096:                rpe.addSelectedColumn(ci);
097:                assert rp.getSelectedColumns().size() == 0;
098:                assert rpe.getSelectedColumns().size() == 1;
099:                assert rpe.getSelectedColumns().get(0).equals(ci);
100:
101:                // add a order by info, check if base object remains unchanged
102:                assert rp.getOrderByColumns().size() == 0;
103:                assert rpe.getOrderByColumns().size() == 0;
104:                final ResultOrderByInfo obi = ORDERBY_EQUAL[0][0];
105:                rpe.addOrderByColumn(obi);
106:                assert rpe.getOrderByColumns().size() == 1;
107:                assert rp.getOrderByColumns().size() == 0;
108:                assert rpe.getOrderByColumns().get(0).equals(obi);
109:            }
110:
111:            @Test
112:            public void resultPreferencesCopy() {
113:                final List<ResultColumnInfo> selectedColumns = Arrays
114:                        .asList(INFOS_UNEQUAL[0]);
115:                final List<ResultOrderByInfo> orderByColumns = Arrays
116:                        .asList(ORDERBY_UNEQUAL[0]);
117:                ResultPreferences rp = new ResultPreferences(selectedColumns,
118:                        orderByColumns, 15, 150);
119:                assert rp.getSelectedColumns().size() == 2;
120:                assert rp.getOrderByColumns().size() == 2;
121:                assert rp.getSelectedColumns().equals(selectedColumns);
122:                assert rp.getOrderByColumns().equals(orderByColumns);
123:                ResultPreferencesEdit rpe = rp.getEditObject();
124:                assert rp.equals(rpe);
125:
126:                // remove column, assert unequal, then restore previous state
127:                final ResultColumnInfo ci = rpe.removeSelectedColumn(1);
128:                assert !rp.equals(rpe);
129:                rpe.addSelectedColumn(ci);
130:                assert rp.equals(rpe);
131:
132:                // remove order by, assert unequal, then restore previous state
133:                final ResultOrderByInfo obi = rpe.removeOrderByColumn(1);
134:                assert (!rp.equals(rpe));
135:                rpe.addOrderByColumn(obi);
136:                assert rp.equals(rpe);
137:
138:                // other tests
139:                rpe.setThumbBoxSize(10);
140:                assert !rp.equals(rpe);
141:                rpe.setThumbBoxSize(rp.getThumbBoxSize());
142:                assert rp.equals(rpe);
143:                rpe.setRowsPerPage(100);
144:                assert !rp.equals(rpe);
145:                rpe.setRowsPerPage(rp.getRowsPerPage());
146:                assert rp.equals(rpe);
147:            }
148:
149:            @Test
150:            public void resultPreferencesAddEmpty() {
151:                ResultPreferences rp = new ResultPreferences();
152:                ResultPreferencesEdit rpe = rp.getEditObject();
153:                try {
154:                    rpe.addSelectedColumn(null);
155:                    assert false : "It should not be possible to add null column infos";
156:                } catch (RuntimeException e) {
157:                    // pass
158:                }
159:                try {
160:                    rpe.addOrderByColumn(null);
161:                    assert false : "It should not be possible to add null order by column infos";
162:                } catch (RuntimeException e) {
163:                    // pass
164:                }
165:            }
166:
167:            @Test(dataProvider="equalColumnInfos")
168:            public void columnInfoEqual(ResultColumnInfo ci1,
169:                    ResultColumnInfo ci2) {
170:                assert ci1.equals(ci2) && ci2.equals(ci1) : ci1
171:                        + " should be equal to " + ci2;
172:            }
173:
174:            @Test(dataProvider="unequalColumnInfos")
175:            public void columnInfoUnequal(ResultColumnInfo ci1,
176:                    ResultColumnInfo ci2) {
177:                assert !ci1.equals(ci2) && !ci2.equals(ci1) : ci1
178:                        + " should not be equal to " + ci2;
179:            }
180:
181:            @Test(dataProvider="equalOrderByInfos")
182:            public void orderByEqual(ResultOrderByInfo obi1,
183:                    ResultOrderByInfo obi2) {
184:                assert obi1.equals(obi2) && obi2.equals(obi1) : obi1
185:                        + " should be equal to " + obi2;
186:            }
187:
188:            @Test(dataProvider="unequalOrderByInfos")
189:            public void orderByUnequal(ResultOrderByInfo obi1,
190:                    ResultOrderByInfo obi2) {
191:                assert !obi1.equals(obi2) && !obi2.equals(obi1) : obi1
192:                        + " should not be equal to " + obi2;
193:            }
194:
195:            @DataProvider(name="equalColumnInfos")
196:            private Object[][] getEqualColumnInfos() {
197:                return INFOS_EQUAL;
198:            }
199:
200:            @DataProvider(name="unequalColumnInfos")
201:            private Object[][] getUnequalColumnInfos() {
202:                return INFOS_UNEQUAL;
203:            }
204:
205:            @DataProvider(name="equalOrderByInfos")
206:            private Object[][] getEqualOrderByInfos() {
207:                return ORDERBY_EQUAL;
208:            }
209:
210:            @DataProvider(name="unequalOrderByInfos")
211:            private Object[][] getUnequalOrderByInfos() {
212:                return ORDERBY_UNEQUAL;
213:            }
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.