blob: 5958bd8d50d5c9636037bfa5de6a968a52595bf5 [file] [log] [blame]
Thomas Vachuska6d697f12015-03-08 20:59:50 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska6d697f12015-03-08 20:59:50 -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.cfg.impl;
17
18import com.google.common.collect.ImmutableSet;
19import org.junit.Test;
20import org.onosproject.cfg.ConfigProperty;
21
22import java.io.ByteArrayInputStream;
23import java.io.ByteArrayOutputStream;
24import java.io.IOException;
25import java.util.Set;
26
27import static org.junit.Assert.*;
28import static org.onosproject.cfg.ConfigProperty.Type.STRING;
29import static org.onosproject.cfg.ConfigProperty.defineProperty;
30import static org.onosproject.cfg.impl.ConfigPropertyDefinitions.read;
31import static org.onosproject.cfg.impl.ConfigPropertyDefinitions.write;
32
33/**
34 * Tests of the config property definitions utility.
35 */
36public class ConfigPropertyDefinitionsTest {
37
38 @Test
39 public void basics() throws IOException {
40 Set<ConfigProperty> original = ImmutableSet
41 .of(defineProperty("foo", STRING, "dingo", "FOO"),
42 defineProperty("bar", STRING, "bat", "BAR"));
43 ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
44 write(out, original);
45 Set<ConfigProperty> read = read(new ByteArrayInputStream(out.toByteArray()));
46 assertEquals("incorrect defs", original, read);
47 }
48
49}