001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019:
020: package org.apache.axis2.phaserule;
021:
022: import org.apache.axis2.AbstractTestCase;
023: import org.apache.axis2.description.HandlerDescription;
024: import org.apache.axis2.description.PhaseRule;
025: import org.apache.axis2.engine.AxisConfiguration;
026: import org.apache.axis2.engine.DispatchPhase;
027: import org.apache.axis2.engine.Handler;
028: import org.apache.axis2.engine.Phase;
029: import org.apache.axis2.phaseresolver.PhaseHolder;
030:
031: import java.util.ArrayList;
032:
033: public class PreDispatchPhaseRuleTest extends AbstractTestCase {
034:
035: PreDispatchPhaseRuleTest phaserul;
036: AxisConfiguration axisSytem;
037:
038: public PreDispatchPhaseRuleTest(String testName) {
039: super (testName);
040: }
041:
042: public void testPhaseRule() throws Exception {
043: //TODO Fix me
044: phaserul = new PreDispatchPhaseRuleTest("");
045: axisSytem = new AxisConfiguration();
046: ArrayList inPhase = axisSytem.getInFlowPhases();
047: Phase transportIN = new Phase("TransportIn");
048: Phase preDispatch = new Phase("PreDispatch");
049: DispatchPhase dispatchPhase = new DispatchPhase();
050: //
051: dispatchPhase.setName("Dispatch");
052: inPhase.add(transportIN);
053: inPhase.add(preDispatch);
054: inPhase.add(dispatchPhase);
055: PhaseHolder ph = new PhaseHolder(inPhase);
056:
057: HandlerDescription pre = new HandlerDescription();
058: pre.setClassName("org.apache.axis2.handlers.AbstractHandler");
059: Handler h1 = new PhaseRuleHandler();
060: h1.init(pre);
061: pre.setHandler(h1);
062: pre.setName("pre-H1");
063: PhaseRule pre_rule1 = new PhaseRule();
064: pre_rule1.setPhaseName("PreDispatch");
065: pre.setRules(pre_rule1);
066: ph.addHandler(pre);
067:
068: HandlerDescription pre2 = new HandlerDescription();
069: pre2.setClassName("org.apache.axis2.handlers.AbstractHandler");
070: Handler h2 = new PhaseRuleHandler();
071: h2.init(pre2);
072: pre2.setHandler(h2);
073: pre2.setName("dispatch");
074: PhaseRule prerule2 = new PhaseRule();
075: prerule2.setPhaseName("Dispatch");
076: pre2.setRules(prerule2);
077: ph.addHandler(pre2);
078:
079: HandlerDescription hm = new HandlerDescription();
080: hm.setClassName("org.apache.axis2.handlers.AbstractHandler");
081: Handler h3 = new PhaseRuleHandler();
082: h3.init(hm);
083: hm.setHandler(h3);
084: hm.setName("pre-H2");
085: PhaseRule rule = new PhaseRule();
086: rule.setPhaseName("PreDispatch");
087: rule.setPhaseFirst(true);
088: hm.setRules(rule);
089: ph.addHandler(hm);
090:
091: HandlerDescription hm1 = new HandlerDescription();
092: hm1.setClassName("org.apache.axis2.handlers.AbstractHandler");
093: Handler h4 = new PhaseRuleHandler();
094: h4.init(hm1);
095: hm1.setHandler(h4);
096: hm1.setName("pre-H3");
097: PhaseRule rule1 = new PhaseRule();
098: rule1.setPhaseName("PreDispatch");
099: 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 PhaseRuleHandler();
106: h5.init(hm2);
107: hm2.setHandler(h5);
108: hm2.setName("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: /*ArrayList oh = ph.getOrderHandler();
117: for (int i = 0; i < oh.size(); i++) {
118: HandlerDescription metadata = (HandlerDescription) oh.get(i);
119: System.out.println("Name:" + metadata.getName().getLocalPart());
120: }*/
121: }
122: }
|