cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From step...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test ExtendedContinuable.java InheritanceFlowTest.java SimpleContinuable.java WrapperContinuable.java AbstractSimpleFlow.java CalculatorFlow.java FlowTest.java SimpleFlow.java
Date Fri, 16 Apr 2004 09:39:58 GMT
stephan     2004/04/16 02:39:58

  Modified:    src/blocks/javaflow/java/org/apache/cocoon/components/flow/java
                        AbstractContinuable.java
               src/blocks/javaflow/java/org/apache/cocoon/forms/flow/java
                        FormInstance.java
               src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test
                        AbstractSimpleFlow.java CalculatorFlow.java
                        FlowTest.java SimpleFlow.java
  Added:       src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test
                        ExtendedContinuable.java InheritanceFlowTest.java
                        SimpleContinuable.java WrapperContinuable.java
  Log:
  Add tests from Peter Mortier.
  
  Revision  Changes    Path
  1.2       +5 -3      cocoon-2.1/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/AbstractContinuable.java
  
  Index: AbstractContinuable.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/AbstractContinuable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractContinuable.java	1 Apr 2004 12:40:40 -0000	1.1
  +++ AbstractContinuable.java	16 Apr 2004 09:39:57 -0000	1.2
  @@ -52,7 +52,8 @@
   
           ContinuationContext context = getContext();
   
  -        context.getLogger().debug("send page and wait '" + uri + "'");
  +				if (context.getLogger()!=null)
  +            context.getLogger().debug("send page and wait '" + uri + "'");
   
           FlowHelper.setContextObject(ContextHelper.getObjectModel(context.getAvalonContext()),
bizdata);
   
  @@ -81,7 +82,8 @@
   
           ContinuationContext context = getContext();
   
  -        context.getLogger().debug("send page '" + uri + "'");
  +				if (context.getLogger()!=null)
  +            context.getLogger().debug("send page '" + uri + "'");
   
           FlowHelper.setContextObject(ContextHelper.getObjectModel(context.getAvalonContext()),
bizdata);
   
  
  
  
  1.6       +8 -6      cocoon-2.1/src/blocks/javaflow/java/org/apache/cocoon/forms/flow/java/FormInstance.java
  
  Index: FormInstance.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/javaflow/java/org/apache/cocoon/forms/flow/java/FormInstance.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FormInstance.java	4 Apr 2004 17:16:17 -0000	1.5
  +++ FormInstance.java	16 Apr 2004 09:39:57 -0000	1.6
  @@ -47,7 +47,6 @@
       private Widget formWidget;
       private Locale locale;
       private boolean isValid;
  -    private String submitId;
       private Object validator; // Used?
     
       /**
  @@ -124,6 +123,13 @@
           }
       }
   
  +		public String getSubmitId() {
  +			
  +		    Widget widget = this.form.getSubmitWidget();
  +  	    // Can be null on "normal" submit
  +				return  widget == null ? null : widget.getId();
  +		}
  +
       /**
        * Sets the point in your script that will be returned to when the form is
        * redisplayed. If setBookmark() is not called, this is implicitly set to
  @@ -205,10 +211,6 @@
               // except a sudden change of repeaters whose size changed from a continuation
to another.
           
           } while(!finished);
  -
  -        Widget widget = this.form.getSubmitWidget();
  -        // Can be null on "normal" submit
  -        this.submitId = widget == null ? null : widget.getId(); 
       }
   
       /**
  
  
  
  1.2       +2 -2      cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test/AbstractSimpleFlow.java
  
  Index: AbstractSimpleFlow.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test/AbstractSimpleFlow.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractSimpleFlow.java	31 Mar 2004 14:12:01 -0000	1.1
  +++ AbstractSimpleFlow.java	16 Apr 2004 09:39:57 -0000	1.2
  @@ -15,10 +15,10 @@
    */
   package org.apache.cocoon.components.flow.java.test;
   
  -import org.apache.cocoon.components.flow.java.AbstractCocoonFlow;
  +import org.apache.cocoon.components.flow.java.*;
   
   
  -public abstract class AbstractSimpleFlow extends AbstractCocoonFlow {
  +public abstract class AbstractSimpleFlow extends AbstractContinuable {
   
       public void parent() {
   
  
  
  
  1.2       +1 -1      cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test/CalculatorFlow.java
  
  Index: CalculatorFlow.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test/CalculatorFlow.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CalculatorFlow.java	31 Mar 2004 14:12:01 -0000	1.1
  +++ CalculatorFlow.java	16 Apr 2004 09:39:57 -0000	1.2
  @@ -17,7 +17,7 @@
   
   import org.apache.cocoon.components.flow.java.*;
   
  -public class CalculatorFlow extends AbstractCocoonFlow {
  +public class CalculatorFlow extends AbstractContinuable {
   
       public void run() {
   
  
  
  
  1.3       +2 -0      cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test/FlowTest.java
  
  Index: FlowTest.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test/FlowTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FlowTest.java	31 Mar 2004 14:16:30 -0000	1.2
  +++ FlowTest.java	16 Apr 2004 09:39:57 -0000	1.3
  @@ -260,6 +260,8 @@
       public void testFormFlow() throws Exception {
           Class clazz = loader.loadClass("org.apache.cocoon.samples.flow.java.FormFlow");
           Continuable flow = (Continuable) clazz.newInstance();
  +        
  +        assertNotNull(flow);
       }
   
   /*    public static void testOJBFlow() throws Exception {
  
  
  
  1.2       +14 -26    cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test/SimpleFlow.java
  
  Index: SimpleFlow.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test/SimpleFlow.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleFlow.java	31 Mar 2004 14:12:01 -0000	1.1
  +++ SimpleFlow.java	16 Apr 2004 09:39:57 -0000	1.2
  @@ -1,52 +1,40 @@
   /*
    * Copyright 1999-2004 The Apache Software Foundation.
  - *
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - *
  - *      http://www.apache.org/licenses/LICENSE-2.0
  - *
  + * 
  + * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  + * use this file except in compliance with the License. You may obtain a copy of
  + * the License at
  + * 
  + * http://www.apache.org/licenses/LICENSE-2.0
  + * 
    * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  + * License for the specific language governing permissions and limitations under
  + * the License.
    */
   package org.apache.cocoon.components.flow.java.test;
   
   import org.apache.cocoon.components.flow.java.*;
   import org.apache.cocoon.forms.FormContext;
  -
   import java.util.Locale;
   
  -
   public class SimpleFlow extends AbstractSimpleFlow {
   
       public SimpleFlow() {
  -        if (Continuation.currentContinuation()!=null)
  +        if (Continuation.currentContinuation() != null)
               throw new RuntimeException("Conitnuation should not exist");
  -
  -        ContinuationStack stack = new ContinuationStack();
  -
  -        sendPageAndWait("should not stop");
  +        //sendPageAndWait("should not stop");
       }
   
       public boolean run() {
  -
           System.out.println("start of flow");
  -
           float a = 1;
  -        
           sendPageAndWait("getNumberA");
  -        
           a = Float.parseFloat(getRequest().getParameter("a"));
           System.out.println("a=" + a);
  -
  -        sendPage("result", new VarMap().add("result", a+1));        
  -
  +        sendPage("result", new VarMap().add("result", a + 1));
           System.out.println("end of flow");
  -
           return true;
       }
   
  
  
  
  1.1                  cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test/ExtendedContinuable.java
  
  Index: ExtendedContinuable.java
  ===================================================================
  /*
   * Copyright 1999-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
   * use this file except in compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   * License for the specific language governing permissions and limitations under
   * the License.
   */
  package org.apache.cocoon.components.flow.java.test;
  
  
  public class ExtendedContinuable extends SimpleContinuable {
  
      public void test() {
          super.suspend();
      }
  }
  
  
  1.1                  cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test/InheritanceFlowTest.java
  
  Index: InheritanceFlowTest.java
  ===================================================================
  /*
   * Copyright 1999-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
   * use this file except in compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   * License for the specific language governing permissions and limitations under
   * the License.
   */
  package org.apache.cocoon.components.flow.java.test;
  
  import java.lang.reflect.InvocationTargetException;
  
  import junit.framework.TestCase;
  
  import org.apache.cocoon.components.flow.java.Continuation;
  import org.apache.cocoon.components.flow.java.ContinuationClassLoader;
  
  public class InheritanceFlowTest extends TestCase {
      
      public InheritanceFlowTest(String s) {
          super(s);
      }
  
      static public void main(String args[]) {
          try {
              testSimpleContinuable();
              System.out.println("SimpleContinuable test done");
              testExtendedContinuable();
              System.out.println("ExtendedContinuable test done");
              testWrapperContinuable();
              System.out.println("Wrapper continuable test done");
          } catch (Throwable e) {
              e.printStackTrace();
          }
      }
  
      public static void testSimpleContinuable() throws Exception {
          ContinuationClassLoader cl = new ContinuationClassLoader(Thread
                  .currentThread().getContextClassLoader());
          Continuation continuation = new Continuation(null);
          continuation.registerThread();
          Class clazz = cl.loadClass("org.apache.cocoon.components.flow.java.test.SimpleContinuable");
          Object object = clazz.newInstance();
          clazz.getMethod("suspend", null).invoke(object, null);
          if (continuation.isCapturing())
              continuation.getStack().popReference();
          continuation = new Continuation(continuation, null);
          continuation.registerThread();
          clazz.getMethod("suspend", null).invoke(object, null);
      }
  
      public static void testWrapperContinuable() throws Exception {
          ContinuationClassLoader cl = new ContinuationClassLoader(Thread
                  .currentThread().getContextClassLoader());
          Continuation continuation = new Continuation(null);
          continuation.registerThread();
          Class clazz = cl.loadClass("org.apache.cocoon.components.flow.java.test.WrapperContinuable");
          Object object = clazz.newInstance();
          clazz.getMethod("test", null).invoke(object, null);
  				if (continuation.isCapturing())
              continuation.getStack().popReference();
          continuation = new Continuation(continuation, null);
          continuation.registerThread();
          clazz.getMethod("test", null).invoke(object, null);
      }
  
      public static void testExtendedContinuable() throws Exception {
          ContinuationClassLoader cl = new ContinuationClassLoader(Thread
                  .currentThread().getContextClassLoader());
          Continuation continuation = new Continuation(null);
          continuation.registerThread();
          Class clazz = cl.loadClass("org.apache.cocoon.components.flow.java.test.ExtendedContinuable");
          Object object = clazz.newInstance();
          clazz.getMethod("test", null).invoke(object, null);
  				if (continuation.isCapturing())
              continuation.getStack().popReference();
          continuation = new Continuation(continuation, null);
          continuation.registerThread();
          clazz.getMethod("test", null).invoke(object, null);
      }
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test/SimpleContinuable.java
  
  Index: SimpleContinuable.java
  ===================================================================
  /*
   * Copyright 1999-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
   * use this file except in compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   * License for the specific language governing permissions and limitations under
   * the License.
   */
  package org.apache.cocoon.components.flow.java.test;
  
  import org.apache.cocoon.components.flow.java.*;
  
  public class SimpleContinuable implements Continuable {
  	public void suspend() {
  		System.out.println("suspending");
  		Continuation.suspend();
  		System.out.println("continuing");
  	}
  }
  
  
  1.1                  cocoon-2.1/src/blocks/javaflow/test/org/apache/cocoon/components/flow/java/test/WrapperContinuable.java
  
  Index: WrapperContinuable.java
  ===================================================================
  /*
   * Copyright 1999-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
   * use this file except in compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   * License for the specific language governing permissions and limitations under
   * the License.
   */
  package org.apache.cocoon.components.flow.java.test;
  
  import org.apache.cocoon.components.flow.java.*;
  
  public class WrapperContinuable implements Continuable {
  
      SimpleContinuable simple;
  
      public WrapperContinuable() {
          simple = new SimpleContinuable();
      }
  
      public void test() {
          simple.suspend();
      }
  
  }
  
  

Mime
View raw message