01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14: * License for the specific language governing permissions and limitations under
15: * the License.
16: */
17: package org.apache.cocoon.components.flow.java.test;
18:
19: import org.apache.cocoon.components.flow.java.*;
20: import org.apache.cocoon.forms.FormContext;
21: import java.util.Locale;
22:
23: public class SimpleFlow extends AbstractSimpleFlow {
24:
25: public SimpleFlow() {
26: if (Continuation.currentContinuation() != null)
27: throw new RuntimeException("Conitnuation should not exist");
28: //sendPageAndWait("should not stop");
29: }
30:
31: public boolean run() {
32: System.out.println("start of flow");
33: float a = 1;
34: sendPageAndWait("getNumberA");
35: a = Float.parseFloat(getRequest().getParameter("a"));
36: System.out.println("a=" + a);
37: sendPage("result", new VarMap().add("result", a + 1));
38: System.out.println("end of flow");
39: return true;
40: }
41:
42: public void testNew(Locale locale) {
43: FormContext formContext = new FormContext(getRequest(), locale);
44: }
45:
46: public void testCatch() {
47: try {
48: sendPageAndWait("getNumberA");
49: float a = Float.parseFloat(getRequest().getParameter("a"));
50: } catch (NumberFormatException nfe) {
51: sendPageAndWait("error");
52: }
53: sendPage("result");
54: }
55:
56: public void testFinally() {
57: try {
58: sendPageAndWait("getNumberA");
59: float a = Float.parseFloat(getRequest().getParameter("a"));
60: } finally {
61: sendPageAndWait("result");
62: }
63: }
64:
65: public void testEmpty() {
66: //nothing
67: }
68:
69: public void testAbstract() {
70: super .parent();
71: }
72:
73: public void testDelegate() {
74: CalculatorFlow flow = new CalculatorFlow();
75: flow.run();
76: }
77: }
|