You are viewing a plain text version of this content. The canonical link for it is here.
Posted to watchdog-dev@jakarta.apache.org by Julien Adler <ja...@oh.verio.com> on 2000/10/05 19:34:26 UTC
/jsp-tests/jsp/core_syntax/directives/taglib/positiveTagLib.jsp
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)};
}
}