You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2004/08/30 02:36:38 UTC

cvs commit: jakarta-commons/jelly/src/test/org/apache/commons/jelly/core testUseBeanTag.jelly TestUseBeanTag.java

dion        2004/08/29 17:36:38

  Added:       jelly/src/test/org/apache/commons/jelly/core
                        testUseBeanTag.jelly TestUseBeanTag.java
  Log:
  Add tests for the useBean tag
  
  Revision  Changes    Path
  1.1                  jakarta-commons/jelly/src/test/org/apache/commons/jelly/core/testUseBeanTag.jelly
  
  Index: testUseBeanTag.jelly
  ===================================================================
  <!--
    Copyright 2002,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.
  -->
  
  <j:jelly xmlns:j="jelly:core">
      <j:if test="${test.simple}">
          <j:useBean var="foo" class="org.apache.commons.jelly.core.Customer"/>
      </j:if>
  </j:jelly>
  
  
  1.1                  jakarta-commons/jelly/src/test/org/apache/commons/jelly/core/TestUseBeanTag.java
  
  Index: TestUseBeanTag.java
  ===================================================================
  /*
   * Copyright 2002,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.commons.jelly.core;
  
  import org.apache.commons.jelly.Script;
  import junit.framework.TestSuite;
  
  /**
   * Tests for UseBean tag
   */
  public class TestUseBeanTag extends BaseJellyTest {
  
      public TestUseBeanTag(String name) {
          super(name);
      }
  
      public static TestSuite suite() throws Exception {
          return new TestSuite(TestUseBeanTag.class);        
      }
      
      /**
       * Test a simple useBean tag works ok
       * @throws Exception
       */
      public void testSimple() throws Exception {
          setUpScript("testUseBeanTag.jelly");
          Script script = getJelly().compileScript();
          getJellyContext().setVariable("test.simple",Boolean.TRUE);
          script.run(getJellyContext(),getXMLOutput());
          assertNotNull(getJellyContext().getVariable("foo"));
          assertTrue(getJellyContext().getVariable("foo") instanceof Customer);
          Customer customer = (Customer)(getJellyContext().getVariable("foo"));
          assertNull(customer.getName());
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org