01: /*
02: * Copyright 2007 Gerd Ziegler (www.gerdziegler.de)
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: * http://www.apache.org/licenses/LICENSE-2.0
07: * Unless required by applicable law or agreed to in writing,
08: * software distributed under the License is distributed on an
09: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
10: * either express or implied. See the License for the specific
11: * language governing permissions and limitations under the License.
12: * 20.09.2007
13: * @author www.gerdziegler.de
14: */
15: package org.ztemplates.test.actions.urlhandler.match.test1;
16:
17: import java.util.List;
18:
19: import junit.framework.TestCase;
20:
21: import org.apache.log4j.Logger;
22: import org.ztemplates.actions.urlhandler.tree.match.ZMatchTree;
23: import org.ztemplates.actions.urlhandler.tree.match.ZMatchTreeNode;
24: import org.ztemplates.actions.urlhandler.tree.term.ZTreeTermFactory;
25: import org.ztemplates.actions.urlhandler.tree.term.ZTreeTermList;
26: import org.ztemplates.classpath.ZClassRepository;
27: import org.ztemplates.classpath.ZIClassRepository;
28:
29: public class TreeTest extends TestCase {
30: static Logger log = Logger.getLogger(TreeTest.class);
31:
32: ZIClassRepository classRepo;
33:
34: protected void setUp() throws Exception {
35: super .setUp();
36: classRepo = new ZClassRepository(TreeTest.class.getPackage()
37: .getName());
38: }
39:
40: protected void tearDown() throws Exception {
41: classRepo = null;
42: super .tearDown();
43: }
44:
45: public void test1() throws Exception {
46: List<ZTreeTermList> l = ZTreeTermFactory.expand(classRepo,
47: Handler1.class);
48: log.info(l);
49: assertEquals(1, l.size());
50: }
51:
52: public void testParseTree() throws Exception {
53: ZMatchTree tree = new ZMatchTree(classRepo);
54: List<ZMatchTreeNode> roots = tree.getRoots();
55: System.out.println(tree.toConsoleString());
56: assertNotNull(tree.toConsoleString(), roots.get(0)
57: .getChildren().get(0).getHandler());
58: }
59: }
|