DisplayLayerHandler implements MessageHandler { Pair<URL, Map<String, Serializable>> createParams(BufferedReader reader) throws Exception { String line = reader.readLine(); URL resourceId = null; Map<String, Serializable> params = new HashMap<String, Serializable>(); while (line != null) { line = line.trim(); if (line.length() > 0) { if (resourceId == null && line.toLowerCase().startsWith(RESOURCE_ID)) { String spec = line.substring(RESOURCE_ID.length()); spec = spec.replaceAll("\\\\;", ";"); resourceId = new URL(spec); } else { addParam(params, line); } } line = reader.readLine(); } return new Pair<URL, Map<String, Serializable>>(resourceId, params); }  boolean canHandleMessge(String header); void execute(BufferedReader reader, Socket socket); static String safeTake(String string, int toTake); static final String HEADER; static final String RESOURCE_ID; }
@Test public void testCreateShpParams() throws Exception { DisplayLayerHandler handler = new DisplayLayerHandler(); String resourceId = "file: String shpId ="file: StringBuilder builder = new StringBuilder("geoResourceId;"+resourceId ); builder.append("\nurl;java.net.URL;"+shpId ); String message = builder.toString(); Pair<URL, Map<String, Serializable>> results = handler.createParams(toReader(message)); assertEquals(resourceId, results.getLeft().toExternalForm()); assertEquals(shpId, ((URL) results.getRight().get("url")).toExternalForm()); }