2 * Copyright (c) 2014 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.controller.hosttracker.northbound;
10 import java.net.InetAddress;
11 import java.net.UnknownHostException;
12 import java.util.HashSet;
15 import org.junit.Assert;
16 import org.junit.Test;
17 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
18 import org.opendaylight.controller.sal.core.ConstructionException;
20 public class HostTrackerNorthboundTest {
23 public void testHosts() throws UnknownHostException, ConstructionException {
24 Hosts h1 = new Hosts();
25 Assert.assertNull(h1.getHostConfig());
27 Hosts h2 = new Hosts(null);
28 Assert.assertNull(h2.getHostConfig());
30 Set<HostConfig> conn = new HashSet<HostConfig>();
31 InetAddress addr = InetAddress.getByName("10.1.1.1");
32 HostNodeConnector c1 = new HostNodeConnector(addr);
33 conn.add(HostConfig.convert(c1));
34 h1.setHostConfig(conn);
35 Assert.assertTrue(h1.getHostConfig().equals(conn));
37 Hosts h3 = new Hosts(conn);
38 Assert.assertTrue(h3.getHostConfig().equals(conn));
39 h3.setHostConfig(null);
40 Assert.assertNull(h3.getHostConfig());