Пример #1
0
  public void testWidgetProcessor() {

    PathProcessor processor = new PathProcessor();
    StaticXmlWidget springInput = new FormInputTag();
    StaticSpringMetawidget metawidget = new StaticSpringMetawidget();
    Map<String, String> attributes = CollectionUtils.newHashMap();

    // Null value

    attributes.put(NAME, "bar");
    springInput = processor.processWidget(springInput, PROPERTY, attributes, metawidget);
    assertEquals("<form:input path=\"bar\"/>", springInput.toString());

    // Non-null value, no dot separator

    metawidget.setValue("foo");
    springInput = processor.processWidget(springInput, PROPERTY, attributes, metawidget);
    assertEquals("<form:input path=\"bar\"/>", springInput.toString());

    // Non-null value, dot separator

    metawidget.setValue("org.foo");
    springInput = processor.processWidget(springInput, PROPERTY, attributes, metawidget);
    assertEquals("<form:input path=\"foo.bar\"/>", springInput.toString());
  }
Пример #2
0
  public void testSimpleType() {

    StaticSpringMetawidget metawidget = new StaticSpringMetawidget();

    // Name is meaningless because it will take the name of the inner class members.
    metawidget.putAttribute(NAME, "meaningless");
    metawidget.setValue("${foo}");
    metawidget.setPath(Foo.class.getName());

    String result =
        "<table>"
            + "<tbody><tr><th><form:label path=\"bar\">Bar:</form:label></th><td><form:input path=\"bar\"/></td><td/></tr>"
            + "<tr><th><form:label path=\"baz\">Baz:</form:label></th><td><form:input path=\"baz\"/></td><td/></tr>"
            + "</tbody></table>";

    assertEquals(result, metawidget.toString());
  }