blob: 7f098721537a9cecb62997fdd95299610345be52 [file] [log] [blame]
Thomas Vachuska02aeb032015-01-06 22:36:30 -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.app;
17
Thomas Vachuskaebf5e542015-02-03 19:38:13 -080018import com.google.common.collect.ImmutableList;
Thomas Vachuska02aeb032015-01-06 22:36:30 -080019import com.google.common.collect.ImmutableSet;
20import org.junit.Test;
Changhoon Yoonbdeb88a2015-05-12 20:35:31 +090021import org.onosproject.core.ApplicationRole;
Thomas Vachuska02aeb032015-01-06 22:36:30 -080022import org.onosproject.core.Permission;
23import org.onosproject.core.Version;
24
25import java.net.URI;
Thomas Vachuskaebf5e542015-02-03 19:38:13 -080026import java.util.List;
Thomas Vachuska02aeb032015-01-06 22:36:30 -080027import java.util.Set;
28
29import static org.junit.Assert.assertEquals;
30import static org.junit.Assert.assertTrue;
Changhoon Yoonbdeb88a2015-05-12 20:35:31 +090031
Thomas Vachuska02aeb032015-01-06 22:36:30 -080032
33/**
34 * Basic tests of the default app description.
35 */
36public class DefaultApplicationDescriptionTest {
37
38 public static final String APP_NAME = "org.foo.app";
39 public static final Version VER = Version.version(1, 2, "a", null);
Thomas Vachuskaad35c342015-06-11 17:25:36 -070040 public static final String DESC = "Awesome application from Circus, Inc.";
Thomas Vachuska02aeb032015-01-06 22:36:30 -080041 public static final String ORIGIN = "Circus";
Changhoon Yoonbdeb88a2015-05-12 20:35:31 +090042 public static final ApplicationRole ROLE = ApplicationRole.ADMIN;
Changhoon Yoona7841ed2015-05-15 02:51:08 +090043 public static final Set<Permission> PERMS = ImmutableSet.of(Permission.FLOWRULE_WRITE, Permission.FLOWRULE_READ);
Thomas Vachuska02aeb032015-01-06 22:36:30 -080044 public static final URI FURL = URI.create("mvn:org.foo-features/1.2a/xml/features");
Thomas Vachuskaebf5e542015-02-03 19:38:13 -080045 public static final List<String> FEATURES = ImmutableList.of("foo", "bar");
Thomas Vachuska02aeb032015-01-06 22:36:30 -080046
47 @Test
48 public void basics() {
49 ApplicationDescription app =
50 new DefaultApplicationDescription(APP_NAME, VER, DESC, ORIGIN,
Changhoon Yoonbdeb88a2015-05-12 20:35:31 +090051 ROLE, PERMS, FURL, FEATURES);
Thomas Vachuska02aeb032015-01-06 22:36:30 -080052 assertEquals("incorrect id", APP_NAME, app.name());
53 assertEquals("incorrect version", VER, app.version());
54 assertEquals("incorrect description", DESC, app.description());
55 assertEquals("incorrect origin", ORIGIN, app.origin());
Changhoon Yoonbdeb88a2015-05-12 20:35:31 +090056 assertEquals("incorect role", ROLE, app.role());
Thomas Vachuska02aeb032015-01-06 22:36:30 -080057 assertEquals("incorrect permissions", PERMS, app.permissions());
58 assertEquals("incorrect features repo", FURL, app.featuresRepo().get());
59 assertEquals("incorrect features", FEATURES, app.features());
60 assertTrue("incorrect toString", app.toString().contains(APP_NAME));
61 }
62
63}