]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added StatusServlet used by Toolkit Automated Testing project.
authorJani Laakso <jani.laakso@itmill.com>
Fri, 11 Apr 2008 14:24:24 +0000 (14:24 +0000)
committerJani Laakso <jani.laakso@itmill.com>
Fri, 11 Apr 2008 14:24:24 +0000 (14:24 +0000)
Default session lifetime is now 20 minutes.

svn changeset:4165/svn branch:trunk

build/package/WebContent/WEB-INF/web.xml
src/com/itmill/toolkit/automatedtests/util/StatusServlet.java [new file with mode: 0644]

index 86ae7b7d2919a09a2b9dd90aa8a2d22c4541143a..686e74ddd9407d9fd891f7e66ecdac92cced1ffa 100644 (file)
      IT Mill Toolkit examples
   </description>
   
+  <session-config>
+    <session-timeout>20</session-timeout>
+  </session-config>
+  
   <!-- Permit use of IT Mill Testing Tools for this servlet container -->
   <context-param>
        <param-name>testingToolsActive</param-name>
     </init-param>
   </servlet>
   
-   <!-- Automated tests used by Testing Tools plug-in client -->
+   <!-- Section begins: Automated tests used by Testing Tools plug-in client -->
    <servlet>
     <servlet-name>TestSimplestApplication</servlet-name>
     <servlet-class>com.itmill.toolkit.terminal.gwt.server.ApplicationServlet</servlet-class>
     </init-param>
   </servlet>
   
+  <servlet>
+    <servlet-name>StatusServlet</servlet-name>
+    <servlet-class>com.itmill.toolkit.automatedtests.util.StatusServlet</servlet-class>
+  </servlet>
+  <!-- Section ends: Automated tests used by Testing Tools plug-in client -->
+  
   <servlet-mapping>
     <servlet-name>ITMillToolkitApplicationRunner</servlet-name>
     <url-pattern>/run/*</url-pattern>
     <url-pattern>/NotificationDemo/*</url-pattern>
   </servlet-mapping>
   
-  <!-- Automated tests used by Testing Tools plug-in client -->
+  <!-- Section begins: Automated tests used by Testing Tools plug-in client -->
     <servlet-mapping>
     <servlet-name>TestSimplestApplication</servlet-name>
     <url-pattern>/TestSimplestApplication/*</url-pattern>
     <servlet-name>TestFeatureBrowser</servlet-name>
     <url-pattern>/TestFeatureBrowser/*</url-pattern>
   </servlet-mapping>
+  
+  <servlet-mapping>
+    <servlet-name>StatusServlet</servlet-name>
+    <url-pattern>/StatusServlet/*</url-pattern>
+  </servlet-mapping>
+  <!-- Section ends: Automated tests used by Testing Tools plug-in client -->
 
   <welcome-file-list>
     <welcome-file>index.jsp</welcome-file>
diff --git a/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java b/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java
new file mode 100644 (file)
index 0000000..07493ce
--- /dev/null
@@ -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 += "<p>StatusServlet " + dfHuman.format(new Date()) + "</p>";
+
+        System.gc();
+        long inUse = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime()
+                .freeMemory());
+        p += "<p>Memory:<br />\n<memused>" + inUse
+                + "</memused> (Used)<br />\n" + "<memtotal>"
+                + Runtime.getRuntime().totalMemory()
+                + "<memtotal> (Total)<br />\n" + "<memfree>"
+                + Runtime.getRuntime().freeMemory() + "<memfree> (Free)</p>\n";
+
+        w.write("<html>\n" + p + "</html>\n");
+    }
+}