001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.test.theme;
023:
024: import org.jboss.mx.util.MBeanProxy;
025: import org.jboss.mx.util.MBeanServerLocator;
026: import org.jboss.portal.test.framework.TestParametrization;
027: import org.jboss.portal.test.framework.driver.TestDriverContainer;
028: import org.jboss.portal.test.framework.driver.command.StartTestCommand;
029: import org.jboss.portal.test.framework.driver.remote.RemoteTestDriver;
030: import org.jboss.portal.test.framework.driver.remote.TestContext;
031:
032: import javax.management.MBeanServer;
033: import javax.management.ObjectName;
034: import javax.servlet.ServletException;
035: import javax.servlet.http.HttpServlet;
036: import javax.servlet.http.HttpServletRequest;
037: import javax.servlet.http.HttpServletResponse;
038: import java.io.IOException;
039: import java.util.HashMap;
040:
041: /** @author <a href="mailto:roy@jboss.org">Roy Russo</a> */
042:
043: public class TestInfoServlet extends HttpServlet {
044:
045: protected void service(HttpServletRequest request,
046: HttpServletResponse response) throws ServletException,
047: IOException {
048: try {
049: proceed(request, response);
050: } catch (Exception e) {
051: throw new ServletException(e);
052: }
053: }
054:
055: public void proceed(HttpServletRequest request,
056: HttpServletResponse response) throws Exception {
057: String pathInfo = request.getPathInfo();
058:
059: //
060: MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
061: TestDriverContainer testServer = (TestDriverContainer) MBeanProxy
062: .get(TestDriverContainer.class, new ObjectName(
063: "portal.test:service=TestDriverServer"),
064: mbeanServer);
065:
066: //
067: RemoteTestDriver driver = (RemoteTestDriver) testServer
068: .getDriver(pathInfo.substring(1));
069: driver.invoke("", new StartTestCommand(
070: new TestParametrization()));
071: driver.pushContext("", new TestContext(0, null,
072: new TestParametrization(), new HashMap()));
073:
074: //
075: // //
076: // if (pathInfo.startsWith("/testsuite"))
077: // {
078: // // Get services
079: // response.setContentType("text/html");
080: // PrintWriter writer = response.getWriter();
081: //
082: // writer.println("<html>");
083: // writer.println("<body>");
084: // writer.println("<table id=\"suiteTable\" cellpadding=\"1\" cellspacing=\"1\" border=\"1\">");
085: // writer.println("<tbody>");
086: // writer.println("<tr><td><b>Test Suite </b> </td> </tr>");
087: //
088: // //
089: // for (Iterator i = suite.keySet().iterator();i.hasNext();)
090: // {
091: // String testId = (String)i.next();
092: // String url = request.getContextPath() + request.getServletPath() + "/init/" + FastURLEncoder.DEFAULT_ENCODER.encode(testId);
093: // writer.println("<tr><td><a href=\"" + url + "\">Test " + testId + "</a></td></tr>");
094: // }
095: //
096: // writer.println("</tbody>");
097: // writer.println("</table>");
098: // writer.println("</body>");
099: // writer.println("</html>");
100: // }
101: // else if (pathInfo.startsWith("/init"))
102: // {
103: // String testId = pathInfo.substring("/init/".length());
104: // DynaTest test = (DynaTest)suite.get(testId);
105: //
106: // //
107: // TestContext testContext = new TestContext(test);
108: // testContext.init();
109: //
110: // //
111: // getServletContext().setAttribute("TestContext", testContext);
112: //
113: // //
114: // if (selenium)
115: // {
116: // response.setContentType("text/html");
117: // PrintWriter writer = response.getWriter();
118: // writer.println("<html>");
119: // writer.println("<body>");
120: //
121: // writer.println("<table cellpadding=\"1\" cellspacing=\"1\" border=\"1\">");
122: // writer.println("<tbody>");
123: // writer.println("<tr><td colspan=\"3\">" + testId + "</td></tr>");
124: //
125: // writer.println("<tr><td>open</td><td>" + request.getContextPath() + request.getServletPath() + "/invoke" + "</td><td> </td></tr>");
126: //
127: //
128: // writer.println("</tbody>");
129: // writer.println("</table>");
130: //
131: // writer.println("</body>");
132: // writer.println("</html>");
133: // // testContext.userAgentCommands
134: // }
135: // else
136: // {
137: // String url = response.encodeRedirectURL(request.getContextPath() + request.getServletPath() + "/invoke");
138: // response.sendRedirect(url);
139: // }
140: // }
141: }
142: }
|