2 * Copyright (c) 2015 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.openflowplugin.impl.registry.meter;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
17 * Test for {@link DeviceMeterRegistryImpl}.
19 public class DeviceMeterRegistryImplTest {
21 private MeterId meterId;
22 private MeterId meterId2;
23 private DeviceMeterRegistryImpl deviceMeterRegistry;
26 public void setUp() throws Exception {
27 deviceMeterRegistry = new DeviceMeterRegistryImpl();
28 meterId = new MeterId(42L);
29 meterId2 = new MeterId(84L);
30 Assert.assertEquals(0, deviceMeterRegistry.getAllMeterIds().size());
31 deviceMeterRegistry.store(meterId);
32 Assert.assertEquals(1, deviceMeterRegistry.getAllMeterIds().size());
36 public void testStore() throws Exception {
37 deviceMeterRegistry.store(meterId2);
38 Assert.assertEquals(2, deviceMeterRegistry.getAllMeterIds().size());
42 public void testRemoveMarked() throws Exception {
43 deviceMeterRegistry.markToBeremoved(meterId);
44 deviceMeterRegistry.removeMarked();
45 Assert.assertEquals(0, deviceMeterRegistry.getAllMeterIds().size());
49 public void testRemoveMarkedNegative() throws Exception {
50 deviceMeterRegistry.markToBeremoved(meterId2);
51 deviceMeterRegistry.removeMarked();
52 Assert.assertEquals(1, deviceMeterRegistry.getAllMeterIds().size());
57 public void testClose() throws Exception {
58 deviceMeterRegistry.markToBeremoved(meterId);
59 deviceMeterRegistry.close();
61 Assert.assertEquals(0, deviceMeterRegistry.getAllMeterIds().size());
62 deviceMeterRegistry.store(meterId);
63 Assert.assertEquals(1, deviceMeterRegistry.getAllMeterIds().size());
64 deviceMeterRegistry.removeMarked();
65 Assert.assertEquals(1, deviceMeterRegistry.getAllMeterIds().size());