velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbris...@apache.org
Subject svn commit: r1298906 [14/14] - in /velocity/sandbox/velosurf: ./ docs/ examples/ examples/ant-vpp/ examples/ant-vpp/lib/ examples/auth-l10n/ examples/auth-l10n/WEB-INF/ examples/auth-l10n/WEB-INF/lib/ examples/auth-l10n/WEB-INF/src/ examples/auth-l10n/...
Date Fri, 09 Mar 2012 16:23:32 GMT
Added: velocity/sandbox/velosurf/test/jetty/etc/webdefault.xml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/jetty/etc/webdefault.xml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/jetty/etc/webdefault.xml (added)
+++ velocity/sandbox/velosurf/test/jetty/etc/webdefault.xml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,347 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- ===================================================================== -->
+<!-- This file contains the default descriptor for web applications.       -->
+<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+<!-- The intent of this descriptor is to include jetty specific or common  -->
+<!-- configuration for all webapps.   If a context has a webdefault.xml    -->
+<!-- descriptor, it is applied before the contexts own web.xml file        -->
+<!--                                                                       -->
+<!-- A context may be assigned a default descriptor by:                    -->
+<!--  + Calling WebApplicationContext.setDefaultsDescriptor                -->
+<!--  + Passed an arg to addWebApplications                                -->
+<!--                                                                       -->
+<!-- This file is used both as the resource within the jetty.jar (which is -->
+<!-- used as the default if no explicit defaults descriptor is set) and it -->
+<!-- is copied to the etc directory of the Jetty distro and explicitly     -->
+<!-- by the jetty.xml file.                                                -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+<web-app 
+   xmlns="http://java.sun.com/xml/ns/javaee" 
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
+   version="2.5"> 
+
+  <description>
+    Default web.xml file.  
+    This file is applied to a Web application before it's own WEB_INF/web.xml file
+  </description>
+
+
+  <!-- ==================================================================== -->
+  <!-- Context params to control Session Cookies                            -->
+  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
+  <!-- UNCOMMENT TO ACTIVATE
+  <context-param>
+    <param-name>org.mortbay.jetty.servlet.SessionDomain</param-name>
+    <param-value>127.0.0.1</param-value>
+  </context-param>
+
+  <context-param>
+    <param-name>org.mortbay.jetty.servlet.SessionPath</param-name>
+    <param-value>/</param-value>
+  </context-param>
+
+  <context-param>
+    <param-name>org.mortbay.jetty.servlet.MaxAge</param-name>
+    <param-value>-1</param-value>
+  </context-param>
+  -->
+
+
+
+  <!-- ==================================================================== -->
+  <!-- The default servlet.                                                 -->
+  <!-- This servlet, normally mapped to /, provides the handling for static -->
+  <!-- content, OPTIONS and TRACE methods for the context.                  -->
+  <!-- The following initParameters are supported:                          -->
+  <!--                                                                      -->
+  <!--   acceptRanges     If true, range requests and responses are         -->
+  <!--                    supported                                         -->
+  <!--                                                                      -->
+  <!--   dirAllowed       If true, directory listings are returned if no    -->
+  <!--                    welcome file is found. Else 403 Forbidden.        -->
+  <!--                                                                      -->
+  <!--   redirectWelcome  If true, redirect welcome file requests           -->
+  <!--                    else use request dispatcher forwards              -->
+  <!--                                                                      -->
+  <!--   resoureBase      Can be set to replace the context resource base   -->
+  <!--                                                                      -->
+  <!--   relativeResourceBase                                               -->
+  <!--                    Set with a pathname relative to the base of the   -->
+  <!--                    servlet context root. Useful for only serving     -->
+  <!--                    static content from only specific subdirectories. -->
+  <!--                                                                      -->
+  <!--   useFileMappedBuffer                                                -->
+  <!--                    If set to true (the default), a  memory mapped    -->
+  <!--                    file buffer will be used to serve static content  -->
+  <!--                    when using an NIO connector. Setting this value   -->
+  <!--                    to false means that a direct buffer will be used  -->
+  <!--                    instead. If you are having trouble with Windows   -->
+  <!--                    file locking, set this to false.                  -->
+  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
+  <servlet>
+    <servlet-name>default</servlet-name>
+    <servlet-class>org.mortbay.jetty.servlet.DefaultServlet</servlet-class>
+    <init-param>
+      <param-name>acceptRanges</param-name>
+      <param-value>true</param-value>
+    </init-param>
+    <init-param>
+      <param-name>dirAllowed</param-name>
+      <param-value>true</param-value>
+    </init-param>
+    <init-param>
+      <param-name>redirectWelcome</param-name>
+      <param-value>false</param-value>
+    </init-param>
+    <init-param>
+      <param-name>maxCacheSize</param-name>
+      <param-value>2000000</param-value>
+    </init-param>
+    <init-param>
+      <param-name>maxCachedFileSize</param-name>
+      <param-value>254000</param-value>
+    </init-param>
+    <init-param>
+      <param-name>maxCachedFiles</param-name>
+      <param-value>1000</param-value>
+    </init-param>
+    <init-param>
+      <param-name>useFileMappedBuffer</param-name>
+      <param-value>true</param-value>
+    </init-param>  
+    <load-on-startup>0</load-on-startup>
+  </servlet> 
+
+  <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
+  
+
+  <!-- ==================================================================== -->
+  <!-- JSP Servlet                                                          -->
+  <!-- This is the jasper JSP servlet from the jakarta project              -->
+  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
+  <!-- The JSP page compiler and execution servlet, which is the mechanism  -->
+  <!-- used by Tomcat to support JSP pages.  Traditionally, this servlet    -->
+  <!-- is mapped to URL patterh "*.jsp".  This servlet supports the         -->
+  <!-- following initialization parameters (default values are in square    -->
+  <!-- brackets):                                                           -->
+  <!--                                                                      -->
+  <!--   checkInterval       If development is false and reloading is true, -->
+  <!--                       background compiles are enabled. checkInterval -->
+  <!--                       is the time in seconds between checks to see   -->
+  <!--                       if a JSP page needs to be recompiled. [300]    -->
+  <!--                                                                      -->
+  <!--   compiler            Which compiler Ant should use to compile JSP   -->
+  <!--                       pages.  See the Ant documenation for more      -->
+  <!--                       information. [javac]                           -->
+  <!--                                                                      -->
+  <!--   classdebuginfo      Should the class file be compiled with         -->
+  <!--                       debugging information?  [true]                 -->
+  <!--                                                                      -->
+  <!--   classpath           What class path should I use while compiling   -->
+  <!--                       generated servlets?  [Created dynamically      -->
+  <!--                       based on the current web application]          -->
+  <!--                                                                      -->
+  <!--   development         Is Jasper used in development mode (will check -->
+  <!--                       for JSP modification on every access)?  [true] -->
+  <!--                                                                      -->
+  <!--   enablePooling       Determines whether tag handler pooling is      -->
+  <!--                       enabled  [true]                                -->
+  <!--                                                                      -->
+  <!--   fork                Tell Ant to fork compiles of JSP pages so that -->
+  <!--                       a separate JVM is used for JSP page compiles   -->
+  <!--                       from the one Tomcat is running in. [true]      -->
+  <!--                                                                      -->
+  <!--   ieClassId           The class-id value to be sent to Internet      -->
+  <!--                       Explorer when using <jsp:plugin> tags.         -->
+  <!--                       [clsid:8AD9C840-044E-11D1-B3E9-00805F499D93]   -->
+  <!--                                                                      -->
+  <!--   javaEncoding        Java file encoding to use for generating java  -->
+  <!--                       source files. [UTF-8]                          -->
+  <!--                                                                      -->
+  <!--   keepgenerated       Should we keep the generated Java source code  -->
+  <!--                       for each page instead of deleting it? [true]   -->
+  <!--                                                                      -->
+  <!--   logVerbosityLevel   The level of detailed messages to be produced  -->
+  <!--                       by this servlet.  Increasing levels cause the  -->
+  <!--                       generation of more messages.  Valid values are -->
+  <!--                       FATAL, ERROR, WARNING, INFORMATION, and DEBUG. -->
+  <!--                       [WARNING]                                      -->
+  <!--                                                                      -->
+  <!--   mappedfile          Should we generate static content with one     -->
+  <!--                       print statement per input line, to ease        -->
+  <!--                       debugging?  [false]                            -->
+  <!--                                                                      -->
+  <!--                                                                      -->
+  <!--   reloading           Should Jasper check for modified JSPs?  [true] -->
+  <!--                                                                      -->
+  <!--   suppressSmap        Should the generation of SMAP info for JSR45   -->
+  <!--                       debugging be suppressed?  [false]              -->
+  <!--                                                                      -->
+  <!--   dumpSmap            Should the SMAP info for JSR45 debugging be    -->
+  <!--                       dumped to a file? [false]                      -->
+  <!--                       False if suppressSmap is true                  -->
+  <!--                                                                      -->
+  <!--   scratchdir          What scratch directory should we use when      -->
+  <!--                       compiling JSP pages?  [default work directory  -->
+  <!--                       for the current web application]               -->
+  <!--                                                                      -->
+  <!--   tagpoolMaxSize      The maximum tag handler pool size  [5]         -->
+  <!--                                                                      -->
+  <!--   xpoweredBy          Determines whether X-Powered-By response       -->
+  <!--                       header is added by generated servlet  [false]  -->
+  <!--                                                                      -->
+  <!-- If you wish to use Jikes to compile JSP pages:                       -->
+  <!--   Set the init parameter "compiler" to "jikes".  Define              -->
+  <!--   the property "-Dbuild.compiler.emacs=true" when starting Jetty     -->
+  <!--   to cause Jikes to emit error messages in a format compatible with  -->
+  <!--   Jasper.                                                            -->
+  <!--   If you get an error reporting that jikes can't use UTF-8 encoding, -->
+  <!--   try setting the init parameter "javaEncoding" to "ISO-8859-1".     -->
+  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
+  <servlet id="jsp">
+    <servlet-name>jsp</servlet-name>
+    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
+    <init-param>
+        <param-name>logVerbosityLevel</param-name>
+        <param-value>DEBUG</param-value>
+    </init-param>
+    <init-param>
+        <param-name>fork</param-name>
+        <param-value>false</param-value>
+    </init-param>
+    <init-param>
+        <param-name>xpoweredBy</param-name>
+        <param-value>false</param-value>
+    </init-param>
+    <load-on-startup>0</load-on-startup>
+  </servlet>
+
+  <servlet-mapping> 
+    <servlet-name>jsp</servlet-name> 
+    <url-pattern>*.jsp</url-pattern> 
+    <url-pattern>*.jspf</url-pattern>
+    <url-pattern>*.jspx</url-pattern>
+    <url-pattern>*.xsp</url-pattern>
+    <url-pattern>*.JSP</url-pattern> 
+    <url-pattern>*.JSPF</url-pattern>
+    <url-pattern>*.JSPX</url-pattern>
+    <url-pattern>*.XSP</url-pattern>
+  </servlet-mapping>
+  <!-- ==================================================================== -->
+  <!-- Dynamic Servlet Invoker.                                             -->
+  <!-- This servlet invokes anonymous servlets that have not been defined   -->
+  <!-- in the web.xml or by other means. The first element of the pathInfo  -->
+  <!-- of a request passed to the envoker is treated as a servlet name for  -->
+  <!-- an existing servlet, or as a class name of a new servlet.            -->
+  <!-- This servlet is normally mapped to /servlet/*                        -->
+  <!-- This servlet support the following initParams:                       -->
+  <!--                                                                      -->
+  <!--  nonContextServlets       If false, the invoker can only load        -->
+  <!--                           servlets from the contexts classloader.    -->
+  <!--                           This is false by default and setting this  -->
+  <!--                           to true may have security implications.    -->
+  <!--                                                                      -->
+  <!--  verbose                  If true, log dynamic loads                 -->
+  <!--                                                                      -->
+  <!--  *                        All other parameters are copied to the     -->
+  <!--                           each dynamic servlet as init parameters    -->
+  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
+  <!-- Uncomment for dynamic invocation
+  <servlet>
+    <servlet-name>invoker</servlet-name>
+    <servlet-class>org.mortbay.jetty.servlet.Invoker</servlet-class>
+    <init-param>
+      <param-name>verbose</param-name>
+      <param-value>false</param-value>
+    </init-param>
+    <init-param>
+      <param-name>nonContextServlets</param-name>
+      <param-value>false</param-value>
+    </init-param>
+    <init-param>
+      <param-name>dynamicParam</param-name>
+      <param-value>anyValue</param-value>
+    </init-param>
+    <load-on-startup>0</load-on-startup>
+  </servlet>
+
+  <servlet-mapping> <servlet-name>invoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping>
+  -->
+
+
+
+  <!-- ==================================================================== -->
+  <session-config>
+    <session-timeout>30</session-timeout>
+  </session-config>
+
+  <!-- ==================================================================== -->
+  <!-- Default MIME mappings                                                -->
+  <!-- The default MIME mappings are provided by the mime.properties        -->
+  <!-- resource in the org.mortbay.jetty.jar file.  Additional or modified  -->
+  <!-- mappings may be specified here                                       -->
+  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
+  <!-- UNCOMMENT TO ACTIVATE
+  <mime-mapping>
+    <extension>mysuffix</extension>
+    <mime-type>mymime/type</mime-type>
+  </mime-mapping>
+  -->
+
+  <!-- ==================================================================== -->
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+    <welcome-file>index.htm</welcome-file>
+    <welcome-file>index.jsp</welcome-file>
+  </welcome-file-list>
+
+  <!-- ==================================================================== -->
+  <locale-encoding-mapping-list>
+    <locale-encoding-mapping><locale>ar</locale><encoding>ISO-8859-6</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>be</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>bg</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>ca</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>cs</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>da</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>de</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>el</locale><encoding>ISO-8859-7</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>en</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>es</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>et</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>fi</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>fr</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>hr</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>hu</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>is</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>it</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>iw</locale><encoding>ISO-8859-8</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>ja</locale><encoding>Shift_JIS</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>ko</locale><encoding>EUC-KR</encoding></locale-encoding-mapping>     
+    <locale-encoding-mapping><locale>lt</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>lv</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>mk</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>nl</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>no</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>pl</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>pt</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>ro</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>ru</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>sh</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>sk</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>sl</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>sq</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>sr</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>sv</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>tr</locale><encoding>ISO-8859-9</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>uk</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>zh</locale><encoding>GB2312</encoding></locale-encoding-mapping>
+    <locale-encoding-mapping><locale>zh_TW</locale><encoding>Big5</encoding></locale-encoding-mapping>   
+  </locale-encoding-mapping-list>
+
+  
+  
+</web-app>
+

Added: velocity/sandbox/velosurf/test/jetty/jetty.sh
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/jetty/jetty.sh?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/jetty/jetty.sh (added)
+++ velocity/sandbox/velosurf/test/jetty/jetty.sh Fri Mar  9 16:23:25 2012
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+java -Djetty.home=. -Djetty.port=8081 -jar lib/start-6.0.1.jar etc/jetty.xml

Propchange: velocity/sandbox/velosurf/test/jetty/jetty.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: velocity/sandbox/velosurf/test/jetty/src/WebappLogger.class
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/jetty/src/WebappLogger.class?rev=1298906&view=auto
==============================================================================
Binary file - no diff available.

Propchange: velocity/sandbox/velosurf/test/jetty/src/WebappLogger.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: velocity/sandbox/velosurf/test/jetty/src/WebappLogger.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/jetty/src/WebappLogger.java?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/jetty/src/WebappLogger.java (added)
+++ velocity/sandbox/velosurf/test/jetty/src/WebappLogger.java Fri Mar  9 16:23:25 2012
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2003 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.PrintWriter;
+
+import org.mortbay.log.Logger;
+import org.mortbay.util.DateCache;
+
+/** Jetty logger for our test webapp
+ *
+ *  @author <a href=mailto:claude.brisson.com>Claude Brisson</a>
+ */
+
+public class WebappLogger implements Logger {
+
+    private boolean debug = true;
+    private String name = null;
+    private DateCache _dateCache=new DateCache("yyyy-MM-dd HH:mm:ss.SSS");
+    private PrintWriter out = null;
+
+    public WebappLogger() {
+        this(null);
+    }
+
+    public WebappLogger(String name) {
+        this.name = name==null? "" : name;
+
+        String context = System.getProperty("velosurf.test.webapp.log.context","");
+        String filename = System.getProperty("velosurf.test.webapp.log.file","log/error.log");
+        String dbg = System.getProperty("velosurf.test.webapp.log.debug","off");
+        debug = (dbg.equals("on") || dbg.equals("true"));
+
+        if (context.equals(name)) {
+
+            try {
+                out = new PrintWriter(filename);
+            } catch (Exception e) {
+                System.err.println("could not log to file: "+filename);
+            }
+
+            logString("logger "+name+" initialized.");
+        } /* else out remains null */
+/*
+        else if (name==null) {
+            try {
+                out = new PrintWriter("/tmp/jetty.log");
+            } catch (Exception e) {
+                System.err.println("could not log to file: "+filename);
+            }
+            logString("logger "+name+" initialized.");
+        }
+*/
+    }
+
+    /*
+     * org.mortbay.log.Logger interface
+     */
+
+    public boolean isDebugEnabled() {
+        return debug;
+    }
+
+    public void setDebugEnabled(boolean enabled) {
+        debug = enabled;
+    }
+
+    public void info(String msg,Object arg0, Object arg1)
+    {
+        if (out == null) return;
+/* a bit of filtering */
+if (msg.startsWith("loaded class") || msg.startsWith("loaded interface")) {
+    return;
+}
+        logString(_dateCache.now()+" "+format(msg,arg0,arg1));
+    }
+
+    public void debug(String msg,Throwable th)
+    {
+        if (debug)
+        {
+            if (out == null) return;
+/* a bit of filtering */
+if (msg.startsWith("loaded class") || msg.startsWith("loaded interface")) {
+    return;
+}
+            logString(_dateCache.now()+" "+msg);
+            logStackTrace(th);
+        }
+    }
+
+    public void debug(String msg,Object arg0, Object arg1)
+    {
+        if (debug)
+        {
+            if (out == null) return;
+/* a bit of filtering */
+if (msg.startsWith("loaded class") || msg.startsWith("loaded interface")) {
+    return;
+}
+            logString(_dateCache.now()+" "+format(msg,arg0,arg1));
+        }
+    }
+
+    public void warn(String msg,Object arg0, Object arg1)
+    {
+        if (out == null) return;
+        logString(_dateCache.now()+" "+format(msg,arg0,arg1));
+    }
+
+    public void warn(String msg, Throwable th)
+    {
+        if (out == null) return;
+        logString(_dateCache.now()+" "+msg);
+        logStackTrace(th);
+    }
+
+    public Logger getLogger(String name) {
+        if ((name==null && this.name==null) ||
+            (name!=null && name.equals(this.name)))
+            return this;
+        return new WebappLogger(name);
+    }
+
+    /*
+     * private helpers
+     */
+
+    private synchronized void logString(String msg) {
+        out.println(msg);
+        out.flush();
+    }
+
+    private synchronized void logStackTrace(Throwable th) {
+        th.printStackTrace(out);
+        out.flush();
+    }
+
+    private String format(String msg, Object arg0, Object arg1)
+    {
+        int i0=msg.indexOf("{}");
+        int i1=i0<0?-1:msg.indexOf("{}",i0+2);
+
+        if (arg1!=null && i1>=0)
+            msg=msg.substring(0,i1)+arg1+msg.substring(i1+2);
+        if (arg0!=null && i0>=0)
+            msg=msg.substring(0,i0)+arg0+msg.substring(i0+2);
+        return msg;
+    }
+
+}

