2 * Copyright (c) 2014, 2015 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.controller.cluster.datastore.node.utils;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotSame;
12 import static org.junit.Assert.assertSame;
14 import org.junit.Test;
15 import org.opendaylight.controller.cluster.datastore.util.TestModel;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.common.Revision;
19 public class QNameFactoryTest {
23 public void testBasicString() {
24 QName expected = TestModel.AUG_NAME_QNAME;
25 QName created = QNameFactory.create(expected.toString());
26 assertNotSame(expected, created);
27 assertEquals(expected, created);
29 QName cached = QNameFactory.create(expected.toString());
30 assertSame(created, cached);
34 public void testBasic() {
35 QName expected = TestModel.AUG_NAME_QNAME;
36 QName created = lookup(expected);
37 assertNotSame(expected, created);
38 assertEquals(expected, created);
40 QName cached = lookup(expected);
41 assertSame(created, cached);
44 private static QName lookup(final QName qname) {
45 return QNameFactory.create(qname.getLocalName(), qname.getNamespace().toString(),
46 qname.getRevision().map(Revision::toString).orElse(null));