@Test public void testEndpointContextUtilWithAdditionalKey() { Set<String> keys = KeySetEndpointContextMatcher.createKeySet(DtlsEndpointContext.KEY_SESSION_ID, DtlsEndpointContext.KEY_CIPHER, "UNKNOWN"); assertThat(EndpointContextUtil.match("test-1", keys, strictMessageContext, connectorContext), is(true)); assertThat(EndpointContextUtil.match("test-2", keys, relaxedMessageContext, connectorContext), is(true)); assertThat(EndpointContextUtil.match("test-3", keys, differentMessageContext, connectorContext), is(false)); assertThat(EndpointContextUtil.match("test-4", keys, differentMessageContext, unsecureMessageContext), is(false)); assertThat(EndpointContextUtil.match("test-5", keys, unsecureMessageContext, unsecureMessageContext2), is(false)); }
public static boolean match(String name, Set<String> keys, EndpointContext context1, EndpointContext context2) { boolean warn = LOGGER.isWarnEnabled(); boolean trace = LOGGER.isTraceEnabled(); boolean matchAll = true; for (String key : keys) { String value1 = context1.get(key); String value2 = context2.get(key); boolean match = (value1 == value2) || (null != value1 && value1.equals(value2)); if (!match && !warn) { return false; } if (!match) { LOGGER.warn("{}, {}: \"{}\" != \"{}\"", name, key, value1, value2); } else if (trace) { LOGGER.trace("{}, {}: \"{}\" == \"{}\"", name, key, value1, value2); } matchAll = matchAll && match; } return matchAll; }
EndpointContextUtil { public static boolean match(String name, Set<String> keys, EndpointContext context1, EndpointContext context2) { boolean warn = LOGGER.isWarnEnabled(); boolean trace = LOGGER.isTraceEnabled(); boolean matchAll = true; for (String key : keys) { String value1 = context1.get(key); String value2 = context2.get(key); boolean match = (value1 == value2) || (null != value1 && value1.equals(value2)); if (!match && !warn) { return false; } if (!match) { LOGGER.warn("{}, {}: \"{}\" != \"{}\"", name, key, value1, value2); } else if (trace) { LOGGER.trace("{}, {}: \"{}\" == \"{}\"", name, key, value1, value2); } matchAll = matchAll && match; } return matchAll; } }
EndpointContextUtil { public static boolean match(String name, Set<String> keys, EndpointContext context1, EndpointContext context2) { boolean warn = LOGGER.isWarnEnabled(); boolean trace = LOGGER.isTraceEnabled(); boolean matchAll = true; for (String key : keys) { String value1 = context1.get(key); String value2 = context2.get(key); boolean match = (value1 == value2) || (null != value1 && value1.equals(value2)); if (!match && !warn) { return false; } if (!match) { LOGGER.warn("{}, {}: \"{}\" != \"{}\"", name, key, value1, value2); } else if (trace) { LOGGER.trace("{}, {}: \"{}\" == \"{}\"", name, key, value1, value2); } matchAll = matchAll && match; } return matchAll; }  }
EndpointContextUtil { public static boolean match(String name, Set<String> keys, EndpointContext context1, EndpointContext context2) { boolean warn = LOGGER.isWarnEnabled(); boolean trace = LOGGER.isTraceEnabled(); boolean matchAll = true; for (String key : keys) { String value1 = context1.get(key); String value2 = context2.get(key); boolean match = (value1 == value2) || (null != value1 && value1.equals(value2)); if (!match && !warn) { return false; } if (!match) { LOGGER.warn("{}, {}: \"{}\" != \"{}\"", name, key, value1, value2); } else if (trace) { LOGGER.trace("{}, {}: \"{}\" == \"{}\"", name, key, value1, value2); } matchAll = matchAll && match; } return matchAll; }  static boolean match(String name, Set<String> keys, EndpointContext context1, EndpointContext context2); static EndpointContext getFollowUpEndpointContext(EndpointContext messageContext,
			EndpointContext connectionContext); }
EndpointContextUtil { public static boolean match(String name, Set<String> keys, EndpointContext context1, EndpointContext context2) { boolean warn = LOGGER.isWarnEnabled(); boolean trace = LOGGER.isTraceEnabled(); boolean matchAll = true; for (String key : keys) { String value1 = context1.get(key); String value2 = context2.get(key); boolean match = (value1 == value2) || (null != value1 && value1.equals(value2)); if (!match && !warn) { return false; } if (!match) { LOGGER.warn("{}, {}: \"{}\" != \"{}\"", name, key, value1, value2); } else if (trace) { LOGGER.trace("{}, {}: \"{}\" == \"{}\"", name, key, value1, value2); } matchAll = matchAll && match; } return matchAll; }  static boolean match(String name, Set<String> keys, EndpointContext context1, EndpointContext context2); static EndpointContext getFollowUpEndpointContext(EndpointContext messageContext,
			EndpointContext connectionContext);  }