blob: b792abccbca241ad46985cb71885cef302b37e84 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
2 * Copyright 2015 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 */
Thomas Vachuska6b331262015-04-27 11:09:07 -070016package org.onlab.jdvue;
17
18import org.junit.Test;
19import org.onlab.jdvue.Catalog;
20import org.onlab.jdvue.JavaPackage;
21import org.onlab.jdvue.JavaSource;
22
23import java.io.IOException;
24
25import static org.junit.Assert.assertEquals;
26import static org.junit.Assert.assertNotNull;
27
28/**
29 * Unit test for the source catalog.
30 *
31 * @author Thomas Vachuska
32 */
33public class CatalogTest {
34
35 @Test
36 public void basics() throws IOException {
37 Catalog cat = new Catalog();
38 cat.load("src/test/resources/catalog.db");
39 cat.analyze();
40
41 assertEquals("incorrect package count", 12, cat.getPackages().size());
42 assertEquals("incorrect source count", 14, cat.getSources().size());
43
44 JavaPackage pkg = cat.getPackage("k");
45 assertNotNull("package should be found", pkg);
46
47 JavaSource src = cat.getSource("k.K");
48 assertNotNull("source should be found", src);
49
50 assertEquals("incorrect package source count", 1, pkg.getSources().size());
51 assertEquals("incorrect package dependency count", 1, pkg.getDependencies().size());
52 assertEquals("incorrect package cycle count", 3, cat.getPackageCycles(pkg).size());
53
54 assertEquals("incorrect segment count", 11, cat.getCycleSegments().size());
55 assertEquals("incorrect cycle count", 5, cat.getCycles().size());
56 }
57
58}