BUG-1521 Unit tests for netconf-util xml package.
[controller.git] / opendaylight / netconf / netconf-util / src / test / java / org / opendaylight / controller / 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.controller.netconf.util.xml;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNull;
13 import static org.junit.Assert.fail;
14
15 import org.junit.Test;
16
17 public class HardcodedNamespaceResolverTest {
18
19     @Test
20     public void testResolver() throws Exception {
21         final HardcodedNamespaceResolver hardcodedNamespaceResolver = new HardcodedNamespaceResolver("prefix", "namespace");
22
23         assertEquals("namespace", hardcodedNamespaceResolver.getNamespaceURI("prefix"));
24         try{
25             hardcodedNamespaceResolver.getNamespaceURI("unknown");
26             fail("Unknown namespace lookup should fail");
27         } catch(IllegalStateException e) {}
28
29         assertNull(hardcodedNamespaceResolver.getPrefix("any"));
30         assertNull(hardcodedNamespaceResolver.getPrefixes("any"));
31     }
32 }