From 00013ab771bb86a62e6f2fc1f4304755d96c75c1 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Mon, 12 Oct 2009 19:12:21 +0200 Subject: [PATCH] Added a test responder. --- build.xml | 14 ++++++++++---- etc/test.jsvc.properties | 2 ++ src/dolda/jsvc/test/Bootstrap.java | 9 +++++++++ src/dolda/jsvc/test/TestResponder.java | 27 +++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 etc/test.jsvc.properties create mode 100644 src/dolda/jsvc/test/Bootstrap.java create mode 100644 src/dolda/jsvc/test/TestResponder.java diff --git a/build.xml b/build.xml index 43314b9..309c9b3 100644 --- a/build.xml +++ b/build.xml @@ -12,19 +12,25 @@ - + + - + - + - + + + + + + diff --git a/etc/test.jsvc.properties b/etc/test.jsvc.properties new file mode 100644 index 0000000..2a50054 --- /dev/null +++ b/etc/test.jsvc.properties @@ -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 index 0000000..49abdd2 --- /dev/null +++ b/src/dolda/jsvc/test/Bootstrap.java @@ -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 index 0000000..fb83ecb --- /dev/null +++ b/src/dolda/jsvc/test/TestResponder.java @@ -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(""); + out.println("Barda"); + out.println(""); + out.println("

Barda

"); + out.println("Bardslen."); + out.println(""); + out.println(""); + } finally { + out.close(); + } + } +} -- 2.11.0