@Test
public void testFormatParser() {

    Map<String,Object> formatParser = new LinkedHashMap<>();
    formatParser.put("pattern", "str:%s num:%d");
    String[] locations = {"msg", "port"};
    formatParser.put("locations", Arrays.asList(locations));
    formatParser.put("altPatternLocation", "altPattern");
    formatParser.put("altLocations", "altLocations");
    
    outgoing.put("formatParser", formatParser);
    
    pHandler = new UDPPublishHandler(outgoing, fakeSocket, sourceName);
    
    // ============ Testing standard locations and pattern ============
    Map<String,Object> testMap = new LinkedHashMap<>();
    testMap.put("msg", "string");
    testMap.put("port",1253);
    
    String expectedData = "str:string num:1253";
    
    // Test UUT
    createMessage(testMap);
    pHandler.handleMessage(extMsg);
    
    assert fakeSocket.compareData(expectedData);
    
    
    // ============ Testing alternate locations ============
    testMap = new LinkedHashMap<>();
    testMap.put("message", "msg");
    testMap.put("harbor", 2718);
    locations[0] = "message";
    locations[1] = "harbor";
    testMap.put("altLocations", Arrays.asList(locations));
    
    expectedData = "str:msg num:2718";
    
    // Test UUT
    createMessage(testMap);
    pHandler.handleMessage(extMsg);
    
    assert fakeSocket.compareData(expectedData);
    
    // ============ Testing alternate pattern and locations ============
    testMap = new LinkedHashMap<>();
    testMap.put("newNum", 6283);
    testMap.put("newStr", "Hello World");
    testMap.put("altPattern", "#:%d txt:%s");
    locations[0] = "newNum";
    locations[1] = "newStr";
    testMap.put("altLocations", Arrays.asList(locations));
    
    expectedData = "#:6283 txt:Hello World";
    
    // Test UUT
    createMessage(testMap);
    pHandler.handleMessage(extMsg);
    
    assert fakeSocket.compareData(expectedData);
}