File: DBContextTest.java

package info (click to toggle)
velocity 1.4-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 17,900 kB
  • ctags: 9,916
  • sloc: java: 24,335; xml: 17,188; sh: 99; lisp: 53; makefile: 16
file content (60 lines) | stat: -rw-r--r-- 1,518 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.Writer;

import java.util.Hashtable;
import java.util.Vector;
import java.util.Properties;

import org.apache.velocity.Template;

import org.apache.velocity.runtime.Runtime;

/**
 *  the ultimate in silliness...
 *
 *  tests the DBContext example by putting a string and a hashtable
 *  into the context and then rendering a simple template with it.
 *
 * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
 * @version $Id: DBContextTest.java,v 1.1 2001/02/12 03:11:25 geirm Exp $
 */

public class DBContextTest
{
    public DBContextTest(String templateFile)
    {
        try
        {
            Runtime.init( new Properties() );
 
            Template template = Runtime.getTemplate(templateFile);

            DBContext dbc = new DBContext();

            Hashtable h = new Hashtable();
            h.put("Bar", "this is from a hashtable!");
       
            dbc.put( "string", "Hello!");
            dbc.put( "hashtable", h );
            
            Writer writer = new BufferedWriter(new OutputStreamWriter(System.out));
       
            template.merge(dbc, writer);

            writer.flush();
            writer.close();
        }
        catch( Exception e )
        {
            Runtime.error(e);
        }
    }

    public static void main(String[] args)
    {
        DBContextTest t;
        t = new DBContextTest(args[0]);
    }
}