Added: velocity/sandbox/velosurf/test/sql/initial.sql
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/sql/initial.sql?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/sql/initial.sql (added)
+++ velocity/sandbox/velosurf/test/sql/initial.sql Fri Mar  9 16:23:25 2012
@@ -0,0 +1,81 @@
+DROP TABLE IF EXISTS empty;
+DROP TABLE IF EXISTS validation;
+DROP TABLE IF EXISTS localized;
+DROP TABLE IF EXISTS book;
+DROP TABLE IF EXISTS author;
+DROP TABLE IF EXISTS publisher;
+DROP TABLE IF EXISTS user;
+
+CREATE TABLE user (
+	id INTEGER IDENTITY NOT NULL PRIMARY KEY,
+	login VARCHAR(50) NOT NULL,
+	password VARCHAR(50) NOT NULL
+);
+
+CREATE TABLE publisher (
+	publisher_id INTEGER NOT NULL PRIMARY KEY,
+	name VARCHAR(128) NOT NULL
+);
+
+CREATE TABLE author (
+	author_id INTEGER IDENTITY,
+	first_name VARCHAR(128) NOT NULL,
+	last_name VARCHAR(128) NOT NULL
+);
+
+CREATE TABLE book (
+	book_id INTEGER NOT NULL PRIMARY KEY,
+	title VARCHAR(255) NOT NULL,
+	isbn VARCHAR(24) NOT NULL,
+	publisher_id INTEGER NOT NULL,
+	author_id INTEGER NOT NULL,
+    FOREIGN KEY(publisher_id) REFERENCES publisher(publisher_id),
+    FOREIGN KEY(author_id) REFERENCES author(author_id)
+);
+
+CREATE TABLE localized (
+  id VARCHAR(100) NOT NULL,
+  locale VARCHAR(50) NOT NULL,
+  string VARCHAR(255) default NULL,
+  PRIMARY KEY  (id,locale)
+);
+
+
+CREATE TABLE validation (
+  id INTEGER GENERATED BY DEFAULT AS IDENTITY,
+  string VARCHAR(255),
+  string2 VARCHAR(255),
+  number INTEGER,
+  oneof VARCHAR(255),
+  mydate DATE,
+  email VARCHAR(100),
+  email2 VARCHAR(100),
+  book_id INTEGER,
+  PRIMARY KEY(id),
+  FOREIGN KEY(book_id) REFERENCES book(book_id)
+);
+
+CREATE TABLE empty (
+  id INTEGER IDENTITY,
+  data VARCHAR(255)
+);
+
+INSERT INTO publisher (publisher_id,name) VALUES (1,'Addison Wesley Professional');
+
+INSERT INTO author (author_id,first_name,last_name) VALUES (1,'Joshua','Bloch');
+INSERT INTO author (author_id,first_name,last_name) VALUES (2,'W.','Stevens');
+
+INSERT INTO book (book_id,title,isbn,publisher_id,author_id) VALUES (1,'Effective Java','0-618-12902-2',1,1);
+INSERT INTO book (book_id,title,isbn,publisher_id,author_id) VALUES (2,'TCP/IP Illustrated, Volume 1','0-201-63346-9',1,2);
+
+INSERT INTO localized (id,locale,string) VALUES ('welcome','en','Hello, Dude!');
+INSERT INTO localized (id,locale,string) VALUES ('welcome','fr','Salut mon gars !');
+INSERT INTO localized (id,locale,string) VALUES ('login','en','Who are you, by the way?');
+INSERT INTO localized (id,locale,string) VALUES ('login','fr','T''es qui toi, d''abord ?');
+INSERT INTO localized (id,locale,string) VALUES ('internalError','en','Houston? We''ve got a problem here...');
+INSERT INTO localized (id,locale,string) VALUES ('internalError','fr','Houston? On a un problème...');
+INSERT INTO localized (id,locale,string) VALUES ('badLogin','en','Bad login or password...');
+INSERT INTO localized (id,locale,string) VALUES ('badLogin','fr','Mauvais login ou mot de passe...');
+
+INSERT INTO user (id,login,password) VALUES (1,'foo','bar');
+

