2 * Copyright (c) 2016 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
9 package org.opendaylight.protocol.bmp.mock;
11 import static org.junit.Assert.assertEquals;
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;
19 public class BmpMockArgumentsTest {
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());
34 @Test(expected = IllegalArgumentException.class)
35 public void testWrongArgument() {
36 BmpMockArguments.parseArguments(new String[]{"--routers_count", "abcd"});
40 public void testGetRoutersCount() throws ArgumentParserException {
41 final BmpMockArguments arguments = BmpMockArguments.parseArguments(new String[]{"--routers_count", "10"});
42 assertEquals(10, arguments.getRoutersCount());
46 public void testGetPeersCount() {
47 final BmpMockArguments arguments = BmpMockArguments.parseArguments(new String[]{"--peers_count", "5"});
48 assertEquals(5, arguments.getPeersCount());
52 public void testGetPrePolicyRoutesCount() {
53 final BmpMockArguments arguments = BmpMockArguments.parseArguments(new String[]{"--pre_policy_routes", "20"});
54 assertEquals(20, arguments.getPrePolicyRoutesCount());
58 public void testGetPostPolicyRoutesCount() {
59 final BmpMockArguments arguments = BmpMockArguments.parseArguments(new String[]{"--post_policy_routes", "100"});
60 assertEquals(100, arguments.getPostPolicyRoutesCount());
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());
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());
78 public void testGetLogLevel() {
79 final BmpMockArguments arguments = BmpMockArguments.parseArguments(new String[]{"--log_level", "TRACE"});
80 assertEquals(Level.TRACE, arguments.getLogLevel());