aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2012-05-31 09:38:58 (EDT)
committerIgor Fedorenko2012-08-26 08:07:27 (EDT)
commit5dee1ca3b5852f9cae4ea07e99d708bce8ef7426 (patch)
tree729e8fcb60b4f6ed03f815863cd2baf217cfe82c
parent4b385e947ca255a7facbee99a3ae44dbff02b4a9 (diff)
downloadorg.eclipse.tycho-5dee1ca3b5852f9cae4ea07e99d708bce8ef7426.zip
org.eclipse.tycho-5dee1ca3b5852f9cae4ea07e99d708bce8ef7426.tar.gz
org.eclipse.tycho-5dee1ca3b5852f9cae4ea07e99d708bce8ef7426.tar.bz2
374349 : Additional elements in Feature model + testsrefs/changes/98/6198/2
-rw-r--r--tycho-metadata-model/src/main/java/org/eclipse/tycho/model/Feature.java127
-rw-r--r--tycho-metadata-model/src/test/java/org/eclipse/tycho/maven/test/EclipseModelTest.java24
-rw-r--r--tycho-metadata-model/src/test/resources/modelio/feature.xml21
3 files changed, 162 insertions, 10 deletions
diff --git a/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/Feature.java b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/Feature.java
index 44b6944..864ce89 100644
--- a/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/Feature.java
+++ b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/Feature.java
@@ -240,4 +240,131 @@ public class Feature {
dom.addNode(feature.getDom());
features = null;
}
+
+ //////
+ // Other (not structural) feature content
+ //////
+
+ // label
+ public String getLabel() {
+ return dom.getAttributeValue("label");
+ }
+
+ public void setLabel(String label) {
+ dom.setAttribute("label", label);
+ }
+
+ // provider
+ public String getProvider() {
+ return dom.getAttributeValue("provider-name");
+ }
+
+ public void setProvider(String provider) {
+ dom.setAttribute("provider-name", provider);
+ }
+
+ // description + url
+ public String getDescription() {
+ Element descElement = dom.getChild("description");
+ if (descElement != null) {
+ return descElement.getText();
+ }
+ return null;
+ }
+
+ public void setDescription(String description) {
+ Element descElement = dom.getChild("description");
+ if (descElement == null) {
+ descElement = new Element("description");
+ dom.addNode(descElement);
+ }
+ descElement.setText(description);
+ }
+
+ public String getDescriptionURL() {
+ Element descElement = dom.getChild("description");
+ if (descElement != null) {
+ return descElement.getAttributeValue("url");
+ }
+ return null;
+ }
+
+ public void setDescriptionURL(String descriptionURL) {
+ Element descElement = dom.getChild("description");
+ if (descElement == null) {
+ descElement = new Element("description");
+ dom.addNode(descElement);
+ }
+ descElement.setAttribute("url", descriptionURL);
+ }
+
+ // copyright + url
+ public String getCopyright() {
+ Element copyrightElement = dom.getChild("copyright");
+ if (copyrightElement != null) {
+ return copyrightElement.getText();
+ }
+ return null;
+ }
+
+ public void setCopyright(String description) {
+ Element copyrightElement = dom.getChild("copyright");
+ if (copyrightElement == null) {
+ copyrightElement = new Element("copyright");
+ dom.addNode(copyrightElement);
+ }
+ copyrightElement.setText(description);
+ }
+
+ public String getCopyrightURL() {
+ Element copyrightElement = dom.getChild("copyright");
+ if (copyrightElement != null) {
+ return copyrightElement.getAttributeValue("url");
+ }
+ return null;
+ }
+
+ public void setCopyrightURL(String copyrightURL) {
+ Element copyrightElement = dom.getChild("copyright");
+ if (copyrightElement == null) {
+ copyrightElement = new Element("copyright");
+ dom.addNode(copyrightElement);
+ }
+ copyrightElement.setAttribute("url", copyrightURL);
+ }
+
+ // license + url
+ public String getLicense() {
+ Element licenseElement = dom.getChild("license");
+ if (licenseElement != null) {
+ return licenseElement.getText();
+ }
+ return null;
+ }
+
+ public void setLicense(String license) {
+ Element licenseElement = dom.getChild("license");
+ if (licenseElement == null) {
+ licenseElement = new Element("license");
+ dom.addNode(licenseElement);
+ }
+ licenseElement.setText(license);
+ }
+
+ public String getLicenseURL() {
+ Element licenseElement = dom.getChild("license");
+ if (licenseElement != null) {
+ return licenseElement.getAttributeValue("url");
+ }
+ return null;
+ }
+
+ public void setLicenseURL(String licenseURL) {
+ Element licenseElement = dom.getChild("license");
+ if (licenseElement == null) {
+ licenseElement = new Element("license");
+ dom.addNode(licenseElement);
+ }
+ licenseElement.setAttribute("url", licenseURL);
+ }
}
diff --git a/tycho-metadata-model/src/test/java/org/eclipse/tycho/maven/test/EclipseModelTest.java b/tycho-metadata-model/src/test/java/org/eclipse/tycho/maven/test/EclipseModelTest.java
index fd1ce2e..df36579 100644
--- a/tycho-metadata-model/src/test/java/org/eclipse/tycho/maven/test/EclipseModelTest.java
+++ b/tycho-metadata-model/src/test/java/org/eclipse/tycho/maven/test/EclipseModelTest.java
@@ -80,14 +80,38 @@ public class EclipseModelTest extends TestCase {
assertEquals("pluginB", requires.get(0).getImports().get(0).getPlugin());
assertEquals("featureC", requires.get(0).getImports().get(1).getFeature());
+ // not structural data - getters
+ assertEquals("featureA", feature.getLabel());
+ assertEquals("COMPANY", feature.getProvider());
+ assertEquals("Test License", feature.getLicense().trim());
+ assertEquals("http://www.example.com/license", feature.getLicenseURL());
+ assertEquals(null, feature.getCopyrightURL());
+ assertEquals(null, feature.getCopyright());
+
feature.setVersion("1.2.3");
plugins.get(0).setVersion("3.4.5");
+ // not structural data - setters
+ feature.setLabel("featureA_MODIFIED");
+ feature.setProvider("COMPANY_MODIFIED");
+ feature.setLicense("Test License MODIFIED");
+ feature.setLicenseURL("http://www.example.com/license_MODIFIED");
+ feature.setCopyright("Test Copyright");
+ feature.setCopyrightURL("http://www.example.com/copyright");
+
File updatedFile = new File(target, "feature.xml");
Feature.write(feature, updatedFile);
Feature updated = Feature.read(updatedFile);
assertEquals("1.2.3", updated.getVersion());
assertEquals("3.4.5", updated.getPlugins().get(0).getVersion());
+
+ // not structural data - persistence
+ assertEquals("featureA_MODIFIED", feature.getLabel());
+ assertEquals("COMPANY_MODIFIED", feature.getProvider());
+ assertEquals("Test License MODIFIED", feature.getLicense());
+ assertEquals("http://www.example.com/license_MODIFIED", feature.getLicenseURL());
+ assertEquals("http://www.example.com/copyright", feature.getCopyrightURL());
+ assertEquals("Test Copyright", feature.getCopyright());
}
public void testPlatform() throws Exception {
diff --git a/tycho-metadata-model/src/test/resources/modelio/feature.xml b/tycho-metadata-model/src/test/resources/modelio/feature.xml
index 5d97086..756e783 100644
--- a/tycho-metadata-model/src/test/resources/modelio/feature.xml
+++ b/tycho-metadata-model/src/test/resources/modelio/feature.xml
@@ -6,21 +6,27 @@
provider-name="COMPANY">
<description url="http://www.example.com/description">
- [Enter Feature Description here.]
+ Test Description
</description>
- <copyright url="http://www.example.com/copyright">
- [Enter Copyright Description here.]
- </copyright>
+ <!-- LEFT Blank to test case dom node does not exist -->
+ <!--copyright url="http://www.example.com/copyright">
+ Test Copyright
+ </copyright-->
<license url="http://www.example.com/license">
- [Enter License Description here.]
+ Test License
</license>
<includes
id="featureB"
version="0.0.0"/>
+ <requires>
+ <import plugin="pluginB"/>
+ <import feature="featureC"/>
+ </requires>
+
<plugin
id="pluginA"
download-size="0"
@@ -28,9 +34,4 @@
version="0.0.0"
unpack="false"/>
- <requires>
- <import plugin="pluginB"/>
- <import feature="featureC"/>
- </requires>
-
</feature>