Added: velocity/sandbox/velosurf/test/src/blackbox/BlackboxTests.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/src/blackbox/BlackboxTests.java?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/src/blackbox/BlackboxTests.java (added)
+++ velocity/sandbox/velosurf/test/src/blackbox/BlackboxTests.java Fri Mar  9 16:23:25 2012
@@ -0,0 +1,179 @@
+package blackbox;
+
+import java.io.PrintWriter;
+import java.util.Arrays;
+
+import org.junit.*;
+import static org.junit.Assert.*;
+
+import com.meterware.httpunit.*;
+
+import org.apache.velocity.velosurf.util.Logger;
+
+public class BlackboxTests
+{
+
+   /* TODO parametrize the port number with ant property ${test.webcontainer.port}
+      (requires a filtered copy of the source files) */
+   public static final int SERVER_PORT = 8081;
+
+    private void checkText(WebResponse resp,String id,String text) throws Exception {
+        HTMLElement element = resp.getElementWithID(id);
+        assertNotNull(element);
+        assertEquals(text,element.getText());
+    }
+
+    public @BeforeClass static void initLogger() throws Exception {
+        Logger.setWriter(new PrintWriter("log/blackbox.log"));
+    }
+
+	public @Test void basicTests() throws Exception {
+        WebConversation wc = new WebConversation();
+        WebRequest     req = new GetMethodWebRequest( "http://localhost:"+SERVER_PORT+"/basic.vhtml" );
+        WebResponse   resp = wc.getResponse( req );
+        checkText(resp,"test1","Addison Wesley Professional");
+        checkText(resp,"test2.1","Effective Java");
+        checkText(resp,"test2.2","TCP/IP Illustrated, Volume 1");
+        assertNull(resp.getElementWithID("test2.3"));
+        checkText(resp,"test3","Effective Java");
+        checkText(resp,"test4","Joshua Bloch");
+    }
+
+    public @Test void paramFetching() throws Exception {
+        WebConversation wc = new WebConversation();
+        WebRequest     req = new GetMethodWebRequest( "http://localhost:"+SERVER_PORT+"/obfuscate.vhtml?id=1" );
+        WebResponse   resp = wc.getResponse( req );
+        String obfId = resp.getElementWithID("obfuscated").getText();
+        req = new GetMethodWebRequest( "http://localhost:"+SERVER_PORT+"/fetch.vhtml?publisher_id="+obfId+"&book_id="+obfId);
+        resp = wc.getResponse( req );
+        checkText(resp,"publisher","Addison Wesley Professional");
+        checkText(resp,"book","Effective Java");
+    }
+
+    public @Test void authentication() throws Exception {
+        /* try to reach a protected resource */
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:"+SERVER_PORT+"/auth/protected.html");
+        WebResponse resp = wc.getResponse(req);
+        assertEquals("Login",resp.getTitle());
+        /* log in */
+        WebForm form = resp.getFormWithName("login");
+        form.setParameter("login","foo");
+        form.setParameter("password","bar");
+        resp = form.submit();
+        /* check we reach the initially requested resource */
+        assertEquals("protected",resp.getTitle());
+        /* log out */
+        WebLink logout = resp.getLinkWith("logout");
+        assertNotNull(logout);
+        resp = logout.click();
+        assertEquals("Login",resp.getTitle());
+        /* bad login */
+        form = resp.getFormWithName("login");
+        form.setParameter("login","foo");
+        form.setParameter("password","badpass");
+        resp = form.submit();
+        assertEquals("Login",resp.getTitle());
+        String msg = resp.getElementWithID("message").getText();
+        /* in english or french, may depend of the system */
+        assertTrue(Arrays.asList(new String[]{"Bad login or password.","Mauvais login ou mot de passe...","badLogin"}).contains(msg));
+        /* log in again, check we reach the auth index */
+        form = resp.getFormWithName("login");
+        form.setParameter("login","foo");
+        form.setParameter("password","bar");
+        resp = form.submit();
+        assertEquals("Protected Index",resp.getTitle());
+    }
+
+    public @Test void validation() throws Exception {
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:"+SERVER_PORT+"/input.vhtml");
+        WebResponse resp = wc.getResponse(req);
+        assertEquals("Input form",resp.getTitle());
+        /* first try with bad values */
+        WebForm form = resp.getFormWithName("input");
+        form.setParameter("string","aa");
+        form.setParameter("string2","123-1234");
+        form.setParameter("number","0");
+        form.setParameter("oneof","test0");
+        form.setParameter("mydate","2-7-2006");
+        form.setParameter("email","toto@tata@titi");
+        //form.setParameter("email2",(String)null);
+        form.setParameter("book_id","0");
+        resp = form.submit();
+        assertEquals("Input form",resp.getTitle());
+        /* check error messages */
+        checkText(resp,"1","field STRING: value [aa] is not of the proper length");
+        checkText(resp,"2","field STRING2: value [123-1234] is not valid");
+        checkText(resp,"3","field NUMBER: [0] is not in the valid range");
+        checkText(resp,"4","field ONEOF: value [test0] must be one of: test1, test2, test3");
+        // checkText(resp,"5","field MYDATE: [2-7-2006] is not a valid date or is outside range"); seems broken...
+        checkText(resp,"5","field EMAIL: [toto@tata@titi] is not a valid email");
+        checkText(resp,"6","field EMAIL2 cannot be empty");
+        checkText(resp,"7","field EMAIL2: [empty value] is not a valid email");
+        checkText(resp,"8","field BOOK_ID: value [0] not found in book.book_id");
+        assertNull(resp.getElementWithID("10"));
+        /* check that the form retained the values */
+        form = resp.getFormWithName("input");
+        assertEquals("aa",form.getParameterValue("string"));
+        assertEquals("123-1234",form.getParameterValue("string2"));
+        assertEquals("0",form.getParameterValue("number"));
+        assertEquals("test0",form.getParameterValue("oneof"));
+        assertEquals("2-7-2006",form.getParameterValue("mydate"));
+        assertEquals("toto@tata@titi",form.getParameterValue("email"));
+        assertEquals("",form.getParameterValue("email2"));
+        assertEquals("0",form.getParameterValue("book_id"));
+        /* resubmit with good values excecpt for email2*/
+        form.setParameter("string","aaaaaa");
+        form.setParameter("string2","123-123");
+        form.setParameter("number","1");
+        form.setParameter("oneof","test1");
+        form.setParameter("mydate","2-8-2006");
+        form.setParameter("email","claude@renegat.net");
+        form.setParameter("book_id","1");
+        /* test DNS email checking */
+        form.setParameter("email2","toto@azerty.blabla");
+        resp = form.submit();
+        assertEquals("Input form",resp.getTitle());
+        checkText(resp,"1","field EMAIL2: [toto@azerty.blabla] is not a valid email");
+        assertNull(resp.getElementWithID("2"));
+        /* test SMTP email checking */
+/*
+        form = resp.getFormWithName("input");
+        form.setParameter("email2","inexistant_email@gmail.com");
+        resp = form.submit();
+        assertEquals("Input form",resp.getTitle());
+        checkText(resp,"1","field email2: [inexistant_email@gmail.com] is not a valid email");
+        assertNull(resp.getElementWithID("2"));
+*/
+        /* now with a valid email... */
+        form = resp.getFormWithName("input");
+        form.setParameter("email2","claude.brisson@gmail.com");
+        resp = form.submit();
+        assertEquals("Good values!",resp.getTitle());
+    }
+
+    public @Test void testXInclude() throws Exception {
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:"+SERVER_PORT+"/xinclude.vhtml");
+        WebResponse resp = wc.getResponse(req);
+        assertEquals("XInclude",resp.getTitle());
+        checkText(resp,"result","1");
+    }
+
+    public @Test void testInsert() throws Exception {
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:"+SERVER_PORT+"/insert.vhtml");
+        WebResponse resp = wc.getResponse(req);
+        checkText(resp,"result","3");
+    }
+
+    public @Test void testParametrizedGetter() throws Exception {
+        WebConversation wc = new WebConversation();
+        WebRequest req = new GetMethodWebRequest("http://localhost:"+SERVER_PORT+"/externalparam.vhtml");
+        WebResponse resp = wc.getResponse(req);
+        checkText(resp,"test.checknbmsg","4");
+
+    }
+
+}

