Merge "Bug 8153: Enforce check-style rules for netconf - client."
[netconf.git] / netconf / netconf-util / src / test / java / org / opendaylight / netconf / util / xml / HardcodedNamespaceResolverTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.netconf.util.xml;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNull;
13 import static org.junit.Assert.assertTrue;
14 import static org.junit.Assert.fail;
15
16 import org.junit.Test;
17
18 public class HardcodedNamespaceResolverTest {
19
20     @Test
21     public void testResolver() throws Exception {
22         final HardcodedNamespaceResolver hardcodedNamespaceResolver =
23                 new HardcodedNamespaceResolver("prefix", "namespace");
24
25         assertEquals("namespace", hardcodedNamespaceResolver.getNamespaceURI("prefix"));
26         try {
27             hardcodedNamespaceResolver.getNamespaceURI("unknown");
28             fail("Unknown namespace lookup should fail");
29         } catch (IllegalStateException e) {
30             assertTrue(e.getMessage().startsWith("Prefix mapping not found for "));
31         }
32
33         assertNull(hardcodedNamespaceResolver.getPrefix("any"));
34         assertNull(hardcodedNamespaceResolver.getPrefixes("any"));
35     }
36 }