Committed by
Gerrit Code Review
Fixed application descriptor parsing.
Change-Id: If4fa4ecc66d0ed2a42e8b240d0e3142340d544eb
Showing
3 changed files
with
12 additions
and
5 deletions
... | @@ -37,7 +37,7 @@ public class DefaultApplicationDescriptionTest { | ... | @@ -37,7 +37,7 @@ public class DefaultApplicationDescriptionTest { |
37 | 37 | ||
38 | public static final String APP_NAME = "org.foo.app"; | 38 | public static final String APP_NAME = "org.foo.app"; |
39 | public static final Version VER = Version.version(1, 2, "a", null); | 39 | public static final Version VER = Version.version(1, 2, "a", null); |
40 | - public static final String DESC = "Awesome application from Circus"; | 40 | + public static final String DESC = "Awesome application from Circus, Inc."; |
41 | public static final String ORIGIN = "Circus"; | 41 | public static final String ORIGIN = "Circus"; |
42 | public static final ApplicationRole ROLE = ApplicationRole.ADMIN; | 42 | public static final ApplicationRole ROLE = ApplicationRole.ADMIN; |
43 | public static final Set<Permission> PERMS = ImmutableSet.of(Permission.FLOWRULE_WRITE, Permission.FLOWRULE_READ); | 43 | public static final Set<Permission> PERMS = ImmutableSet.of(Permission.FLOWRULE_WRITE, Permission.FLOWRULE_READ); | ... | ... |
... | @@ -150,7 +150,11 @@ public class ApplicationArchive | ... | @@ -150,7 +150,11 @@ public class ApplicationArchive |
150 | */ | 150 | */ |
151 | public ApplicationDescription getApplicationDescription(String appName) { | 151 | public ApplicationDescription getApplicationDescription(String appName) { |
152 | try { | 152 | try { |
153 | - return loadAppDescription(new XMLConfiguration(appFile(appName, APP_XML))); | 153 | + XMLConfiguration cfg = new XMLConfiguration(); |
154 | + cfg.setAttributeSplittingDisabled(true); | ||
155 | + cfg.setDelimiterParsingDisabled(true); | ||
156 | + cfg.load(appFile(appName, APP_XML)); | ||
157 | + return loadAppDescription(cfg); | ||
154 | } catch (Exception e) { | 158 | } catch (Exception e) { |
155 | throw new ApplicationException("Unable to get app description", e); | 159 | throw new ApplicationException("Unable to get app description", e); |
156 | } | 160 | } |
... | @@ -258,6 +262,8 @@ public class ApplicationArchive | ... | @@ -258,6 +262,8 @@ public class ApplicationArchive |
258 | private ApplicationDescription parsePlainAppDescription(InputStream stream) | 262 | private ApplicationDescription parsePlainAppDescription(InputStream stream) |
259 | throws IOException { | 263 | throws IOException { |
260 | XMLConfiguration cfg = new XMLConfiguration(); | 264 | XMLConfiguration cfg = new XMLConfiguration(); |
265 | + cfg.setAttributeSplittingDisabled(true); | ||
266 | + cfg.setDelimiterParsingDisabled(true); | ||
261 | try { | 267 | try { |
262 | cfg.load(stream); | 268 | cfg.load(stream); |
263 | return loadAppDescription(cfg); | 269 | return loadAppDescription(cfg); |
... | @@ -267,8 +273,6 @@ public class ApplicationArchive | ... | @@ -267,8 +273,6 @@ public class ApplicationArchive |
267 | } | 273 | } |
268 | 274 | ||
269 | private ApplicationDescription loadAppDescription(XMLConfiguration cfg) { | 275 | private ApplicationDescription loadAppDescription(XMLConfiguration cfg) { |
270 | - cfg.setAttributeSplittingDisabled(true); | ||
271 | - cfg.setDelimiterParsingDisabled(true); | ||
272 | String name = cfg.getString(NAME); | 276 | String name = cfg.getString(NAME); |
273 | Version version = Version.version(cfg.getString(VERSION)); | 277 | Version version = Version.version(cfg.getString(VERSION)); |
274 | String desc = cfg.getString(DESCRIPTION); | 278 | String desc = cfg.getString(DESCRIPTION); |
... | @@ -277,7 +281,7 @@ public class ApplicationArchive | ... | @@ -277,7 +281,7 @@ public class ApplicationArchive |
277 | Set<Permission> perms = getPermissions(cfg); | 281 | Set<Permission> perms = getPermissions(cfg); |
278 | String featRepo = cfg.getString(FEATURES_REPO); | 282 | String featRepo = cfg.getString(FEATURES_REPO); |
279 | URI featuresRepo = featRepo != null ? URI.create(featRepo) : null; | 283 | URI featuresRepo = featRepo != null ? URI.create(featRepo) : null; |
280 | - List<String> features = ImmutableList.copyOf(cfg.getStringArray(FEATURES)); | 284 | + List<String> features = ImmutableList.copyOf(cfg.getString(FEATURES).split(",")); |
281 | 285 | ||
282 | return new DefaultApplicationDescription(name, version, desc, origin, role, | 286 | return new DefaultApplicationDescription(name, version, desc, origin, role, |
283 | perms, featuresRepo, features); | 287 | perms, featuresRepo, features); | ... | ... |
... | @@ -33,6 +33,9 @@ import java.util.Set; | ... | @@ -33,6 +33,9 @@ import java.util.Set; |
33 | import static org.junit.Assert.*; | 33 | import static org.junit.Assert.*; |
34 | import static org.onosproject.app.DefaultApplicationDescriptionTest.*; | 34 | import static org.onosproject.app.DefaultApplicationDescriptionTest.*; |
35 | 35 | ||
36 | +/** | ||
37 | + * Suite of tests for the application archive utility. | ||
38 | + */ | ||
36 | public class ApplicationArchiveTest { | 39 | public class ApplicationArchiveTest { |
37 | 40 | ||
38 | static final String ROOT = "/tmp/app-junit/"; | 41 | static final String ROOT = "/tmp/app-junit/"; | ... | ... |
-
Please register or login to post a comment