### Question:
HttpEventTask implements Runnable { protected static void parseSingleParam(String single, CommandRequest request) { if (single == null || single.length() < 3) { return; } int index = single.indexOf('='); if (index <= 0 || index >= single.length() - 1) { return; } String value = StringUtil.trim(single.substring(index + 1)); String key = StringUtil.trim(single.substring(0, index)); try { key = URLDecoder.decode(key, SentinelConfig.charset()); value = URLDecoder.decode(value, SentinelConfig.charset()); } catch (UnsupportedEncodingException e) { } request.addParam(key, value); } HttpEventTask(Socket socket); void close(); @Override void run(); static final String SERVER_ERROR_MESSAGE; static final String INVALID_COMMAND_MESSAGE; }### Answer:
@Test public void parseSingleParam() { CommandRequest request; request = new CommandRequest(); HttpEventTask.parseSingleParam(null, request); assertEquals(0, request.getParameters().size()); request = new CommandRequest(); HttpEventTask.parseSingleParam("", request); assertEquals(0, request.getParameters().size()); request = new CommandRequest(); HttpEventTask.parseSingleParam("a", request); assertEquals(0, request.getParameters().size()); request = new CommandRequest(); HttpEventTask.parseSingleParam("=", request); assertEquals(0, request.getParameters().size()); request = new CommandRequest(); HttpEventTask.parseSingleParam("a=", request); assertEquals(0, request.getParameters().size()); request = new CommandRequest(); HttpEventTask.parseSingleParam("=a", request); assertEquals(0, request.getParameters().size()); request = new CommandRequest(); HttpEventTask.parseSingleParam("test=", request); assertEquals(0, request.getParameters().size()); request = new CommandRequest(); HttpEventTask.parseSingleParam("=test", request); assertEquals(0, request.getParameters().size()); request = new CommandRequest(); HttpEventTask.parseSingleParam("a=1", request); assertEquals(1, request.getParameters().size()); assertEquals("1", request.getParam("a")); request = new CommandRequest(); HttpEventTask.parseSingleParam("a_+=1+", request); assertEquals(1, request.getParameters().size()); assertEquals("1 ", request.getParam("a_ ")); }