package org.lastaflute.web.servlet.filter;

import org.dbflute.utflute.core.PlainTestCase;

/**
 * @author jflute
 */
public class RequestLoggingFilterTest extends PlainTestCase {

    public void test_filterAttributeDisp_cut() throws Exception {
        // ## Arrange ##
        RequestLoggingFilter filter = new RequestLoggingFilter();

        // ## Act ##
        // ## Assert ##
        assertEquals(null, filter.filterAttributeDisp(null));
        assertEquals("sea", filter.filterAttributeDisp("sea"));
        assertEquals("se...", filter.filterAttributeDisp("se\na"));

        StringBuilder overSb = new StringBuilder();
        for (int i = 0; i < 800; i++) {
            overSb.append("a");
        }
        StringBuilder justSb = new StringBuilder();
        for (int i = 0; i < 500; i++) {
            justSb.append("a");
        }
        String justMsg = justSb.toString();
        String overMsg = overSb.toString();
        assertEquals(justMsg + "...", filter.filterAttributeDisp(overMsg));
        assertEquals(justMsg, filter.filterAttributeDisp(justMsg));

        StringBuilder mixSb = new StringBuilder();
        for (int i = 0; i < 600; i++) {
            if (i == 400) {
                mixSb.append("\n");
            }
            mixSb.append("a");
        }
        StringBuilder linedSb = new StringBuilder();
        for (int i = 0; i < 400; i++) {
            linedSb.append("a");
        }
        String mixMsg = mixSb.toString();
        String linedMsg = linedSb.toString();
        assertEquals(linedMsg + "...", filter.filterAttributeDisp(mixMsg));
    }
}

@@ -1588,11 +1588,305 @@
 );%0A    %7D
+%0A%0A    public void test_convertToCutDisp_null() throws Exception %7B%0A        assertNull(new RequestLoggingFilter().convertToCutDisp(null));%0A    %7D%0A%0A    public void test_convertToOneLinerDisp_null() throws Exception %7B%0A        assertNull(new RequestLoggingFilter().convertToOneLinerDisp(null));%0A    %7D
 %0A%7D%0A

test null