@SuppressWarnings("unchecked")
  @Test
  public void testLoadSpecifiedValues() {
    pf.setDefaultValue("testDefault");
    pf.setRegex("testRegex");
    pf.setNormalize(new CaseNormalizer(Case.UPPER, Locale.CANADA));
    startPage();

    AbstractTextComponent<String> defaultValue =
        (AbstractTextComponent<String>)
            tester.getComponentFromLastRenderedPage("form:panel:defaultValue");
    AbstractTextComponent<String> regex =
        (AbstractTextComponent<String>) tester.getComponentFromLastRenderedPage("form:panel:regex");
    AbstractSingleSelectChoice<Case> kase =
        (AbstractSingleSelectChoice<Case>)
            tester.getComponentFromLastRenderedPage("form:panel:normalize:case");
    AbstractSingleSelectChoice<Locale> locale =
        (AbstractSingleSelectChoice<Locale>)
            tester.getComponentFromLastRenderedPage("form:panel:normalize:locale");

    assertThat(defaultValue.getValue(), equalTo("testDefault"));
    assertThat(regex.getValue(), equalTo("testRegex"));
    assertThat(kase.getValue(), equalTo("UPPER"));
    assertThat(locale.getValue(), equalTo("en_CA"));
  }
Exemplo n.º 2
0
  /**
   * Add a {@link RegexpParameterFilter} set accept anything, replacing any existing filter for the
   * same parameter.
   *
   * @param tileLayerInfo layer to update the filter on
   * @param paramKey key for the parameter
   * @param createParam create a new filter if there is none to replace for the specified key
   */
  public static void updateAcceptAllRegExParameterFilter(
      final GeoServerTileLayerInfo tileLayerInfo, final String paramKey, boolean createParam) {

    createParam |= tileLayerInfo.removeParameterFilter(paramKey);

    if (createParam) {
      RegexParameterFilter filter = new RegexParameterFilter();
      filter.setKey(paramKey);
      filter.setDefaultValue("");
      filter.setRegex(".*");
      tileLayerInfo.addParameterFilter(filter);
    }
  }