Package net.sourceforge.urlrewriter4j.core

Examples of net.sourceforge.urlrewriter4j.core.RewriterEngine


    oConfiguration.getRules().add(new SetCookieAction("MyCookie", "MyValue"));

    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/test.aspx"));
    RewriterEngine oEngine = new RewriterEngine(oConfiguration);
    oEngine.rewrite(oMockFacade);

    oMockFacade.expectStatusCode(200);
    oMockFacade.expectLocation("/test.aspx");
    oMockFacade.expectCookieSet("MyCookie", "MyValue");
  }
View Full Code Here


    oConfiguration.getRules().add(
        new SetStatusAction(HttpServletResponse.SC_PARTIAL_CONTENT));
   
    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/test.aspx"));
    RewriterEngine oEngine = new RewriterEngine(oConfiguration);
    oEngine.rewrite(oMockFacade);

    oMockFacade.expectStatusCode(206);
    oMockFacade.expectLocation("/test.aspx");
  }
View Full Code Here

  public void testGooglebotUserAgent() throws Exception {
    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/robots.txt"));
    oMockFacade.addServerVariable("HTTP_USER_AGENT", "Googlebot/2.1");
    RewriterEngine oEngine = new RewriterEngine(GetConfig());
    try {
      oEngine.rewrite(oMockFacade);
      fail();
    } catch (RewriteException e) {
    }
    oMockFacade.expectStatusCode(403);
  }
View Full Code Here

  public void testForbiddenIPRange() throws Exception {
    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/robots.txt"));
    oMockFacade.addServerVariable("REMOTE_ADDR", "10.0.0.1");
    RewriterEngine oEngine = new RewriterEngine(GetConfig());
    try {
      oEngine.rewrite(oMockFacade);
      fail();
    } catch (RewriteException e) {
    }
    oMockFacade.expectStatusCode(403);
  }
View Full Code Here

  }

  public void testGoneContent() throws Exception {
    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/dead_content/boring_article.html"));
    RewriterEngine oEngine = new RewriterEngine(GetConfig());
    try {
      oEngine.rewrite(oMockFacade);
      fail();
    } catch (RewriteException e) {
    }
    oMockFacade.expectStatusCode(410);
  }
View Full Code Here

  }

  public void testMethodNotAllowed() throws Exception {
    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "DELETE", new URL("http://localhost/robots.txt"));
    RewriterEngine oEngine = new RewriterEngine(GetConfig());
    try {
      oEngine.rewrite(oMockFacade);
      fail();
    } catch (RewriteException e) {
    }
    oMockFacade.expectStatusCode(405);
  }
View Full Code Here

  public void testNotImplemented() throws Exception {
    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/advanced-functions/"));
    oMockFacade.addServerVariable("HTTP_HOST", "simple.com");
    RewriterEngine oEngine = new RewriterEngine(GetConfig());
    try {
      oEngine.rewrite(oMockFacade);
      fail();
    } catch (RewriteException e) {
    }
    oMockFacade.expectStatusCode(501);
  }
View Full Code Here

    if (f.exists())
      f.delete();

    MockContextFacade oMockFacade = new MockContextFacade("/", "src/test/resources",
        "GET", new URL("http://localhost/upload/info/12345.txt"));
    RewriterEngine oEngine = new RewriterEngine(GetConfig());
    oEngine.rewrite(oMockFacade);
    oMockFacade.expectStatusCode(200);

    f.createNewFile();

    MockContextFacade oMockFacade2 = new MockContextFacade("/", "src/test/resources",
        "GET", new URL("http://localhost/upload/info/12345.txt"));
    RewriterEngine oEngine2 = new RewriterEngine(GetConfig());
    oEngine2.rewrite(oMockFacade2);
    oMockFacade2.expectStatusCode(206);
  }
View Full Code Here

  }

  public void testRewrite() throws Exception {
    MockContextFacade oMockFacade = new MockContextFacade("/", "src/test/resources",
        "GET", new URL("http://localhost/browse/antiques"));
    RewriterEngine oEngine = new RewriterEngine(GetConfig());
    oEngine.rewrite(oMockFacade);
    oMockFacade.expectLocation("/browse.aspx?cat=antiques");
    oMockFacade.expectStatusCode(200);
  }
View Full Code Here

    if (f.exists())
      f.delete();

    MockContextFacade oMockFacade = new MockContextFacade("/", "src/test/resources",
        "GET", new URL("http://localhost/advertiser/home.html"));
    RewriterEngine oEngine = new RewriterEngine(GetConfig());
    oEngine.rewrite(oMockFacade);
    oMockFacade.expectLocation("/advertiser/home.html");
    oMockFacade.expectStatusCode(200);

    f.createNewFile();

    MockContextFacade oMockFacade2 = new MockContextFacade("/", "src/test/resources",
        "GET", new URL("http://localhost/advertiser/home.html"));
    RewriterEngine oEngine2 = new RewriterEngine(GetConfig());
    oEngine2.rewrite(oMockFacade2);
    oMockFacade2.expectStatusCode(302);
    oMockFacade2.expectRedirectLocation("/advertiser/down.html");
    oMockFacade2.expectHeaderSet("Pragma", "no-cache");
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.urlrewriter4j.core.RewriterEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.