Examples of RewriterConfiguration


Examples of net.sourceforge.urlrewriter4j.core.configuration.RewriterConfiguration

   */
  public void init(FilterConfig pConfig) throws ServletException {
    mServletContext = pConfig.getServletContext();
    if (mEngine != null) return;
    try {
      RewriterConfiguration oConfig = new RewriterConfiguration(getBeanFactory());
      String oPropsFile = pConfig.getInitParameter(PROPERTIES_FILE);
      if (oPropsFile != null) {
        String oFilePath = findPath(pConfig.getServletContext(), oPropsFile);
        Properties oProps = new Properties();
        FileInputStream oIS = null;
        try {
          oIS = new FileInputStream(oFilePath);
          oProps.load(oIS);
          oConfig.setProperties(oProps);
        } catch (IOException oIOE) {
          mLogger.error("Error loading properties file \"" + oFilePath + "\".", oIOE);
          throw oIOE;
        } finally {
          if (oIS != null) oIS.close();
        }
      }
      String oConfigFile = pConfig.getInitParameter(CONFIG_FILE);
      if (oConfigFile == null) throw new ServletException("Must specify configuration file for filter " + pConfig.getFilterName() + " using key \"" + CONFIG_FILE + "\".");

      String oFilePath = pConfig.getServletContext().getRealPath(oConfigFile);
      if (oFilePath == null) throw new ServletException("Could not find configuration file within Servlet Context. Path: " + oConfigFile + ", Real Path: " + oFilePath);
      if (mLogger.isDebugEnabled()) mLogger.debug("Initializing Rewriter Engine with configuration at " + oFilePath + "...");
      oConfig.setConfigurationFromFile(oFilePath);
      if (mLogger.isDebugEnabled()) mLogger.debug("Done reading Rewriter configuration.");
      mEngine = new RewriterEngine(oConfig);     
    } catch (Exception e) {
      mLogger.fatal("Error starting URLRewriter.", e);
      throw new ServletException(e.getMessage(), e);
View Full Code Here

Examples of net.sourceforge.urlrewriter4j.core.configuration.RewriterConfiguration

*
*/
public class ActionTest extends TestCase {

  private RewriterConfiguration getConfig() {
    return new RewriterConfiguration();
  }
View Full Code Here

Examples of net.sourceforge.urlrewriter4j.core.configuration.RewriterConfiguration

  private RewriterConfiguration getConfig() {
    return new RewriterConfiguration();
  }

  public void testAddHeaderAction() throws Exception {
    RewriterConfiguration oConfig = getConfig();
    oConfig.getRules().add(new AddHeaderAction("MyHeader", "header"));

    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/test.aspx"));
    RewriterEngine oEngine = new RewriterEngine(oConfig);
    oEngine.rewrite(oMockFacade);
View Full Code Here

Examples of net.sourceforge.urlrewriter4j.core.configuration.RewriterConfiguration

    oMockFacade.expectHeaderSet("MyHeader", "header");
    oMockFacade.expectLocation("/test.aspx");
  }

  public void testForbiddenAction() throws Exception {
    RewriterConfiguration oConfig = getConfig();
    oConfig.getRules().add(new ForbiddenAction());

    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/test.aspx"));
    RewriterEngine oEngine = new RewriterEngine(oConfig);
    try {
View Full Code Here

Examples of net.sourceforge.urlrewriter4j.core.configuration.RewriterConfiguration

    oMockFacade.expectStatusCode(403);
    oMockFacade.expectLocation("/test.aspx");
  }

  public void testGoneAction() throws Exception {
    RewriterConfiguration oConfiguration = getConfig();

    oConfiguration.getRules().add(new GoneAction());

    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/test.aspx"));
    RewriterEngine oEngine = new RewriterEngine(oConfiguration);
    try {
View Full Code Here

Examples of net.sourceforge.urlrewriter4j.core.configuration.RewriterConfiguration

    oMockFacade.expectStatusCode(410);
    oMockFacade.expectLocation("/test.aspx");
  }

  public void testMethodNotAllowedAction() throws Exception {
    RewriterConfiguration oConfiguration = getConfig();

    oConfiguration.getRules().add(new MethodNotAllowedAction());

    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/test.aspx"));
    RewriterEngine oEngine = new RewriterEngine(oConfiguration);
    try {
View Full Code Here

Examples of net.sourceforge.urlrewriter4j.core.configuration.RewriterConfiguration

    oMockFacade.expectStatusCode(405);
    oMockFacade.expectLocation("/test.aspx");
  }

  public void testNotFoundAction() throws Exception {
    RewriterConfiguration oConfiguration = getConfig();

    oConfiguration.getRules().add(new NotFoundAction());

    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/test.aspx"));
    RewriterEngine oEngine = new RewriterEngine(oConfiguration);
    try {
View Full Code Here

Examples of net.sourceforge.urlrewriter4j.core.configuration.RewriterConfiguration

    oMockFacade.expectStatusCode(404);
    oMockFacade.expectLocation("/test.aspx");
  }

  public void testNotImplementedAction() throws Exception {
    RewriterConfiguration oConfiguration = getConfig();

    oConfiguration.getRules().add(new NotImplementedAction());

    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/test.aspx"));
    RewriterEngine oEngine = new RewriterEngine(oConfiguration);
    try {
View Full Code Here

Examples of net.sourceforge.urlrewriter4j.core.configuration.RewriterConfiguration

    oMockFacade.expectStatusCode(501);
    oMockFacade.expectLocation("/test.aspx");
  }

  public void testMovedAction() throws Exception {
    RewriterConfiguration oConfiguration = getConfig();

    oConfiguration.getRules().add(new RedirectAction("/foo.aspx", true));

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

Examples of net.sourceforge.urlrewriter4j.core.configuration.RewriterConfiguration

    oMockFacade.expectStatusCode(301);
    oMockFacade.expectRedirectLocation("/foo.aspx");
  }

  public void testRedirectAction() throws Exception {
    RewriterConfiguration oConfiguration = getConfig();

    oConfiguration.getRules().add(new RedirectAction("/foo.aspx", false));

    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/test.aspx"));
    RewriterEngine oEngine = new RewriterEngine(oConfiguration);
    oEngine.rewrite(oMockFacade);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.