public void testPutInsert2()
      throws IOException, NestedActionException, ClassNotFoundException, InstantiationException,
          IllegalAccessException, InvocationTargetException, NoSuchMethodException,
          BadXMLException {

    execContext.put(ActionConst.WEB_REAL_PATH_BEAN_REF, "/pages");
    String page =
        "<pager:put key=\"put-content\"><pager:insert page=\"insert3.xhtml\"/></pager:put>"
            + "<pager:echo>put-content:[${put-content}]</pager:echo>";

    Action action = new Action("/pages", "", ActionConst.DEFAULT_PAGER_NAMESPACE);
    String newPage = action.processPage(execContext, page);
    String s = execContext.getString("put-content");
    assertEquals("content of insert3.html", s);
    assertEquals("put-content:[content of insert3.html]", newPage);
  }
  public void testPutInsert()
      throws IOException, NestedActionException, ClassNotFoundException, InstantiationException,
          IllegalAccessException, InvocationTargetException, NoSuchMethodException,
          BadXMLException {
    URL url = ResourceUtils.class.getResource("/pages");
    Validate.notNull(url, "Resource [" + "/pages" + "] not found");

    // log.warn("url.path:" + url.getPath());
    // log.warn("url.file:" + url.getFile());
    execContext.put(ActionConst.WEB_REAL_PATH_BEAN_REF, "/pages");
    String page =
        "<pager:put key=\"put-content\"><pager:insert page=\"insert3.xhtml\"/></pager:put>"
            + "<pager:echo>put-content:${put-content}</pager:echo>";

    Action action = new Action("", "", ActionConst.DEFAULT_PAGER_NAMESPACE);
    String newPage = action.processPage(execContext, page);
    String s = execContext.getString("put-content");
    assertEquals("content of insert3.html", s);
    assertEquals("put-content:content of insert3.html", newPage);
  }
  public static Html[] addLinksToExecContext(
      IExecContext execContext, List<Link> links, Theme theme) {
    Html[] htmlAs = new HtmlA[links.size()];

    int i = 0;
    for (Link link : links) {
      Html htmlA = link.draw(execContext, theme);
      execContext.put(link.getName(), htmlA);
      htmlAs[i++] = htmlA;
    }
    return htmlAs;
  }
  public static HtmlInput[] addButtonsToExecContext(
      IExecContext execContext, List<Button> buttons, Theme theme) {

    HtmlInput[] inputs = new HtmlInput[buttons.size()];

    int i = 0;
    for (Button button : buttons) {
      HtmlInput input = button.draw(execContext, theme);
      execContext.put(button.getName(), input);
      inputs[i++] = input;
    }
    return inputs;
  }
 public void testLogMap()
     throws IOException, DocumentException, ClassNotFoundException, InstantiationException,
         IllegalAccessException, InvocationTargetException, NoSuchMethodException, BadXMLException,
         NestedActionException {
   LogAction logAction = new LogAction();
   Map<String, Object> map = new HashMap<String, Object>();
   map.put("k1", "Value k1");
   map.put("k2", "Value k2");
   execContext.put("map1", map);
   logAction.setKey("map1");
   String output = logAction.execute(execContext);
   log.debug(output);
 }
  public void test()
      throws ConfigurationException, IOException, NestedActionException, DocumentException,
          ClassNotFoundException, InstantiationException, IllegalAccessException,
          InvocationTargetException, NoSuchMethodException, BadXMLException {

    // execContext.put("data_source", DataStructureTest.getDatabase());
    // execContext.put("connection", DBServerTest.getConnection());
    execContext.put(ActionConst.WEB_REAL_PATH_BEAN_REF, "src/test/resources");
    Action action = new Action("/pages", "callback_phone.uhtml", "pager");
    String page = action.processPage(execContext);
    log.debug("page:" + page);
    assertTrue(page.indexOf("form action") > -1);
  }
  public void setUp() {

    if (execContext == null) {
      ClassPathXmlApplicationContext applicationContext =
          new ClassPathXmlApplicationContext(
              new String[] {
                ActionConst.SPRING_STARTUP_CONFIG,
                "classpath*:/config/spring/test-spring-pager-web-startup.xml"
              });
      execContext = (ExecContext) applicationContext.getBean(ActionConst.EXEC_CONTEXT_BEAN_REF);
      execContext.setApplicationContext(applicationContext);
    }
  }
  public void testPagerLoad()
      throws IOException, NestedActionException, DocumentException, ClassNotFoundException,
          InstantiationException, IllegalAccessException, InvocationTargetException,
          NoSuchMethodException, BadXMLException {

    execContext.put(ActionConst.PAGE_NAMESPACE_BEAN_REF, "pager");
    execContext.put(ActionConst.WEB_REAL_PATH_BEAN_REF, "/pages");
    Action action = new Action("/pages", "put.xhtml", "pager");
    String page = action.processPage(execContext);
    // log.debug("page:" + page);
    assertTrue(
        "Should have found [1st put content] on the page", page.indexOf("1st put content") > -1);
  }