Author: jfrederic.clere(a)jboss.com
Date: 2011-02-15 08:02:07 -0500 (Tue, 15 Feb 2011)
New Revision: 1662
Added:
sandbox/ajp/src/main/java/org/apache/protocol/ajp/Serv.java
Removed:
sandbox/ajp/build.xml
Modified:
sandbox/ajp/src/main/java/org/apache/protocol/ajp/SendBodyChunkMessage.java
Log:
Add a test corresponding to a commun error message.
Deleted: sandbox/ajp/build.xml
===================================================================
--- sandbox/ajp/build.xml 2011-02-14 14:03:48 UTC (rev 1661)
+++ sandbox/ajp/build.xml 2011-02-15 13:02:07 UTC (rev 1662)
@@ -1,294 +0,0 @@
-<?xml version="1.0"?>
-<!-- Build file for Apache AJP Protocol -->
-<project name="Apache AJP Protocol" default="compile"
basedir=".">
- <!-- Give user a chance to override without editing this file
- (and without typing -D each time it compiles it
- -->
- <property file="${user.home}/.ant.properties" />
- <property file="${user.home}/build.properties" />
- <property file="build.properties" />
- <property file=".ant.properties" />
-
- <!-- Initialization properties -->
- <property name="name" value="Apache AJP Protocol"/>
- <property name="title" value="Apache AJP Protocol
Library"/>
- <property name="version" value="1.4.0"/>
- <property name="version.number" value="140"/>
- <property name="project" value="ajp"/>
- <property name="build.dir" value="./dist"/>
- <property name="build.src" value="${build.dir}/src"/>
- <property name="build.dest" value="${build.dir}/bin"/>
- <property name="src.dir" value="."/>
- <property name="final.name"
value="${project}-${version}"/>
- <property name="dist.root" value="./dist"/>
- <property name="ant.home" value="."/>
-
- <property name="debug" value="off"/>
- <property name="optimize" value="on"/>
- <property name="deprecation" value="on"/>
- <property name="compile.source" value="1.4"/>
-
- <property name="docs.src" value="./xdocs"/>
- <property name="docs.dest" value="${dist.root}/doc"/>
- <property name="docs.dest.print"
value="${dist.root}/doc/printable"/>
- <property name="test.runner"
value="junit.textui.TestRunner"/>
- <property name="test.dir" value="${build.dest}/test"/>
- <property name="examples.dir"
value="${build.dest}/examples"/>
- <property name="junit.home" value="/usr/local/junit3.8"/>
- <property name="junit.jar"
value="${junit.home}/junit.jar"/>
-
- <!-- The base directory for component sources -->
- <property name="source.home"
value="classes"/>
-
- <!-- Build classpath -->
- <path id="classpath">
- <pathelement location="${build.dest}/classes"/>
- </path>
-
- <!-- Test classpath -->
- <path id="test.classpath">
- <pathelement location="${build.dest}/classes"/>
- <pathelement location="${build.dest}/test"/>
- <pathelement location="${junit.jar}"/>
- </path>
-
- <!-- Examples classpath -->
- <path id="examples.classpath">
- <pathelement location="${build.dest}/classes"/>
- <pathelement location="${build.dest}/examples"/>
- </path>
-
- <!-- =================================================================== -->
- <!-- prints the environment -->
- <!-- =================================================================== -->
- <target name="env">
- <echo message="java.home = ${java.home}"/>
- <echo message="user.home = ${user.home}"/>
- <!--
- <echo message="java.class.path = ${java.class.path}"/>
- -->
- <echo message=""/>
- </target>
-
- <target name="prepare" depends="env">
- <mkdir dir="${build.dir}"/>
- </target>
-
- <!-- =================================================================== -->
- <!-- Creates the API documentation -->
- <!-- =================================================================== -->
- <target name="javadocs" description="Java documentation">
- <mkdir dir="${docs.dest}"/>
- <mkdir dir="${docs.dest}/api"/>
- <javadoc sourcepath="${build.src}/classes"
- destdir="${docs.dest}/api"
- author="true"
- version="true"
- overview="${src.dir}/classes/overview.html"
- packagenames="org.apache.protocol.ajp.*"
- windowtitle="${title} (Version ${version})"
- doctitle="<h2>${title}</h2>"
- bottom="Copyright © 2000-2006 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.-->">
- <classpath refid="classpath"/>
- </javadoc>
- </target>
-
- <!-- =================================================================== -->
- <!-- Cleans up the build directory -->
- <!-- =================================================================== -->
- <target name="clean">
- <delete dir="${build.dir}"/>
- </target>
-
- <!-- =================================================================== -->
- <!-- Compiles the source directory -->
- <!-- =================================================================== -->
- <target name="compile" depends="prepare">
- <mkdir dir="${build.dest}"/>
- <mkdir dir="${build.dest}/classes"/>
- <mkdir dir="${build.src}"/>
- <mkdir dir="${build.src}/classes"/>
- <tstamp>
- <format property="TODAY" pattern="MMM d yyyy"
locale="en"/>
- <format property="TSTAMP" pattern="hh:mm:ss"/>
- </tstamp>
- <!-- Copy static resource files -->
- <filter token="VERSION" value="${version}"/>
- <filter token="VERSION_NUMBER"
value="${version.number}"/>
- <filter token="VERSION_BUILT" value="${TODAY}
${TSTAMP}"/>
- <copy todir="${build.src}/classes" filtering="yes">
- <fileset dir="${src.dir}/classes">
- <include name="**/*.java"/>
- <include name="**/*.xml"/>
- <include name="**/*.properties"/>
- </fileset>
- </copy>
-
- <javac srcdir="${build.src}/classes"
- destdir="${build.dest}/classes"
- debug="${debug}"
- deprecation="${deprecation}"
- failonerror="false"
- source="${compile.source}"
- optimize="${optimize}">
- <classpath refid="classpath"/>
- <compilerarg line="-Xmaxerrs 1000"/>
- </javac>
- <copy todir="${build.dest}/classes" filtering="yes">
- <fileset dir="${build.src}/classes">
- <include name="**/*.xml"/>
- <include name="**/*.properties"/>
- </fileset>
- </copy>
- </target>
-
- <target name="compile-only"
- description="Compile shareable components">
-
- <javac srcdir="${source.home}"
- destdir="${build.home}/classes"
- debug="${compile.debug}"
- deprecation="${compile.deprecation}"
- source="${compile.source}"
- optimize="${compile.optimize}">
- <classpath refid="classpath"/>
- </javac>
- <copy todir="${build.home}/classes" filtering="on">
- <fileset dir="${source.home}" excludes="**/*.java"/>
- </copy>
- </target>
-
- <!-- =================================================================== -->
- <!-- Compiles the examples directory -->
- <!-- =================================================================== -->
- <target name="examples" depends="compile">
- <mkdir dir="${build.dest}"/>
- <mkdir dir="${build.dest}/examples"/>
- <mkdir dir="${build.src}"/>
- <mkdir dir="${build.src}/examples"/>
- <tstamp>
- <format property="TODAY" pattern="MMM d yyyy"
locale="en"/>
- <format property="TSTAMP" pattern="hh:mm:ss"/>
- </tstamp>
- <!-- Copy static resource files -->
- <filter token="VERSION" value="${version}"/>
- <filter token="VERSION_NUMBER"
value="${version.number}"/>
- <filter token="VERSION_BUILT" value="${TODAY}
${TSTAMP}"/>
- <copy todir="${build.src}/examples" filtering="yes">
- <fileset dir="${src.dir}/examples">
- <include name="**/*.java"/>
- <include name="**/*.xml"/>
- <include name="**/*.properties"/>
- </fileset>
- </copy>
-
- <javac srcdir="${build.src}/examples"
- destdir="${build.dest}/examples"
- debug="${debug}"
- deprecation="${deprecation}"
- source="${compile.source}"
- optimize="${optimize}">
- <classpath refid="examples.classpath"/>
- </javac>
- <copy todir="${build.dest}/examples" filtering="yes">
- <fileset dir="${build.src}/examples">
- <include name="**/*.xml"/>
- <include name="**/*.properties"/>
- </fileset>
- </copy>
- </target>
-
- <!-- ================================================================== -->
- <!-- Make AJP jar -->
- <!-- ================================================================== -->
- <target name="jar" depends="compile"
- description="Generates the Jar file">
- <jar
- destfile="${build.dir}/${final.name}.jar"
- basedir="${build.dir}/bin/classes"
- excludes="**/*.java">
- <manifest>
- <section name="org/apache/protocol/ajp">
- <attribute name="Specification-Title" value="Apache
AJP Protocol"/>
- <attribute name="Specification-Version"
value="${version}"/>
- <attribute name="Specification-Vendor"
value="Apache Software Foundation"/>
- <attribute name="Implementation-Title"
value="org.apache.protocol.ajp"/>
- <attribute name="Implementation-Vendor"
value="Apache Software Foundation"/>
- <attribute name="Implementation-Vendor-Id"
value="org.apache"/>
- <attribute name="Implementation-Version"
value="${version} (build ${DSTAMP} ${TSTAMP})"/>
- </section>
- </manifest>
- </jar>
- </target>
-
- <!-- =================================================================== -->
- <!-- Compiles the test directory -->
- <!-- =================================================================== -->
- <target name="compile-tests" depends="compile">
- <mkdir dir="${build.dest}/test"/>
- <mkdir dir="${build.src}/test"/>
- <copy todir="${build.src}/test" filtering="yes">
- <fileset dir="${src.dir}/test">
- <include name="**/*.java"/>
- <include name="**/*.xml"/>
- <include name="**/*.properties"/>
- </fileset>
- </copy>
- <javac srcdir="${build.src}/test"
- destdir="${build.dest}/test"
- debug="${debug}"
- deprecation="${deprecation}"
- source="${compile.source}"
- optimize="${optimize}">
-
- <classpath refid="test.classpath"/>
- </javac>
- </target>
-
- <!-- =================================================================== -->
- <!-- Junit tests -->
- <!-- =================================================================== -->
- <target name="test.file" depends="compile-tests">
- <echo message="Running Tomcat Native package tests ..."/>
- <java dir="${test.dir}" classname="${test.runner}"
fork="yes" failonerror="${test.failonerror}">
- <arg value="org.jboss.clr.ObjectTestSuite"/>
- <classpath refid="test.classpath"/>
- </java>
- </target>
-
- <!-- =================================================================== -->
- <!-- Compiles the examples directory -->
- <!-- =================================================================== -->
- <target name="compile-examples" depends="compile">
- <mkdir dir="${build.dest}/examples"/>
- <mkdir dir="${build.src}/examples"/>
- <copy todir="${build.src}/examples" filtering="yes">
- <fileset dir="${src.dir}/examples">
- <include name="**/*.java"/>
- <include name="**/*.xml"/>
- <include name="**/*.properties"/>
- </fileset>
- </copy>
- <javac srcdir="${build.src}/examples"
- destdir="${build.dest}/examples"
- debug="${debug}"
- deprecation="${deprecation}"
- source="${compile.source}"
- optimize="${optimize}">
-
- <classpath refid="examples.classpath"/>
- </javac>
- </target>
-</project>
Modified: sandbox/ajp/src/main/java/org/apache/protocol/ajp/SendBodyChunkMessage.java
===================================================================
--- sandbox/ajp/src/main/java/org/apache/protocol/ajp/SendBodyChunkMessage.java 2011-02-14
14:03:48 UTC (rev 1661)
+++ sandbox/ajp/src/main/java/org/apache/protocol/ajp/SendBodyChunkMessage.java 2011-02-15
13:02:07 UTC (rev 1662)
@@ -31,6 +31,7 @@
size = data.length;
pos = len = Ajp.HEADER_LENGTH;
Encode.W(buf, 0, dir);
+ Encode.W(buf, 2, size-4);
buf[4] = Ajp.SEND_BODY_CHUNK;
}
Added: sandbox/ajp/src/main/java/org/apache/protocol/ajp/Serv.java
===================================================================
--- sandbox/ajp/src/main/java/org/apache/protocol/ajp/Serv.java
(rev 0)
+++ sandbox/ajp/src/main/java/org/apache/protocol/ajp/Serv.java 2011-02-15 13:02:07 UTC
(rev 1662)
@@ -0,0 +1,74 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+package org.apache.protocol.ajp;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/*
+ * Allow to test AJP of mod_jk/mod_proxy_ajp.
+ */
+class Serv {
+ public static void main(String[] argv) {
+ ServerSocket serverSocket = null;
+ try {
+ serverSocket = new ServerSocket(8009);
+ } catch (IOException e1) {
+ System.out.println("ServerSocket failed: " + e1);
+ System.exit(-1);
+ }
+ Socket clientSocket = null;
+
+ try {
+ clientSocket = serverSocket.accept();
+ } catch (IOException e) {
+ System.out.println("Accept failed");
+ System.exit(-1);
+ }
+ AjpMessageReader ajp = null;
+ try {
+ ajp = new AjpMessageReader(clientSocket.getInputStream());
+ } catch (IOException e) {
+ System.out.println("AjpMessageReader failed");
+ System.exit(-1);
+ } catch (Exception e) {
+ System.out.println("AjpMessageReader failed " + e);
+ System.exit(-1);
+ }
+ System.out.println(ajp.dump());
+ /* Normal behaviour
+ if (ajp.getByte() == Ajp.CPING_REQUEST) {
+ CpongMessage msg = new CpongMessage();
+ try {
+ clientSocket.getOutputStream().write(msg.buf, 0, msg.len);
+ } catch (IOException e) {
+ System.out.println("write failed: " + e);
+ }
+ }
+ */
+ if (ajp.getByte() == Ajp.CPING_REQUEST) {
+ SendBodyChunkMessage msg = new SendBodyChunkMessage("12345BAD
ME!!!".getBytes());
+ try {
+ clientSocket.getOutputStream().write(msg.buf, 0, msg.size);
+ System.out.println("sending: " + msg.len);
+ } catch (IOException e) {
+ System.out.println("write failed: " + e);
+ }
+ }
+ }
+}