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
diff --git a/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/xml/HardcodedNamespaceResolverTest.java b/opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/xml/HardcodedNamespaceResolverTest.java
new file mode 100644 (file)
index 0000000..f083cc1
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.util.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
+public class HardcodedNamespaceResolverTest {
+
+    @Test
+    public void testResolver() throws Exception {
+        final HardcodedNamespaceResolver hardcodedNamespaceResolver = new HardcodedNamespaceResolver("prefix", "namespace");
+
+        assertEquals("namespace", hardcodedNamespaceResolver.getNamespaceURI("prefix"));
+        try{
+            hardcodedNamespaceResolver.getNamespaceURI("unknown");
+            fail("Unknown namespace lookup should fail");
+        } catch(IllegalStateException e) {}
+
+        assertNull(hardcodedNamespaceResolver.getPrefix("any"));
+        assertNull(hardcodedNamespaceResolver.getPrefixes("any"));
+    }
+}
\ No newline at end of file