From: Jani Laakso Date: Fri, 11 Apr 2008 14:24:24 +0000 (+0000) Subject: Added StatusServlet used by Toolkit Automated Testing project. X-Git-Tag: 6.7.0.beta1~4902 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9f92df84e9f0a99fd765116522b4e5ed6722251f;p=vaadin-framework.git Added StatusServlet used by Toolkit Automated Testing project. Default session lifetime is now 20 minutes. svn changeset:4165/svn branch:trunk --- diff --git a/build/package/WebContent/WEB-INF/web.xml b/build/package/WebContent/WEB-INF/web.xml index 86ae7b7d29..686e74ddd9 100644 --- a/build/package/WebContent/WEB-INF/web.xml +++ b/build/package/WebContent/WEB-INF/web.xml @@ -11,6 +11,10 @@ IT Mill Toolkit examples + + 20 + + testingToolsActive @@ -270,7 +274,7 @@ - + TestSimplestApplication com.itmill.toolkit.terminal.gwt.server.ApplicationServlet @@ -298,6 +302,12 @@ + + StatusServlet + com.itmill.toolkit.automatedtests.util.StatusServlet + + + ITMillToolkitApplicationRunner /run/* @@ -414,7 +424,7 @@ /NotificationDemo/* - + TestSimplestApplication /TestSimplestApplication/* @@ -429,6 +439,12 @@ TestFeatureBrowser /TestFeatureBrowser/* + + + StatusServlet + /StatusServlet/* + + index.jsp diff --git a/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java b/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java new file mode 100644 index 0000000000..07493cebeb --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java @@ -0,0 +1,87 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests.util; + +import java.io.IOException; +import java.io.Writer; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class StatusServlet extends HttpServlet { + + private static final long serialVersionUID = -6764317622536660947L; + + public static DateFormat dfHuman = new SimpleDateFormat( + "yyyy-MM-dd HH:mm:ss"); + + /** + * Version number of this release. For example "5.0.0". + */ + public static final String VERSION; + + /** + * Major version number. For example 5 in 5.1.0. + */ + public static final int VERSION_MAJOR; + + /** + * Minor version number. For example 1 in 5.1.0. + */ + public static final int VERSION_MINOR; + + /** + * Builds number. For example 0-custom_tag in 5.0.0-custom_tag. + */ + public static final String VERSION_BUILD; + + /* Initialize version numbers from string replaced by build-script. */ + static { + if ("@VERSION@".equals("@" + "VERSION" + "@")) { + VERSION = "5.9.9-INTERNAL-NONVERSIONED-DEBUG-BUILD"; + } else { + VERSION = "@VERSION@"; + } + final String[] digits = VERSION.split("\\."); + VERSION_MAJOR = Integer.parseInt(digits[0]); + VERSION_MINOR = Integer.parseInt(digits[1]); + VERSION_BUILD = digits[2]; + } + + public void init(javax.servlet.ServletConfig servletConfig) + throws javax.servlet.ServletException { + super.init(servletConfig); + } + + protected void service(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + Writer w = response.getWriter(); + + // not cacheable + response.setHeader("Cache-Control", "no-cache"); + response.setHeader("Pragma", "no-cache"); + response.setDateHeader("Expires", 0); + response.setContentType("text/html"); + + String p = ""; + p += "

StatusServlet " + dfHuman.format(new Date()) + "

"; + + System.gc(); + long inUse = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime() + .freeMemory()); + p += "

Memory:
\n" + inUse + + " (Used)
\n" + "" + + Runtime.getRuntime().totalMemory() + + " (Total)
\n" + "" + + Runtime.getRuntime().freeMemory() + " (Free)

\n"; + + w.write("\n" + p + "\n"); + } +}