KickJava   Java API By Example, From Geeks To Geeks.

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


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:35:33 PM
36  */

37 public class InvalidPhaseRuleTest extends AbstractTestCase {
38
39     InvalidPhaseRuleTest phaserul;
40     AxisConfiguration axisSytem;
41
42     public InvalidPhaseRuleTest(String JavaDoc 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 JavaDoc 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 JavaDoc("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 JavaDoc("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 JavaDoc("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 JavaDoc 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 JavaDoc 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 JavaDoc("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 JavaDoc("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 JavaDoc e) {
133             e.printStackTrace();
134         }
135     }
136
137
138 }
139
Popular Tags