1 7 package com.inversoft.verge.mvc.controller.actionflow.config.test; 8 9 10 import junit.framework.TestCase; 11 12 import com.inversoft.util.BaseException; 13 import com.inversoft.verge.mvc.controller.actionflow.config.ActionLink; 14 import com.inversoft.verge.mvc.controller.actionflow.config.BaseNamespace; 15 import com.inversoft.verge.mvc.controller.actionflow.config.BaseNode; 16 import com.inversoft.verge.mvc.controller.actionflow.config.DefaultTypes; 17 import com.inversoft.verge.mvc.controller.actionflow.config.ExceptionLink; 18 import com.inversoft.verge.mvc.controller.actionflow.config.Link; 19 import com.inversoft.verge.mvc.controller.actionflow.config.Namespace; 20 import com.inversoft.verge.mvc.controller.actionflow.config.RegexLink; 21 22 23 32 public class BaseNodeTest extends TestCase { 33 34 37 public BaseNodeTest(String name) { 38 super(name); 39 } 40 41 42 45 public void testBaseNode() { 46 47 Namespace namespace = new BaseNamespace("namespace", DefaultTypes.NAMESPACE); 49 BaseNode node = new BaseNode("one", "actionHandler", namespace, null, null, 50 false, false, null); 51 BaseNode dest = new BaseNode("two", "actionHandler", namespace, null, null, 52 false, false, null); 53 54 Link submit = new ActionLink("submit", node, dest); 55 Link cancel = new ActionLink("cancel", node, dest); 56 node.addLink(submit); 57 node.addLink(cancel); 58 59 assertTrue("Should find submit link", node.findLink("submit") == submit); 60 assertTrue("Should find cancel link", node.findLink("cancel") == cancel); 61 assertTrue("Should NOT find login link", node.findLink("login") == null); 62 63 Link regex = new RegexLink("l.*", node, dest); 64 node.addLink(regex); 65 assertTrue("Should find login link", node.findLink("login") == regex); 66 } 67 68 71 public void testExceptionLinks() { 72 73 Namespace namespace = new BaseNamespace("namespace", DefaultTypes.NAMESPACE); 75 BaseNode node = new BaseNode("one", "actionHandler", namespace, null, null, 76 false, false, null); 77 BaseNode dest = new BaseNode("two", "actionHandler", namespace, null, null, 78 false, false, null); 79 80 Link generic = new ExceptionLink(new Exception (), node, dest); 81 Link specific = new ExceptionLink(new TestException(), node, dest); 82 node.addLink(generic); 83 node.addLink(specific); 84 85 assertTrue("Should find specific link first", 86 node.findLink(new TestException()) == specific); 87 assertTrue("Should NOT find specific link for BaseException", 88 node.findLink(new BaseException()) != specific); 89 assertTrue("Should find generic link for BaseException", 90 node.findLink(new BaseException()) == generic); 91 assertTrue("Should find generic link for ClassNotFoundException", 92 node.findLink(new ClassNotFoundException ()) == generic); 93 } 94 } 95 | Popular Tags |