Thomas Vachuska
Committed by Gerrit Code Review

Fixed application descriptor parsing.

Change-Id: If4fa4ecc66d0ed2a42e8b240d0e3142340d544eb
......@@ -37,7 +37,7 @@ public class DefaultApplicationDescriptionTest {
public static final String APP_NAME = "org.foo.app";
public static final Version VER = Version.version(1, 2, "a", null);
public static final String DESC = "Awesome application from Circus";
public static final String DESC = "Awesome application from Circus, Inc.";
public static final String ORIGIN = "Circus";
public static final ApplicationRole ROLE = ApplicationRole.ADMIN;
public static final Set<Permission> PERMS = ImmutableSet.of(Permission.FLOWRULE_WRITE, Permission.FLOWRULE_READ);
......
......@@ -150,7 +150,11 @@ public class ApplicationArchive
*/
public ApplicationDescription getApplicationDescription(String appName) {
try {
return loadAppDescription(new XMLConfiguration(appFile(appName, APP_XML)));
XMLConfiguration cfg = new XMLConfiguration();
cfg.setAttributeSplittingDisabled(true);
cfg.setDelimiterParsingDisabled(true);
cfg.load(appFile(appName, APP_XML));
return loadAppDescription(cfg);
} catch (Exception e) {
throw new ApplicationException("Unable to get app description", e);
}
......@@ -258,6 +262,8 @@ public class ApplicationArchive
private ApplicationDescription parsePlainAppDescription(InputStream stream)
throws IOException {
XMLConfiguration cfg = new XMLConfiguration();
cfg.setAttributeSplittingDisabled(true);
cfg.setDelimiterParsingDisabled(true);
try {
cfg.load(stream);
return loadAppDescription(cfg);
......@@ -267,8 +273,6 @@ public class ApplicationArchive
}
private ApplicationDescription loadAppDescription(XMLConfiguration cfg) {
cfg.setAttributeSplittingDisabled(true);
cfg.setDelimiterParsingDisabled(true);
String name = cfg.getString(NAME);
Version version = Version.version(cfg.getString(VERSION));
String desc = cfg.getString(DESCRIPTION);
......@@ -277,7 +281,7 @@ public class ApplicationArchive
Set<Permission> perms = getPermissions(cfg);
String featRepo = cfg.getString(FEATURES_REPO);
URI featuresRepo = featRepo != null ? URI.create(featRepo) : null;
List<String> features = ImmutableList.copyOf(cfg.getStringArray(FEATURES));
List<String> features = ImmutableList.copyOf(cfg.getString(FEATURES).split(","));
return new DefaultApplicationDescription(name, version, desc, origin, role,
perms, featuresRepo, features);
......
......@@ -33,6 +33,9 @@ import java.util.Set;
import static org.junit.Assert.*;
import static org.onosproject.app.DefaultApplicationDescriptionTest.*;
/**
* Suite of tests for the application archive utility.
*/
public class ApplicationArchiveTest {
static final String ROOT = "/tmp/app-junit/";
......