Source Code Cross Referenced for TestTemplateLocator.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » locator » 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.locator 
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.locator;
018:
019:        import java.util.ArrayList;
020:
021:        import junit.framework.Test;
022:        import junit.framework.TestCase;
023:        import junit.framework.TestSuite;
024:
025:        /**
026:         * TestTemplateLocator
027:         *
028:         * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
029:         * @version $Id: TestTemplateLocator.java 516448 2007-03-09 16:25:47Z ate $
030:         */
031:        public class TestTemplateLocator extends TestCase {
032:            private JetspeedTemplateLocator templateLocator;
033:
034:            public TestTemplateLocator(String name) {
035:                super (name);
036:            }
037:
038:            /**
039:             * Start the tests.
040:             *
041:             * @param args the arguments. Not used
042:             */
043:            public static void main(String args[]) {
044:                junit.awtui.TestRunner
045:                        .main(new String[] { TestTemplateLocator.class
046:                                .getName() });
047:            }
048:
049:            public static Test suite() {
050:                // All methods starting with "test" will be executed in the test suite.
051:                return new TestSuite(TestTemplateLocator.class);
052:            }
053:
054:            public void testLocateTemplate() throws Exception {
055:                // TemplateLocator component = (TemplateLocator)componentManager.getComponent("TemplateLocator");
056:                assertNotNull("template service is null", templateLocator);
057:                LocatorDescriptor locator = templateLocator
058:                        .createLocatorDescriptor("email");
059:                locator.setName("test.vm");
060:                TemplateDescriptor template = templateLocator
061:                        .locateTemplate(locator);
062:                assertNotNull("template is null", template);
063:                System.out.println("template1 = " + template);
064:                assertTrue("template1 result", "type/email/name/test.vm"
065:                        .endsWith(template.toString()));
066:
067:                LocatorDescriptor locator2 = templateLocator
068:                        .createLocatorDescriptor("email");
069:                locator2.setName("htmltest.vm");
070:                locator2.setMediaType("html");
071:                template = templateLocator.locateTemplate(locator2);
072:                assertNotNull("template is null", template);
073:                System.out.println("template2 = " + template);
074:                assertTrue("template2 result",
075:                        "type/email/media-type/html/name/htmltest.vm"
076:                                .endsWith(template.toString()));
077:
078:                LocatorDescriptor locator3 = templateLocator
079:                        .createLocatorDescriptor("email");
080:                locator3.setName("entest.vm");
081:                locator3.setMediaType("html");
082:                locator3.setLanguage("en");
083:                template = templateLocator.locateTemplate(locator3);
084:                assertNotNull("template is null", template);
085:                System.out.println("template3 = " + template);
086:                assertTrue("template3 result",
087:                        "type/email/media-type/html/language/en/name/entest.vm"
088:                                .endsWith(template.toString()));
089:
090:                LocatorDescriptor locator4 = templateLocator
091:                        .createLocatorDescriptor("email");
092:                locator4.setName("ustest.vm");
093:                locator4.setMediaType("html");
094:                locator4.setLanguage("en");
095:                locator4.setCountry("US");
096:                template = templateLocator.locateTemplate(locator4);
097:                assertNotNull("template is null", template);
098:                System.out.println("template4 = " + template);
099:                assertTrue("template4 result",
100:                        "type/email/media-type/html/language/en/country/US/name/ustest.vm"
101:                                .endsWith(template.toString()));
102:
103:                // test fallback
104:                LocatorDescriptor locator5 = templateLocator
105:                        .createLocatorDescriptor("email");
106:                locator5.setName("entest.vm");
107:                locator5.setMediaType("html");
108:                locator5.setLanguage("en");
109:                locator5.setCountry("UZ");
110:                template = templateLocator.locateTemplate(locator5);
111:                assertNotNull("template is null", template);
112:                System.out.println("template5 = " + template);
113:                assertTrue("template5 result",
114:                        "type/email/media-type/html/language/en/name/entest.vm"
115:                                .endsWith(template.toString()));
116:
117:                // test fallback all the way to email
118:                LocatorDescriptor locator6 = templateLocator
119:                        .createLocatorDescriptor("email");
120:                locator6.setName("test.vm");
121:                locator6.setMediaType("html");
122:                locator6.setLanguage("en");
123:                locator6.setCountry("UZ");
124:                template = templateLocator.locateTemplate(locator6);
125:                System.out.println("template6 = " + template);
126:                assertTrue("template6 result", "type/email/name/test.vm"
127:                        .endsWith(template.toString()));
128:
129:            }
130:
131:            /* (non-Javadoc)
132:             * @see junit.framework.TestCase#setUp()
133:             */
134:            protected void setUp() throws Exception {
135:                ArrayList roots = new ArrayList(1);
136:                roots.add("./testdata/templates");
137:                ArrayList classes = new ArrayList(2);
138:                classes.add(JetspeedTemplateDescriptor.class);
139:                classes.add(JetspeedLocatorDescriptor.class);
140:
141:                templateLocator = new JetspeedTemplateLocator(roots, classes,
142:                        "email", "./");
143:                templateLocator.start();
144:            }
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.