1   /*
2    * Copyright 2002,2004 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.commons.jelly.tags.define;
17  
18  import java.io.File;
19  import java.io.StringWriter;
20  
21  import junit.framework.Test;
22  import junit.framework.TestCase;
23  import junit.framework.TestSuite;
24  import junit.textui.TestRunner;
25  
26  import org.apache.commons.jelly.JellyContext;
27  import org.apache.commons.jelly.XMLOutput;
28  import org.apache.commons.logging.Log;
29  import org.apache.commons.logging.LogFactory;
30  
31  /*** Tests dynamic tags
32    *
33    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
34    * @version $Revision: 155420 $
35    */
36  public class TestDynamicTags extends TestCase {
37  
38      JellyContext context = new JellyContext();
39      XMLOutput output;
40  
41      /*** The Log to which logging calls will be made. */
42      private static final Log log = LogFactory.getLog(TestDynamicTags.class);
43  
44      public static void main(String[] args) {
45          TestRunner.run(suite());
46      }
47  
48      public static Test suite() {
49          return new TestSuite(TestDynamicTags.class);
50      }
51  
52      public TestDynamicTags(String testName) {
53          super(testName);
54      }
55  
56      public void testParse() throws Exception {
57          StringWriter buffer = new StringWriter();
58          output = XMLOutput.createXMLOutput(buffer);
59  
60          //runScript("src/test/org/apache/commons/jelly/define/babelfishTaglib.jelly");
61          runScript("src/test/org/apache/commons/jelly/tags/define/example.jelly");
62  
63          log.info("The output was as follows");
64          log.info(buffer.toString());
65      }
66  
67      public void testJellyBean() throws Exception {
68          StringWriter buffer = new StringWriter();
69          output = XMLOutput.createXMLOutput(buffer);
70  
71      log.warn("commented out test, need to rewrite without ant");
72          //runScript("src/test/org/apache/commons/jelly/define/jellyBeanSample.jelly");
73  
74          log.info("The output was as follows");
75          log.info(buffer.toString());
76      }
77  
78      protected void runScript(String name) throws Exception {
79          context.runScript(new File(name), output);
80      }
81  }