### Question:
URISupport { public static URI createURIWithQuery(URI uri, String query) throws URISyntaxException { String schemeSpecificPart = uri.getRawSchemeSpecificPart(); int questionMark = schemeSpecificPart.lastIndexOf("?"); if (questionMark < schemeSpecificPart.lastIndexOf(")")) { questionMark = -1; } if (questionMark > 0) { schemeSpecificPart = schemeSpecificPart.substring(0, questionMark); } if (query != null && query.length() > 0) { schemeSpecificPart += "?" + query; } return new URI(uri.getScheme(), schemeSpecificPart, uri.getFragment()); }  static Map<String, String> parseQuery(String uri); static Map<String, String> parseParameters(URI uri); static URI applyParameters(URI uri, Map<String, String> queryParameters); static URI applyParameters(URI uri, Map<String, String> queryParameters, String optionPrefix); static URI removeQuery(URI uri); static URI createURIWithQuery(URI uri, String query); static CompositeData parseComposite(URI uri); static boolean isCompositeURI(URI uri); static int indexOfParenthesisMatch(String str, int first); static String stripPrefix(String value, String prefix); static URI stripScheme(URI uri); static String createQueryString(Map<String, ? extends Object> options); static URI createRemainingURI(URI originalURI, Map<String, String> params); static URI changeScheme(URI bindAddr, String scheme); static boolean checkParenthesis(String str);  }### Answer:
@Test public void testCompositeCreateURIWithQuery() throws Exception { String queryString = "query=value"; URI originalURI = new URI("outerscheme:(innerscheme:innerssp)"); URI querylessURI = originalURI; assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, null)); assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, "")); assertEquals(new URI(querylessURI + "?" + queryString), URISupport.createURIWithQuery(originalURI, queryString)); originalURI = new URI("outerscheme:(innerscheme:innerssp)?outerquery=0"); assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, null)); assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, "")); assertEquals(new URI(querylessURI + "?" + queryString), URISupport.createURIWithQuery(originalURI, queryString)); originalURI = new URI("outerscheme:(innerscheme:innerssp?innerquery=0)"); querylessURI = originalURI; assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, null)); assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, "")); assertEquals(new URI(querylessURI + "?" + queryString), URISupport.createURIWithQuery(originalURI, queryString)); originalURI = new URI("outerscheme:(innerscheme:innerssp?innerquery=0)?outerquery=0"); assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, null)); assertEquals(querylessURI, URISupport.createURIWithQuery(originalURI, "")); assertEquals(new URI(querylessURI + "?" + queryString), URISupport.createURIWithQuery(originalURI, queryString)); }