2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.app;
18 import com.google.common.collect.ImmutableList;
19 import com.google.common.collect.ImmutableSet;
20 import org.junit.Test;
21 import org.onosproject.core.ApplicationRole;
22 import org.onosproject.core.Version;
23 import org.onosproject.security.AppPermission;
24 import org.onosproject.security.Permission;
27 import java.util.List;
30 import static org.junit.Assert.assertEquals;
31 import static org.junit.Assert.assertTrue;
35 * Basic tests of the default app description.
37 public class DefaultApplicationDescriptionTest {
39 public static final String APP_NAME = "org.foo.app";
40 public static final Version VER = Version.version(1, 2, "a", null);
41 public static final String DESC = "Awesome application from Circus, Inc.";
42 public static final String ORIGIN = "Circus";
43 public static final ApplicationRole ROLE = ApplicationRole.ADMIN;
44 public static final Set<Permission> PERMS = ImmutableSet.of(
45 new Permission(AppPermission.class.getName(), "FLOWRULE_WRITE"),
46 new Permission(AppPermission.class.getName(), "FLOWRULE_READ"));
47 public static final URI FURL = URI.create("mvn:org.foo-features/1.2a/xml/features");
48 public static final List<String> FEATURES = ImmutableList.of("foo", "bar");
51 public void basics() {
52 ApplicationDescription app =
53 new DefaultApplicationDescription(APP_NAME, VER, DESC, ORIGIN,
54 ROLE, PERMS, FURL, FEATURES);
55 assertEquals("incorrect id", APP_NAME, app.name());
56 assertEquals("incorrect version", VER, app.version());
57 assertEquals("incorrect description", DESC, app.description());
58 assertEquals("incorrect origin", ORIGIN, app.origin());
59 assertEquals("incorect role", ROLE, app.role());
60 assertEquals("incorrect permissions", PERMS, app.permissions());
61 assertEquals("incorrect features repo", FURL, app.featuresRepo().get());
62 assertEquals("incorrect features", FEATURES, app.features());
63 assertTrue("incorrect toString", app.toString().contains(APP_NAME));