Source Code Cross Referenced for TestPortletPlacement.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » layout » 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 » Portal » jetspeed 2.1.3 » org.apache.jetspeed.layout 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jetspeed.layout;
018:
019:        import junit.framework.TestCase;
020:
021:        import org.apache.jetspeed.components.portletregistry.PortletRegistry;
022:        import org.apache.jetspeed.layout.impl.CoordinateImpl;
023:        import org.apache.jetspeed.layout.impl.PortletPlacementContextImpl;
024:        import org.apache.jetspeed.om.page.Fragment;
025:        import org.apache.jetspeed.request.RequestContext;
026:
027:        /**
028:         * Test for Fragment placement
029:         * 
030:         * @author <a>David Gurney </a>
031:         * @version $Id: $
032:         */
033:        public class TestPortletPlacement extends TestCase {
034:            private PortletRegistry portletRegistry;
035:
036:            public void setUp() {
037:                portletRegistry = MockPortletRegistryFactory
038:                        .createMockPortletRegistry();
039:            }
040:
041:            public void testGetFragmentAt() {
042:                // Build a request object and populate it with fragments
043:                RequestContext requestContext = FragmentUtil
044:                        .buildFullRequestContext();
045:
046:                try {
047:                    PortletPlacementContext ppc = new PortletPlacementContextImpl(
048:                            requestContext.getPage(), portletRegistry);
049:                    int a_iNumCols = ppc.getNumberColumns();
050:                    assertEquals(a_iNumCols, 2);
051:
052:                    int a_iNumRows = ppc.getNumberRows(0);
053:                    assertEquals(a_iNumRows, 2);
054:
055:                    a_iNumRows = ppc.getNumberRows(1);
056:                    assertEquals(a_iNumRows, 3);
057:
058:                    // Check the fragments
059:                    Fragment a_oFrag = ppc
060:                            .getFragmentAtNewCoordinate(new CoordinateImpl(0,
061:                                    0, 0, 0));
062:                    assertNotNull("null fragment found at 0,0", a_oFrag);
063:                    assertEquals(a_oFrag.getId(), "1");
064:                    assertEquals(a_oFrag.getName(), "frag1");
065:
066:                    a_oFrag = ppc
067:                            .getFragmentAtNewCoordinate(new CoordinateImpl(0,
068:                                    1, 0, 1));
069:                    assertNotNull("null fragment found at 0,1", a_oFrag);
070:                    assertEquals(a_oFrag.getId(), "2");
071:                    assertEquals(a_oFrag.getName(), "frag2");
072:
073:                    a_oFrag = ppc
074:                            .getFragmentAtNewCoordinate(new CoordinateImpl(1,
075:                                    0, 1, 0));
076:                    assertNotNull("null fragment found at 1,0", a_oFrag);
077:                    assertEquals(a_oFrag.getId(), "3");
078:                    assertEquals(a_oFrag.getName(), "frag3");
079:
080:                    a_oFrag = ppc
081:                            .getFragmentAtNewCoordinate(new CoordinateImpl(1,
082:                                    1, 1, 1));
083:                    assertNotNull("null fragment found at 1,1", a_oFrag);
084:                    assertEquals(a_oFrag.getId(), "4");
085:                    assertEquals(a_oFrag.getName(), "frag4");
086:
087:                    a_oFrag = ppc
088:                            .getFragmentAtNewCoordinate(new CoordinateImpl(1,
089:                                    2, 1, 2));
090:                    assertNotNull("null fragment found at 1,2", a_oFrag);
091:                    assertEquals(a_oFrag.getId(), "5");
092:                    assertEquals(a_oFrag.getName(), "frag5");
093:
094:                } catch (PortletPlacementException e) {
095:                    fail("creating the PortletPlacementManager failed");
096:                }
097:            }
098:
099:            public void testGetFragmentById() {
100:                // Build a request object and populate it with fragments
101:                RequestContext requestContext = FragmentUtil
102:                        .buildFullRequestContext();
103:
104:                try {
105:                    PortletPlacementContext ppc = new PortletPlacementContextImpl(
106:                            requestContext.getPage(), portletRegistry);
107:
108:                    // Check the fragments
109:                    Fragment a_oFrag = ppc.getFragmentById("1");
110:                    assertNotNull("null fragment with id 1", a_oFrag);
111:                    assertEquals(a_oFrag.getId(), "1");
112:                    assertEquals(a_oFrag.getName(), "frag1");
113:
114:                    a_oFrag = ppc.getFragmentById("2");
115:                    assertNotNull("null fragment with id 2", a_oFrag);
116:                    assertEquals(a_oFrag.getId(), "2");
117:                    assertEquals(a_oFrag.getName(), "frag2");
118:
119:                    a_oFrag = ppc.getFragmentById("3");
120:                    assertNotNull("null fragment with id 3", a_oFrag);
121:                    assertEquals(a_oFrag.getId(), "3");
122:                    assertEquals(a_oFrag.getName(), "frag3");
123:
124:                    a_oFrag = ppc.getFragmentById("4");
125:                    assertNotNull("null fragment with id 4", a_oFrag);
126:                    assertEquals(a_oFrag.getId(), "4");
127:                    assertEquals(a_oFrag.getName(), "frag4");
128:
129:                    a_oFrag = ppc.getFragmentById("5");
130:                    assertNotNull("null fragment with id 5", a_oFrag);
131:                    assertEquals(a_oFrag.getId(), "5");
132:                    assertEquals(a_oFrag.getName(), "frag5");
133:
134:                } catch (PortletPlacementException e) {
135:                    fail("creating the PortletPlacementManager failed");
136:                }
137:            }
138:
139:            public void testRemoveFragment() {
140:                RequestContext requestContext = FragmentUtil
141:                        .buildFullRequestContext();
142:
143:                try {
144:                    PortletPlacementContext ppc = new PortletPlacementContextImpl(
145:                            requestContext.getPage(), portletRegistry);
146:
147:                    Fragment a_oFrag = ppc
148:                            .getFragmentAtNewCoordinate(new CoordinateImpl(0,
149:                                    0, 0, 0));
150:
151:                    Coordinate a_oCoordinate = ppc.remove(a_oFrag);
152:
153:                    assertEquals(a_oCoordinate.getOldCol(), 0);
154:                    assertEquals(a_oCoordinate.getOldRow(), 0);
155:
156:                    // Should be the second fragment now that the first has been deleted
157:                    a_oFrag = ppc
158:                            .getFragmentAtNewCoordinate(new CoordinateImpl(0,
159:                                    0, 0, 0));
160:                    assertEquals(a_oFrag.getId(), "2");
161:                    assertEquals(a_oFrag.getName(), "frag2");
162:                } catch (PortletPlacementException e) {
163:                    fail("creating the PortletPlacementManager failed");
164:                }
165:            }
166:
167:            public void testFragmentMoveabs() {
168:                RequestContext requestContext = FragmentUtil
169:                        .buildFullRequestContext();
170:
171:                try {
172:                    PortletPlacementContext ppc = new PortletPlacementContextImpl(
173:                            requestContext.getPage(), portletRegistry);
174:
175:                    Fragment a_oFrag = ppc
176:                            .getFragmentAtNewCoordinate(new CoordinateImpl(0,
177:                                    0, 0, 0));
178:
179:                    Coordinate a_oCoordinate = ppc.moveAbsolute(a_oFrag,
180:                            new CoordinateImpl(0, 0, 0, 1));
181:
182:                    assertEquals(a_oCoordinate.getOldCol(), 0);
183:                    assertEquals(a_oCoordinate.getOldRow(), 0);
184:                    assertEquals(a_oCoordinate.getNewCol(), 0);
185:                    assertEquals(a_oCoordinate.getNewRow(), 1);
186:
187:                    // Should be the second fragment now that the first has been moved
188:                    a_oFrag = ppc
189:                            .getFragmentAtNewCoordinate(new CoordinateImpl(0,
190:                                    0, 0, 0));
191:                    assertEquals(a_oFrag.getId(), "2");
192:                    assertEquals(a_oFrag.getName(), "frag2");
193:
194:                    a_oFrag = ppc
195:                            .getFragmentAtNewCoordinate(new CoordinateImpl(0,
196:                                    0, 0, 1));
197:                    assertEquals(a_oFrag.getId(), "1");
198:                    assertEquals(a_oFrag.getName(), "frag1");
199:                } catch (PortletPlacementException e) {
200:                    fail("creating the PortletPlacementManager failed");
201:                }
202:            }
203:
204:            public void testFragmentMoveUp() {
205:                RequestContext requestContext = FragmentUtil
206:                        .buildFullRequestContext();
207:
208:                try {
209:                    PortletPlacementContext ppc = new PortletPlacementContextImpl(
210:                            requestContext.getPage(), portletRegistry);
211:
212:                    Fragment a_oFrag = ppc
213:                            .getFragmentAtNewCoordinate(new CoordinateImpl(0,
214:                                    0, 0, 1));
215:
216:                    Coordinate a_oCoordinate = ppc.moveUp(a_oFrag);
217:
218:                    assertEquals(a_oCoordinate.getOldCol(), 0);
219:                    assertEquals(a_oCoordinate.getOldRow(), 1);
220:                    assertEquals(a_oCoordinate.getNewCol(), 0);
221:                    assertEquals(a_oCoordinate.getNewRow(), 0);
222:
223:                    // Should be the second fragment since it was moved up
224:                    a_oFrag = ppc
225:                            .getFragmentAtNewCoordinate(new CoordinateImpl(0,
226:                                    0, 0, 0));
227:                    assertEquals(a_oFrag.getId(), "2");
228:                    assertEquals(a_oFrag.getName(), "frag2");
229:
230:                    a_oFrag = ppc
231:                            .getFragmentAtNewCoordinate(new CoordinateImpl(0,
232:                                    0, 0, 1));
233:                    assertEquals(a_oFrag.getId(), "1");
234:                    assertEquals(a_oFrag.getName(), "frag1");
235:                } catch (PortletPlacementException e) {
236:                    fail("creating the PortletPlacementManager failed");
237:                }
238:            }
239:
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.