Mass-convert all compontents to use -no-zone addresses
[bgpcep.git] / bmp / bmp-mock / src / test / java / org / opendaylight / protocol / bmp / mock / BmpMockArgumentsTest.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.protocol.bmp.mock;
10
11 import static org.junit.Assert.assertEquals;
12
13 import ch.qos.logback.classic.Level;
14 import java.net.InetSocketAddress;
15 import java.util.Collections;
16 import net.sourceforge.argparse4j.inf.ArgumentParserException;
17 import org.junit.Test;
18
19 public class BmpMockArgumentsTest {
20
21     @Test
22     public void testDefaultArguments() {
23         final BmpMockArguments arguments = BmpMockArguments.parseArguments(new String[]{});
24         assertEquals(1, arguments.getRoutersCount());
25         assertEquals(0, arguments.getPeersCount());
26         assertEquals(0, arguments.getPrePolicyRoutesCount());
27         assertEquals(0, arguments.getPostPolicyRoutesCount());
28         assertEquals(Level.INFO, arguments.getLogLevel());
29         assertEquals(new InetSocketAddress("127.0.0.1", 0), arguments.getLocalAddress());
30         assertEquals(Collections.singletonList(new InetSocketAddress("127.0.0.1", 12345)),
31                 arguments.getRemoteAddress());
32     }
33
34     @Test(expected = IllegalArgumentException.class)
35     public void testWrongArgument() {
36         BmpMockArguments.parseArguments(new String[]{"--routers_count", "abcd"});
37     }
38
39     @Test
40     public void testGetRoutersCount() throws ArgumentParserException {
41         final BmpMockArguments arguments = BmpMockArguments.parseArguments(new String[]{"--routers_count", "10"});
42         assertEquals(10, arguments.getRoutersCount());
43     }
44
45     @Test
46     public void testGetPeersCount() {
47         final BmpMockArguments arguments = BmpMockArguments.parseArguments(new String[]{"--peers_count", "5"});
48         assertEquals(5, arguments.getPeersCount());
49     }
50
51     @Test
52     public void testGetPrePolicyRoutesCount() {
53         final BmpMockArguments arguments = BmpMockArguments.parseArguments(new String[]{"--pre_policy_routes", "20"});
54         assertEquals(20, arguments.getPrePolicyRoutesCount());
55     }
56
57     @Test
58     public void testGetPostPolicyRoutesCount() {
59         final BmpMockArguments arguments = BmpMockArguments.parseArguments(new String[]{"--post_policy_routes", "100"});
60         assertEquals(100, arguments.getPostPolicyRoutesCount());
61     }
62
63     @Test
64     public void testGetLocalAddress() {
65         final BmpMockArguments arguments = BmpMockArguments.parseArguments(new String[]{"--local_address", "1.2.3.4"});
66         assertEquals(new InetSocketAddress("1.2.3.4", 0), arguments.getLocalAddress());
67     }
68
69     @Test
70     public void testGetRemoteAddress() {
71         final BmpMockArguments arguments = BmpMockArguments
72                 .parseArguments(new String[]{"--remote_address", "4.5.6.7:1025"});
73         assertEquals(Collections.singletonList(new InetSocketAddress("4.5.6.7", 1025)),
74                 arguments.getRemoteAddress());
75     }
76
77     @Test
78     public void testGetLogLevel() {
79         final BmpMockArguments arguments = BmpMockArguments.parseArguments(new String[]{"--log_level", "TRACE"});
80         assertEquals(Level.TRACE, arguments.getLogLevel());
81     }
82
83 }