package com.bastengao.struts2.freeroute;

import org.junit.Assert;
import org.junit.Test;

/**
 * @author bastengao
 * @date 13-1-12 16:45
 */
public class ResultsTest {
    @Test
    public void testOnlyType() {
        String result = Results.result("json");
        Assert.assertNotNull(result);
        Assert.assertEquals("json", result);
    }

    @Test
    public void testResult() {
        String result = Results.result("dispatcher", "/test.html");
        Assert.assertNotNull(result);
        Assert.assertEquals("dispatcher:/test.html", result);
    }

    @Test
    public void testLocationResult() {
        String result = Results.dispatcher("/test.html");
        Assert.assertNotNull(result);
        Assert.assertEquals("dispatcher:/test.html", result);

        String result2 = Results.html("/test.html");
        Assert.assertNotNull(result2);
        Assert.assertEquals("dispatcher:/test.html", result2);

        String result3 = Results.jsp("/test.jsp");
        Assert.assertNotNull(result3);
        Assert.assertEquals("dispatcher:/test.jsp", result3);
    }

    @Test
    public void testPadEnd() {
        String result = Results.padEnd("test.html", ".html");
        Assert.assertEquals("test.html", result);

        result = Results.padEnd("test", ".html");
        Assert.assertEquals("test.html", result);
    }

    @Test
    public void testAutoCompleteSuffix() {
        Assert.assertEquals("dispatcher:/test.html", Results.html("/test.html"));
        Assert.assertEquals("dispatcher:/test.html", Results.html("/test"));

        Assert.assertEquals("dispatcher:/test.jsp", Results.jsp("/test.jsp"));
        Assert.assertEquals("dispatcher:/test.jsp", Results.jsp("/test"));

        Assert.assertEquals("freemarker:/test.ftl", Results.ftl("/test.ftl"));
        Assert.assertEquals("freemarker:/test.ftl", Results.freemarker("/test.ftl"));

        Assert.assertEquals("freemarker:/test.ftl", Results.ftl("/test"));
        Assert.assertEquals("freemarker:/test.ftl", Results.freemarker("/test"));

        Assert.assertEquals("velocity:/test.vm", Results.vm("/test.vm"));
        Assert.assertEquals("velocity:/test.vm", Results.velocity("/test.vm"));

        Assert.assertEquals("velocity:/test.vm", Results.vm("/test"));
        Assert.assertEquals("velocity:/test.vm", Results.velocity("/test"));
    }
}

@@ -2344,11 +2344,426 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testRedirect()%7B%0A        String result = Results.redirect(%22/page.html%22);%0A        Assert.assertEquals(%22redirect:/page.html%22, result);%0A    %7D%0A%0A    @Test%0A    public void testCustomResult() %7B%0A        Assert.assertNotNull(Results.json());%0A%0A        Assert.assertNotNull(Results.chain());%0A%0A        Assert.assertNotNull(Results.stream());%0A%0A        Assert.assertNotNull(Results.httpHeader());%0A    %7D
 %0A%7D%0A

test Results