<commit_before>package org.displaytag.tags;

import javax.servlet.jsp.tagext.BodyContent;

import org.apache.cactus.WebResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.displaytag.sample.TestList;


/**
 * Test for CaptionTag.
 * @author fgiust
 * @version $Revision$ ($Author$)
 */
public class CaptionTagTest extends DisplaytagTestCase
{

    /**
     * logger.
     */
    private static Log log = LogFactory.getLog(CaptionTagTest.class);

    /**
     * @param name test name
     */
    public CaptionTagTest(String name)
    {
        super(name);
    }

    /**
     * base test for the caption tag. @todo unfinished test!
     * @throws Exception any exception thrown during test.
     */
    public void testCaption() throws Exception
    {
        CaptionTag tag = new CaptionTag();
        tag.setPageContext(this.pageContext);
        tag.setClass("cssclass");
        tag.setId("captionid");
        tag.setStyle("border: 1px solid red");
        tag.setTitle("caption title");
        tag.setLang("english");
        tag.setDir("ltr");


        // table setup
        TableTag table = new TableTag();
        table.setPageContext(this.pageContext);
        request.setAttribute("test", new TestList(2, false));
        table.setName("requestScope.test");

        tag.setParent(table);

        // start lifecycle methods
        tag.doStartTag();

        BodyContent bodyContent = this.pageContext.pushBody();
        tag.setBodyContent(bodyContent);
        tag.doInitBody();
        bodyContent.println("This is the caption content");

        // actually handles the processing of the body
        tag.doAfterBody();

        // after the body processing completes
        tag.doEndTag();

        // finally call popBody
        this.pageContext.popBody();

    }

    /**
     * end the test for caption.
     * @param webresponse WebResponse
     */
    public void endCaption(WebResponse webresponse)
    {
        assertContains(webresponse, "<caption");
        assertContains(webresponse, ">This is the caption content<");

        log.debug("RESPONSE" + webresponse.getText());
    }


}<commit_msg>working test case<commit_after>package org.displaytag.tags;

import org.apache.cactus.WebResponse;
import org.apache.cactus.extension.jsp.JspTagLifecycle;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.displaytag.sample.TestList;


/**
 * Test for CaptionTag.
 * @author fgiust
 * @version $Revision$ ($Author$)
 */
public class CaptionTagTest extends DisplaytagTestCase
{

    /**
     * logger.
     */
    private static Log log = LogFactory.getLog(CaptionTagTest.class);

    /**
     * caption tag lifecycle.
     */
    JspTagLifecycle captionLifeCycle;

    /**
     * @param name test name
     */
    public CaptionTagTest(String name)
    {
        super(name);
    }

    /**
     * test set up.
     * @throws Exception any exception thrown during test.
     */
    protected void setUp() throws Exception
    {
        CaptionTag tag = new CaptionTag();
        tag.setPageContext(this.pageContext);
        tag.setClass("cssclass");
        tag.setId("captionid");
        tag.setStyle("border: 1px solid red");
        tag.setTitle("caption title");
        tag.setLang("english");
        tag.setDir("ltr");

        // table setup
        TableTag table = new TableTag();
        table.setPageContext(this.pageContext);
        this.pageContext.setAttribute("test", new TestList(2, false));
        table.setName("pageScope.test");

        tag.setParent(table);

        JspTagLifecycle tableLifeCycle = new JspTagLifecycle(this.pageContext, table);
        captionLifeCycle = tableLifeCycle.addNestedTag(tag);
        captionLifeCycle.addNestedText("This is the caption content");

        tableLifeCycle.invoke();
    }

    /**
     * base test for the caption tag.
     * @throws Exception any exception thrown during test.
     */
    public void testCaption() throws Exception
    {
        captionLifeCycle.expectBodyEvaluated(1);
        captionLifeCycle.expectBodyEvaluated(2);
    }

    /**
     * end the test for caption.
     * @param webresponse WebResponse
     */
    public void endCaption(WebResponse webresponse)
    {
        log.debug("RESPONSE: " + webresponse.getText());

        assertContains(webresponse, "<caption");
        assertContains(webresponse, "class=\"cssclass\"");
        assertContains(webresponse, "id=\"captionid\"");
        assertContains(webresponse, "style=\"border: 1px solid red\"");
        assertContains(webresponse, "title=\"caption title\"");
        assertContains(webresponse, "lang=\"english\"");
        assertContains(webresponse, "dir=\"ltr\"");
        assertContains(webresponse, ">This is the caption content</caption>");
    }


}
{'fraction_non_alphanumeric': 0.1197110423116615, 'fraction_numerical': 0.0014447884416924665, 'mean_word_length': 2.6628873771730914, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2653302', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1348, 'n_words': 302}