You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by mi...@apache.org on 2003/06/21 23:35:06 UTC

cvs commit: jakarta-tapestry/junit/src/org/apache/tapestry/junit/mock/c27 Good.java

mindbridge    2003/06/21 14:35:06

  Modified:    junit/mock-scripts TestAutoParameters.xml
                        TestFailNotComponent.xml
               junit/src/org/apache/tapestry/junit BasicTestSuite.java
  Added:       junit/mock-scripts TestDefaultParameterValues.xml
               junit/src/org/apache/tapestry/junit/enhance
                        TestEnhancedClassFactory.java
               junit/context27/WEB-INF Good.jwc Good.html
               junit/context27 README Home.html
               junit/src/org/apache/tapestry/junit/mock/c27 Good.java
  Removed:     junit/src/org/apache/tapestry/junit/enhance
                        TestClassFabricator.java
  Log:
  Unit tests for the following features:
  - javassist enhancement code
  - parameter default value
  - template tag
  - Any changes
  
  Revision  Changes    Path
  1.2       +2 -2      jakarta-tapestry/junit/mock-scripts/TestAutoParameters.xml
  
  Index: TestAutoParameters.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/junit/mock-scripts/TestAutoParameters.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestAutoParameters.xml	23 Mar 2003 23:20:34 -0000	1.1
  +++ TestAutoParameters.xml	21 Jun 2003 21:35:06 -0000	1.2
  @@ -101,7 +101,7 @@
   		</assert-output>
   		
   		<assert-output name="Message">
  -		Parameter 'flag' must be required as it uses direction 'auto'.	
  +		Parameter 'flag' must be required or have a default value as it uses direction 'auto'.	
   		</assert-output>
   	</request>
   	
  
  
  
  1.4       +2 -2      jakarta-tapestry/junit/mock-scripts/TestFailNotComponent.xml
  
  Index: TestFailNotComponent.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/junit/mock-scripts/TestFailNotComponent.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestFailNotComponent.xml	18 Mar 2003 20:55:29 -0000	1.3
  +++ TestFailNotComponent.xml	21 Jun 2003 21:35:06 -0000	1.4
  @@ -22,7 +22,7 @@
   				
   			
   		<assert-output name="Error">
  -Class java.lang.Object does not implement the IComponent interface.
  +does not implement the IComponent interface.
   		</assert-output>
   								
   	</request>		
  
  
  
  1.1                  jakarta-tapestry/junit/mock-scripts/TestDefaultParameterValues.xml
  
  Index: TestDefaultParameterValues.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <!-- $Id: TestDefaultParameterValues.xml,v 1.1 2003/06/21 21:35:06 mindbridge Exp $ -->
  
  <mock-test>
      <context name="c27" root="context27"/>
  
    	<servlet name="app" class="org.apache.tapestry.ApplicationServlet"/>
  
  	<request>
  		<assert-output name="Page Title">
  <![CDATA[		
  <title>Home</title>
  ]]>
  		</assert-output>
    	  	  	
  
  		<assert-output name="bound int value">
  <![CDATA[
  <td>Bound intValue    = 10</td>
  ]]>
  		</assert-output>
  
  		<assert-output name="bound double value">
  <![CDATA[
  <td>Bound doubleValue = 2.72</td>
  ]]>
  		</assert-output>
  
  		<assert-output name="bound object value">
  <![CDATA[
  <td>Bound objectValue = zh_TW</td>
  ]]>
  		</assert-output>
  
  
  		<assert-output name="default int value">
  <![CDATA[
  <td>Default intValue    = 5</td>
  ]]>
  		</assert-output>
  
  		<assert-output name="default double value">
  <![CDATA[
  <td>Default doubleValue = 3.14</td>
  ]]>
  		</assert-output>
  
  		<assert-output name="default object value">
  <![CDATA[
  <td>Default objectValue = en_US</td>
  ]]>
  		</assert-output>
  
  		<assert-output name="default object value">
  <![CDATA[
  <span>span tag</span>
  ]]>
  		</assert-output>
  
  		<assert-output name="default object value">
  <![CDATA[
  <div>div tag</div>
  ]]>
  		</assert-output>
  		
  	</request>
  	
  		
   </mock-test>
  
  
  1.7       +3 -3      jakarta-tapestry/junit/src/org/apache/tapestry/junit/BasicTestSuite.java
  
  Index: BasicTestSuite.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/junit/src/org/apache/tapestry/junit/BasicTestSuite.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BasicTestSuite.java	28 May 2003 14:53:53 -0000	1.6
  +++ BasicTestSuite.java	21 Jun 2003 21:35:06 -0000	1.7
  @@ -58,7 +58,7 @@
   import junit.framework.Test;
   import junit.framework.TestSuite;
   
  -import org.apache.tapestry.junit.enhance.TestClassFabricator;
  +import org.apache.tapestry.junit.enhance.TestEnhancedClassFactory;
   import org.apache.tapestry.junit.enhance.TestMethodSignature;
   import org.apache.tapestry.junit.form.TestListEditMap;
   import org.apache.tapestry.junit.parse.TestLocation;
  @@ -120,7 +120,7 @@
           suite.addTestSuite(TestBindings.class);
           suite.addTestSuite(TestPropertySource.class);
           suite.addTestSuite(TestComponent.class);
  -        suite.addTestSuite(TestClassFabricator.class);
  +        suite.addTestSuite(TestEnhancedClassFactory.class);
           suite.addTestSuite(TestMethodSignature.class);
           suite.addTestSuite(TestTapestryGetClassName.class);
           suite.addTestSuite(TestRegexpMatcher.class);
  
  
  
  1.1                  jakarta-tapestry/junit/src/org/apache/tapestry/junit/enhance/TestEnhancedClassFactory.java
  
  Index: TestEnhancedClassFactory.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation", "Tapestry" 
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" 
   *    or "Tapestry", nor may "Apache" or "Tapestry" appear in their 
   *    name, without prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE TAPESTRY CONTRIBUTOR COMMUNITY
   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.tapestry.junit.enhance;
  
  import org.apache.tapestry.ApplicationRuntimeException;
  import org.apache.tapestry.IResourceResolver;
  import org.apache.tapestry.enhance.IEnhancedClass;
  import org.apache.tapestry.enhance.IEnhancedClassFactory;
  import org.apache.tapestry.enhance.javassist.EnhancedClassFactory;
  import org.apache.tapestry.junit.TapestryTestCase;
  import org.apache.tapestry.util.DefaultResourceResolver;
  import org.apache.tapestry.util.prop.OgnlUtils;
  
  /**
   *  Tests the classes used by the 
   *  {@link org.apache.tapestry.enhance.DefaultComponentClassEnhancer} to
   *  construct new classes.
   *
   *  @author Howard Lewis Ship
   *  @version $Id: TestEnhancedClassFactory.java,v 1.1 2003/06/21 21:35:06 mindbridge Exp $
   *  @since 3.0
   **/
  
  public class TestEnhancedClassFactory extends TapestryTestCase
  {
  
      public TestEnhancedClassFactory(String name)
      {
          super(name);
      }
  
  
      /**
       *  Test the ability to create a class that implements a read/write property.
       * 
       **/
  
      public void testCreateProperty() throws Exception
      {
          IResourceResolver resolver = new DefaultResourceResolver();
          IEnhancedClassFactory factory = new EnhancedClassFactory(resolver);
  
          String className = "org.apache.tapestry.junit.enhance.PropertyHolder";
          IEnhancedClass enhancedClass = factory.createEnhancedClass(className, Object.class);
  
          String propertyName = "name";
          enhancedClass.createProperty(propertyName, "java.lang.String");
  
          Class holderClass = enhancedClass.createEnhancedSubclass();
  
          Object holder = holderClass.newInstance();
  
          String value = "abraxis";
  
          OgnlUtils.set("name", resolver, holder, value);
  
          Object actual = OgnlUtils.get("name", resolver, holder);
  
          assertEquals("Holder name property.", value, actual);
      }
  
  
      public void testCreateFailure()
      {
          IResourceResolver resolver = new DefaultResourceResolver();
          IEnhancedClassFactory factory = new EnhancedClassFactory(resolver);
  
          String className = "org.apache.tapestry.junit.enhance.Invalid";
          IEnhancedClass enhancedClass = factory.createEnhancedClass(className, Boolean.class);
  
          try
          {
              enhancedClass.createEnhancedSubclass();
  
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              checkException(ex, "Cannot inherit from final class");
          }
  
      }
  }
  
  
  1.1                  jakarta-tapestry/junit/context27/WEB-INF/Good.jwc
  
  Index: Good.jwc
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- $Id: Good.jwc,v 1.1 2003/06/21 21:35:06 mindbridge Exp $ -->
  <!DOCTYPE component-specification PUBLIC 
    "-//Apache Software Foundation//Tapestry Specification 3.0//EN" 
    "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
  
  <component-specification class="org.apache.tapestry.junit.mock.c27.Good">
  	
  	<parameter name="prefix" type="java.lang.String" direction="auto" default-value='defaultPrefix'/>
  
  	<parameter name="intValue" type="int" direction="auto" default-value="5"/>
  	<parameter name="doubleValue" type="double" direction="in" default-value="3.14"/>
  	<parameter name="objectValue" type="java.util.Locale" direction="in" default-value="defaultLocale"/>
  
  </component-specification>
  
  
  
  1.1                  jakarta-tapestry/junit/context27/WEB-INF/Good.html
  
  Index: Good.html
  ===================================================================
  <table>
  	<tr>
  		<td><span jwcid="@Insert" value="ognl:prefix"/> intValue    = <span jwcid="@Insert" value="ognl:intValue"/></td>
  		<td><span jwcid="@Insert" value="ognl:prefix"/> doubleValue = <span jwcid="@Insert" value="ognl:doubleValue"/></td>
  		<td><span jwcid="@Insert" value="ognl:prefix"/> objectValue = <span jwcid="@Insert" value="ognl:objectValue"/></td>
  	</tr>
  </table>		
  		
  
  
  1.1                  jakarta-tapestry/junit/context27/README
  
  Index: README
  ===================================================================
  Tests the parameter default values
  
  See TestDefaultParameterValues.xml
  
  
  
  1.1                  jakarta-tapestry/junit/context27/Home.html
  
  Index: Home.html
  ===================================================================
  <html jwcid="@Shell" title="Home">
  <body>
  
  	<span jwcid="@Good"/>
  
  	<span jwcid="@Good" 
  		prefix="Bound"
  		intValue="10" 
  		doubleValue="2.72" 
  		objectValue="ognl:@java.util.Locale@TAIWAN"
  	/>
  
  	<div jwcid="@Any" element="span">span tag</div>
  
  	<div jwcid="@Any">div tag</div>
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-tapestry/junit/src/org/apache/tapestry/junit/mock/c27/Good.java
  
  Index: Good.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation", "Tapestry" 
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" 
   *    or "Tapestry", nor may "Apache" or "Tapestry" appear in their 
   *    name, without prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE TAPESTRY CONTRIBUTOR COMMUNITY
   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.tapestry.junit.mock.c27;
  
  import java.util.Locale;
  
  import org.apache.tapestry.BaseComponent;
  
  public class Good extends BaseComponent
  {
      public String getDefaultPrefix()
      {
          return "Default";
      }
  
      public Locale getDefaultLocale()
      {
          return Locale.US;
      }
  }