### Question:
URISupport { public static boolean checkParenthesis(String str) { boolean result = true; if (str != null) { int open = 0; int closed = 0; int i = 0; while ((i = str.indexOf('(', i)) >= 0) { i++; open++; } i = 0; while ((i = str.indexOf(')', i)) >= 0) { i++; closed++; } result = open == closed; } return result; }  static CompositeData parseComposite(URI uri); static boolean isCompositeURI(URI uri); static boolean checkParenthesis(String str); static int indexOfParenthesisMatch(String str, int first); static String[] splitComponents(String str); static URI removeQuery(URI 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);  }### Answer:
@Test public void testCheckParenthesis() throws Exception { String str = "fred:(((ddd))"; assertFalse(URISupport.checkParenthesis(str)); str += ")"; assertTrue(URISupport.checkParenthesis(str)); }
@Test public void testCheckParenthesisWithNullOrEmpty() throws Exception { assertTrue(URISupport.checkParenthesis(null)); assertTrue(URISupport.checkParenthesis("")); }