1 17 18 package org.apache.commons.digester.xmlrules; 19 20 21 import junit.framework.TestCase; 22 import junit.framework.TestSuite; 23 24 25 33 public class DigesterPatternStackTest extends TestCase { 34 35 public DigesterPatternStackTest(String testName) { 36 super(testName); 37 } 38 39 public static void main(java.lang.String [] args) { 40 junit.textui.TestRunner.run(suite()); 41 } 42 43 public static junit.framework.Test suite() { 44 TestSuite suite = new TestSuite(DigesterPatternStackTest.class); 45 46 return suite; 47 } 48 49 private DigesterRuleParser.PatternStack stack; 50 51 public void setUp() { 52 DigesterRuleParser parser = new DigesterRuleParser(); 53 stack = parser.patternStack; 54 } 55 56 public void test1() throws Exception { 57 assertEquals("", stack.toString()); 58 } 59 60 public void test2() throws Exception { 61 stack.push("A"); 62 assertEquals("A", stack.toString()); 63 stack.pop(); 64 assertEquals("", stack.toString()); 65 } 66 67 public void test3() throws Exception { 68 stack.push("A"); 69 stack.push("B"); 70 assertEquals("A/B", stack.toString()); 71 72 stack.pop(); 73 assertEquals("A", stack.toString()); 74 } 75 76 public void test4() throws Exception { 77 stack.push(""); 78 assertEquals("", stack.toString()); 79 80 stack.push(""); 81 assertEquals("", stack.toString()); 82 } 83 84 public void test5() throws Exception { 85 stack.push("A"); 86 assertEquals("A", stack.toString()); 87 88 stack.push(""); 89 stack.push(""); 90 assertEquals("A", stack.toString()); 91 92 } 93 94 public void test6() throws Exception { 95 stack.push("A"); 96 stack.push("B"); 97 stack.clear(); 98 assertEquals("", stack.toString()); 99 } 100 101 public void test7() throws Exception { 102 stack.push("///"); 103 assertEquals("///", stack.toString()); 104 105 stack.push("/"); 106 assertEquals("/////", stack.toString()); 107 108 stack.pop(); 109 assertEquals("///", stack.toString()); 110 111 stack.pop(); 112 assertEquals("", stack.toString()); 113 } 114 115 } 116 | Popular Tags |