DefaultNamespaceValidator implements NamespaceValidator { @Override public void checkAllowed(Collection<String> allowedNamespaces, String namespace) throws NamespaceNotAllowedException { if (!isAllowed(allowedNamespaces, namespace)) { throw new NamespaceNotAllowedException( "Allowed namespace list [" + allowedNamespaces + "] does not matches namespace [" + namespace + "]"); } }  @Override boolean isAllowed(Collection<String> allowedNamespaces, String namespace); @Override void checkAllowed(Collection<String> allowedNamespaces, String namespace);  }
@Test void checkAllowed() throws NamespaceNotAllowedException { this.validator.checkAllowed(Arrays.asList("namespace"), "namespace"); }
@Test void checkNoAllowed() { Throwable exception = assertThrows(NamespaceNotAllowedException.class, () -> { this.validator.checkAllowed(Arrays.asList("namespace"), "wrong"); }); assertEquals("Allowed namespace list [[namespace]] does not matches namespace [wrong]", exception.getMessage()); }