Merge "BUG-1276: fixed generated union constructor"
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / codec / xml / RandomPrefixTest.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 package org.opendaylight.yangtools.yang.data.impl.codec.xml;
9
10 import org.junit.Assert;
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.data.impl.codec.xml.RandomPrefix;
15
16 /**
17  * @author tkubas
18  */
19 public class RandomPrefixTest {
20     private RandomPrefix randomPrefix;
21
22     /**
23      * setup {@link #randomPrefix} instance
24      */
25     @Before
26     public void setUp() {
27         randomPrefix = new RandomPrefix();
28     }
29     /**
30      * Test method for {@link org.opendaylight.yangtools.yang.data.impl.codec.xml.RandomPrefix#encodeQName(QName)}.
31      */
32     @Test
33     public void testEncodeQName() {
34         QName node = QName.create("","2013-06-07","node");
35         String encodedQName = randomPrefix.encodeQName(node);
36         Assert.assertNotNull(encodedQName);
37         Assert.assertTrue("prefix is expected to contain 4 small letters as prefix but result is: "+encodedQName,
38                 encodedQName.matches("[a-z]{4}:node"));
39     }
40
41 }