Source Code Cross Referenced for TestRegistryCache.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.Arrays;
020:        import java.util.Iterator;
021:        import java.util.Locale;
022:
023:        import javax.portlet.PortletMode;
024:
025:        import org.apache.jetspeed.components.persistence.store.LockFailedException;
026:        import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
027:        import org.apache.jetspeed.om.common.JetspeedServiceReference;
028:        import org.apache.jetspeed.om.common.UserAttribute;
029:        import org.apache.jetspeed.om.common.UserAttributeRef;
030:        import org.apache.jetspeed.om.common.portlet.ContentTypeComposite;
031:        import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
032:        import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
033:        import org.apache.jetspeed.om.common.preference.PreferenceComposite;
034:        import org.apache.jetspeed.om.impl.JetspeedServiceReferenceImpl;
035:        import org.apache.jetspeed.om.impl.UserAttributeImpl;
036:        import org.apache.jetspeed.om.impl.UserAttributeRefImpl;
037:        import org.apache.jetspeed.om.portlet.impl.ContentTypeImpl;
038:        import org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl;
039:        import org.apache.jetspeed.om.portlet.impl.PortletDefinitionImpl;
040:        import org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl;
041:        import org.apache.jetspeed.util.JetspeedLocale;
042:        import org.apache.pluto.om.common.PreferenceSetCtrl;
043:        import org.apache.pluto.om.portlet.PortletApplicationDefinition;
044:
045:        /**
046:         * <p>
047:         * TestPortletRegistryDAO
048:         * </p>
049:         * 
050:         * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
051:         * @version $Id: TestPortletRegistryDAO.java 506825 2007-02-13 02:47:07Z taylor $
052:         */
053:        public class TestRegistryCache extends DatasourceEnabledSpringTestCase {
054:            protected PortletRegistry portletRegistry;
055:
056:            /*
057:             * @see TestCase#setUp()
058:             */
059:            protected void setUp() throws Exception {
060:                super .setUp();
061:                this .portletRegistry = (PortletRegistry) ctx
062:                        .getBean("portletRegistry");
063:
064:                buildTestData();
065:
066:            }
067:
068:            // impl not complete
069:            public void xtestProxy() throws Exception {
070:                MutablePortletApplication app = portletRegistry
071:                        .getPortletApplication("PA-001");
072:                MutablePortletApplication cached = MutablePortletApplicationProxy
073:                        .createProxy(app);
074:                if (cached instanceof  MutablePortletApplication)
075:                    System.out.println("ISA Mutable");
076:                if (cached instanceof  PortletApplicationProxy)
077:                    System.out.println("ISA Mutable Proxy");
078:                PortletApplicationProxy proxy = (PortletApplicationProxy) cached;
079:                MutablePortletApplication two = proxy.getRealApplication();
080:                proxy.setRealApplication(two);
081:                System.out.println("Two is " + two);
082:                assertEquals(app, two);
083:            }
084:
085:            public void testCache() throws Exception {
086:                assertNotNull(portletRegistry);
087:                MutablePortletApplication one = portletRegistry
088:                        .getPortletApplication("PA-001");
089:                MutablePortletApplication two = portletRegistry
090:                        .getPortletApplication("PA-001");
091:                assertEquals(one, two);
092:                PortletDefinitionComposite def = portletRegistry
093:                        .getPortletDefinitionByUniqueName("PA-001::Portlet-1");
094:                assertNotNull(def);
095:                assertEquals(def.getPortletApplicationDefinition(), one);
096:                assertEquals(def, two.getPortletDefinitions().iterator().next());
097:                MutablePortletApplication o = (MutablePortletApplication) portletRegistry
098:                        .getPortletApplications().iterator().next();
099:                assertEquals(one, o);
100:                assertEquals(portletRegistry.getAllPortletDefinitions()
101:                        .iterator().next(), def);
102:            }
103:
104:            private void buildTestData() throws RegistryException,
105:                    LockFailedException {
106:                // start clean
107:                Iterator itr = portletRegistry.getPortletApplications()
108:                        .iterator();
109:                while (itr.hasNext()) {
110:                    portletRegistry
111:                            .removeApplication((PortletApplicationDefinition) itr
112:                                    .next());
113:                }
114:
115:                // Create an Application and a Web app
116:
117:                PortletApplicationDefinitionImpl app = new PortletApplicationDefinitionImpl();
118:                app.setName("PA-001");
119:                UserAttributeRef uaRef = new UserAttributeRefImpl(
120:                        "user-name-family", "user.name.family");
121:                app.addUserAttributeRef(uaRef);
122:
123:                UserAttribute ua = new UserAttributeImpl("user.name.family",
124:                        "User Last Name");
125:                app.addUserAttribute(ua);
126:
127:                JetspeedServiceReference service1 = new JetspeedServiceReferenceImpl(
128:                        "PortletEntityAccessComponent");
129:                app.addJetspeedService(service1);
130:                JetspeedServiceReference service2 = new JetspeedServiceReferenceImpl(
131:                        "PortletRegistryComponent");
132:                app.addJetspeedService(service2);
133:
134:                WebApplicationDefinitionImpl webApp = new WebApplicationDefinitionImpl();
135:                webApp.setContextRoot("/pa-001");
136:                webApp.addDescription(Locale.FRENCH,
137:                        "Description: Le fromage est dans mon pantalon!");
138:                webApp.addDisplayName(Locale.FRENCH,
139:                        "Display Name: Le fromage est dans mon pantalon!");
140:
141:                PortletDefinitionComposite portlet = new PortletDefinitionImpl();
142:                portlet.setClassName("org.apache.Portlet");
143:                portlet.setName("Portlet-1");
144:                portlet.addDescription(Locale.getDefault(),
145:                        "POrtlet description.");
146:                portlet.addDisplayName(Locale.getDefault(),
147:                        "Portlet display Name.");
148:
149:                portlet
150:                        .addInitParameter("testparam", "test value",
151:                                "This is a test portlet parameter", Locale
152:                                        .getDefault());
153:
154:                // PreferenceComposite pc = new PrefsPreference();
155:                app.addPortletDefinition(portlet);
156:
157:                PreferenceSetCtrl prefSetCtrl = (PreferenceSetCtrl) portlet
158:                        .getPreferenceSet();
159:                PreferenceComposite pc = (PreferenceComposite) prefSetCtrl.add(
160:                        "preference 1", Arrays.asList(new String[] { "value 1",
161:                                "value 2" }));
162:                pc.addDescription(JetspeedLocale.getDefaultLocale(),
163:                        "Preference Description");
164:
165:                assertNotNull(pc.getValueAt(0));
166:
167:                portlet.addLanguage(portletRegistry.createLanguage(Locale
168:                        .getDefault(), "Portlet 1", "Portlet 1",
169:                        "This is Portlet 1", null));
170:
171:                ContentTypeComposite html = new ContentTypeImpl();
172:                html.setContentType("html/text");
173:                ContentTypeComposite wml = new ContentTypeImpl();
174:                html.addPortletMode(new PortletMode("EDIT"));
175:                html.addPortletMode(new PortletMode("VIEW"));
176:                html.addPortletMode(new PortletMode("HELP"));
177:                wml.setContentType("wml");
178:                wml.addPortletMode(new PortletMode("HELP"));
179:                wml.addPortletMode(new PortletMode("VIEW"));
180:                portlet.addContentType(html);
181:                portlet.addContentType(wml);
182:
183:                app.setWebApplicationDefinition(webApp);
184:                portletRegistry.updatePortletApplication(app);
185:            }
186:
187:            /*
188:             * @see TestCase#tearDown()
189:             */
190:            protected void tearDown() throws Exception {
191:                Iterator itr = portletRegistry.getPortletApplications()
192:                        .iterator();
193:                while (itr.hasNext()) {
194:                    portletRegistry
195:                            .removeApplication((PortletApplicationDefinition) itr
196:                                    .next());
197:                }
198:            }
199:
200:            protected String[] getConfigurations() {
201:                return new String[] { "transaction.xml", "registry-test.xml",
202:                        "prefs.xml", "cache.xml" };
203:            }
204:
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.