fa316d174adb9c9763e3b4e1230653959bfaf439
[yangtools.git] / model / ietf / ietf-inet-types / src / test / java / org / opendaylight / yang / gen / v1 / urn / ietf / params / xml / ns / yang / ietf / inet / types / rev100924 / HostBuilderTest.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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924;
10
11 import junit.framework.Assert;
12 import org.junit.Test;
13
14 public class HostBuilderTest {
15
16     @Test
17     public void testGetDefaultInstanceIpv4() throws Exception {
18         Host host = HostBuilder.getDefaultInstance("127.0.0.1");
19         Assert.assertEquals(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))), host);
20     }
21
22     @Test
23     public void testGetDefaultInstanceIpv6() throws Exception {
24         testIpv6("2001:db8:8s5a3:0:0:8a2e:370:7334");
25         testIpv6("2001:db8:85a3::8a2e:370:7334");
26     }
27
28     private void testIpv6(String ivp6string) {
29         Host host = HostBuilder.getDefaultInstance(ivp6string);
30         Assert.assertEquals(new Host(new IpAddress(new Ipv6Address(ivp6string))), host);
31     }
32
33     @Test
34     public void testGetDefaultInstanceDomain() throws Exception {
35         Host host = HostBuilder.getDefaultInstance("localhost");
36         Assert.assertEquals(new Host(new DomainName("localhost")), host);
37     }
38 }