Bulk-add copyright headers to java files
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / sal / binding / test / bugfix / UnionSerializationTest.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.controller.sal.binding.test.bugfix;
9
10 import org.junit.Test;
11 import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
14 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.igp.node.attributes.Prefix;
15 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.igp.node.attributes.PrefixBuilder;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
18
19
20
21
22
23
24
25
26 import static org.junit.Assert.*;
27
28 public class UnionSerializationTest extends AbstractDataServiceTest {
29     
30     public static final String PREFIX_STRING = "192.168.0.1/32";
31     
32     
33     @Test
34     public void testPrefixSerialization() throws Exception {
35         
36         Ipv4Prefix ipv4prefix = new Ipv4Prefix(PREFIX_STRING);
37         IpPrefix ipPrefix = new IpPrefix(ipv4prefix);
38         Prefix prefix = new PrefixBuilder().setPrefix(ipPrefix).build();
39         
40         CompositeNode serialized = testContext.getBindingToDomMappingService().toDataDom(prefix);
41         assertNotNull(serialized);
42         assertNotNull(serialized.getFirstSimpleByName(Prefix.QNAME));
43         assertEquals(PREFIX_STRING, serialized.getFirstSimpleByName(Prefix.QNAME).getValue());
44         
45         Prefix deserialized = (Prefix) testContext.getBindingToDomMappingService().dataObjectFromDataDom(InstanceIdentifier.builder().node(Prefix.class).build(), serialized);
46         assertNotNull(deserialized);
47         assertNotNull(deserialized.getPrefix());
48         assertNotNull(deserialized.getPrefix().getIpv4Prefix());
49         assertEquals(PREFIX_STRING, deserialized.getPrefix().getIpv4Prefix().getValue());
50     }
51
52 }