use of jakarta.servlet.jsp.tagext.Tag in project spring-framework by spring-projects.
the class TagUtilsTests method testAssertHasAncestorOfTypeDoesNotThrowExceptionOnPass.
@Test
public void testAssertHasAncestorOfTypeDoesNotThrowExceptionOnPass() throws Exception {
Tag a = new TagA();
Tag b = new TagB();
Tag c = new TagC();
a.setParent(b);
b.setParent(c);
TagUtils.assertHasAncestorOfType(a, TagC.class, "a", "c");
}
use of jakarta.servlet.jsp.tagext.Tag in project spring-framework by spring-projects.
the class TagUtilsTests method assertHasAncestorOfTypeThrowsExceptionOnFail.
@Test
public void assertHasAncestorOfTypeThrowsExceptionOnFail() throws Exception {
Tag a = new TagA();
Tag b = new TagB();
Tag anotherB = new TagB();
a.setParent(b);
b.setParent(anotherB);
assertThatIllegalStateException().isThrownBy(() -> TagUtils.assertHasAncestorOfType(a, TagC.class, "a", "c"));
}
use of jakarta.servlet.jsp.tagext.Tag in project spring-framework by spring-projects.
the class TagUtilsTests method hasAncestorOfTypeTrueScenario.
@Test
public void hasAncestorOfTypeTrueScenario() throws Exception {
Tag a = new TagA();
Tag b = new TagB();
Tag c = new TagC();
a.setParent(b);
b.setParent(c);
assertThat(TagUtils.hasAncestorOfType(a, TagC.class)).isTrue();
}
use of jakarta.servlet.jsp.tagext.Tag in project tomcat by apache.
the class TagHandlerPool method get.
/**
* Gets the next available tag handler from this tag handler pool,
* instantiating one if this tag handler pool is empty.
*
* @param handlerClass
* Tag handler class
* @return Reused or newly instantiated tag handler
* @throws JspException
* if a tag handler cannot be instantiated
*/
public Tag get(Class<? extends Tag> handlerClass) throws JspException {
Tag handler;
synchronized (this) {
if (current >= 0) {
handler = handlers[current--];
return handler;
}
}
// wait for us to construct a tag for this thread.
try {
if (useInstanceManagerForTags) {
return (Tag) instanceManager.newInstance(handlerClass.getName(), handlerClass.getClassLoader());
} else {
Tag instance = handlerClass.getConstructor().newInstance();
instanceManager.newInstance(instance);
return instance;
}
} catch (Exception e) {
Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
ExceptionUtils.handleThrowable(t);
throw new JspException(e.getMessage(), t);
}
}
use of jakarta.servlet.jsp.tagext.Tag in project spring-framework by spring-projects.
the class TagUtilsTests method hasAncestorOfTypeFalseScenario.
@Test
public void hasAncestorOfTypeFalseScenario() throws Exception {
Tag a = new TagA();
Tag b = new TagB();
Tag anotherB = new TagB();
a.setParent(b);
b.setParent(anotherB);
assertThat(TagUtils.hasAncestorOfType(a, TagC.class)).isFalse();
}
Aggregations