Search in sources :

Example 1 with MockRequest

use of testutils.mock.MockRequest in project runwar by cfmlprojects.

the class UrlRewriteFilterTest method simpleApacheHConf.

@Test
public void simpleApacheHConf() throws IOException, ServletException, InvocationTargetException {
    Conf conf = new Conf(servletContext, new FileInputStream(new File("src/test/resources/urlrewrite.htaccess")), "urlrewrite.htaccess", null, true);
    assertTrue(conf.isEngineEnabled());
    assertTrue(conf.isOk());
    assertTrue(conf.getRules().size() > 0);
    NormalRewrittenUrl rewrittenRequest;
    MockRequest request;
    UrlRewriter urlRewriter = new UrlRewriter(conf);
    request = new MockRequest("/notthere");
    rewrittenRequest = (NormalRewrittenUrl) urlRewriter.processRequest(request, response);
    assertNotNull(rewrittenRequest);
    assertEquals("index.cfm/notthere", rewrittenRequest.getTarget());
}
Also used : Conf(org.tuckey.web.filters.urlrewrite.Conf) UrlRewriter(org.tuckey.web.filters.urlrewrite.UrlRewriter) MockRequest(testutils.mock.MockRequest) File(java.io.File) FileInputStream(java.io.FileInputStream) NormalRewrittenUrl(org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl) Test(org.junit.jupiter.api.Test)

Aggregations

File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 Test (org.junit.jupiter.api.Test)1 Conf (org.tuckey.web.filters.urlrewrite.Conf)1 NormalRewrittenUrl (org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl)1 UrlRewriter (org.tuckey.web.filters.urlrewrite.UrlRewriter)1 MockRequest (testutils.mock.MockRequest)1