KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > phaserule > PreDispatchPhaseRuleTest


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 JavaDoc;
12 import java.util.ArrayList JavaDoc;
13
14 /*
15 * Copyright 2004,2005 The Apache Software Foundation.
16 *
17 * Licensed under the Apache License, Version 2.0 (the "License");
18 * you may not use this file except in compliance with the License.
19 * You may obtain a copy of the License at
20 *
21 * http://www.apache.org/licenses/LICENSE-2.0
22 *
23 * Unless required by applicable law or agreed to in writing, software
24 * distributed under the License is distributed on an "AS IS" BASIS,
25 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 * See the License for the specific language governing permissions and
27 * limitations under the License.
28 *
29 *
30 */

31
32 /**
33  * Author : Deepal Jayasinghe
34  * Date: May 10, 2005
35  * Time: 4:28:27 PM
36  */

37 public class PreDispatchPhaseRuleTest extends AbstractTestCase{
38
39     PreDispatchPhaseRuleTest phaserul;
40     AxisConfiguration axisSytem;
41
42     public PreDispatchPhaseRuleTest(String JavaDoc testName) {
43         super(testName);
44     }
45
46     public void testPhaseRule() throws Exception JavaDoc {
47         //TODO Fix me
48
phaserul = new PreDispatchPhaseRuleTest("");
49         axisSytem = new AxisConfigurationImpl();
50         ArrayList JavaDoc 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 JavaDoc("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 JavaDoc("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 JavaDoc("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 JavaDoc("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 JavaDoc("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 JavaDoc("H4"));
122         PhaseRule rule3 = new PhaseRule();
123         rule3.setPhaseName("PostDispatch");
124         hm3.setRules(rule3);
125         ph.addHandler(hm3);
126
127
128         /*ArrayList oh = ph.getOrderHandler();
129         for (int i = 0; i < oh.size(); i++) {
130             HandlerDescription metadata = (HandlerDescription) oh.get(i);
131             System.out.println("Name:" + metadata.getName().getLocalPart());
132         }*/

133     }
134 }
135
Popular Tags