1 package org.apache.axis2.phaserule; 2 3 import org.apache.axis2.AbstractTestCase; 4 import org.apache.axis2.description.HandlerDescription; 5 import org.apache.axis2.description.PhaseRule; 6 import org.apache.axis2.engine.AxisConfiguration; 7 import org.apache.axis2.engine.AxisConfigurationImpl; 8 import org.apache.axis2.engine.Handler; 9 import org.apache.axis2.phaseresolver.PhaseHolder; 10 11 import javax.xml.namespace.QName ; 12 import java.util.ArrayList ; 13 14 31 32 37 public class PreDispatchPhaseRuleTest extends AbstractTestCase{ 38 39 PreDispatchPhaseRuleTest phaserul; 40 AxisConfiguration axisSytem; 41 42 public PreDispatchPhaseRuleTest(String testName) { 43 super(testName); 44 } 45 46 public void testPhaseRule() throws Exception { 47 phaserul = new PreDispatchPhaseRuleTest(""); 49 axisSytem = new AxisConfigurationImpl(); 50 ArrayList inPhase = axisSytem.getInPhasesUptoAndIncludingPostDispatch(); 51 52 Handler han = null; 53 PhaseHolder ph = new PhaseHolder(inPhase); 54 55 56 HandlerDescription pre = new HandlerDescription(); 57 pre.setClassName("org.apache.axis2.handlers.AbstractHandler"); 58 Handler h1 = new PhaseRuleHandlers(); 59 h1.init(pre); 60 pre.setHandler(h1); 61 pre.setName(new QName ("pre-H1")); 62 PhaseRule pre_rule1 = new PhaseRule(); 63 pre_rule1.setPhaseName("PreDispatch"); 64 pre.setRules(pre_rule1); 65 ph.addHandler(pre); 66 67 HandlerDescription pre2 = new HandlerDescription(); 68 pre2.setClassName("org.apache.axis2.handlers.AbstractHandler"); 69 Handler h2 = new PhaseRuleHandlers(); 70 h2.init(pre2); 71 pre2.setHandler(h2); 72 pre2.setName(new QName ("dispatch")); 73 PhaseRule prerule2 = new PhaseRule(); 74 prerule2.setPhaseName("Dispatch"); 75 pre2.setRules(prerule2); 76 ph.addHandler(pre2); 77 78 79 HandlerDescription hm = new HandlerDescription(); 80 hm.setClassName("org.apache.axis2.handlers.AbstractHandler"); 81 Handler h3 = new PhaseRuleHandlers(); 82 h3.init(hm); 83 hm.setHandler(h3); 84 hm.setName(new QName ("pre-H2")); 85 PhaseRule rule = new PhaseRule(); 86 rule.setPhaseName("PreDispatch"); 87 rule.setPhaseFirst(true); 88 hm.setRules(rule); 89 ph.addHandler(hm); 90 91 HandlerDescription hm1 = new HandlerDescription(); 92 hm1.setClassName("org.apache.axis2.handlers.AbstractHandler"); 93 Handler h4 = new PhaseRuleHandlers(); 94 h4.init(hm1); 95 hm1.setHandler(h4); 96 hm1.setName(new QName ("pre-H3")); 97 PhaseRule rule1 = new PhaseRule(); 98 rule1.setPhaseName("PreDispatch"); 99 rule1.setAfter("pre-H2"); 100 hm1.setRules(rule1); 101 ph.addHandler(hm1); 102 103 HandlerDescription hm2 = new HandlerDescription(); 104 hm2.setClassName("org.apache.axis2.handlers.AbstractHandler"); 105 Handler h5 = new PhaseRuleHandlers(); 106 h5.init(hm2); 107 hm2.setHandler(h5); 108 hm2.setName(new QName ("H3")); 109 PhaseRule rule2 = new PhaseRule(); 110 rule2.setPhaseName("PreDispatch"); 111 rule2.setAfter("pre-H2"); 112 rule2.setBefore("pre-H3"); 113 hm2.setRules(rule2); 114 ph.addHandler(hm2); 115 116 HandlerDescription hm3 = new HandlerDescription(); 117 hm3.setClassName("org.apache.axis2.handlers.AbstractHandler"); 118 Handler h6 =new PhaseRuleHandlers(); 119 h6.init(hm3); 120 hm3.setHandler(h6); 121 hm3.setName(new QName ("H4")); 122 PhaseRule rule3 = new PhaseRule(); 123 rule3.setPhaseName("PostDispatch"); 124 hm3.setRules(rule3); 125 ph.addHandler(hm3); 126 127 128 133 } 134 } 135 | Popular Tags |