1 16 17 package org.apache.jetspeed.util; 18 19 import junit.awtui.TestRunner; 21 import junit.framework.Test; 22 import junit.framework.TestSuite; 23 24 import org.apache.cactus.ServletTestCase; 26 import org.apache.cactus.WebRequest; 27 import org.apache.cactus.WebResponse; 28 29 import org.apache.jetspeed.capability.CapabilityMap; 31 import org.apache.jetspeed.om.profile.Profile; 32 import org.apache.jetspeed.services.Profiler; 33 import org.apache.jetspeed.services.resources.JetspeedResources; 34 import org.apache.jetspeed.services.rundata.JetspeedRunData; 35 import org.apache.jetspeed.test.TurbineTestUtilities; 36 37 import org.apache.turbine.services.pull.TurbinePull; 40 import org.apache.turbine.services.velocity.TurbineVelocity; 41 import org.apache.turbine.util.RunData; 42 import org.apache.turbine.util.RunDataFactory; 43 44 import org.apache.velocity.context.Context; 46 47 52 53 public class TestMimeType extends ServletTestCase 54 { 55 private static final String TEST_ANON_USER_NAME = ""; 56 private static final String TEST_CONTEXT = null; 57 private static final String TEST_DEFAULT_PAGE = "default"; 58 private static final String TEST_HOST = "localhost"; 59 private static final String TEST_SERVLET = "/portal"; 60 private static final String TEST_GROUP = "apache"; 61 private static final String TEST_PAGE = "news"; 62 private static final String TEST_USER = "turbine"; 63 private static final String TEST_USER_PASSWORD = "turbine"; 64 65 private RunData rundata = null; 66 67 72 public TestMimeType(String name) 73 { 74 super(name); 75 } 76 77 82 public static void main(String args[]) 83 { 84 TestRunner.main(new String [] { TestMimeType.class.getName() }); 85 } 86 87 93 public static Test suite() 94 { 95 return new TestSuite(TestMimeType.class); 97 } 98 99 103 protected void setUp () throws Exception 104 { 105 } 106 107 114 public void 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 } 120 121 126 public void testDefaultURL() throws Exception 127 { 128 rundata = RunDataFactory.getRunData(request, response, config); 130 assertNotNull("Got rundata", rundata); 131 TurbineTestUtilities.setupRunData(rundata); 132 133 CapabilityMap cm = ((JetspeedRunData) rundata).getCapability(); 135 assertNotNull("Got Capability", cm); 136 137 Profile profile = Profiler.getProfile(rundata); 139 assertNotNull("Got profile from Profiler", profile); 140 System.out.println("DocumentName = " + profile.getDocument().getName()); 141 142 Context context = TurbineVelocity.getContext(rundata); 144 assertNotNull("Got context", context); 145 TurbinePull.populateContext(context, rundata); 146 147 assertNotNull("Got jlink from context", context.get("jlink")); 149 150 TurbineTestUtilities.generatePage(rundata); 152 assertEquals("Verifying page's character set", 153 rundata.getCharSet(), 154 JetspeedResources.getString(JetspeedResources.CONTENT_ENCODING_KEY, "utf-8")); 155 156 TurbineTestUtilities.outputPage(rundata); 157 158 RunDataFactory.putRunData(rundata); 160 } 161 162 public void endDefaultURL(WebResponse theResponse) 163 { 164 System.out.println("text length = " + theResponse.getText().length()); 165 } 166 } 167 | Popular Tags |