jakarta-watchdog-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julien Adler <jad...@oh.verio.com>
Subject /jsp-tests/jsp/core_syntax/directives/taglib/positiveTagLib.jsp
Date Thu, 05 Oct 2000 17:34:26 GMT

The following code in example.TestTag.doInitBody is circumspect:

         TestTagExtraInfo texInfo=new TestTagExtraInfo();
         TagInfo tagInfo=texInfo.getInfoObj();
         TagLibraryInfo tlibInfo=tagInfo.getTagLibrary();
         TagAttributeInfo[] tagAttrInfo=tagInfo.getAttributes();

The second line, in our implementation, returns null and therefore the 
third line will cause a NullPointerException. This will fail on any 
implementation which uses a new process to translate the jsp or and 
implementation which uses a new ClassLoader to load the TagExtraInfo during 
the translation phase.

The only portable way to test the translate phase is to look at the 
side-effects of that phase, i.e. was a proper java file created. For 
example, the following tests whether setTagInfo, isValid, and 
getVariableInfo are called in the proper order.

package examples;

package examples;

import javax.servlet.jsp.tagext.*;

public class TestTagExtraInfo extends TagExtraInfo
{
     private bool isValidCalled= false;

     public TestTagExtraInfo(){}

     // order of calls should be setTagInfo, isValid, and getVariableInfo

     public boolean isValid(TagData tagData)
     {
         if(getTagInfo()==null)
             throw IllegalStateException("'isValid' called before
'setTagInfo'");

         isValidCalled= true;
         return true;
     }

     public VariableInfo[] getVariableInfo(TagData data)
     {
         if(isValidCalled==false)
             throw IllegalStateException("'getVariableInfo' called before
'isValidCalled'");

         return new VariableInfo[] { new VariableInfo("member", "String",
true, VariableInfo.NESTED)};
     }
}

Mime
View raw message