blob: 1ea1d2c8271d34008d80cd2249f7304e0f1624e8 [file] [log] [blame]
Thomas Vachuskafe8c98a2015-02-04 01:24:32 -08001/*
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 */
16package org.onosproject.ui;
17
18import com.google.common.collect.ImmutableList;
19import org.junit.Test;
20
21import java.io.IOException;
22
23import static com.google.common.io.ByteStreams.toByteArray;
24import static org.junit.Assert.assertEquals;
25import static org.junit.Assert.assertTrue;
26
27/**
28 * Tests the default user interface extension descriptor.
29 */
30public class UiExtensionTest {
31
32 @Test
33 public void basics() throws IOException {
34 UiExtension ext = new UiExtension(ImmutableList.of(new UiView("foo", "Foo View")),
35 getClass().getClassLoader());
36 String css = new String(toByteArray(ext.css()));
37 assertTrue("incorrect css stream", css.contains("foo-css"));
38 String js = new String(toByteArray(ext.js()));
39 assertTrue("incorrect js stream", js.contains("foo-js"));
40 assertEquals("incorrect views stream", "foo", ext.views().get(0).id());
41 }
42
43 @Test
44 public void withPath() throws IOException {
45 UiExtension ext = new UiExtension(ImmutableList.of(new UiView("foo", "Foo View")),
46 "custom", getClass().getClassLoader());
47 String css = new String(toByteArray(ext.css()));
48 assertTrue("incorrect css stream", css.contains("custom-css"));
49 String js = new String(toByteArray(ext.js()));
50 assertTrue("incorrect js stream", js.contains("custom-js"));
51 assertEquals("incorrect views stream", "foo", ext.views().get(0).id());
52 }
53}