@Test public void testQueryString() { m_genericURLConnection = new StubGenericURLConnection(m_baseUrlPathQueryString); assertEquals("Argument 1", m_genericURLConnection.getQueryArgs().get("arg1"), "value1"); assertEquals("Argument 2", m_genericURLConnection.getQueryArgs().get("arg2"), "value2"); assertEquals("Argument 3", m_genericURLConnection.getQueryArgs().get("arg3"), "value3"); }
protected Map<String, String> getQueryArgs() { HashMap<String, String> hashMap = new HashMap<String, String>(); String queryString = this.m_url.getQuery(); if (queryString != null) { try { queryString = URLDecoder.decode(queryString, UTF8_ENCODING); } catch (UnsupportedEncodingException e) { logger.error("Unsupported " + UTF8_ENCODING + " encoding for URL query string: '{}'. Error message: '{}'", queryString, e.getMessage()); } String[] queryArgs = queryString.split(URL_QUERY_ARGS_DELIMITERS); for (String queryArg : queryArgs) { String key = queryArg; String value = EMPTY_STRING; if (queryArg.contains(KEY_VALUE_DELIMITER)) { String[] keyValue = queryArg.split(KEY_VALUE_DELIMITER); key = keyValue[0]; value = keyValue[1]; } if (!EMPTY_STRING.equals(key)) { hashMap.put(key, value); logger.debug("Key: '{}' : Value: '{}'", key, value); } } } return hashMap; }
GenericURLConnection extends URLConnection { protected Map<String, String> getQueryArgs() { HashMap<String, String> hashMap = new HashMap<String, String>(); String queryString = this.m_url.getQuery(); if (queryString != null) { try { queryString = URLDecoder.decode(queryString, UTF8_ENCODING); } catch (UnsupportedEncodingException e) { logger.error("Unsupported " + UTF8_ENCODING + " encoding for URL query string: '{}'. Error message: '{}'", queryString, e.getMessage()); } String[] queryArgs = queryString.split(URL_QUERY_ARGS_DELIMITERS); for (String queryArg : queryArgs) { String key = queryArg; String value = EMPTY_STRING; if (queryArg.contains(KEY_VALUE_DELIMITER)) { String[] keyValue = queryArg.split(KEY_VALUE_DELIMITER); key = keyValue[0]; value = keyValue[1]; } if (!EMPTY_STRING.equals(key)) { hashMap.put(key, value); logger.debug("Key: '{}' : Value: '{}'", key, value); } } } return hashMap; } }
GenericURLConnection extends URLConnection { protected Map<String, String> getQueryArgs() { HashMap<String, String> hashMap = new HashMap<String, String>(); String queryString = this.m_url.getQuery(); if (queryString != null) { try { queryString = URLDecoder.decode(queryString, UTF8_ENCODING); } catch (UnsupportedEncodingException e) { logger.error("Unsupported " + UTF8_ENCODING + " encoding for URL query string: '{}'. Error message: '{}'", queryString, e.getMessage()); } String[] queryArgs = queryString.split(URL_QUERY_ARGS_DELIMITERS); for (String queryArg : queryArgs) { String key = queryArg; String value = EMPTY_STRING; if (queryArg.contains(KEY_VALUE_DELIMITER)) { String[] keyValue = queryArg.split(KEY_VALUE_DELIMITER); key = keyValue[0]; value = keyValue[1]; } if (!EMPTY_STRING.equals(key)) { hashMap.put(key, value); logger.debug("Key: '{}' : Value: '{}'", key, value); } } } return hashMap; } protected  GenericURLConnection(URL url); }
GenericURLConnection extends URLConnection { protected Map<String, String> getQueryArgs() { HashMap<String, String> hashMap = new HashMap<String, String>(); String queryString = this.m_url.getQuery(); if (queryString != null) { try { queryString = URLDecoder.decode(queryString, UTF8_ENCODING); } catch (UnsupportedEncodingException e) { logger.error("Unsupported " + UTF8_ENCODING + " encoding for URL query string: '{}'. Error message: '{}'", queryString, e.getMessage()); } String[] queryArgs = queryString.split(URL_QUERY_ARGS_DELIMITERS); for (String queryArg : queryArgs) { String key = queryArg; String value = EMPTY_STRING; if (queryArg.contains(KEY_VALUE_DELIMITER)) { String[] keyValue = queryArg.split(KEY_VALUE_DELIMITER); key = keyValue[0]; value = keyValue[1]; } if (!EMPTY_STRING.equals(key)) { hashMap.put(key, value); logger.debug("Key: '{}' : Value: '{}'", key, value); } } } return hashMap; } protected  GenericURLConnection(URL url);  }
GenericURLConnection extends URLConnection { protected Map<String, String> getQueryArgs() { HashMap<String, String> hashMap = new HashMap<String, String>(); String queryString = this.m_url.getQuery(); if (queryString != null) { try { queryString = URLDecoder.decode(queryString, UTF8_ENCODING); } catch (UnsupportedEncodingException e) { logger.error("Unsupported " + UTF8_ENCODING + " encoding for URL query string: '{}'. Error message: '{}'", queryString, e.getMessage()); } String[] queryArgs = queryString.split(URL_QUERY_ARGS_DELIMITERS); for (String queryArg : queryArgs) { String key = queryArg; String value = EMPTY_STRING; if (queryArg.contains(KEY_VALUE_DELIMITER)) { String[] keyValue = queryArg.split(KEY_VALUE_DELIMITER); key = keyValue[0]; value = keyValue[1]; } if (!EMPTY_STRING.equals(key)) { hashMap.put(key, value); logger.debug("Key: '{}' : Value: '{}'", key, value); } } } return hashMap; } protected  GenericURLConnection(URL url);   }