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 InvalidPhaseRuleTest extends AbstractTestCase { 38 39 InvalidPhaseRuleTest phaserul; 40 AxisConfiguration axisSytem; 41 42 public InvalidPhaseRuleTest(String testName) { 43 super(testName); 44 } 45 46 public void testInvalidPhaseRule1() { 47 try { 48 super.setUp(); 49 phaserul = new InvalidPhaseRuleTest(""); 50 axisSytem = new AxisConfigurationImpl(); 51 ArrayList inPhase = axisSytem.getInPhasesUptoAndIncludingPostDispatch(); 52 53 Handler han = null; 54 PhaseHolder ph = new PhaseHolder(inPhase); 55 56 57 HandlerDescription hm = new HandlerDescription(); 58 hm.setClassName("org.apache.axis2.handlers.AbstractHandler"); 59 hm.setHandler(han); 60 hm.setName(new QName ("H1")); 61 PhaseRule rule = new PhaseRule(); 62 rule.setPhaseName("global"); 63 rule.setPhaseFirst(true); 64 hm.setRules(rule); 65 ph.addHandler(hm); 66 67 HandlerDescription hm1 = new HandlerDescription(); 68 hm1.setClassName("org.apache.axis2.handlers.AbstractHandler"); 69 hm1.setHandler(han); 70 hm1.setName(new QName ("H2")); 71 PhaseRule rule1 = new PhaseRule(); 72 rule1.setPhaseName("global"); 73 rule1.setAfter("H1"); 74 hm1.setRules(rule1); 75 ph.addHandler(hm1); 76 77 HandlerDescription hm3 = new HandlerDescription(); 78 hm3.setClassName("org.apache.axis2.handlers.AbstractHandler"); 79 hm3.setHandler(han); 80 hm3.setName(new QName ("H4")); 81 PhaseRule rule3 = new PhaseRule(); 82 rule3.setPhaseName("Logging"); 83 hm3.setRules(rule3); 84 ph.addHandler(hm3); 85 fail("this must failed gracefully with PhaseException "); 86 } catch (Exception e) { 87 e.printStackTrace(); 88 } 89 } 90 91 92 public void testInvalidPhaseRule2() { 93 try { 94 super.setUp(); 95 96 phaserul = new InvalidPhaseRuleTest(""); 97 axisSytem = new AxisConfigurationImpl(); 98 ArrayList inPhase = axisSytem.getInPhasesUptoAndIncludingPostDispatch(); 99 100 inPhase.add("global"); 101 ((AxisConfigurationImpl) axisSytem).setInPhases(inPhase); 102 ((AxisConfigurationImpl) axisSytem).setInFaultPhases(inPhase); 103 ((AxisConfigurationImpl) axisSytem).setOutFaultPhases(inPhase); 104 ((AxisConfigurationImpl) axisSytem).setOutPhases(inPhase); 105 106 Handler han = null; 107 PhaseHolder ph = new PhaseHolder(inPhase); 108 109 110 HandlerDescription hm = new HandlerDescription(); 111 hm.setClassName("org.apache.axis2.handlers.AbstractHandler"); 112 hm.setHandler(han); 113 hm.setName(new QName ("H1")); 114 PhaseRule rule = new PhaseRule(); 115 rule.setPhaseName("global"); 116 rule.setPhaseFirst(true); 117 rule.setPhaseLast(true); 118 hm.setRules(rule); 119 ph.addHandler(hm); 120 121 HandlerDescription hm1 = new HandlerDescription(); 122 hm1.setClassName("org.apache.axis2.handlers.AbstractHandler"); 123 hm1.setHandler(han); 124 hm1.setName(new QName ("H2")); 125 PhaseRule rule1 = new PhaseRule(); 126 rule1.setPhaseName("global"); 127 rule1.setAfter("H1"); 128 hm1.setRules(rule1); 129 ph.addHandler(hm1); 130 131 fail("this must failed gracefully with PhaseException "); 132 } catch (Exception e) { 133 e.printStackTrace(); 134 } 135 } 136 137 138 } 139 | Popular Tags |