Package net.infopeers.restrant.engine.parser

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


   
    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


   
    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

    ParserManager pm = new ParserManager(exPolicy);
    pm.setParsers(parsers);
    pm.setRequest(req);
    pm.select(path);
    Params params = pm.getSelectedParam();
    PatternParser selectedParser = pm.getSelectedParser();
    logger.log(Level.FINE, "selectedParser: " + selectedParser);

    if (params == null) {
      throw new ResourceNotFoundException(path + "に対応するフォーマットがありません");
    }
View Full Code Here

   
    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

    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

    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

    params.addParams("uid", "111");
    assertEquals("111", params.get("uid"));
   
    //qqqに対応する引数が存在しない
   
    PatternParser parser = new TextUrlParser(format, phFormatter);
    assertFalse(parser.parse(params, path));
  }
View Full Code Here

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

    PatternParser parser = new TextUrlParser(format, phFormatter);
    assertFalse(parser.parse(params, path));
  }
View Full Code Here

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

    String format = "/:controller?id=:id :action=put";
    String path = "/con";

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

TOP

Related Classes of net.infopeers.restrant.engine.parser.PatternParser

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.