OPNFLWPLUG-1032: Neon-MRI: Bump odlparent, yangtools, mdsal
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / configuration / OpenFlowProviderConfigImplTest.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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 package org.opendaylight.openflowplugin.impl.configuration;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.ArgumentMatchers.any;
12 import static org.mockito.ArgumentMatchers.eq;
13 import static org.mockito.Mockito.when;
14
15 import org.junit.After;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.junit.runner.RunWith;
19 import org.mockito.Mock;
20 import org.mockito.runners.MockitoJUnitRunner;
21 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationProperty;
22 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
24
25 @RunWith(MockitoJUnitRunner.class)
26 public class OpenFlowProviderConfigImplTest {
27     private static final Boolean IS_STATISTICS_POLLING_ON = true;
28     private static final Integer BARRIER_COUNT_LIMIT = 2000;
29     private static final Long BARRIER_INTERVAL_TIMEOUT_LIMIT = 3000L;
30     private static final Long ECHO_REPLY_TIMEOUT = 4000L;
31     private static final Boolean ENABLE_FLOW_REMOVED_NOTIFICATION = true;
32     private static final Boolean SKIP_TABLE_FEATURES = true;
33     private static final Long BASIC_TIMER_DELAY = 2690L;
34     private static final Long MAXIMUM_TIMER_DELAY = 3679L;
35     private static final Boolean SWITCH_FEATURES_MANDATORY = false;
36     private static final Boolean IS_STATISTICS_RPC_ENABLED = false;
37     private static final Boolean USE_SINGLE_LAYER_SERIALIZATION = true;
38     private static final Integer RPC_REQUESTS_QUOTA = 2500;
39     private static final Long GLOBAL_NOTIFICATION_QUOTA = 9000L;
40     private static final Integer THREAD_POOL_MIN_THREADS = 3;
41     private static final Integer THREAD_POOL_MAX_THREADS = 1000;
42     private static final Long THREAD_POOL_TIMEOUT = 60L;
43     private static final Integer DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = 0;
44
45     @Mock
46     private ConfigurationService configurationService;
47     private OpenflowProviderConfig openflowProviderConfig;
48
49     @Before
50     public void setUp() throws Exception {
51         when(configurationService.getProperty(eq(ConfigurationProperty.IS_STATISTICS_POLLING_ON.toString()), any()))
52                 .thenReturn(IS_STATISTICS_POLLING_ON);
53         when(configurationService.getProperty(eq(ConfigurationProperty.BARRIER_COUNT_LIMIT.toString()), any()))
54                 .thenReturn(BARRIER_COUNT_LIMIT);
55         when(configurationService.getProperty(eq(ConfigurationProperty.BARRIER_INTERVAL_TIMEOUT_LIMIT.toString()),
56                 any())).thenReturn(BARRIER_INTERVAL_TIMEOUT_LIMIT);
57         when(configurationService.getProperty(eq(ConfigurationProperty.ECHO_REPLY_TIMEOUT.toString()), any()))
58                 .thenReturn(ECHO_REPLY_TIMEOUT);
59         when(configurationService.getProperty(eq(ConfigurationProperty.ENABLE_FLOW_REMOVED_NOTIFICATION.toString()),
60                 any())).thenReturn(ENABLE_FLOW_REMOVED_NOTIFICATION);
61         when(configurationService.getProperty(eq(ConfigurationProperty.SKIP_TABLE_FEATURES.toString()), any()))
62                 .thenReturn(SKIP_TABLE_FEATURES);
63         when(configurationService.getProperty(eq(ConfigurationProperty.BASIC_TIMER_DELAY.toString()), any()))
64                 .thenReturn(BASIC_TIMER_DELAY);
65         when(configurationService.getProperty(eq(ConfigurationProperty.MAXIMUM_TIMER_DELAY.toString()), any()))
66                 .thenReturn(MAXIMUM_TIMER_DELAY);
67         when(configurationService.getProperty(eq(ConfigurationProperty.SWITCH_FEATURES_MANDATORY.toString()), any()))
68                 .thenReturn(SWITCH_FEATURES_MANDATORY);
69         when(configurationService.getProperty(eq(ConfigurationProperty.IS_STATISTICS_RPC_ENABLED.toString()), any()))
70                 .thenReturn(IS_STATISTICS_RPC_ENABLED);
71         when(configurationService.getProperty(eq(ConfigurationProperty.USE_SINGLE_LAYER_SERIALIZATION.toString()),
72                 any())).thenReturn(USE_SINGLE_LAYER_SERIALIZATION);
73         when(configurationService.getProperty(eq(ConfigurationProperty.RPC_REQUESTS_QUOTA.toString()), any()))
74                 .thenReturn(RPC_REQUESTS_QUOTA);
75         when(configurationService.getProperty(eq(ConfigurationProperty.GLOBAL_NOTIFICATION_QUOTA.toString()), any()))
76                 .thenReturn(GLOBAL_NOTIFICATION_QUOTA);
77         when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MIN_THREADS.toString()), any()))
78                 .thenReturn(THREAD_POOL_MIN_THREADS);
79         when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MAX_THREADS.toString()), any()))
80                 .thenReturn(THREAD_POOL_MAX_THREADS);
81         when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_TIMEOUT.toString()), any()))
82                 .thenReturn(THREAD_POOL_TIMEOUT);
83         when(configurationService.getProperty(eq(ConfigurationProperty.DEVICE_CONNECTION_RATE_LIMIT_PER_MIN.toString()),
84                 any())).thenReturn(DEVICE_CONNECTION_RATE_LIMIT_PER_MIN);
85         openflowProviderConfig = new OpenFlowProviderConfigImpl(configurationService);
86     }
87
88     @After
89     public void tearDown() throws Exception {
90         configurationService.close();
91     }
92
93     @Test
94     public void getRpcRequestsQuota() throws Exception {
95         assertEquals(RPC_REQUESTS_QUOTA, openflowProviderConfig.getRpcRequestsQuota().getValue());
96     }
97
98     @Test
99     public void isSwitchFeaturesMandatory() throws Exception {
100         assertEquals(SWITCH_FEATURES_MANDATORY, openflowProviderConfig.isSwitchFeaturesMandatory());
101     }
102
103     @Test
104     public void getGlobalNotificationQuota() throws Exception {
105         assertEquals(GLOBAL_NOTIFICATION_QUOTA, openflowProviderConfig.getGlobalNotificationQuota());
106     }
107
108     @Test
109     public void isIsStatisticsPollingOn() throws Exception {
110         assertEquals(IS_STATISTICS_POLLING_ON, openflowProviderConfig.isIsStatisticsPollingOn());
111     }
112
113     @Test
114     public void isIsStatisticsRpcEnabled() throws Exception {
115         assertEquals(IS_STATISTICS_RPC_ENABLED, openflowProviderConfig.isIsStatisticsRpcEnabled());
116     }
117
118     @Test
119     public void getBarrierIntervalTimeoutLimit() throws Exception {
120         assertEquals(BARRIER_INTERVAL_TIMEOUT_LIMIT, openflowProviderConfig.getBarrierIntervalTimeoutLimit()
121                 .getValue());
122     }
123
124     @Test
125     public void getBarrierCountLimit() throws Exception {
126         assertEquals(BARRIER_COUNT_LIMIT, openflowProviderConfig.getBarrierCountLimit().getValue());
127     }
128
129     @Test
130     public void getEchoReplyTimeout() throws Exception {
131         assertEquals(ECHO_REPLY_TIMEOUT, openflowProviderConfig.getEchoReplyTimeout().getValue());
132     }
133
134     @Test
135     public void getThreadPoolMinThreads() throws Exception {
136         assertEquals(THREAD_POOL_MIN_THREADS, openflowProviderConfig.getThreadPoolMinThreads());
137     }
138
139     @Test
140     public void getThreadPoolMaxThreads() throws Exception {
141         assertEquals(THREAD_POOL_MAX_THREADS, openflowProviderConfig.getThreadPoolMaxThreads().getValue());
142     }
143
144     @Test
145     public void getThreadPoolTimeout() throws Exception {
146         assertEquals(THREAD_POOL_TIMEOUT, openflowProviderConfig.getThreadPoolTimeout());
147     }
148
149     @Test
150     public void isEnableFlowRemovedNotification() throws Exception {
151         assertEquals(ENABLE_FLOW_REMOVED_NOTIFICATION, openflowProviderConfig.isEnableFlowRemovedNotification());
152     }
153
154     @Test
155     public void isSkipTableFeatures() throws Exception {
156         assertEquals(SKIP_TABLE_FEATURES, openflowProviderConfig.isSkipTableFeatures());
157     }
158
159     @Test
160     public void getBasicTimerDelay() throws Exception {
161         assertEquals(BASIC_TIMER_DELAY, openflowProviderConfig.getBasicTimerDelay().getValue());
162     }
163
164     @Test
165     public void getMaximumTimerDelay() throws Exception {
166         assertEquals(MAXIMUM_TIMER_DELAY, openflowProviderConfig.getMaximumTimerDelay().getValue());
167     }
168
169     @Test
170     public void isUseSingleLayerSerialization() throws Exception {
171         assertEquals(USE_SINGLE_LAYER_SERIALIZATION, openflowProviderConfig.isUseSingleLayerSerialization());
172     }
173
174     @Test
175     public void getDeviceConnectionRateLimitPerMin() throws Exception {
176         assertEquals(DEVICE_CONNECTION_RATE_LIMIT_PER_MIN, openflowProviderConfig.getDeviceConnectionRateLimitPerMin());
177     }
178
179 }