Added: velocity/sandbox/velosurf/test/src/whitebox/sql/WhiteboxTests.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/src/whitebox/sql/WhiteboxTests.java?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/src/whitebox/sql/WhiteboxTests.java (added)
+++ velocity/sandbox/velosurf/test/src/whitebox/sql/WhiteboxTests.java Fri Mar  9 16:23:25 2012
@@ -0,0 +1,189 @@
+package whitebox.sql;
+
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.io.PrintWriter;
+
+import org.junit.*;
+import static org.junit.Assert.*;
+
+import org.apache.velocity.velosurf.sql.Database;
+import org.apache.velocity.velosurf.sql.PooledPreparedStatement;
+import org.apache.velocity.velosurf.context.RowIterator;
+import org.apache.velocity.velosurf.context.Instance;
+import org.apache.velocity.velosurf.model.Action;
+import org.apache.velocity.velosurf.model.Entity;
+import org.apache.velocity.velosurf.model.Transaction;
+import org.apache.velocity.velosurf.model.Attribute;
+import org.apache.velocity.velosurf.util.Logger;
+import org.apache.velocity.velosurf.util.UserContext;
+
+public class WhiteboxTests
+{
+    protected static final String MODEL_FILE = "conf/model.xml";
+
+    protected static Database database = null;
+
+	public static @BeforeClass void openDatabase() throws Exception {
+        Logger.setWriter(new PrintWriter("log/whitebox.log"));
+        database = Database.getInstance(MODEL_FILE);
+    }
+
+    public @Test void testQuery() throws SQLException {
+        RowIterator iterator = database.query("select * from publisher order by publisher_id");
+        assertTrue(iterator.hasNext());
+        Object row = iterator.next();
+        assertFalse(iterator.hasNext());
+        assertNotNull(row);
+        assertTrue(row instanceof Instance);
+        Instance i = (Instance)row;
+        assertTrue(i.get("publisher_id") != null);
+        assertTrue(i.get("name") != null);
+    }
+
+    public @Test void testQuery2() throws SQLException {
+        Entity book = database.getEntity("book");
+        assertNotNull(book);
+        RowIterator iterator = book.query();
+        assertTrue(iterator.hasNext());
+        Object row = iterator.next();
+        assertNotNull(row);
+        assertTrue(row instanceof Instance);
+        Instance instance = (Instance)row;
+        assertTrue(instance.getEntity() != null);
+        assertTrue(instance.get("book_id") != null);
+        assertTrue(instance.get("title") != null);
+        assertTrue(instance.get("ref") != null);
+        assertTrue(instance.get("publisher_id") != null);
+        assertTrue(instance.get("author_id") != null);
+        assertTrue(iterator.hasNext());
+        row = iterator.next();
+        assertNotNull(row);
+        instance = (Instance)row;
+        assertTrue(instance.getEntity() != null);
+        assertTrue(instance.get("book_id") != null);
+        assertTrue(instance.get("title") != null);
+        assertTrue(instance.get("ref") != null);
+        assertTrue(instance.get("publisher_id") != null);
+        assertTrue(instance.get("author_id") != null);
+        assertFalse(iterator.hasNext());
+        row = iterator.next();
+        assertNull(row);
+    }
+
+    public @Test void testEvaluate() throws SQLException {
+        Object scalar = database.evaluate("select count(*) from publisher");
+        assertTrue(scalar instanceof Number);
+    }
+
+    public @Test void testPrepare() throws SQLException {
+        PooledPreparedStatement prep = database.prepare("select * from publisher where publisher_id=?");
+        Object result = prep.fetch(Arrays.asList(new String[] {"1"}),database.getEntity("publisher"));
+        assertTrue(result != null && result instanceof Instance);
+    }
+
+    public @Test void testEmptyTable() throws SQLException {
+        Entity empty = database.getEntity("empty");
+        assertNotNull(empty);
+        RowIterator iterator = empty.query();
+        assertFalse(iterator.hasNext());
+        Object row = iterator.next();
+        assertNull(row);
+    }
+
+    public @Test void testInsert() throws SQLException {
+        UserContext ctx = new UserContext();
+        database.setUserContext(ctx);
+        Entity user = database.getEntity("user");
+        assertNotNull(user);
+        Map<String,Object> row = new HashMap<String,Object>();
+        row.put("login","donald");
+        row.put("password","duck");
+        assertTrue(user.insert(row));
+        long id = ctx.getLastInsertedID(user);
+        assertTrue(id == 2);
+    }
+
+    public @Test void testSuccessfullTransaction() throws SQLException {
+        Entity root = database.getRootEntity();
+        Transaction transaction = new Transaction("testSuccessfullTransaction",root);
+        transaction.setQueries(
+                Arrays.asList(
+                        new String[] {
+                            "insert into publisher (publisher_id,name) values (200,'test')",
+                            "delete from publisher where publisher_id=200"
+                        }
+                )
+        );
+        List params = new ArrayList<List>();
+        params.add(new ArrayList<String>());
+        params.add(new ArrayList<String>());
+        transaction.setParamNamesLists(params);
+        transaction.perform(new HashMap<String,Object>());
+    }
+
+    public @Test(expected=SQLException.class) void testUnsuccessfullTransaction() throws SQLException {
+        try {
+            Entity root = database.getRootEntity();
+            Transaction transaction = new Transaction("testUnsuccessfullTransaction",root);
+            transaction.setQueries(
+                    Arrays.asList(
+                            new String[] {
+                                "insert into publisher (publisher_id,name) values (201,'test')",
+                                "insert into publisher (publisher_id,name) values (1,'test')",
+                            }
+                    )
+            );
+            List params = new ArrayList<List>();
+            params.add(new ArrayList<String>());
+            params.add(new ArrayList<String>());
+            transaction.setParamNamesLists(params);
+            transaction.perform(new HashMap<String,Object>());
+        } finally {
+            Instance row = database.getEntity("publisher").fetch(201);
+            assertNull(row);
+        }
+    }
+
+    public @Test void testXInclude() throws SQLException {
+        /* testing the included attribute */
+        Attribute attribute = database.getRootEntity().getAttribute("count_publishers");
+        Object result = attribute.evaluate(null);
+        assertEquals("java.lang.Long",result.getClass().getName());
+        assertEquals(1,result);
+    }
+
+    public static @AfterClass void closeDatabase() throws SQLException {
+        database.close();
+    }
+
+  public static void main(String args[])
+  {
+    try
+    {
+      Logger.log2Stderr();
+      openDatabase();
+      WhiteboxTests t = new WhiteboxTests();
+      t.testQuery();
+      t.testQuery2();
+      t.testEvaluate();
+      t.testPrepare();
+      t.testEmptyTable();
+      t.testInsert();
+      t.testSuccessfullTransaction();
+      t.testUnsuccessfullTransaction();
+      t.testXInclude();
+      closeDatabase();
+    }
+    catch(Throwable t)
+    {
+      Logger.log(t);
+    }
+  }
+
+}
+

