Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 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 | package org.onosproject.app; |
| 17 | |
Thomas Vachuska | ebf5e54 | 2015-02-03 19:38:13 -0800 | [diff] [blame] | 18 | import com.google.common.collect.ImmutableList; |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 19 | import com.google.common.collect.ImmutableSet; |
| 20 | import org.junit.Test; |
Changhoon Yoon | bdeb88a | 2015-05-12 20:35:31 +0900 | [diff] [blame] | 21 | import org.onosproject.core.ApplicationRole; |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 22 | import org.onosproject.core.Version; |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 23 | import org.onosproject.security.AppPermission; |
| 24 | import org.onosproject.security.Permission; |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 25 | |
| 26 | import java.net.URI; |
Thomas Vachuska | ebf5e54 | 2015-02-03 19:38:13 -0800 | [diff] [blame] | 27 | import java.util.List; |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 28 | import java.util.Set; |
| 29 | |
| 30 | import static org.junit.Assert.assertEquals; |
| 31 | import static org.junit.Assert.assertTrue; |
Changhoon Yoon | bdeb88a | 2015-05-12 20:35:31 +0900 | [diff] [blame] | 32 | |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Basic tests of the default app description. |
| 36 | */ |
| 37 | public class DefaultApplicationDescriptionTest { |
| 38 | |
| 39 | public static final String APP_NAME = "org.foo.app"; |
| 40 | public static final Version VER = Version.version(1, 2, "a", null); |
Simon Hunt | afae2f7 | 2016-03-04 21:18:23 -0800 | [diff] [blame] | 41 | public static final String TITLE = "Awesome App"; |
Thomas Vachuska | ad35c34 | 2015-06-11 17:25:36 -0700 | [diff] [blame] | 42 | public static final String DESC = "Awesome application from Circus, Inc."; |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 43 | public static final String ORIGIN = "Circus"; |
Jian Li | c35415d | 2016-01-14 17:22:31 -0800 | [diff] [blame] | 44 | public static final String CATEGORY = "other"; |
| 45 | public static final String URL = "http://www.onosproject.org"; |
| 46 | public static final String README = "Awesome application from Circus, Inc."; |
| 47 | public static final byte[] ICON = new byte[] {}; |
Changhoon Yoon | bdeb88a | 2015-05-12 20:35:31 +0900 | [diff] [blame] | 48 | public static final ApplicationRole ROLE = ApplicationRole.ADMIN; |
Changhoon Yoon | b856b81 | 2015-08-10 03:47:19 +0900 | [diff] [blame] | 49 | public static final Set<Permission> PERMS = ImmutableSet.of( |
| 50 | new Permission(AppPermission.class.getName(), "FLOWRULE_WRITE"), |
| 51 | new Permission(AppPermission.class.getName(), "FLOWRULE_READ")); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 52 | public static final URI FURL = URI.create("mvn:org.foo-features/1.2a/xml/features"); |
Thomas Vachuska | ebf5e54 | 2015-02-03 19:38:13 -0800 | [diff] [blame] | 53 | public static final List<String> FEATURES = ImmutableList.of("foo", "bar"); |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame] | 54 | public static final List<String> APPS = ImmutableList.of("fifi"); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 55 | |
| 56 | @Test |
| 57 | public void basics() { |
| 58 | ApplicationDescription app = |
Simon Hunt | afae2f7 | 2016-03-04 21:18:23 -0800 | [diff] [blame] | 59 | new DefaultApplicationDescription(APP_NAME, VER, TITLE, DESC, ORIGIN, |
Jian Li | c35415d | 2016-01-14 17:22:31 -0800 | [diff] [blame] | 60 | CATEGORY, URL, README, ICON, |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame] | 61 | ROLE, PERMS, FURL, FEATURES, APPS); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 62 | assertEquals("incorrect id", APP_NAME, app.name()); |
| 63 | assertEquals("incorrect version", VER, app.version()); |
Simon Hunt | afae2f7 | 2016-03-04 21:18:23 -0800 | [diff] [blame] | 64 | assertEquals("incorrect title", TITLE, app.title()); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 65 | assertEquals("incorrect description", DESC, app.description()); |
| 66 | assertEquals("incorrect origin", ORIGIN, app.origin()); |
Jian Li | c35415d | 2016-01-14 17:22:31 -0800 | [diff] [blame] | 67 | assertEquals("incorrect category", CATEGORY, app.category()); |
| 68 | assertEquals("incorrect URL", URL, app.url()); |
| 69 | assertEquals("incorrect readme", README, app.readme()); |
| 70 | assertEquals("incorrect role", ROLE, app.role()); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 71 | assertEquals("incorrect permissions", PERMS, app.permissions()); |
| 72 | assertEquals("incorrect features repo", FURL, app.featuresRepo().get()); |
| 73 | assertEquals("incorrect features", FEATURES, app.features()); |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame] | 74 | assertEquals("incorrect apps", APPS, app.requiredApps()); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 75 | assertTrue("incorrect toString", app.toString().contains(APP_NAME)); |
| 76 | } |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 77 | } |