blob: 973fcd5dbf8107bc8433ea3b69d8e753d015239e [file] [log] [blame]
Carmelo Cascone17fc9e42016-05-31 11:29:21 -07001/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
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 */
16
17package org.onosproject.bmv2.ctl;
18
19import org.junit.Test;
20import org.onosproject.bmv2.api.context.Bmv2Configuration;
21import org.onosproject.bmv2.api.runtime.Bmv2ParsedTableEntry;
22
23import java.io.IOException;
24import java.net.URISyntaxException;
25import java.nio.charset.Charset;
26import java.nio.file.Files;
27import java.nio.file.Paths;
28import java.util.List;
29
30import static org.hamcrest.MatcherAssert.assertThat;
31import static org.hamcrest.Matchers.equalTo;
32
33public class Bmv2TableDumpParserTest {
34
35 private Bmv2Configuration configuration = Bmv2DeviceContextServiceImpl.loadDefaultConfiguration();
36
37 @Test
38 public void testParse() throws Exception {
39 String text = readFile();
40 List<Bmv2ParsedTableEntry> result = Bmv2TableDumpParser.parse(text, configuration);
41 assertThat(result.size(), equalTo(10));
42 }
43
44 private String readFile()
45 throws IOException, URISyntaxException {
46 byte[] encoded = Files.readAllBytes(Paths.get(this.getClass().getResource("/tabledump.txt").toURI()));
47 return new String(encoded, Charset.defaultCharset());
48 }
49}