Added: velocity/sandbox/velosurf/test/webapp/WEB-INF/db.xml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/WEB-INF/db.xml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/WEB-INF/db.xml (added)
+++ velocity/sandbox/velosurf/test/webapp/WEB-INF/db.xml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE velosurf>
+<database user="sa" password="" url="jdbc:hsqldb:hsql://127.0.0.1/test" read-only="false" loglevel="trace" reverse="full" xmlns:xi="http://www.w3.org/2001/XInclude">
+    <!-- entities -->
+
+    <entity name="publisher" obfuscate="publisher_id" autofetch="publisher_id">
+        <attribute name="books" result="rowset/book" xml:space="preserve">
+            SELECT * FROM book WHERE publisher_id=<publisher_id/>
+        </attribute>
+    </entity>
+
+    <entity name="author" obfuscate="author_id" autofetch="author_id">
+        <attribute name="books" result="rowset/book" xml:space="preserve">
+            SELECT * FROM book WHERE author_id=<author_id/>
+        </attribute>
+        <attribute name="full_name" result="scalar" xml:space="preserve">
+            SELECT CONCAT(first_name,CONCAT(' ',last_name)) FROM author WHERE author_id=<author_id/>
+        </attribute>
+    </entity>
+
+    <entity name="book" obfuscate="book_id,author_id,publisher_id" autofetch="book_id">
+        <attribute name="publisher" result="row/publisher" foreign-key="publisher_id"/>
+        <attribute name="author" result="row/author" foreign-key="author_id"/>
+    </entity>
+
+    <entity name="validation">
+        <constraint column="string" min-len="6" max-len="20"/>
+        <constraint column="string2" regex="\d{3}-\d{3}" />
+        <constraint column="number" min="1" max="10"/>
+        <constraint column="oneof" one-of="test1,test2,test3"/>
+        <constraint column="mydate" after="20060802"/>
+        <constraint column="email" type="email"/>
+        <constraint column="email2" not-empty="yes">
+          <email dns-check="yes" smtp-check="no"/>
+        </constraint>
+        <constraint column="book_id" reference="book.book_id"/>
+    </entity>
+
+    <!-- root attributes -->
+
+    <attribute name="books_nb" result="scalar">
+        select count(*) from book
+    </attribute>
+
+    <attribute name="messages" result="rowset/localized">
+      select * from localized where locale = <mylocale/>
+    </attribute>
+
+    <attribute name="user_by_login" result="row/user" xml:space="preserve">
+        select * from user where login=<login/>
+    </attribute>
+
+    <xi:include href="included.xml"/>
+
+</database>

Added: velocity/sandbox/velosurf/test/webapp/WEB-INF/included.xml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/WEB-INF/included.xml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/WEB-INF/included.xml (added)
+++ velocity/sandbox/velosurf/test/webapp/WEB-INF/included.xml Fri Mar  9 16:23:25 2012
@@ -0,0 +1 @@
+<attribute name="count_publishers" result="scalar"><xi:include href="included2.xml"/></attribute>

Added: velocity/sandbox/velosurf/test/webapp/WEB-INF/included2.xml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/WEB-INF/included2.xml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/WEB-INF/included2.xml (added)
+++ velocity/sandbox/velosurf/test/webapp/WEB-INF/included2.xml Fri Mar  9 16:23:25 2012
@@ -0,0 +1 @@
+select count(*) from publisher

