示例#1
0
  @Test
  public void shouldIgnoreMatrixParamsWithoutValueOnPath() throws Exception {
    String matrixParameterString = ";Param2=1;address=";
    restResource.setPath("/maps/api/geocode/xml" + matrixParameterString);

    assertThat(restResource.getFullPath(), not(containsString(matrixParameterString)));

    String childResourceParameterString = ";ver=";
    RestResource childResource =
        restResource.addNewChildResource(
            "Child", "{test}/test/version" + childResourceParameterString);
    assertThat(childResource.getPath(), not(containsString(childResourceParameterString)));

    assertThat(childResource.getFullPath(), not(containsString(matrixParameterString)));
    assertThat(childResource.getFullPath(), not(containsString(childResourceParameterString)));
  }
示例#2
0
  @Test
  public void shouldListenToChangesInConfiguredParameters() throws Exception {
    RestService parentService = restResource.getService();
    RestResourceConfig config = RestResourceConfig.Factory.newInstance();
    RestParametersConfig restParametersConfig = config.addNewParameters();
    RestParameterConfig parameterConfig = restParametersConfig.addNewParameter();
    String parameterName = "theName";
    parameterConfig.setName(parameterName);
    parameterConfig.setStyle(
        RestParameterConfig.Style.Enum.forInt(
            RestParamsPropertyHolder.ParameterStyle.QUERY.ordinal()));
    config.setPath("/actual_path");

    RestResource restResource = new RestResource(parentService, config);
    restResource
        .getParams()
        .getProperty(parameterName)
        .setStyle(RestParamsPropertyHolder.ParameterStyle.TEMPLATE);
    assertThat(restResource.getPath(), containsString(parameterName));
  }