blob: 93c40ec989592e0ec73f65396adc704dbf561635 [file] [log] [blame]
Ray Milkey24e60b32015-08-12 11:39:54 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Ray Milkey24e60b32015-08-12 11:39:54 -07003 *
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.store.flowobjective.impl;
17
18import org.junit.After;
19import org.junit.Before;
20import org.junit.Test;
21import org.onosproject.net.behaviour.DefaultNextGroup;
22import org.onosproject.net.behaviour.NextGroup;
23import org.onosproject.net.flowobjective.FlowObjectiveStore;
24import org.onosproject.store.service.TestStorageService;
25
26import com.google.common.base.Charsets;
27import static org.hamcrest.MatcherAssert.assertThat;
28import static org.hamcrest.Matchers.*;
29
30/**
31 * Unit tests for distributed flow objective store.
32 */
33public class DistributedFlowObjectiveStoreTest {
34 DistributedFlowObjectiveStore storeImpl;
35 FlowObjectiveStore store;
36
37 @Before
38 public void setUp() {
39 storeImpl = new DistributedFlowObjectiveStore();
40 storeImpl.storageService = new TestStorageService();
41 storeImpl.activate();
42 store = storeImpl;
43 }
44
45 @After
46 public void tearDown() {
47 storeImpl.deactivate();
48 }
49
50 @Test
51 public void testFlowObjectiveStore() {
52 NextGroup group2 = new DefaultNextGroup("2".getBytes(Charsets.US_ASCII));
53 int group1Id = store.allocateNextId();
54 int group2Id = store.allocateNextId();
55
56 NextGroup group1add = store.getNextGroup(group1Id);
57 assertThat(group1add, nullValue());
58
59 store.putNextGroup(group2Id, group2);
60 NextGroup group2Query = store.getNextGroup(group2Id);
61 assertThat(group2Query.data(), is(group2.data()));
62 }
63}