Added: velocity/sandbox/velosurf/test/webapp/WEB-INF/toolbox.xml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/WEB-INF/toolbox.xml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/WEB-INF/toolbox.xml (added)
+++ velocity/sandbox/velosurf/test/webapp/WEB-INF/toolbox.xml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+
+<toolbox>
+
+  <tool>
+    <key>db</key>
+    <scope>request</scope>
+    <class>org.apache.velocity.velosurf.web.VelosurfTool</class>
+    <parameter name='config' value='/WEB-INF/db.xml'/>
+  </tool>
+
+  <tool>
+    <key>query</key>
+    <scope>request</scope>
+    <class>org.apache.velocity.velosurf.web.HttpQueryTool</class>
+  </tool>
+
+  <tool>
+    <key>logger</key>
+    <scope>application</scope>
+    <class>org.apache.velocity.velosurf.util.Logger</class>
+  </tool>
+
+  <tool>
+    <key>local</key>
+    <scope>session</scope>
+    <class>org.apache.velocity.velosurf.web.l10n.SimpleDBLocalizer</class>
+  </tool>
+
+  <tool>
+    <key>auth</key>
+    <scope>session</scope>
+    <class>org.apache.velocity.velosurf.web.auth.SimpleDBAuthenticator</class>
+    <parameter name='method' value='HmacMD5'/>
+  </tool>
+
+</toolbox>

Added: velocity/sandbox/velosurf/test/webapp/WEB-INF/velocity.properties
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/WEB-INF/velocity.properties?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/WEB-INF/velocity.properties (added)
+++ velocity/sandbox/velosurf/test/webapp/WEB-INF/velocity.properties Fri Mar  9 16:23:25 2012
@@ -0,0 +1,20 @@
+# we want stacktraces
+
+runtime.log.error.stacktrace = true
+runtime.log.warn.stacktrace = false
+runtime.log.info.stacktrace = false
+runtime.log.invalid.reference = false
+
+# we want relative resource loading
+
+eventhandler.include.class = org.apache.velocity.app.event.implement.IncludeRelativePath
+
+# VelocityViewServlet uses the WebappLoader.
+
+resource.loader = webapp
+webapp.resource.loader.class = org.apache.velocity.tools.view.servlet.WebappLoader
+webapp.resource.loader.path = /
+
+# Use the VelosurfUberspector to allow parametrized getters
+
+runtime.introspector.uberspect = org.apache.velocity.util.introspection.UberspectImpl,org.apache.velocity.velosurf.util.VelosurfUberspector

