2 * Copyright (c) 2016 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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotNull;
14 import java.lang.reflect.Constructor;
15 import org.junit.Test;
17 public class IpAddressNoZoneBuilderTest {
20 public void testGetDefaultInstance() throws Exception {
21 final Constructor<IpAddressNoZoneBuilder> constructor = IpAddressNoZoneBuilder.class.getDeclaredConstructor();
22 assertFalse(constructor.isAccessible());
23 constructor.setAccessible(true);
24 final IpAddressNoZoneBuilder newInstance = constructor.newInstance();
25 assertNotNull(newInstance);
28 testIpv4("192.168.155.100");
29 testIpv4("1.192.1.221");
30 testIpv6("ABCD:EF01:2345:6789:ABCD:EF01:2345:6789");
31 testIpv6("2001:DB8:0:0:8:800:200C:417A");
32 testIpv6("0:0:0:0:0:0:0:0");
33 testIpv6("::1.2.3.4");
34 testIpv6("ABCD:EF01:2345:6789:ABCD:EF01:2345:6789");
35 testIpv6("2001:DB8:0:0:8:800:200C:417A");
36 testIpv6("2001:DB8::8:800:200C:417A");
37 testIpv6("FF01:0:0:0:0:0:0:101");
38 testIpv6("FF01::101");
39 testIpv6("0:0:0:0:0:0:0:1");
44 @Test(expected = IllegalArgumentException.class)
45 public void testIllegalArgumentException() {
46 IpAddressNoZoneBuilder.getDefaultInstance("2001:0DB8::CD3/60");
49 private static void testIpv4(final String ip) {
50 final IpAddressNoZone defaultInstance = IpAddressNoZoneBuilder.getDefaultInstance(ip);
51 assertEquals(new IpAddressNoZone(new Ipv4AddressNoZone(ip)), defaultInstance);
54 private static void testIpv6(final String ip) {
55 final IpAddressNoZone defaultInstance = IpAddressNoZoneBuilder.getDefaultInstance(ip);
56 assertEquals(new IpAddressNoZone(new Ipv6AddressNoZone(ip)), defaultInstance);