Add NoZone support
[mdsal.git] / model / ietf / ietf-inet-types-2013-07-15 / src / test / java / org / opendaylight / yang / gen / v1 / urn / ietf / params / xml / ns / yang / ietf / inet / types / rev130715 / IpPrefixBuilderTest.java
1 /*
2  * Copyright (c) 2016 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.rev130715;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertNotNull;
14
15 import java.lang.reflect.Constructor;
16 import org.junit.Test;
17
18 public class IpPrefixBuilderTest {
19
20     @Test
21     public void testGetDefaultInstance() throws Exception {
22         final Constructor<IpPrefixBuilder> constructor = IpPrefixBuilder.class.getDeclaredConstructor();
23         assertFalse(constructor.isAccessible());
24         constructor.setAccessible(true);
25         final IpPrefixBuilder newInstance = constructor.newInstance();
26         assertNotNull(newInstance);
27
28         testIpv6("ff00::/8");
29         testIpv4("192.0.2.1/24");
30     }
31
32     @Test(expected = IllegalArgumentException.class)
33     public void testIllegalArgumentException1() {
34         IpPrefixBuilder.getDefaultInstance("badIp");
35     }
36
37     private static void testIpv4(final String ip) {
38         final IpPrefix defaultInstance = IpPrefixBuilder.getDefaultInstance(ip);
39         assertEquals(new IpPrefix(new Ipv4Prefix(ip)), defaultInstance);
40     }
41
42     private static void testIpv6(final String ip) {
43         final IpPrefix defaultInstance = IpPrefixBuilder.getDefaultInstance(ip);
44         assertEquals(new IpPrefix(new Ipv6Prefix(ip)), defaultInstance);
45     }
46 }