Package jodd.madvoc.component

Examples of jodd.madvoc.component.ResultMapper


  @Test
  public void testResolveResultPath() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    ResultMapper resultMapper = webapp.getComponent(ResultMapper.class);

    String path = "/boo.foo.html";
    ResultPath resultPath = resultMapper.resolveResultPath(path, "ok");
    assertEquals("/boo.foo.html.ok", resultPath.getPathValue());
    assertEquals("/boo.foo.html", resultPath.getPath());
    assertEquals("ok", resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "doo.ok");
    assertEquals("/boo.foo.html.doo.ok", resultPath.getPathValue());
    assertEquals("/boo.foo.html", resultPath.getPath());
    assertEquals("doo.ok", resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "#ok");
    assertEquals("/boo.foo.ok", resultPath.getPathValue());
    assertEquals("/boo.foo.ok", resultPath.getPath());
    assertNull(resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "#.ok");
    assertEquals("/boo.foo.ok", resultPath.getPathValue());
    assertEquals("/boo.foo", resultPath.getPath());
    assertEquals("ok", resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "#.ok.do");
    assertEquals("/boo.foo.ok.do", resultPath.getPathValue());
    assertEquals("/boo.foo", resultPath.getPath());
    assertEquals("ok.do", resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "##ok");
    assertEquals("/boo.ok", resultPath.getPathValue());
    assertEquals("/boo.ok", resultPath.getPath());
    assertNull(resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "##.ok");
    assertEquals("/boo.ok", resultPath.getPathValue());
    assertEquals("/boo", resultPath.getPath());
    assertEquals("ok", resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "##ok.do");
    assertEquals("/boo.ok.do", resultPath.getPathValue());
    assertEquals("/boo.ok.do", resultPath.getPath());
    assertNull(resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "##ok..do");
    assertEquals("/boo.ok.do", resultPath.getPathValue());
    assertEquals("/boo.ok", resultPath.getPath());
    assertEquals("do", resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "#");
    assertEquals("/boo.foo", resultPath.getPath());
    assertNull(resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, null);
    assertEquals("/boo.foo.html", resultPath.getPath());
    assertNull(resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "/xxx");
    assertEquals("/xxx", resultPath.getPath());
    assertNull(resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "/xxx.ext");
    assertEquals("/xxx.ext", resultPath.getPath());
    assertNull(resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "/xxx..ext");
    assertEquals("/xxx", resultPath.getPath());
    assertEquals("ext", resultPath.getValue());

    path = "/boo.html";
    resultPath = resultMapper.resolveResultPath(path, "ok");
    assertEquals("/boo.html", resultPath.getPath());
    assertEquals("ok", resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "#.ok");
    assertEquals("/boo", resultPath.getPath());
    assertEquals("ok", resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "##ok");
    assertEquals("/ok", resultPath.getPath());
    assertEquals(null, resultPath.getValue());

    resultPath = resultMapper.resolveResultPath(path, "##.ok");
    assertEquals("/", resultPath.getPath());
    assertEquals("ok", resultPath.getValue());
  }
View Full Code Here


  @Test
  public void testMethodWithPrefix() {
    WebApplication webapp = new WebApplication(true);
    webapp.registerMadvocComponents();
    ResultMapper resultMapper = webapp.getComponent(ResultMapper.class);
    MadvocConfig madvocConfig = webapp.getComponent(MadvocConfig.class);
    madvocConfig.setResultPathPrefix("/WEB-INF");

    String path = "/boo.foo";

    ResultPath resultPath = resultMapper.resolveResultPath(path, "ok");
    assertEquals("/WEB-INF/boo.foo.ok", resultPath.getPathValue());

    resultPath = resultMapper.resolveResultPath(path, "doo.ok");
    assertEquals("/WEB-INF/boo.foo.doo.ok", resultPath.getPathValue());

    resultPath = resultMapper.resolveResultPath(path, "#ok");
    assertEquals("/WEB-INF/boo.ok", resultPath.getPathValue());

    resultPath = resultMapper.resolveResultPath(path, "#");
    assertEquals("/WEB-INF/boo", resultPath.getPathValue());

    resultPath = resultMapper.resolveResultPath(path, "#doo.ok");
    assertEquals("/WEB-INF/boo.doo.ok", resultPath.getPathValue());

    resultPath = resultMapper.resolveResultPath(path, null);
    assertEquals("/WEB-INF/boo.foo", resultPath.getPathValue());

    resultPath = resultMapper.resolveResultPath(path, "/xxx");
    assertEquals("/xxx", resultPath.getPathValue());

    resultPath = resultMapper.resolveResultPath(path, "/xxx.ext");
    assertEquals("/xxx.ext", resultPath.getPathValue());
  }
View Full Code Here

    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    actionsManager.register(BooAction.class, "foo5");
    actionsManager.registerPathAlias("ok", "xxx.jsp");
    actionsManager.registerPathAlias("sok", "zzz");

    ResultMapper resultMapper = webapp.getComponent(ResultMapper.class);

    String path = "/boo.foo.html";

    ResultPath resultPath = resultMapper.resolveResultPath(path, "/<ok>?foo=1");
    assertEquals("/xxx.jsp?foo=1", resultPath.getPathValue());

    resultPath = resultMapper.resolveResultPath(path, "<sok>");
    assertEquals("/boo.foo.html.zzz", resultPath.getPathValue());

    resultPath = resultMapper.resolveResultPath(path, "#<sok>");
    assertEquals("/boo.foo.zzz", resultPath.getPathValue());

    resultPath = resultMapper.resolveResultPath(path, "<dude>?foo=1");
    assertEquals("/xxx.html?foo=1", resultPath.getPathValue());
  }
View Full Code Here

    ActionsManager actionsManager = webapp.getComponent(ActionsManager.class);
    actionsManager.register(BooAction.class, "foo2");
    actionsManager.registerPathAlias("/boo.foo2.xxx", "/aliased");

    ResultMapper resultMapper = webapp.getComponent(ResultMapper.class);
    ActionMethodParser actionMethodParser = webapp.getComponent(ActionMethodParser.class);

    ActionConfig cfg = parse(actionMethodParser, "tst.BooAction#foo2");
    String path = cfg.getActionPath();

    String resultPath = resultMapper.resolveResultPathString(path, null);
    assertEquals("/aliased", resultPath);
  }
View Full Code Here

        targets.add(target);
        return false;
      }
    };

    ResultMapper resultMapper = webapp.getComponent(ResultMapper.class);
    BeanUtil.setDeclaredProperty(sdr, "resultMapper", resultMapper);

    ActionRequest actionRequest = createActionRequest("/hello.world.html");
    sdr.render(actionRequest, "ok");
View Full Code Here

TOP

Related Classes of jodd.madvoc.component.ResultMapper

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.