Added: velocity/sandbox/velosurf/test/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/WEB-INF/web.xml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/WEB-INF/web.xml (added)
+++ velocity/sandbox/velosurf/test/webapp/WEB-INF/web.xml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+
+   <access-log id='$app-dir/WEB-INF/log/access.log' rollover-period='1D' />
+   <log href='$app-dir/WEB-INF/log/error.log' rollover-period='1D' />
+   <classpath id='WEB-INF/classes' source='WEB-INF/src'/>
+
+  <!-- Listeners -->
+<!--
+  <listener>
+    <listener-class>SessionLogger</listener-class>
+  </listener>
+-->
+  <!-- Filters -->
+
+  <filter>
+    <filter-name>localization</filter-name>
+    <filter-class>org.apache.velocity.velosurf.web.l10n.LocalizationFilter</filter-class>
+    <init-param>
+      <param-name>supported-locales</param-name>
+      <param-value>en,fr</param-value>
+    </init-param>
+    <init-param>
+      <param-name>default-locale</param-name>
+      <param-value>en</param-value>
+    </init-param>
+    <init-param>
+      <param-name>localization-method</param-name>
+      <param-value>redirect</param-value>
+    </init-param>
+    <init-param>
+      <param-name>rewrite-uri</param-name>
+      <param-value>/localized/@/$1</param-value>
+    </init-param>
+    <init-param>
+      <param-name>inspect-uri</param-name>
+      <param-value>^/localized/(.+)(?:/|$)</param-value>
+    </init-param>
+  </filter>
+
+  <filter>
+    <filter-name>authentication</filter-name>
+    <filter-class>org.apache.velocity.velosurf.web.auth.AuthenticationFilter</filter-class>
+    <init-param>
+      <param-name>index-page</param-name>
+      <param-value>/index.vhtml</param-value>
+    </init-param>
+    <init-param>
+      <param-name>max-inactive</param-name>
+      <param-value>300</param-value>
+    </init-param>
+    <init-param>
+      <param-name>login-page</param-name>
+      <param-value>/login.vhtml</param-value>
+    </init-param>
+    <init-param>
+      <param-name>authenticated-index-page</param-name>
+      <param-value>/auth/index.vhtml</param-value>
+    </init-param>
+  </filter>
+
+  <filter>
+    <filter-name>localized-authentication</filter-name>
+    <filter-class>org.apache.velocity.velosurf.web.auth.AuthenticationFilter</filter-class>
+    <init-param>
+      <param-name>index-page</param-name>
+      <param-value>/localized/@/index.vhtml</param-value>
+    </init-param>
+    <init-param>
+      <param-name>max-inactive</param-name>
+      <param-value>20</param-value>
+    </init-param>
+    <init-param>
+      <param-name>login-page</param-name>
+      <param-value>/localized/@/login.vhtml</param-value>
+    </init-param>
+    <init-param>
+      <param-name>authenticated-index-page</param-name>
+      <param-value>localized/@/auth/index.vhtml</param-value>
+    </init-param>
+  </filter>
+
+  <filter>
+    <filter-name>validation</filter-name>
+    <filter-class>org.apache.velocity.velosurf.validation.ValidationFilter</filter-class>
+  </filter>
+
+  <!-- Filter Mapping -->
+
+  <filter-mapping>
+    <filter-name>localization</filter-name>
+    <url-pattern>/localized/*</url-pattern>
+    <dispatcher>REQUEST</dispatcher>
+    <dispatcher>FORWARD</dispatcher>
+  </filter-mapping>
+
+  <filter-mapping>
+    <filter-name>authentication</filter-name>
+    <url-pattern>/auth/*</url-pattern>
+    <url-pattern>/login.do</url-pattern>
+    <url-pattern>/logout.do</url-pattern>
+    <dispatcher>REQUEST</dispatcher>
+    <dispatcher>FORWARD</dispatcher>
+  </filter-mapping>
+
+  <filter-mapping>
+    <filter-name>localized-authentication</filter-name>
+    <url-pattern>/localized/en/auth/*</url-pattern>
+    <url-pattern>/localized/fr/auth/*</url-pattern>
+<!--    <url-pattern>/localized/*.do</url-pattern> -->
+    <dispatcher>REQUEST</dispatcher>
+    <dispatcher>FORWARD</dispatcher>
+  </filter-mapping>
+
+  <filter-mapping>
+    <filter-name>validation</filter-name>
+    <url-pattern>/*</url-pattern>
+    <dispatcher>REQUEST</dispatcher>
+    <dispatcher>FORWARD</dispatcher>
+  </filter-mapping>
+
+
+  <!-- Servlets -->
+
+  <context-param>
+    <param-name>org.apache.velocity.properties</param-name>
+    <param-value>/WEB-INF/velocity.properties</param-value>
+  </context-param>
+  <context-param>
+    <param-name>org.apache.velocity.toolbox</param-name>
+    <param-value>/WEB-INF/toolbox.xml</param-value>
+  </context-param>
+  <context-param>
+    <param-name>velosurf.config</param-name>
+    <param-value>/WEB-INF/db.xml</param-value>
+  </context-param>
+
+  <servlet>
+    <servlet-name>velocityview</servlet-name> 
+    <servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
+<!--    <servlet-class>DebugServlet</servlet-class> -->
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+
+  <!-- Servlet Mapping -->
+
+<servlet-mapping>
+  <servlet-name>velocityview</servlet-name> 
+  <url-pattern>*.vhtml</url-pattern> 
+</servlet-mapping>
+
+<welcome-file-list>
+  <welcome-file>index.vhtml</welcome-file> 
+</welcome-file-list>
+
+</web-app>

Added: velocity/sandbox/velosurf/test/webapp/auth/index.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/auth/index.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/auth/index.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/auth/index.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,11 @@
+<html>
+<head>
+<title>Protected Index</title>
+</head>
+<body>
+<div id="result">loggued</div>
+<br>
+<a href="logout.do">Logout</a>
+</body>
+</html>
+

Added: velocity/sandbox/velosurf/test/webapp/auth/protected.html
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/auth/protected.html?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/auth/protected.html (added)
+++ velocity/sandbox/velosurf/test/webapp/auth/protected.html Fri Mar  9 16:23:25 2012
@@ -0,0 +1,7 @@
+<html>
+<title>protected</title>
+<body>
+<a href="logout.do">logout</a>
+</body>
+</html>
+

Added: velocity/sandbox/velosurf/test/webapp/basic.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/basic.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/basic.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/basic.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,24 @@
+<html>
+<head><title>Basic tests</title></head>
+<body>
+Basic tests
+<br>
+Fetch a publisher by key<br>
+#set($publisher = $db.publisher.fetch($db.obfuscate(1)))
+<div id="test1">$publisher.name</div>
+<br>
+<br>
+Foreach on books:
+<ul>
+#foreach($book in $publisher.books)
+<li><div id="test2.$velocityCount">$book.title</div></li>
+#end
+</ul>
+<br>
+<br>
+Fetch a book<br>
+#set($book = $db.book.fetch($db.obfuscate(1)))
+title: <div id="test3">$book.title</div>
+<br>
+author: <div id="test4">$book.author.full_name</div>
+</body>

Added: velocity/sandbox/velosurf/test/webapp/externalparam.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/externalparam.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/externalparam.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/externalparam.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,14 @@
+<html>
+<body>
+#set($messages = $db.messages({'mylocale':'en'}).rows)
+
+All english messages:<br/>
+<ul>
+#foreach($msg in $messages)
+<li>$msg.string</li>
+#end
+</ul>
+(found <span id="test.checknbmsg">$messages.size()</span> messages)
+</body>
+</html>
+

Added: velocity/sandbox/velosurf/test/webapp/fetch.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/fetch.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/fetch.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/fetch.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,9 @@
+#set($publisher = $db.publisher.fetch("$query.publisher_id"))
+#set($book = $db.book.fetch("$query.book_id"))
+<html>
+<body>
+<div id="publisher">$publisher.name</div>
+<div id="book">$book.title</div>
+</body>
+</html>
+

Added: velocity/sandbox/velosurf/test/webapp/goodvalues.html
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/goodvalues.html?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/goodvalues.html (added)
+++ velocity/sandbox/velosurf/test/webapp/goodvalues.html Fri Mar  9 16:23:25 2012
@@ -0,0 +1,9 @@
+<html>
+<head>
+<title>Good values!</title>
+</head>
+<body>
+good values!
+</body>
+</html>
+

Added: velocity/sandbox/velosurf/test/webapp/index.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/index.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/index.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/index.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,5 @@
+<html>
+<body>
+Hello there
+</body>
+</html>

Added: velocity/sandbox/velosurf/test/webapp/input.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/input.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/input.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/input.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,29 @@
+<html>
+<head>
+<title>Input form</title>
+</head>
+<body>
+#set($errors = $db.validationErrors)
+#if($errors)
+  <font color='red'>Errors:
+  <ul>
+  #foreach($error in $errors)
+    <li><div id="$velocityCount">$error</div>
+  #end
+  </ul>
+  </font>
+#end
+<form name="input" action="goodvalues.html">
+<input type="hidden" name="velosurf.entity" value="validation">
+<input type="text" name="string" value="$!validation.string">
+<input type="text" name="string2" value="$!validation.string2">
+<input type="text" name="number" value="$!validation.number">
+<input type="text" name="oneof" value="$!validation.oneof">
+<input type="text" name="mydate" value="$!validation.mydate">
+<input type="text" name="email" value="$!validation.email">
+<input type="text" name="email2" value="$!validation.email2">
+<input type="text" name="book_id" value="$!validation.book_id">
+<input type="submit" value="Ok">
+</form>
+</body>
+</html>

Added: velocity/sandbox/velosurf/test/webapp/insert.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/insert.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/insert.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/insert.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,12 @@
+<html>
+<head>
+<title>insertion</title>
+</head>
+<body>
+#set($user = $db.user.newInstance())
+#set($user.login = "John")
+#set($user.password = "Secret")
+#set($ok = $user.insert())
+<div id="result">#if(!$ok)ERROR:$db.error#else $user.id#end</div>
+</body>
+</html>

Added: velocity/sandbox/velosurf/test/webapp/localized/en/auth/index.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/localized/en/auth/index.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/localized/en/auth/index.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/localized/en/auth/index.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,14 @@
+<html>
+<body>
+Loggued!
+
+test:<br>
+messages=<br>
+<ul>
+#foreach($msg in $db.foo)
+  <li>$msg.message
+#end
+</ul>
+</body>
+</html>
+

Added: velocity/sandbox/velosurf/test/webapp/localized/en/forbidden.html
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/localized/en/forbidden.html?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/localized/en/forbidden.html (added)
+++ velocity/sandbox/velosurf/test/webapp/localized/en/forbidden.html Fri Mar  9 16:23:25 2012
@@ -0,0 +1,9 @@
+<html>
+<head>
+<title>Error</title>
+</head>
+<body>
+<b>Forbidden: You don't have access to this page.</b>
+</body>
+</hml>
+

Added: velocity/sandbox/velosurf/test/webapp/localized/en/index.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/localized/en/index.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/localized/en/index.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/localized/en/index.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,5 @@
+<html>
+<body>
+Hello there
+</body>
+</html>

Added: velocity/sandbox/velosurf/test/webapp/localized/en/login.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/localized/en/login.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/localized/en/login.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/localized/en/login.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title>Login</title>
+#parse('login.vjs')
+</head>
+<body>
+$!loginMessage<br>
+Identification:<br>
+<form name="login" action="login.do" method=POST onSubmit="calcAnswer();">
+    Login: <input type="text" name="login" size="25" maxlength="30"><br>
+    Password: <input type="password" name="password" size="15" maxlenght="50"><br>
+    <input type="hidden" name="answer">
+    <input type="submit" value="Ok"><br>
+</form>
+</body>
+</html>
+

Added: velocity/sandbox/velosurf/test/webapp/localized/en/login.vjs
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/localized/en/login.vjs?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/localized/en/login.vjs (added)
+++ velocity/sandbox/velosurf/test/webapp/localized/en/login.vjs Fri Mar  9 16:23:25 2012
@@ -0,0 +1,28 @@
+<script type='text/javascript' src='bigint.js'></script>
+<script type="text/javascript" language="javascript">
+<!--
+	function hash(s) 
+	{
+		hash = 0;		
+		for(i=0; i<s.length; i++)
+			hash += s.charCodeAt(i) * Math.pow(31, (s.length)-(i+1));
+		return hash;
+	}
+
+    function generateAnswer(pwd)
+    {
+        var alpha = str2bigInt("$authent.challenge", 10, 0);
+        var h = str2bigInt(""+hash(pwd), 10, 0);
+        var beta = str2bigInt("$authent.prime", 10, 0);
+        var ret =  bigInt2str(powMod(alpha, h, beta), 10);
+        return ret;
+    }
+
+	function calcAnswer()
+	{
+		document.login.elements['answer'].value = generateAnswer(document.login.elements['password'].value);
+		document.login.elements['password'].value = "";
+		document.ident.submit();
+	}
+-->
+</script>

Added: velocity/sandbox/velosurf/test/webapp/localized/fr/auth/index.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/localized/fr/auth/index.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/localized/fr/auth/index.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/localized/fr/auth/index.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,9 @@
+<html>
+<body>
+loggué !
+
+<a href="logout.do">logout</a>
+
+</body>
+</html>
+

Added: velocity/sandbox/velosurf/test/webapp/localized/fr/forbidden.html
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/localized/fr/forbidden.html?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/localized/fr/forbidden.html (added)
+++ velocity/sandbox/velosurf/test/webapp/localized/fr/forbidden.html Fri Mar  9 16:23:25 2012
@@ -0,0 +1,9 @@
+<html>
+<head>
+<title>Erreur</title>
+</head>
+<body>
+<b>Vous n'avez pas accès à cette page.</b>
+</body>
+</hml>
+

Added: velocity/sandbox/velosurf/test/webapp/localized/fr/index.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/localized/fr/index.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/localized/fr/index.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/localized/fr/index.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,8 @@
+<html>
+<body>
+Salut !
+
+##parse("/foo.html")
+
+</body>
+</html>

Added: velocity/sandbox/velosurf/test/webapp/localized/fr/login.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/localized/fr/login.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/localized/fr/login.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/localized/fr/login.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title>Login</title>
+#parse('login.vjs')
+</head>
+<body>
+$!loginMessage<br>
+Identification :<br>
+<form name="login" action="login.do" method="POST" onSubmit="calcAnswer();">
+    Login : <input type="text" name="login" size="25" maxlength="30"><br>
+    Mot de passe : <input type="password" name="password" size="15" maxlenght="50"><br>
+    <input type="hidden" name="answer">
+    <input type="submit" value="Ok"><br>
+</form>
+</body>
+</html>
+

Added: velocity/sandbox/velosurf/test/webapp/localized/fr/login.vjs
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/localized/fr/login.vjs?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/localized/fr/login.vjs (added)
+++ velocity/sandbox/velosurf/test/webapp/localized/fr/login.vjs Fri Mar  9 16:23:25 2012
@@ -0,0 +1,27 @@
+<script type='text/javascript' src='bigint.js'></script>
+<script type="text/javascript" language="javascript">
+<!--
+	function hash(s) 
+	{
+		hash = 0;		
+		for(i=0; i<s.length; i++)
+			hash += s.charCodeAt(i) * Math.pow(31, (s.length)-(i+1));
+		return hash;
+	}
+
+    function generateAnswer(pwd)
+    {
+        var alpha = str2bigInt("$authent.challenge", 10, 0);
+        var h = str2bigInt(""+hash(pwd), 10, 0);
+        var beta = str2bigInt("$authent.prime", 10, 0);
+        var ret =  bigInt2str(powMod(alpha, h, beta), 10);
+        return ret;
+    }
+
+	function calcAnswer()
+	{
+		document.login.elements['answer'].value = generateAnswer(document.login.elements['password'].value);
+		document.login.elements['password'].value = "";
+	}
+-->
+</script>

Added: velocity/sandbox/velosurf/test/webapp/login.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/login.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/login.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/login.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,26 @@
+<html>
+<head>
+<title>Login</title>
+<script type="text/javascript" src="md5.js"></script>
+<script type="text/javascript">
+    function sendLogin() {
+        document.hidden.elements['login'].value = document.login.elements['login'].value;
+        document.hidden.elements['password'].value = b64_hmac_md5(document.login.elements['password'].value,'$auth.challenge');
+        document.hidden.submit();
+    }
+</script>
+</head>
+<body>
+<div id="message">$!loginMessage</div><br>
+Identification:<br>
+<form name="login" action="javascript:sendLogin()" method=POST>
+    Login: <input type="text" name="login" size=25 maxlength="30"><br>
+    Password: <input type="password" name="password" size="15" maxlenght="50"><br>
+    <input type="submit" value="Ok"><br>
+</form>
+<form name="hidden" action="login.do" method=POST>
+  <input type="hidden" name="login">
+  <input type="hidden" name="password">
+</form>
+</body>
+</html>

Added: velocity/sandbox/velosurf/test/webapp/md5.js
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/md5.js?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/md5.js (added)
+++ velocity/sandbox/velosurf/test/webapp/md5.js Fri Mar  9 16:23:25 2012
@@ -0,0 +1,256 @@
+/*
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
+ * Digest Algorithm, as defined in RFC 1321.
+ * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
+ * Distributed under the BSD License
+ * See http://pajhome.org.uk/crypt/md5 for more info.
+ */
+
+/*
+ * Configurable variables. You may need to tweak these to be compatible with
+ * the server-side, but the defaults work in most cases.
+ */
+var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
+var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
+var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */
+
+/*
+ * These are the functions you'll usually want to call
+ * They take string arguments and return either hex or base-64 encoded strings
+ */
+function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
+function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
+function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
+function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
+function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
+function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
+
+/*
+ * Perform a simple self-test to see if the VM is working
+ */
+function md5_vm_test()
+{
+  return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
+}
+
+/*
+ * Calculate the MD5 of an array of little-endian words, and a bit length
+ */
+function core_md5(x, len)
+{
+  /* append padding */
+  x[len >> 5] |= 0x80 << ((len) % 32);
+  x[(((len + 64) >>> 9) << 4) + 14] = len;
+
+  var a =  1732584193;
+  var b = -271733879;
+  var c = -1732584194;
+  var d =  271733878;
+
+  for(var i = 0; i < x.length; i += 16)
+  {
+    var olda = a;
+    var oldb = b;
+    var oldc = c;
+    var oldd = d;
+
+    a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
+    d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
+    c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
+    b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
+    a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
+    d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
+    c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
+    b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
+    a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
+    d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
+    c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
+    b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
+    a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
+    d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
+    c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
+    b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);
+
+    a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
+    d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
+    c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);
+    b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
+    a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
+    d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
+    c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
+    b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
+    a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
+    d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
+    c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
+    b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
+    a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
+    d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
+    c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
+    b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
+
+    a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
+    d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
+    c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
+    b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
+    a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
+    d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
+    c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
+    b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
+    a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
+    d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
+    c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
+    b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
+    a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
+    d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
+    c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);
+    b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
+
+    a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
+    d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
+    c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
+    b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
+    a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
+    d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
+    c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
+    b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
+    a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
+    d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
+    c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
+    b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
+    a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
+    d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
+    c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
+    b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
+
+    a = safe_add(a, olda);
+    b = safe_add(b, oldb);
+    c = safe_add(c, oldc);
+    d = safe_add(d, oldd);
+  }
+  return Array(a, b, c, d);
+
+}
+
+/*
+ * These functions implement the four basic operations the algorithm uses.
+ */
+function md5_cmn(q, a, b, x, s, t)
+{
+  return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
+}
+function md5_ff(a, b, c, d, x, s, t)
+{
+  return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
+}
+function md5_gg(a, b, c, d, x, s, t)
+{
+  return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
+}
+function md5_hh(a, b, c, d, x, s, t)
+{
+  return md5_cmn(b ^ c ^ d, a, b, x, s, t);
+}
+function md5_ii(a, b, c, d, x, s, t)
+{
+  return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
+}
+
+/*
+ * Calculate the HMAC-MD5, of a key and some data
+ */
+function core_hmac_md5(key, data)
+{
+  var bkey = str2binl(key);
+  if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
+
+  var ipad = Array(16), opad = Array(16);
+  for(var i = 0; i < 16; i++)
+  {
+    ipad[i] = bkey[i] ^ 0x36363636;
+    opad[i] = bkey[i] ^ 0x5C5C5C5C;
+  }
+
+  var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
+  return core_md5(opad.concat(hash), 512 + 128);
+}
+
+/*
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
+ * to work around bugs in some JS interpreters.
+ */
+function safe_add(x, y)
+{
+  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
+  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
+  return (msw << 16) | (lsw & 0xFFFF);
+}
+
+/*
+ * Bitwise rotate a 32-bit number to the left.
+ */
+function bit_rol(num, cnt)
+{
+  return (num << cnt) | (num >>> (32 - cnt));
+}
+
+/*
+ * Convert a string to an array of little-endian words
+ * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
+ */
+function str2binl(str)
+{
+  var bin = Array();
+  var mask = (1 << chrsz) - 1;
+  for(var i = 0; i < str.length * chrsz; i += chrsz)
+    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
+  return bin;
+}
+
+/*
+ * Convert an array of little-endian words to a string
+ */
+function binl2str(bin)
+{
+  var str = "";
+  var mask = (1 << chrsz) - 1;
+  for(var i = 0; i < bin.length * 32; i += chrsz)
+    str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
+  return str;
+}
+
+/*
+ * Convert an array of little-endian words to a hex string.
+ */
+function binl2hex(binarray)
+{
+  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
+  var str = "";
+  for(var i = 0; i < binarray.length * 4; i++)
+  {
+    str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
+           hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);
+  }
+  return str;
+}
+
+/*
+ * Convert an array of little-endian words to a base-64 string
+ */
+function binl2b64(binarray)
+{
+  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+  var str = "";
+  for(var i = 0; i < binarray.length * 4; i += 3)
+  {
+    var triplet = (((binarray[i   >> 2] >> 8 * ( i   %4)) & 0xFF) << 16)
+                | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
+                |  ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
+    for(var j = 0; j < 4; j++)
+    {
+      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
+      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
+    }
+  }
+  return str;
+}

Added: velocity/sandbox/velosurf/test/webapp/obfuscate.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/obfuscate.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/obfuscate.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/obfuscate.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,5 @@
+<html>
+<body>
+<div id="obfuscated">$db.obfuscate($query.id)</div>
+</body>
+</html>

Added: velocity/sandbox/velosurf/test/webapp/test.html
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/test.html?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/test.html (added)
+++ velocity/sandbox/velosurf/test/webapp/test.html Fri Mar  9 16:23:25 2012
@@ -0,0 +1 @@
+hello

Added: velocity/sandbox/velosurf/test/webapp/xinclude.vhtml
URL: http://svn.apache.org/viewvc/velocity/sandbox/velosurf/test/webapp/xinclude.vhtml?rev=1298906&view=auto
==============================================================================
--- velocity/sandbox/velosurf/test/webapp/xinclude.vhtml (added)
+++ velocity/sandbox/velosurf/test/webapp/xinclude.vhtml Fri Mar  9 16:23:25 2012
@@ -0,0 +1,6 @@
+<html>
+<head><title>XInclude</title></head>
+<body>
+<div id="result">$db.count_publishers</div>
+</body>
+</html>



Mime
View raw message