2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.util.xml;
10 import static org.hamcrest.CoreMatchers.startsWith;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNull;
14 import static org.junit.Assert.assertThrows;
16 import org.junit.Test;
18 public class HardcodedNamespaceResolverTest {
20 public void testResolver() throws Exception {
21 final HardcodedNamespaceResolver hardcodedNamespaceResolver =
22 new HardcodedNamespaceResolver("prefix", "namespace");
24 assertEquals("namespace", hardcodedNamespaceResolver.getNamespaceURI("prefix"));
25 final IllegalStateException ex = assertThrows(IllegalStateException.class,
26 () -> hardcodedNamespaceResolver.getNamespaceURI("unknown"));
27 assertThat(ex.getMessage(), startsWith("Prefix mapping not found for "));
29 assertNull(hardcodedNamespaceResolver.getPrefix("any"));
30 assertNull(hardcodedNamespaceResolver.getPrefixes("any"));