コード例 #1
0
ファイル: SelectTest.java プロジェクト: JUGMadagascar/struts
  /**
   * WW-1747 - should be a valid test case for the described issue
   *
   * @throws Exception
   */
  public void testMultipleWithLists() throws Exception {
    TestAction testAction = (TestAction) action;
    Collection collection = new ArrayList(2);

    collection.add(1l);
    collection.add(300000000l);
    testAction.setCollection(collection);

    List selectList = new ArrayList();
    selectList.add(new LongObject(1l, "foo"));
    selectList.add(new LongObject(2l, "bar"));
    selectList.add(new LongObject(300000000l, "foobar"));
    testAction.setList2(selectList);

    SelectTag tag = new SelectTag();
    tag.setPageContext(pageContext);
    tag.setLabel("mylabel");
    tag.setName("collection");
    tag.setList("list2");
    tag.setListKey("id");
    tag.setListValue("value");
    tag.setMultiple("true");
    tag.setOnmousedown("alert('onmousedown');");
    tag.setOnmousemove("alert('onmousemove');");
    tag.setOnmouseout("alert('onmouseout');");
    tag.setOnmouseover("alert('onmouseover');");
    tag.setOnmouseup("alert('onmouseup');");

    tag.doStartTag();
    tag.doEndTag();

    verify(SelectTag.class.getResource("Select-12.txt"));
  }
コード例 #2
0
ファイル: SelectTest.java プロジェクト: JUGMadagascar/struts
  public void testMultiple() throws Exception {
    TestAction testAction = (TestAction) action;
    Collection collection = new ArrayList(2);
    collection.add("hello");
    collection.add("foo");
    testAction.setCollection(collection);
    testAction.setList(
        new String[][] {
          {"hello", "world"},
          {"foo", "bar"},
          {"cat", "dog"}
        });

    SelectTag tag = new SelectTag();
    tag.setPageContext(pageContext);
    tag.setLabel("mylabel");
    tag.setName("collection");
    tag.setList("list");
    tag.setListKey("top[0]");
    tag.setListValue("top[1]");
    tag.setMultiple("true");
    tag.setOnmousedown("alert('onmousedown');");
    tag.setOnmousemove("alert('onmousemove');");
    tag.setOnmouseout("alert('onmouseout');");
    tag.setOnmouseover("alert('onmouseover');");
    tag.setOnmouseup("alert('onmouseup');");

    tag.doStartTag();
    tag.doEndTag();

    verify(SelectTag.class.getResource("Select-2.txt"));
  }
コード例 #3
0
ファイル: SelectTest.java プロジェクト: JUGMadagascar/struts
  private void prepareTagGeneric(SelectTag tag) {
    TestAction testAction = (TestAction) action;
    ArrayList collection = new ArrayList();
    collection.add("foo");
    collection.add("bar");
    collection.add("baz");

    testAction.setCollection(collection);

    tag.setList("collection");
  }
コード例 #4
0
ファイル: SelectTest.java プロジェクト: JUGMadagascar/struts
  /** Tests WW-455: Select tag template does not work properly for Object like BigDecimal. */
  public void testBigDecimal() throws Exception {
    BigDecimalObject hello = new BigDecimalObject("hello", new BigDecimal(1));
    BigDecimalObject foo = new BigDecimalObject("foo", new BigDecimal(2));

    TestAction testAction = (TestAction) action;

    Collection collection = new ArrayList(2);
    // expect strings to be returned, we're still dealing with HTTP here!
    collection.add("hello");
    collection.add("foo");
    testAction.setCollection(collection);

    List list2 = new ArrayList();
    list2.add(hello);
    list2.add(foo);
    list2.add(new BigDecimalObject("<cat>", new BigDecimal(1.500)));
    testAction.setList2(list2);

    SelectTag tag = new SelectTag();
    tag.setPageContext(pageContext);
    tag.setLabel("mylabel");
    tag.setName("collection");
    tag.setList("list2");
    tag.setListKey("name");
    tag.setListValue("bigDecimal");
    tag.setMultiple("true");
    tag.setTitle("mytitle");
    tag.setOnmousedown("alert('onmousedown');");
    tag.setOnmousemove("alert('onmousemove');");
    tag.setOnmouseout("alert('onmouseout');");
    tag.setOnmouseover("alert('onmouseover');");
    tag.setOnmouseup("alert('onmouseup');");

    tag.doStartTag();
    tag.doEndTag();

    verify(SelectTag.class.getResource("Select-3.txt"));
  }