Examples of TextUrlParser


Examples of net.infopeers.restrant.engine.parser.TextUrlParser

        }
      }
    }

    for (RouteInfo route : routes) {
      parserHolder.addParser(new TextUrlParser(route.format, phFormatter));
    }

  }
View Full Code Here

Examples of net.infopeers.restrant.engine.parser.TextUrlParser

  private PrefixedPlaceholderFormatter phFormatter = new PrefixedPlaceholderFormatter();

  public void testNonHttpMethod() throws Exception {

    //フォーマットにHTTPメソッドの指定が無い
    TextUrlParser content = new TextUrlParser(
        "/:controller?content=:content&comment=:comment :action=post",
        phFormatter);
   
    TestParams params = new TestParams();
    params.addParams("content", "testcontent");
    params.addParams("comment", "testcomment");

    //どんなメソッドでコールされても動作する
    {
      params.setMethod("get");
      assertTrue(content.parse(params, "/contents"));
    }
    {
      params.setMethod("post");
      assertTrue(content.parse(params, "/contents"));
    }
    {
      params.setMethod("head");
      assertTrue(content.parse(params, "/contents"));
    }
  }
View Full Code Here

Examples of net.infopeers.restrant.engine.parser.TextUrlParser

  }

  public void testWithHttpMethod() throws Exception {

    //フォーマットにHTTPメソッド(@post)が指定されている
    TextUrlParser content = new TextUrlParser(
        "/:controller?content=:content&comment=:comment :action=post @post",
        phFormatter);
   
    TestParams params = new TestParams();
    params.addParams("content", "testcontent");
    params.addParams("comment", "testcomment");

    //POSTでのみ動作する。
    {
      params.setMethod("get");
      assertFalse(content.parse(params, "/contents"));
    }
    {
      params.setMethod("post");
      assertTrue(content.parse(params, "/contents"));
    }
    {
      params.setMethod("head");
      assertFalse(content.parse(params, "/contents"));
    }
  }
View Full Code Here

Examples of net.infopeers.restrant.engine.parser.TextUrlParser

      assertFalse(content.parse(params, "/contents"));
    }
  }
 
  public void testCombine() throws Exception{
    TextUrlParser content = new TextUrlParser(
        "/moba/location?datum=:datum&unit=:unit&lat=:lat&lon=:lon :controller=info :action=location @get",
        phFormatter);
   
    TestParams params = new TestParams();
    params.addParams("datum", "DATUM");
    params.addParams("unit", "UNIT");
    params.addParams("lon", "LON");
    params.addParams("lat", "LAT");
    params.setMethod("get");
       
    assertTrue(content.parse(params, "/moba/location"));
  }
View Full Code Here

Examples of net.infopeers.restrant.engine.parser.TextUrlParser

       
    assertTrue(content.parse(params, "/moba/location"));
  }
 
  public void testSplit() throws Exception{
    TextUrlParser content = new TextUrlParser(
        "/moba/:topic/augps?lat=:lat&lon=:lon :controller=info :action=auGps @get",
        phFormatter);
   
    TestParams params = new TestParams();
    params.addParams("lon", "LON");
    params.addParams("lat", "LAT");
    params.setMethod("get");
       
    assertTrue(content.parse(params, "/moba/TOPIC/augps"));
  }
View Full Code Here

Examples of net.infopeers.restrant.engine.parser.TextUrlParser

   
    TestParams params = new TestParams();
    String format = "/:controller/:action/:id";
    String path = "/con/act/uid";

    PatternParser parser = new TextUrlParser(format, phFormatter);
    assertTrue(parser.parse(params, path));
   
    assertEquals("con", params.get("controller"));
    assertEquals("act", params.get("action"));
    assertEquals("uid", params.get("id"));
  }
View Full Code Here

Examples of net.infopeers.restrant.engine.parser.TextUrlParser

   
    TestParams params = new TestParams();
    String format = "/:controller/:action/:id";
    String path = "/con/act";
   
    PatternParser parser = new TextUrlParser(format, phFormatter);
    assertFalse(parser.parse(params, path));
  }
View Full Code Here

Examples of net.infopeers.restrant.engine.parser.TextUrlParser

   
    TestParams params = new TestParams();
    String format = "/con/:id :action=act   :controller=don";
    String path = "/con/uid";
   
    PatternParser parser = new TextUrlParser(format, phFormatter);
    assertTrue(parser.parse(params, path));
   
    assertEquals("don", params.get("controller"));
    assertEquals("act", params.get("action"));
    assertEquals("uid", params.get("id"));
  }
View Full Code Here

Examples of net.infopeers.restrant.engine.parser.TextUrlParser

    params.addParams("uid", "111");
    assertEquals("111", params.get("uid"));
    params.addParams("uid2", "222");
    assertEquals("222", params.get("uid2"));
   
    PatternParser parser = new TextUrlParser(format, phFormatter);
    assertTrue(parser.parse(params, path));
   
    assertEquals("con", params.get("controller"));
    assertEquals("act", params.get("action"));
    assertEquals("111", params.get("id"));
    assertEquals("222", params.get("id2"));
View Full Code Here

Examples of net.infopeers.restrant.engine.parser.TextUrlParser

    String path = "/con/act";
    params.addParams("uid", "111");
    assertEquals("111", params.get("uid"));
   
    try{
      PatternParser parser = new TextUrlParser(format, phFormatter);
      parser.parse(params, path);
      fail("「?」が複数なら例外");
    }catch(IllegalArgumentException e){
      //ここに来ればよい
    }
  }
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.