01: /******************************************************************************
02: * JBoss, a division of Red Hat *
03: * Copyright 2006, Red Hat Middleware, LLC, and individual *
04: * contributors as indicated by the @authors tag. See the *
05: * copyright.txt in the distribution for a full listing of *
06: * individual contributors. *
07: * *
08: * This is free software; you can redistribute it and/or modify it *
09: * under the terms of the GNU Lesser General Public License as *
10: * published by the Free Software Foundation; either version 2.1 of *
11: * the License, or (at your option) any later version. *
12: * *
13: * This software is distributed in the hope that it will be useful, *
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16: * Lesser General Public License for more details. *
17: * *
18: * You should have received a copy of the GNU Lesser General Public *
19: * License along with this software; if not, write to the Free *
20: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
21: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
22: ******************************************************************************/package org.jboss.portal.test.server.response;
23:
24: import org.jboss.portal.server.ServerInvocation;
25: import org.jboss.portal.test.framework.driver.DriverCommand;
26: import org.jboss.portal.test.framework.driver.DriverResponse;
27: import org.jboss.portal.test.framework.driver.remote.TestContext;
28: import org.jboss.portal.test.framework.driver.response.EndTestResponse;
29: import org.jboss.portal.test.framework.driver.response.ErrorResponse;
30: import org.jboss.portal.test.framework.server.driver.AbstractTest;
31: import org.jboss.portal.test.server.Utils;
32:
33: import javax.servlet.http.HttpServletResponse;
34: import java.io.IOException;
35: import java.io.PrintWriter;
36:
37: /**
38: * To rewrite.
39: *
40: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
41: * @version $Revision: 8784 $
42: */
43: public class EncodeResponseTest extends AbstractTest {
44:
45: /** . */
46: private static final String content = Utils.compute(0, 10000);
47:
48: public EncodeResponseTest() {
49: super ("EncodeResponseTest", "/test");
50: }
51:
52: public DriverResponse execute(ServerInvocation invocation,
53: TestContext testContext) throws IOException {
54: if (testContext.isRequestCount(0)) {
55: HttpServletResponse resp = invocation.getServerContext()
56: .getClientResponse();
57: resp.setContentType("text/html");
58: resp.setCharacterEncoding("utf-8");
59: PrintWriter pw = resp.getWriter();
60: pw.print(content);
61: pw.close();
62: return new EndTestResponse();
63: // return new SendResponseResponse();
64: } else {
65: return new ErrorResponse();
66: }
67: }
68:
69: public DriverResponse execute(DriverCommand driverCommand,
70: TestContext testContext) throws Exception {
71: if (testContext.isRequestCount(1)) {
72: // SendResponseCommand src = (SendResponseCommand)driverCommand;
73: // byte[] bytes = src.getBytes();
74: // String s = new String(bytes, "utf-8");
75: // String result = Utils.compareString(content, s);
76: // ExtendedAssert.assertEquals(null, result);
77: return new EndTestResponse();
78: } else {
79: return new ErrorResponse();
80: }
81: }
82: }
|