jon 00/11/03 20:58:52
Modified: src/java/org/apache/velocity/test/misc Test.java
Log:
updated to latest JSP writer stuff
Revision Changes Path
1.4 +45 -8
jakarta-velocity/src/java/org/apache/velocity/test/misc/Test.java
Index: Test.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/test/misc/Test.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Test.java 2000/11/04 02:41:57 1.3
+++ Test.java 2000/11/04 04:58:52 1.4
@@ -56,8 +56,7 @@
import java.io.*;
-import java.util.ArrayList;
-import java.util.Hashtable;
+import java.util.*;
import org.apache.velocity.Context;
import org.apache.velocity.Template;
@@ -71,13 +70,19 @@
* test all the directives support by Velocity.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Test.java,v 1.3 2000/11/04 02:41:57 jvanzyl Exp $
+ * @version $Id: Test.java,v 1.4 2000/11/04 04:58:52 jon Exp $
*/
public class Test
{
+ /**
+ * Cache of writers
+ */
+ private static Stack writerStack = new Stack();
+
public Test(String templateFile)
{
- Writer writer = null;
+// Writer writer = null;
+ JspWriterImpl vw = null;
TestProvider provider = new TestProvider();
ArrayList al = provider.getCustomers();
Hashtable h = new Hashtable();
@@ -103,24 +108,56 @@
context.put("menu", provider.getMenu());
context.put("stringarray", provider.getArray());
- writer = new BufferedWriter(new OutputStreamWriter(System.out));
- template.merge(context, writer);
+// writer = new BufferedWriter(new OutputStreamWriter(System.out));
+// template.merge(context, writer);
+ try
+ {
+ vw = (JspWriterImpl) writerStack.pop();
+ }
+ catch (Exception e)
+ {
+ }
+ if (vw == null)
+ vw = new JspWriterImpl(new OutputStreamWriter(System.out), 4*1024,
true);
+ else
+ vw.recycle(new OutputStreamWriter(System.out));
+ template.merge(context, vw);
+ writerStack.push(vw);
- writer.flush();
- writer.close();
}
catch( Exception e )
{
Runtime.error(e);
}
+ finally
+ {
+ try
+ {
+ if (vw != null)
+ {
+ vw.flush();
+ }
+ }
+ catch (Exception e)
+ {
+ // do nothing
+ }
+ }
}
public static void main(String[] args)
{
Test t;
+ /*
if (args.length > 0)
t = new Test(args[0]);
else
t = new Test(null);
+*/
+ t = new Test(null);
+ t = new Test(null);
+ t = new Test(null);
+ t = new Test(null);
+
}
}