* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.netconf.callhome.mount;
-
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import com.google.common.net.InetAddresses;
import java.net.Inet4Address;
import java.net.Inet6Address;
-import java.net.InetAddress;
import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.netconf.client.NetconfClientSession;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
-
+import org.opendaylight.yangtools.yang.common.Uint16;
public class ContextKeyTest {
private IpAddress address1;
@Before
public void setup() {
- address1 = IpAddressBuilder.getDefaultInstance("1.2.3.4");
- address2 = IpAddressBuilder.getDefaultInstance("5.6.7.8");
+ address1 = new IpAddress(new Ipv4Address("1.2.3.4"));
+ address2 = new IpAddress(new Ipv4Address("5.6.7.8"));
- port1 = new PortNumber(123);
- port2 = new PortNumber(456);
+ port1 = new PortNumber(Uint16.valueOf(123));
+ port2 = new PortNumber(Uint16.valueOf(456));
mockNode = mock(NetconfNode.class);
mockSession = mock(NetconfClientSession.class);
// expect
assertTrue(instance1.equals(instance1));
assertFalse(instance1.equals(null));
- assertFalse(instance1.equals(new Long(123456)));
+ assertFalse(instance1.equals(123456L));
assertFalse(instance1.equals(instance2));
assertFalse(instance1.equals(instance3));
assertFalse(instance1.equals(instance4));
}
@Test
- public void newContextCanBeCreatedFromASocketAddress() throws UnknownHostException {
+ public void newContextCanBeCreatedFromASocketAddress() {
// given
- Inet4Address someAddressIpv4 = (Inet4Address) InetAddress.getByName("1.2.3.4");
- Inet6Address someAddressIpv6 = (Inet6Address) InetAddress.getByName("::1");
+ Inet4Address someAddressIpv4 = (Inet4Address) InetAddresses.forString("1.2.3.4");
+ Inet6Address someAddressIpv6 = (Inet6Address) InetAddresses.forString("::1");
// and
ContextKey key1 = ContextKey.from(new InetSocketAddress(someAddressIpv4, 123));
ContextKey key2 = ContextKey.from(new InetSocketAddress(someAddressIpv6, 123));