KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > flow > java > test > SimpleFlow


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package org.apache.cocoon.components.flow.java.test;
17
18 import org.apache.cocoon.components.flow.java.*;
19 import org.apache.cocoon.forms.FormContext;
20 import java.util.Locale JavaDoc;
21
22 public class SimpleFlow extends AbstractSimpleFlow {
23
24     public SimpleFlow() {
25         if (Continuation.currentContinuation() != null)
26             throw new RuntimeException JavaDoc("Conitnuation should not exist");
27         //sendPageAndWait("should not stop");
28
}
29
30     public boolean run() {
31         System.out.println("start of flow");
32         float a = 1;
33         sendPageAndWait("getNumberA");
34         a = Float.parseFloat(getRequest().getParameter("a"));
35         System.out.println("a=" + a);
36         sendPage("result", new VarMap().add("result", a + 1));
37         System.out.println("end of flow");
38         return true;
39     }
40
41     public void testNew(Locale JavaDoc locale) {
42         FormContext formContext = new FormContext(getRequest(), locale);
43     }
44
45     public void testCatch() {
46         try {
47             sendPageAndWait("getNumberA");
48             float a = Float.parseFloat(getRequest().getParameter("a"));
49         } catch (NumberFormatException JavaDoc nfe) {
50             sendPageAndWait("error");
51         }
52         sendPage("result");
53     }
54
55     public void testFinally() {
56         try {
57             sendPageAndWait("getNumberA");
58             float a = Float.parseFloat(getRequest().getParameter("a"));
59         } finally {
60             sendPageAndWait("result");
61         }
62     }
63
64     public void testEmpty() {
65         //nothing
66
}
67
68     public void testAbstract() {
69         super.parent();
70     }
71
72     public void testDelegate() {
73         CalculatorFlow flow = new CalculatorFlow();
74         flow.run();
75     }
76 }
77
Popular Tags