@Test public void testIsConfiguredToSend() { Map<String,Object> outgoing = new LinkedHashMap<>(); outgoing.put("passPureMapOut", true); outgoing.put("targetAddress","notValidAddress"); outgoing.put("targetPort", -100); assert !udpConfig.isConfiguredToSend(outgoing); outgoing.put("targetPort", 100); assert !udpConfig.isConfiguredToSend(outgoing); outgoing.put("targetAddress","localhost"); assert udpConfig.isConfiguredToSend(outgoing); outgoing.put("passPureMapOut", "not a bool"); assert udpConfig.isConfiguredToSend(outgoing); outgoing.put("targetPort", -100); assert !udpConfig.isConfiguredToSend(outgoing); }
boolean isConfiguredToSend(Map outgoing) { if (outgoing == null || !(outgoing.get("targetAddress") instanceof String) || !(outgoing.get("targetPort") instanceof Integer)) { return false; } int port = (Integer) outgoing.get("targetPort"); String addr = (String) outgoing.get("targetAddress"); if (port < 0 || port > 65535) { return false; } try { InetAddress.getByName(addr); return true; } catch (Exception e) { return false; } }
UDPConfigHandler extends Handler<ExtensionServiceMessage> { boolean isConfiguredToSend(Map outgoing) { if (outgoing == null || !(outgoing.get("targetAddress") instanceof String) || !(outgoing.get("targetPort") instanceof Integer)) { return false; } int port = (Integer) outgoing.get("targetPort"); String addr = (String) outgoing.get("targetAddress"); if (port < 0 || port > 65535) { return false; } try { InetAddress.getByName(addr); return true; } catch (Exception e) { return false; } } }
UDPConfigHandler extends Handler<ExtensionServiceMessage> { boolean isConfiguredToSend(Map outgoing) { if (outgoing == null || !(outgoing.get("targetAddress") instanceof String) || !(outgoing.get("targetPort") instanceof Integer)) { return false; } int port = (Integer) outgoing.get("targetPort"); String addr = (String) outgoing.get("targetAddress"); if (port < 0 || port > 65535) { return false; } try { InetAddress.getByName(addr); return true; } catch (Exception e) { return false; } }  }
UDPConfigHandler extends Handler<ExtensionServiceMessage> { boolean isConfiguredToSend(Map outgoing) { if (outgoing == null || !(outgoing.get("targetAddress") instanceof String) || !(outgoing.get("targetPort") instanceof Integer)) { return false; } int port = (Integer) outgoing.get("targetPort"); String addr = (String) outgoing.get("targetAddress"); if (port < 0 || port > 65535) { return false; } try { InetAddress.getByName(addr); return true; } catch (Exception e) { return false; } }  @Override void handleMessage(ExtensionServiceMessage message); }
UDPConfigHandler extends Handler<ExtensionServiceMessage> { boolean isConfiguredToSend(Map outgoing) { if (outgoing == null || !(outgoing.get("targetAddress") instanceof String) || !(outgoing.get("targetPort") instanceof Integer)) { return false; } int port = (Integer) outgoing.get("targetPort"); String addr = (String) outgoing.get("targetAddress"); if (port < 0 || port > 65535) { return false; } try { InetAddress.getByName(addr); return true; } catch (Exception e) { return false; } }  @Override void handleMessage(ExtensionServiceMessage message);  }