This project has retired. For details please refer to its
Attic page.
TestMimeType xref
1/*2 * Copyright 2000-2001,2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.util;
1819// Junit imports20import junit.awtui.TestRunner;
21import junit.framework.Test;
22import junit.framework.TestSuite;
2324// Cactus imports25import org.apache.cactus.ServletTestCase;
26import org.apache.cactus.WebRequest;
27import org.apache.cactus.WebResponse;
2829// Jetspeed imports30import org.apache.jetspeed.capability.CapabilityMap;
31import org.apache.jetspeed.om.profile.Profile;
32import org.apache.jetspeed.services.Profiler;
33import org.apache.jetspeed.services.resources.JetspeedResources;
34import org.apache.jetspeed.services.rundata.JetspeedRunData;
35import org.apache.jetspeed.test.TurbineTestUtilities;
3637// Turbine imports38//import org.apache.turbine.om.security.User;39import org.apache.turbine.services.pull.TurbinePull;
40import org.apache.turbine.services.velocity.TurbineVelocity;
41import org.apache.turbine.util.RunData;
42import org.apache.turbine.util.RunDataFactory;
4344// Velocity45import org.apache.velocity.context.Context;
4647/***48 *49 * @author <a href="paulsp@apache.org">Paul Spencer</a>50 * @version $Id: TestMimeType.java,v 1.1 2004/04/07 22:02:42 jford Exp $51 */5253publicclassTestMimeTypeextends ServletTestCase
54 {
55privatestaticfinal String TEST_ANON_USER_NAME = "";
56privatestaticfinal String TEST_CONTEXT = null;
57privatestaticfinal String TEST_DEFAULT_PAGE = "default";
58privatestaticfinal String TEST_HOST = "localhost";
59privatestaticfinal String TEST_SERVLET = "/portal";
60privatestaticfinal String TEST_GROUP = "apache";
61privatestaticfinal String TEST_PAGE = "news";
62privatestaticfinal String TEST_USER = "turbine";
63privatestaticfinal String TEST_USER_PASSWORD = "turbine";
6465private RunData rundata = null;
6667/***68 * Defines the testcase name for JUnit.69 *70 * @param name the testcase's name.71 */72publicTestMimeType(String name)
73 {
74super(name);
75 }
7677/***78 * Start the tests.79 *80 * @param args the arguments. Not used81 */82publicstaticvoid main(String args[])
83 {
84 TestRunner.main(new String[] { TestMimeType.class.getName() });
85 }
8687/***88 * Creates the test suite.89 *90 * @return a test suite (<code>TestSuite</code>) that includes all methods91 * starting with "test"92 */93publicstatic Test suite()
94 {
95// All methods starting with "test" will be executed in the test suite.96returnnew TestSuite(TestMimeType.class);
97 }
9899/***100 * Sets up the test case.101 *102 */103protectedvoid setUp () throws Exception
104 {
105 }
106107/***108 * Test: DefaultURL109 * With the default URL "/"110 * 1) A page is generated 111 * 2) The user is anonymous112 * 3) Group and Role are not set113 */114publicvoid beginDefaultURL(WebRequest theRequest)
115 {
116 System.out.println("URL = " + theRequest.getURL());
117 theRequest.setURL(TEST_HOST, TEST_CONTEXT, TEST_SERVLET, "", null);
118 System.out.println("post set URL = " + theRequest.getURL());
119 }
120121/***122 * Execute the test123 *124 * @throws Exception125 */126publicvoid testDefaultURL() throws Exception
127 {
128// Create the RunData object to be used during testing. 129 rundata = RunDataFactory.getRunData(request, response, config);
130 assertNotNull("Got rundata", rundata);
131 TurbineTestUtilities.setupRunData(rundata);
132133// Verify we have a CapabilityMap134 CapabilityMap cm = ((JetspeedRunData) rundata).getCapability();
135 assertNotNull("Got Capability", cm);
136137// Verify we have a profile138 Profile profile = Profiler.getProfile(rundata);
139 assertNotNull("Got profile from Profiler", profile);
140 System.out.println("DocumentName = " + profile.getDocument().getName());
141142// Get and populate the context143 Context context = TurbineVelocity.getContext(rundata);
144 assertNotNull("Got context", context);
145 TurbinePull.populateContext(context, rundata);
146147// Verify tool are in the context148 assertNotNull("Got jlink from context", context.get("jlink"));
149150// Generatate and output thre page151 TurbineTestUtilities.generatePage(rundata);
152 assertEquals("Verifying page's character set",
153 rundata.getCharSet(),
154 JetspeedResources.getString(JetspeedResources.CONTENT_ENCODING_KEY, "utf-8"));
155156 TurbineTestUtilities.outputPage(rundata);
157158// Return the used RunData to the factory for recycling.159 RunDataFactory.putRunData(rundata);
160 }
161162publicvoid endDefaultURL(WebResponse theResponse)
163 {
164 System.out.println("text length = " + theResponse.getText().length());
165 }
166 }