Added a test responder.
authorFredrik Tolf <fredrik@dolda2000.com>
Mon, 12 Oct 2009 17:12:21 +0000 (19:12 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Mon, 12 Oct 2009 17:12:21 +0000 (19:12 +0200)
build.xml
etc/test.jsvc.properties [new file with mode: 0644]
src/dolda/jsvc/test/Bootstrap.java [new file with mode: 0644]
src/dolda/jsvc/test/TestResponder.java [new file with mode: 0644]

index 43314b9..309c9b3 100644 (file)
--- a/build.xml
+++ b/build.xml
     
    <target name="build-env">
       <mkdir dir="build" />
-      <mkdir dir="build/classes" />
+      <mkdir dir="build/bin" />
+      <mkdir dir="build/test-bin" />
     </target>
 
     <target name="jsvc" depends="build-env">
-      <javac srcdir="src" destdir="build/classes" debug="on">
+      <javac srcdir="src" destdir="build/bin" debug="on">
        <!-- <classpath refid="classpath" /> -->
         <compilerarg value="-Xlint:unchecked" />
       </javac>
-      <copy todir="build/classes/dolda/jsvc/j2ee" file="etc/web.xml.template" />
+      <copy todir="build/bin/dolda/jsvc/j2ee" file="etc/web.xml.template" />
     </target>
     
     <target name="jsvc-jar" depends="build-env, jsvc">
-        <jar destfile="build/jsvc.jar" basedir="build/classes" />
+        <jar destfile="build/jsvc.jar" basedir="build/bin" />
+    </target>
+    
+    <target name="test-jar" depends="build-env, jsvc-jar">
+      <copy tofile="build/test-bin/jsvc.properties" file="etc/test.jsvc.properties" />
+      <jar destfile="build/jsvc-test.jar" basedir="build/test-bin" />
     </target>
     
     <target name="clean">
diff --git a/etc/test.jsvc.properties b/etc/test.jsvc.properties
new file mode 100644 (file)
index 0000000..2a50054
--- /dev/null
@@ -0,0 +1,2 @@
+jsvc.j2ee.appname = JSvc Test War
+jsvc.bootstrap = dolda.jsvc.test.Bootstrap
diff --git a/src/dolda/jsvc/test/Bootstrap.java b/src/dolda/jsvc/test/Bootstrap.java
new file mode 100644 (file)
index 0000000..49abdd2
--- /dev/null
@@ -0,0 +1,9 @@
+package dolda.jsvc.test;
+
+import dolda.jsvc.*;
+
+public class Bootstrap {
+    public static Responder responder() {
+       return(new TestResponder());
+    }
+}
diff --git a/src/dolda/jsvc/test/TestResponder.java b/src/dolda/jsvc/test/TestResponder.java
new file mode 100644 (file)
index 0000000..fb83ecb
--- /dev/null
@@ -0,0 +1,27 @@
+package dolda.jsvc.test;
+
+import dolda.jsvc.*;
+import java.io.*;
+
+public class TestResponder implements Responder {
+    public void respond(Request req) {
+       req.outheaders().put("Content-Type", "text/html; charset=utf-8");
+       PrintWriter out;
+       try {
+           out = new PrintWriter(new OutputStreamWriter(req.output(), "UTF-8"));
+       } catch(UnsupportedEncodingException e) {
+           throw(new Error(e));
+       }
+       try {
+           out.println("<html>");
+           out.println("<head><title>Barda</title></head>");
+           out.println("<body>");
+           out.println("<h1>Barda</h1>");
+           out.println("Bardslen.");
+           out.println("</body>");
+           out.println("</html>");
+       } finally {
+           out.close();
+       }
+    }
+}