Source Code Cross Referenced for AbstractRegistryTest.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » components » portletregistry » 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.components.portletregistry 
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.components.portletregistry;
018:
019:        import java.util.Collection;
020:        import java.util.Iterator;
021:        import java.util.Locale;
022:
023:        import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
024:        import org.apache.jetspeed.om.common.DublinCore;
025:        import org.apache.jetspeed.om.common.GenericMetadata;
026:        import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
027:        import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
028:        import org.apache.jetspeed.om.impl.DublinCoreImpl;
029:        import org.apache.jetspeed.om.portlet.impl.PortletDefinitionImpl;
030:        import org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl;
031:
032:        /**
033:         * @author scott
034:         */
035:        public abstract class AbstractRegistryTest extends
036:                DatasourceEnabledSpringTestCase {
037:
038:            protected static final String PORTLET_0_CLASS = "com.portlet.MyClass0";
039:
040:            protected static final String PORTLET_0_NAME = "Portlet 0";
041:
042:            protected static final String PORTLET_1_CLASS = "com.portlet.MyClass";
043:
044:            protected static final String PORTLET_1_NAME = "Portlet 1";
045:
046:            protected static final String PORTLET_1_UID = "com.portlet.MyClass.Portlet 1";
047:
048:            protected static final String PORTLET_0_UID = "com.portlet.MyClass0.Portlet 0";
049:
050:            protected static final String MODE_HELP = "HELP";
051:
052:            protected static final String MODE_VIEW = "VIEW";
053:
054:            protected static final String MODE_EDIT = "EDIT";
055:
056:            public static final String APP_1_NAME = "RegistryTestPortlet";
057:
058:            protected PortletRegistry registry;
059:
060:            private static int testPasses = 0;
061:
062:            /**
063:             * <p>
064:             * setUp
065:             * </p>
066:             * 
067:             * @see junit.framework.TestCase#setUp()
068:             * @throws Exception
069:             */
070:            protected void setUp() throws Exception {
071:                super .setUp();
072:                this .registry = (PortletRegistry) ctx
073:                        .getBean("portletRegistry");
074:
075:                testPasses++;
076:            }
077:
078:            /**
079:             * <p>
080:             * tearDown
081:             * </p>
082:             * 
083:             * @see junit.framework.TestCase#tearDown()
084:             * @throws Exception
085:             */
086:            protected void tearDown() throws Exception {
087:                //super.tearDown();
088:            }
089:
090:            protected void validateDublinCore(GenericMetadata metadata) {
091:                DublinCore dc = new DublinCoreImpl(metadata);
092:                assertEquals(dc.getTitles().size(), 3);
093:                assertEquals(dc.getContributors().size(), 1);
094:                assertEquals(dc.getCoverages().size(), 2);
095:                assertEquals(dc.getCreators().size(), 1);
096:                assertEquals(dc.getDescriptions().size(), 1);
097:                assertEquals(dc.getFormats().size(), 1);
098:                assertEquals(dc.getIdentifiers().size(), 1);
099:                assertEquals(dc.getLanguages().size(), 1);
100:                assertEquals(dc.getPublishers().size(), 1);
101:                assertEquals(dc.getRelations().size(), 1);
102:                assertEquals(dc.getRights().size(), 1);
103:                assertEquals(dc.getSources().size(), 1);
104:                assertEquals(dc.getSubjects().size(), 1);
105:                assertEquals(dc.getTypes().size(), 1);
106:            }
107:
108:            // protected void invalidate( Object[] objs ) throws LockFailedException
109:            // {
110:            // persistenceStore.getTransaction().begin();
111:            // for (int i = 0; i < objs.length; i++)
112:            // {
113:            // persistenceStore.invalidate(objs[i]);
114:            // }
115:            // persistenceStore.getTransaction().commit();
116:            // }
117:
118:            protected void verifyData(boolean afterUpdates) throws Exception {
119:                MutablePortletApplication app;
120:                WebApplicationDefinitionImpl webApp;
121:                PortletDefinitionComposite portlet;
122:
123:                app = null;
124:
125:                app = registry.getPortletApplication("App_1");
126:
127:                webApp = (WebApplicationDefinitionImpl) app
128:                        .getWebApplicationDefinition();
129:                portlet = (PortletDefinitionImpl) app
130:                        .getPortletDefinitionByName("Portlet 1");
131:
132:                assertNotNull("Failed to reteive portlet application", app);
133:
134:                validateDublinCore(app.getMetadata());
135:
136:                Collection services = app.getJetspeedServices();
137:                assertNotNull("jetspeed services is null", services);
138:                System.out.println("services is " + services);
139:
140:                assertNotNull(
141:                        "Failed to reteive portlet application via registry",
142:                        registry.getPortletApplication("App_1"));
143:                assertNotNull(
144:                        "Web app was not saved along with the portlet app.",
145:                        webApp);
146:                assertNotNull(
147:                        "Portlet was not saved along with the portlet app.",
148:                        app.getPortletDefinitionByName("Portlet 1"));
149:                if (!afterUpdates) {
150:                    assertTrue(
151:                            "\"user.name.family\" user attribute was not found.",
152:                            app.getUserAttributes().size() == 1);
153:                } else {
154:                    assertTrue(
155:                            "\"user.name.family\" and user.pets user attributes were not found.",
156:                            app.getUserAttributes().size() == 2);
157:
158:                }
159:
160:                portlet = registry
161:                        .getPortletDefinitionByUniqueName("App_1::Portlet 1");
162:
163:                assertNotNull("Portlet could not be retreived by unique name.",
164:                        portlet);
165:
166:                validateDublinCore(portlet.getMetadata());
167:
168:                assertNotNull(
169:                        "Portlet Application was not set in the portlet defintion.",
170:                        portlet.getPortletApplicationDefinition());
171:                assertNotNull(
172:                        "French description was not materialized for the web app.",
173:                        webApp.getDescription(Locale.FRENCH));
174:                assertNotNull(
175:                        "French display name was not materialized for the web app.",
176:                        webApp.getDisplayName(Locale.FRENCH));
177:                assertNotNull(
178:                        "description was not materialized for the portlet.",
179:                        portlet.getDescription(Locale.getDefault()));
180:                assertNotNull(
181:                        "display name was not materialized for the portlet.",
182:                        portlet.getDisplayName(Locale.getDefault()));
183:                assertNotNull("\"testparam\" portlet parameter was not saved",
184:                        portlet.getInitParameterSet().get("testparam"));
185:                assertNotNull("\"preference 1\" was not found.", portlet
186:                        .getPreferenceSet().get("preference 1"));
187:                assertNotNull("Language information not found for Portlet 1",
188:                        portlet.getLanguageSet().get(Locale.getDefault()));
189:                assertNotNull("Content Type html not found.", portlet
190:                        .getContentTypeSet().get("html/text"));
191:                assertNotNull("Content Type wml not found.", portlet
192:                        .getContentTypeSet().get("wml"));
193:                Iterator itr = portlet.getPreferenceSet().get("preference 1")
194:                        .getValues();
195:                int valueCount = 0;
196:
197:                while (itr.hasNext()) {
198:                    itr.next();
199:                    valueCount++;
200:                }
201:                assertEquals("\"preference 1\" did not have 2 values.", 2,
202:                        valueCount);
203:
204:                // Pull out our Web app and add a Description to it
205:
206:                webApp = null;
207:
208:                app = registry.getPortletApplication("App_1");
209:
210:                webApp = (WebApplicationDefinitionImpl) app
211:                        .getWebApplicationDefinition();
212:                assertNotNull("Web app was not located by query.", webApp);
213:                webApp.addDescription(Locale.getDefault(),
214:                        "Web app description");
215:
216:                webApp = null;
217:
218:                app = registry.getPortletApplication("App_1");
219:                webApp = (WebApplicationDefinitionImpl) app
220:                        .getWebApplicationDefinition();
221:
222:                assertNotNull("Web app was not located by query.", webApp);
223:                assertNotNull("Web app did NOT persist its description", webApp
224:                        .getDescription(Locale.FRENCH));
225:
226:            }
227:
228:            protected String[] getConfigurations() {
229:                return new String[] { "transaction.xml", "prefs.xml",
230:                        "registry-test.xml", "cache.xml" };
231:            }
232:
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.