@VisibleForTesting
  String getRequestBodyParamsAsStr( NameValuePair[] pairs, String charset ) throws KettleException {
    StringBuffer buf = new StringBuffer();
    try {
      for ( int i = 0; i < pairs.length; ++i ) {
        NameValuePair pair = pairs[ i ];
        if ( pair.getName() != null ) {
          if ( i > 0 ) {
            buf.append( "&" );
          }

          buf.append( URLEncoder.encode( pair.getName(), !StringUtil.isEmpty( charset ) ? charset : DEFAULT_ENCODING ) );
          buf.append( "=" );
          if ( pair.getValue() != null ) {
            buf.append( URLEncoder.encode( pair.getValue(), !StringUtil.isEmpty( charset ) ? charset : DEFAULT_ENCODING ) );
          }
        }
      }
      return buf.toString();
    } catch ( UnsupportedEncodingException e ) {
      throw new KettleException( e.getMessage(), e.getCause() );
    }
  }
@Test
  public void getRequestBodyParametersAsStringWithNullEncoding() throws KettleException {
    HTTPPOST http = mock( HTTPPOST.class );
    doCallRealMethod().when( http ).getRequestBodyParamsAsStr( any( NameValuePair[].class ), nullable( String.class ) );

    NameValuePair[] pairs = new NameValuePair[] {
      new BasicNameValuePair( "u", "usr" ),
      new BasicNameValuePair( "p", "pass" )
    };

    assertEquals( "u=usr&p=pass", http.getRequestBodyParamsAsStr( pairs, null ) );
  }