Package net.sourceforge.urlrewriter4j.core.actions

Examples of net.sourceforge.urlrewriter4j.core.actions.ConditionalAction


   * @see net.urlrewriter.parsers.RewriteActionParserBase#parse(org.w3c.dom.Node, java.lang.Object)
   */
  @Override
  public IRewriteAction parse(Node pNode, RewriterConfiguration pConfig)
      throws ConfigurationException {
    ConditionalAction oRule = new ConditionalAction();
    // Process the conditions on the element.
    boolean oNegative = (Constants.ELEMENT_IFNOT.equals(pNode.getNodeName()));
    if (mLogger.isDebugEnabled()) mLogger.debug("Parsing conditions...");
    parseConditions(pNode, oRule.getConditions(), oNegative, pConfig);

    // Next, process the actions on the element.
    readActions(pNode, oRule.getActions(), pConfig);

    return oRule;
  }
View Full Code Here


    RewriterConfiguration oConfiguration = new RewriterConfiguration();
    //rule.setFrom("^/([a-z]+)/([0-9]+)/" + i + "/$");
      // rule.setTo("/blah/a/$2/");   
    for (int i = 0; i < 1000; i++) {
      RewriteAction oRewriteAction = new RewriteAction("/blah/a/$2/", RewriteProcessing.StopProcessing); // RewriteProcessing.StopProcessing);
      ConditionalAction oAction = new ConditionalAction();
      oAction.getConditions().add(new UrlMatchCondition("^/([a-z]+)/([0-9]+)/" + i + "/$"));
      oAction.getActions().add(oRewriteAction);
      oConfiguration.getRules().add(oAction);
    }   
    final RewriterEngine oEngine = new RewriterEngine(oConfiguration);
    final MockContextFacade oMockFacade = new MockContextFacade("http://localhost/dir/999/45/");
   
View Full Code Here

  }

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

    ConditionalAction oAction = new ConditionalAction();
    oAction.getConditions().add(new AddressCondition("127.0.0.1"));
    oAction.getActions().add(new NotImplementedAction());

    oConfiguration.getRules().add(oAction);

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

  }

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

    ConditionalAction oAction = new ConditionalAction();
    oAction.getConditions().add(new AddressCondition("127.0.0.1"));
    oAction.getActions().add(new NotImplementedAction());

    oConfiguration.getRules().add(oAction);

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

  }

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

    ConditionalAction oAction = new ConditionalAction();
    oAction.getConditions().add(new ExistsCondition("/foo.aspx"));
    oAction.getActions().add(new NotImplementedAction());

    oConfiguration.getRules().add(oAction);

    MockContextFacade oMockFacade = new MockContextFacade("/", "src/test/resources",
        "GET", new URL("http://localhost/test.aspx"));
View Full Code Here

  }

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

    ConditionalAction oAction = new ConditionalAction();
    oAction.getConditions().add(new ExistsCondition("/foo1.aspx"));
    oAction.getActions().add(new NotImplementedAction());

    oConfiguration.getRules().add(oAction);

    MockContextFacade oMockFacade = new MockContextFacade("/", "src/test/resources",
        "GET", new URL("http://localhost/test.aspx"));
View Full Code Here

  }

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

    ConditionalAction oAction = new ConditionalAction();
    oAction.getConditions().add(new UrlMatchCondition("/test.aspx"));
    oAction.getActions().add(new NotImplementedAction());

    oConfiguration.getRules().add(oAction);

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

  }

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

    ConditionalAction oAction = new ConditionalAction();
    oAction.getConditions().add(new UrlMatchCondition("/foo1.aspx"));
    oAction.getActions().add(new NotImplementedAction());

    oConfiguration.getRules().add(oAction);

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

  protected void tearDown() throws Exception {
    //BasicConfigurator.resetConfiguration();
  }

  public void testReduceWithRegEx() throws Exception {
    ConditionalAction oAction = createUrlConditionAndRewirteAction("/rewritten-$1.html", "/test.aspx\\?location=(\\d+)");
    mConfiguration.getRules().add(oAction);
   
    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/test.aspx?location=1234"));
    mEngine.rewrite(oMockFacade);
View Full Code Here

    mEngine.rewrite(oMockFacade);
    oMockFacade.expectLocation("/rewritten-1234.html");
  }
 
  public void testReduceWithQueryStringParam() throws Exception {
    ConditionalAction oAction = createUrlConditionAndRewirteAction("/rewritten-$(location).html", "/test.aspx.*");
    mConfiguration.getRules().add(oAction);
   
    MockContextFacade oMockFacade = new MockContextFacade("/", ".",
        "GET", new URL("http://localhost/test.aspx?location=1234"));
    mEngine.rewrite(oMockFacade);
View Full Code Here

TOP

Related Classes of net.sourceforge.urlrewriter4j.core.actions.ConditionalAction

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.