blob: 097a44ad917afb73a25c4f6f25237f34639b1266 [file] [log] [blame]
Jian Lib1a8fd02016-12-27 03:55:32 +09001/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.lisp.ctl;
17
18import org.junit.After;
19import org.junit.Before;
20import org.junit.Test;
21import org.onlab.packet.IpAddress;
22
23import static org.hamcrest.CoreMatchers.is;
24import static org.hamcrest.MatcherAssert.assertThat;
25
26/**
27 * Unit test class for LispRouterFactory.
28 */
29public class LispRouterFactoryTest {
30
31 private LispRouterFactory routerFactory;
32 private LispRouterAgent agent = new LispRouterAgentAdapter();
33
34 @Before
35 public void setUp() throws Exception {
36 routerFactory = LispRouterFactory.getInstance();
37 routerFactory.setAgent(agent);
38 }
39
40 @After
41 public void tearDown() throws Exception {
42 routerFactory = null;
43 }
44
45 @Test
46 public void testSetAgent() throws Exception {
47 routerFactory.setAgent(agent);
48
49 assertThat(routerFactory, is(routerFactory));
50 }
51
52 @Test
53 public void testGetRouterInstance() throws Exception {
54 IpAddress ipAddress = IpAddress.valueOf("192.168.1.1");
55
56 LispRouter router1 = routerFactory.getRouterInstance(ipAddress);
57 LispRouter router2 = routerFactory.getRouterInstance(ipAddress);
58
59 assertThat(router1, is(router2));
60 }
61}