commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwaldh...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/core TestSwitchTag.java testSwitchTag.jelly
Date Tue, 22 Oct 2002 16:15:50 GMT
rwaldhoff    2002/10/22 09:15:49

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/core
                        CaseTag.java
               jelly/src/test/org/apache/commons/jelly/core
                        TestSwitchTag.java testSwitchTag.jelly
  Log:
  don't allow <case> after <default>, and add a test demonstrating that
  add test for <switch> without @on
  
  Revision  Changes    Path
  1.2       +8 -5      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/CaseTag.java
  
  Index: CaseTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/CaseTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CaseTag.java	22 Oct 2002 15:13:43 -0000	1.1
  +++ CaseTag.java	22 Oct 2002 16:15:49 -0000	1.2
  @@ -104,6 +104,9 @@
           if(null == tag) {
               throw new JellyException("This tag must be enclosed inside a <switch>
tag" );
           }
  +        if(tag.hasDefaultBeenEncountered()) {
  +            throw new JellyException("<default> should be the last tag within a <switch>"
);
  +        }
           Object value = valueExpression.evaluate(context);        
           if(tag.isFallingThru() || 
              (null == tag.getValue() && null == value) || 
  
  
  
  1.3       +29 -5     jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/core/TestSwitchTag.java
  
  Index: TestSwitchTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/core/TestSwitchTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestSwitchTag.java	22 Oct 2002 16:03:05 -0000	1.2
  +++ TestSwitchTag.java	22 Oct 2002 16:15:49 -0000	1.3
  @@ -179,6 +179,18 @@
                      context.getVariable("a.default"));
       }
   
  +    public void testSwitchWithoutOn() throws Exception {
  +        setUpScript("testSwitchTag.jelly");
  +        Script script = jelly.compileScript();
  +        context.setVariable("switch.without.on",new Boolean(true));
  +        try {
  +            script.run(context,xmlOutput);
  +            fail("Expected MissingAttributeException");
  +        } catch(MissingAttributeException e) {
  +            // expected
  +        }
  +    }
  +
       public void testCaseWithoutSwitch() throws Exception {
           setUpScript("testSwitchTag.jelly");
           Script script = jelly.compileScript();
  @@ -219,6 +231,18 @@
           setUpScript("testSwitchTag.jelly");
           Script script = jelly.compileScript();
           context.setVariable("multiple.defaults",new Boolean(true));
  +        try {
  +            script.run(context,xmlOutput);
  +            fail("Expected JellyException");
  +        } catch(JellyException e) {
  +            // expected
  +        }
  +    }
  +    
  +    public void testCaseAfterDefault() throws Exception {
  +        setUpScript("testSwitchTag.jelly");
  +        Script script = jelly.compileScript();
  +        context.setVariable("case.after.default",new Boolean(true));
           try {
               script.run(context,xmlOutput);
               fail("Expected JellyException");
  
  
  
  1.3       +19 -0     jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/core/testSwitchTag.jelly
  
  Index: testSwitchTag.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/core/testSwitchTag.jelly,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- testSwitchTag.jelly	22 Oct 2002 16:03:05 -0000	1.2
  +++ testSwitchTag.jelly	22 Oct 2002 16:15:49 -0000	1.3
  @@ -17,6 +17,16 @@
           </j:default>
       </j:switch>
       
  +    <j:if test="${switch.without.on}">
  +        <j:switch>
  +            <j:case value="one" fallThru="true"/>
  +            <j:case value="two"/>
  +            <j:case value="three"/>
  +            <j:case value="${null}"/>
  +            <j:default/>
  +        </j:switch>
  +    </j:if>
  +
       <j:if test="${case.without.switch}">
           <j:case value="this tag should cause an exception"/>
       </j:if>
  @@ -45,5 +55,14 @@
           </j:switch>
       </j:if>
       
  +    <j:if test="${case.after.default}">
  +        <j:switch on="foo">
  +            <j:default>
  +            </j:default>
  +            <j:case value="bar">
  +                <!-- this one should cause an exception (or even better, fail on validation)
-->
  +            </j:case>
  +        </j:switch>
  +    </j:if>
   
   </j:jelly>
  
  
  

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


Mime
View raw message