aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-23 07:53:16 (EST)
committerWinston Prakash2011-12-01 20:47:09 (EST)
commit3122f68d48cc8eea5aa4dbd6eb2a4a4714d1fd55 (patch)
tree9763dc4b605321b062271c8daccfcb01b187da3e
parent6a5775ca46447c55c0b7b4656c12aa5cd45bd17e (diff)
downloadorg.eclipse.hudson.core-3122f68d48cc8eea5aa4dbd6eb2a4a4714d1fd55.zip
org.eclipse.hudson.core-3122f68d48cc8eea5aa4dbd6eb2a4a4714d1fd55.tar.gz
org.eclipse.hudson.core-3122f68d48cc8eea5aa4dbd6eb2a4a4714d1fd55.tar.bz2
Draft implementation of publisher project properties for FreeStyleProject. Improve unit tests. Implement methods for conversion legacy fields to new properties
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractProject.java32
-rw-r--r--hudson-core/src/main/java/hudson/model/FreeStyleProject.java10
-rw-r--r--hudson-core/src/main/java/hudson/model/Job.java25
-rw-r--r--hudson-core/src/main/java/hudson/model/Project.java67
-rw-r--r--hudson-core/src/main/java/hudson/util/DescribableListUtil.java30
-rw-r--r--hudson-core/src/main/resources/lib/hudson/project/config-publishers.jelly26
-rw-r--r--hudson-core/src/test/java/hudson/model/LegacyProjectTest.java179
7 files changed, 313 insertions, 56 deletions
diff --git a/hudson-core/src/main/java/hudson/model/AbstractProject.java b/hudson-core/src/main/java/hudson/model/AbstractProject.java
index f25ee0f..cf14b63 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractProject.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractProject.java
@@ -336,38 +336,62 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
@Override
protected void buildProjectProperties() throws IOException {
super.buildProjectProperties();
+ convertBlockBuildWhenUpstreamBuildingProperty();
+ convertBlockBuildWhenDownstreamBuildingProperty();
+ convertConcurrentBuildProperty();
+ convertCleanWorkspaceRequiredProperty();
+ convertQuietPeriodProperty();
+ convertScmCheckoutRetryCountProperty();
+ convertJDKProperty();
+ }
+
+ void convertBlockBuildWhenUpstreamBuildingProperty() throws IOException {
if (null == getProperty(BLOCK_BUILD_WHEN_UPSTREAM_BUILDING_PROPERTY_NAME)) {
setBlockBuildWhenUpstreamBuilding(blockBuildWhenUpstreamBuilding);
blockBuildWhenUpstreamBuilding = false;
}
+ }
+
+ void convertBlockBuildWhenDownstreamBuildingProperty() throws IOException {
if (null == getProperty(BLOCK_BUILD_WHEN_DOWNSTREAM_BUILDING_PROPERTY_NAME)) {
setBlockBuildWhenDownstreamBuilding(blockBuildWhenDownstreamBuilding);
blockBuildWhenDownstreamBuilding = false;
}
+ }
+
+ void convertConcurrentBuildProperty() throws IOException {
if (null == getProperty(CONCURRENT_BUILD_PROPERTY_NAME)) {
setConcurrentBuild(concurrentBuild);
concurrentBuild = false;
}
+ }
+
+ void convertCleanWorkspaceRequiredProperty() throws IOException {
if (null == getProperty(CLEAN_WORKSPACE_REQUIRED_PROPERTY_NAME)) {
setCleanWorkspaceRequired(cleanWorkspaceRequired);
cleanWorkspaceRequired = false;
}
+ }
+
+ void convertQuietPeriodProperty() throws IOException {
if (null == getProperty(QUIET_PERIOD_PROPERTY_NAME)) {
setQuietPeriod(quietPeriod);
quietPeriod = null;
}
+ }
+
+ void convertScmCheckoutRetryCountProperty() throws IOException {
if (null == getProperty(SCM_CHECKOUT_RETRY_COUNT_PROPERTY_NAME)) {
setScmCheckoutRetryCount(scmCheckoutRetryCount);
scmCheckoutRetryCount = null;
}
+ }
+
+ void convertJDKProperty() throws IOException {
if (null == getProperty(JDK_PROPERTY_NAME)) {
setJDK(jdk);
jdk = null;
}
- if (null == getProperty(SCM_PROPERTY_NAME)) {
- setScm(scm);
- scm = null;
- }
}
@Override
diff --git a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
index 65d4196..569b621 100644
--- a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
+++ b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
@@ -102,7 +102,15 @@ public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> i
@Override
protected void buildProjectProperties() throws IOException {
super.buildProjectProperties();
- //Convert legacy customWorkspace property to IProjectProperty logic
+ convertCustomWorkspaceProperty();
+ }
+
+ /**
+ * Converts customWorkspace property to ProjectProperty.
+ *
+ * @throws IOException if any.
+ */
+ void convertCustomWorkspaceProperty() throws IOException {
if (null != customWorkspace && null == getProperty(CUSTOM_WORKSPACE_PROPERTY_NAME)) {
setCustomWorkspace(customWorkspace);
customWorkspace = null;//Reset to null. No longer needed.
diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java
index f44b5ed..f1fec03 100644
--- a/hudson-core/src/main/java/hudson/model/Job.java
+++ b/hudson-core/src/main/java/hudson/model/Job.java
@@ -19,6 +19,7 @@ package hudson.model;
import hudson.Functions;
import org.eclipse.hudson.api.model.project.property.AxisListProjectProperty;
+import org.eclipse.hudson.api.model.project.property.BaseProjectProperty;
import org.eclipse.hudson.api.model.project.property.BooleanProjectProperty;
import org.eclipse.hudson.api.model.project.property.DescribableListProjectProperty;
import org.eclipse.hudson.api.model.project.property.IntegerProjectProperty;
@@ -224,6 +225,22 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
}
/**
+ * Put map of job properties to existing ones.
+ *
+ * @param projectProperties new properties map.
+ * @param replace true - to replace current properties, false - add to existing map
+ */
+ protected void putAllProjectProperties(Map<String, ? extends IProjectProperty> projectProperties,
+ boolean replace) {
+ if (null != projectProperties) {
+ if (replace) {
+ jobProperties.clear();
+ }
+ jobProperties.putAll(projectProperties);
+ }
+ }
+
+ /**
* Returns job property by specified key.
*
* @param key key.
@@ -261,6 +278,10 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return (StringProjectProperty) getProperty(key, StringProjectProperty.class);
}
+ public BaseProjectProperty getBaseProjectProperty(String key) {
+ return (BaseProjectProperty) getProperty(key, BaseProjectProperty.class);
+ }
+
public ResultProjectProperty getResultProperty(String key) {
return (ResultProjectProperty) getProperty(key, ResultProjectProperty.class);
}
@@ -357,6 +378,10 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
property.setKey(entry.getKey());
property.setJob(this);
}
+ convertLogRotatorProperty();
+ }
+
+ void convertLogRotatorProperty() {
if (null == getProperty(LOG_ROTATOR_PROPERTY_NAME)) {
setLogRotator(logRotator);
logRotator = null;
diff --git a/hudson-core/src/main/java/hudson/model/Project.java b/hudson-core/src/main/java/hudson/model/Project.java
index a4e4571..412d4a4 100644
--- a/hudson-core/src/main/java/hudson/model/Project.java
+++ b/hudson-core/src/main/java/hudson/model/Project.java
@@ -16,6 +16,7 @@
package hudson.model;
+import hudson.Functions;
import hudson.Util;
import hudson.diagnosis.OldDataMonitor;
import hudson.model.Descriptor.FormException;
@@ -32,8 +33,10 @@ import hudson.tasks.Maven.MavenInstallation;
import hudson.triggers.Trigger;
import hudson.util.DescribableList;
import hudson.util.DescribableListUtil;
+import java.util.concurrent.CopyOnWriteArrayList;
import net.sf.json.JSONObject;
import org.eclipse.hudson.api.model.IProject;
+import org.eclipse.hudson.api.model.project.property.BaseProjectProperty;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
@@ -105,17 +108,29 @@ public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
@Override
protected void buildProjectProperties() throws IOException {
super.buildProjectProperties();
- if (null == getProperty(BUILDERS_PROPERTY_NAME)) {
- setBuilders(builders);
- builders = null;
+ convertBuildersProjectProperty();
+ convertBuildWrappersProjectProperties();
+ convertPublishersProperties();
+ }
+
+ void convertPublishersProperties() {
+ if (null != publishers) {
+ putAllProjectProperties(DescribableListUtil.convertToProjectProperties(publishers, this), false);
+ publishers = null;
}
+ }
+
+ void convertBuildWrappersProjectProperties() {
if (null == getProperty(BUILD_WRAPPERS_PROPERTY_NAME)) {
setBuildWrappers(buildWrappers);
buildWrappers = null;
}
- if (null == getProperty(PUBLISHERS_PROPERTY_NAME)) {
- setPublishers(publishers);
- publishers = null;
+ }
+
+ void convertBuildersProjectProperty() {
+ if (null == getProperty(BUILDERS_PROPERTY_NAME)) {
+ setBuilders(builders);
+ builders = null;
}
}
@@ -140,11 +155,18 @@ public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
}
public DescribableList<Publisher, Descriptor<Publisher>> getPublishersList() {
- return getDescribableListProjectProperty(PUBLISHERS_PROPERTY_NAME).getValue();
- }
-
- public void setPublishers(DescribableList<Publisher, Descriptor<Publisher>> publishers) {
- getDescribableListProjectProperty(PUBLISHERS_PROPERTY_NAME).setValue(publishers);
+ List<Descriptor<Publisher>> descriptors = Functions.getPublisherDescriptors(this);
+ List<Publisher> publisherList = new CopyOnWriteArrayList<Publisher>();
+ DescribableList<Publisher, Descriptor<Publisher>> result
+ = new DescribableList<Publisher, Descriptor<Publisher>>(this);
+ for (Descriptor<Publisher> descriptor : descriptors) {
+ BaseProjectProperty<Publisher> property = getBaseProjectProperty(descriptor.getJsonSafeClassName());
+ if (null != property.getValue()) {
+ publisherList.add(property.getValue());
+ }
+ }
+ result.addAllTo(publisherList);
+ return result;
}
public Map<Descriptor<BuildWrapper>,BuildWrapper> getBuildWrappers() {
@@ -178,7 +200,7 @@ public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
* Use {@code getPublishersList().add(x)}
*/
public void addPublisher(Publisher buildStep) throws IOException {
- getPublishersList().add(buildStep);
+ getBaseProjectProperty(buildStep.getDescriptor().getJsonSafeClassName()).setValue(buildStep);
}
/**
@@ -192,11 +214,7 @@ public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
}
public Publisher getPublisher(Descriptor<Publisher> descriptor) {
- for (Publisher p : getPublishersList()) {
- if(p.getDescriptor()==descriptor)
- return p;
- }
- return null;
+ return (Publisher) getBaseProjectProperty(descriptor.getJsonSafeClassName()).getValue();
}
protected void buildDependencyGraph(DependencyGraph graph) {
@@ -227,8 +245,19 @@ public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
JSONObject json = req.getSubmittedForm();
setBuildWrappers(DescribableListUtil.buildFromJson(this, req, json, BuildWrappers.getFor(this)));
setBuilders(DescribableListUtil.buildFromHetero(this, req, json, "builder", Builder.all()));
- setPublishers(DescribableListUtil.buildFromJson(this, req, json,
- BuildStepDescriptor.filter(Publisher.all(), this.getClass())));
+ buildPublishers(req, json, BuildStepDescriptor.filter(Publisher.all(), this.getClass()));
+ }
+
+ private void buildPublishers( StaplerRequest req, JSONObject json, List<Descriptor<Publisher>> descriptors) throws FormException{
+ for (Descriptor<Publisher> d : descriptors) {
+ String name = d.getJsonSafeClassName();
+ BaseProjectProperty<Publisher> baseProperty = getBaseProjectProperty(name);
+ Publisher publisher = null;
+ if (json.has(name)) {
+ publisher = d.newInstance(req, json.getJSONObject(name));
+ }
+ baseProperty.setValue(publisher);
+ }
}
@Override
diff --git a/hudson-core/src/main/java/hudson/util/DescribableListUtil.java b/hudson-core/src/main/java/hudson/util/DescribableListUtil.java
index c8fe6ce..a91f377 100644
--- a/hudson-core/src/main/java/hudson/util/DescribableListUtil.java
+++ b/hudson-core/src/main/java/hudson/util/DescribableListUtil.java
@@ -15,6 +15,7 @@
package hudson.util;
+import com.google.common.collect.Maps;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.Saveable;
@@ -22,7 +23,10 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import net.sf.json.JSONObject;
+import org.eclipse.hudson.api.model.IJob;
+import org.eclipse.hudson.api.model.project.property.BaseProjectProperty;
import org.kohsuke.stapler.StaplerRequest;
/**
@@ -94,4 +98,30 @@ public final class DescribableListUtil {
return new DescribableList<T, D>(owner, Descriptor.newInstancesFromHeteroList(req, formData, key, descriptors));
}
+ /**
+ * Converts describableList data to project properties map. {@link hudson.model.Descriptor#getJsonSafeClassName()}
+ * is used as key, value - {@link BaseProjectProperty}.
+ *
+ * @param describableList source.
+ * @param owner new owner for properties.
+ * @param <T> T describable
+ * @param <D> Descriptor
+ * @return map of converted properties.
+ */
+ public static <T extends Describable<T>, D extends Descriptor<T>>
+ Map<String, BaseProjectProperty<T>> convertToProjectProperties(DescribableList<T, D> describableList, IJob owner) {
+ Map<String, BaseProjectProperty<T>> result = Maps.newConcurrentMap();
+ if (null != describableList) {
+ for (Map.Entry<D, T> entry : describableList.toMap().entrySet()) {
+ BaseProjectProperty<T> property = new BaseProjectProperty<T>(owner);
+ String key = entry.getKey().getJsonSafeClassName();
+ property.setKey(key);
+ property.setValue(entry.getValue());
+ result.put(key, property);
+ }
+ }
+ return result;
+ }
+
}
+
diff --git a/hudson-core/src/main/resources/lib/hudson/project/config-publishers.jelly b/hudson-core/src/main/resources/lib/hudson/project/config-publishers.jelly
index 2b5eac6..69166df 100644
--- a/hudson-core/src/main/resources/lib/hudson/project/config-publishers.jelly
+++ b/hudson-core/src/main/resources/lib/hudson/project/config-publishers.jelly
@@ -1,6 +1,6 @@
<!-- **************************************************************************
#
-# Copyright (c) 2004-2009 Oracle Corporation.
+# Copyright (c) 2004-2011 Oracle Corporation.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
@@ -9,7 +9,7 @@
#
# Contributors:
#
-# Kohsuke Kawaguchi
+# Kohsuke Kawaguchi, Nikita Levyankov
#
#
#************************************************************************** -->
@@ -19,7 +19,21 @@
Publisher config pane
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:p="/lib/hudson/project">
- <f:descriptorList title="${%Post-build Actions}"
- descriptors="${h.getPublisherDescriptors(it)}"
- instances="${it.publishers}" />
-</j:jelly>
+ <j:set var="targetType" value="${it.class}"/>
+ <j:set var="descriptors" value="${h.getPublisherDescriptors(it)}"/>
+
+ <j:if test="${!empty(descriptors)}">
+ <f:section title="${%Post-build Actions}" name="${entry.field}">
+ <j:forEach var="descriptor" items="${descriptors}">
+ <j:set var="instanceProperty" value="${it.getBaseProjectProperty(descriptor.jsonSafeClassName)}"/>
+ <j:set var="instance" value="${instanceProperty.getValue()}"/>
+ <f:optionalBlock name="${descriptor.jsonSafeClassName}" help="${descriptor.helpFile}"
+ title="${descriptor.displayName}" checked="${instance!=null}"
+ resetUrl="${jobUrl}/resetProjectProperty?propertyName=${descriptor.jsonSafeClassName}"
+ isPropertyOverridden="${instanceProperty.isOverridden()}">
+ <st:include from="${descriptor}" page="${descriptor.configPage}" optional="true"/>
+ </f:optionalBlock>
+ </j:forEach>
+ </f:section>
+ </j:if>
+</j:jelly> \ No newline at end of file
diff --git a/hudson-core/src/test/java/hudson/model/LegacyProjectTest.java b/hudson-core/src/test/java/hudson/model/LegacyProjectTest.java
index f048163..51cc0d4 100644
--- a/hudson-core/src/test/java/hudson/model/LegacyProjectTest.java
+++ b/hudson-core/src/test/java/hudson/model/LegacyProjectTest.java
@@ -14,17 +14,22 @@
*******************************************************************************/
package hudson.model;
+import hudson.tasks.Mailer;
import hudson.tasks.Maven;
+import hudson.tasks.junit.JUnitResultArchiver;
import java.io.File;
import java.net.URISyntaxException;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import static junit.framework.Assert.*;
+import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertFalse;
+import static org.powermock.api.easymock.PowerMock.*;
/**
* Test for legacy
@@ -45,95 +50,217 @@ public class LegacyProjectTest {
}
/**
- * Tests unmarshalls FreeStyleProject configuration and checks whether properties are configured based
- * on legacy values,
+ * Tests unmarshalls FreeStyleProject configuration and checks whether CustomWorkspace is configured based
+ * on legacy value.
*
* @throws Exception if any.
*/
@Test
- public void testLoadLegacyFreeStyleProject() throws Exception {
+ public void testСonvertLegacyCustomWorkspaceProperty() throws Exception {
FreeStyleProject project = (FreeStyleProject) Items.getConfigFile(config).read();
project.setAllowSave(false);
project.initProjectProperties();
- //Checks customWorkspace value
assertNull(project.getProperty(FreeStyleProject.CUSTOM_WORKSPACE_PROPERTY_NAME));
- project.buildProjectProperties();
+ project.convertCustomWorkspaceProperty();
assertNotNull(project.getProperty(FreeStyleProject.CUSTOM_WORKSPACE_PROPERTY_NAME));
}
/**
- * Tests unmarshalls FreeStyleProject configuration and checks whether properties
+ * Tests unmarshalls FreeStyleProject configuration and checks whether Builders
* from Project are configured
*
* @throws Exception if any.
*/
@Test
- public void testLoadLegacyProject() throws Exception {
+ public void testСonvertLegacyBuildersProperty() throws Exception {
Project project = (Project) Items.getConfigFile(config).read();
project.setAllowSave(false);
project.initProjectProperties();
- //All properties should be null, because of legacy implementation. Version < 2.2.1
+ //Property should be null, because of legacy implementation. Version < 2.2.0
assertNull(project.getProperty(Project.BUILDERS_PROPERTY_NAME));
- assertNull(project.getProperty(Project.BUILD_WRAPPERS_PROPERTY_NAME));
- assertNull(project.getProperty(Project.PUBLISHERS_PROPERTY_NAME));
- project.buildProjectProperties();
+ project.convertBuildersProjectProperty();
//Verify builders
assertNotNull(project.getProperty(Project.BUILDERS_PROPERTY_NAME));
assertFalse(project.getBuildersList().isEmpty());
assertEquals(1, project.getBuildersList().size());
assertTrue(project.getBuildersList().get(0) instanceof Maven);
+ }
+ /**
+ * Tests unmarshalls FreeStyleProject configuration and checks whether BuildWrappers
+ * from Project are configured
+ *
+ * @throws Exception if any.
+ */
+ @Test
+ public void testСonvertLegacyBuildWrappersProperty() throws Exception {
+ Project project = (Project) Items.getConfigFile(config).read();
+ project.setAllowSave(false);
+ project.initProjectProperties();
+ //Property should be null, because of legacy implementation. Version < 2.2.0
+ assertNull(project.getProperty(Project.BUILD_WRAPPERS_PROPERTY_NAME));
+ project.convertBuildWrappersProjectProperties();
//Verify buildWrappers
assertNotNull(project.getProperty(Project.BUILD_WRAPPERS_PROPERTY_NAME));
assertTrue(project.getBuildWrappersList().isEmpty());
+ }
+ /**
+ * Tests unmarshalls FreeStyleProject configuration and checks whether publishers
+ * from Project are configured
+ *
+ * @throws Exception if any.
+ */
+ @Test
+ @Ignore
+ //TODO investigate how to mock descriptor loading and creation.
+ public void testСonvertPublishersProperty() throws Exception {
+ Hudson hudson = createMock(Hudson.class);
+ expect(hudson.getDescriptorOrDie(Mailer.class)).andReturn(new Mailer.DescriptorImpl());
+ expect(hudson.getDescriptorOrDie(JUnitResultArchiver.class)).andReturn(
+ new JUnitResultArchiver.DescriptorImpl());
+ mockStatic(Hudson.class);
+ expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
+ replayAll();
+ Project project = (Project) Items.getConfigFile(config).read();
+ project.setAllowSave(false);
+ project.initProjectProperties();
+ String mailerKey = "hudson-tasks-Mailer";
+ //Publishers should be null, because of legacy implementation. Version < 2.2.0
+ assertNull(project.getProperty(mailerKey));
+ project.convertPublishersProperties();
//Verify publishers
- assertNotNull(project.getProperty(Project.PUBLISHERS_PROPERTY_NAME));
assertFalse(project.getPublishersList().isEmpty());
assertEquals(2, project.getPublishersList().size());
+ assertNotNull(project.getProperty(mailerKey).getValue());
+ verifyAll();
}
/**
- * Tests unmarshalls FreeStyleProject configuration and checks whether properties
- * from AbstractProject are configured
+ * Tests unmarshalls FreeStyleProject configuration and checks whether expected property
+ * from AbstractProject is configured
*
* @throws Exception if any.
*/
@Test
- public void testLoadLegacyAbstractProject() throws Exception {
+ public void testСonvertLegacyBlockBuildWhenDownstreamBuildingProperty() throws Exception {
AbstractProject project = (AbstractProject) Items.getConfigFile(config).read();
project.setAllowSave(false);
project.initProjectProperties();
- assertNull(project.getProperty(AbstractProject.BLOCK_BUILD_WHEN_UPSTREAM_BUILDING_PROPERTY_NAME));
assertNull(project.getProperty(AbstractProject.BLOCK_BUILD_WHEN_DOWNSTREAM_BUILDING_PROPERTY_NAME));
- assertNull(project.getProperty(AbstractProject.CONCURRENT_BUILD_PROPERTY_NAME));
- assertNull(project.getProperty(AbstractProject.CLEAN_WORKSPACE_REQUIRED_PROPERTY_NAME));
- assertNull(project.getProperty(AbstractProject.QUIET_PERIOD_PROPERTY_NAME));
- assertNull(project.getProperty(AbstractProject.SCM_CHECKOUT_RETRY_COUNT_PROPERTY_NAME));
- assertNull(project.getProperty(AbstractProject.JDK_PROPERTY_NAME));
- project.buildProjectProperties();
- assertNotNull(project.getProperty(AbstractProject.BLOCK_BUILD_WHEN_UPSTREAM_BUILDING_PROPERTY_NAME));
+ project.convertBlockBuildWhenDownstreamBuildingProperty();
assertNotNull(project.getProperty(AbstractProject.BLOCK_BUILD_WHEN_DOWNSTREAM_BUILDING_PROPERTY_NAME));
+ }
+
+ /**
+ * Tests unmarshalls FreeStyleProject configuration and checks whether expected property
+ * from AbstractProject is configured
+ *
+ * @throws Exception if any.
+ */
+ @Test
+ public void testСonvertLegacyBlockBuildWhenUpstreamBuildingProperty() throws Exception {
+ AbstractProject project = (AbstractProject) Items.getConfigFile(config).read();
+ project.setAllowSave(false);
+ project.initProjectProperties();
+ assertNull(project.getProperty(AbstractProject.BLOCK_BUILD_WHEN_UPSTREAM_BUILDING_PROPERTY_NAME));
+ project.convertBlockBuildWhenUpstreamBuildingProperty();
+ assertNotNull(project.getProperty(AbstractProject.BLOCK_BUILD_WHEN_UPSTREAM_BUILDING_PROPERTY_NAME));
+ }
+
+ /**
+ * Tests unmarshalls FreeStyleProject configuration and checks whether expected property
+ * from AbstractProject is configured
+ *
+ * @throws Exception if any.
+ */
+ @Test
+ public void testСonvertLegacyConcurrentBuildProperty() throws Exception {
+ AbstractProject project = (AbstractProject) Items.getConfigFile(config).read();
+ project.setAllowSave(false);
+ project.initProjectProperties();
+ assertNull(project.getProperty(AbstractProject.CONCURRENT_BUILD_PROPERTY_NAME));
+ project.convertConcurrentBuildProperty();
assertNotNull(project.getProperty(AbstractProject.CONCURRENT_BUILD_PROPERTY_NAME));
+ }
+
+ /**
+ * Tests unmarshalls FreeStyleProject configuration and checks whether expected property
+ * from AbstractProject is configured
+ *
+ * @throws Exception if any.
+ */
+ @Test
+ public void testСonvertLegacyCleanWorkspaceRequiredProperty() throws Exception {
+ AbstractProject project = (AbstractProject) Items.getConfigFile(config).read();
+ project.setAllowSave(false);
+ project.initProjectProperties();
+ assertNull(project.getProperty(AbstractProject.CLEAN_WORKSPACE_REQUIRED_PROPERTY_NAME));
+ project.convertCleanWorkspaceRequiredProperty();
assertNotNull(project.getProperty(AbstractProject.CLEAN_WORKSPACE_REQUIRED_PROPERTY_NAME));
+ }
+
+ /**
+ * Tests unmarshalls FreeStyleProject configuration and checks whether expected property
+ * from AbstractProject is configured
+ *
+ * @throws Exception if any.
+ */
+ @Test
+ public void testСonvertLegacyQuietPeriodProperty() throws Exception {
+ AbstractProject project = (AbstractProject) Items.getConfigFile(config).read();
+ project.setAllowSave(false);
+ project.initProjectProperties();
+ assertNull(project.getProperty(AbstractProject.QUIET_PERIOD_PROPERTY_NAME));
+ project.convertQuietPeriodProperty();
assertNotNull(project.getProperty(AbstractProject.QUIET_PERIOD_PROPERTY_NAME));
+ }
+
+ /**
+ * Tests unmarshalls FreeStyleProject configuration and checks whether expected property
+ * from AbstractProject is configured
+ *
+ * @throws Exception if any.
+ */
+ @Test
+ public void testСonvertLegacyScmCheckoutRetryCountProperty() throws Exception {
+ AbstractProject project = (AbstractProject) Items.getConfigFile(config).read();
+ project.setAllowSave(false);
+ project.initProjectProperties();
+ assertNull(project.getProperty(AbstractProject.SCM_CHECKOUT_RETRY_COUNT_PROPERTY_NAME));
+ project.convertScmCheckoutRetryCountProperty();
assertNotNull(project.getProperty(AbstractProject.SCM_CHECKOUT_RETRY_COUNT_PROPERTY_NAME));
+ }
+
+ /**
+ * Tests unmarshalls FreeStyleProject configuration and checks whether expected property
+ * from AbstractProject is configured
+ *
+ * @throws Exception if any.
+ */
+ @Test
+ public void testСonvertLegacyJDKProperty() throws Exception {
+ AbstractProject project = (AbstractProject) Items.getConfigFile(config).read();
+ project.setAllowSave(false);
+ project.initProjectProperties();
+ assertNull(project.getProperty(AbstractProject.JDK_PROPERTY_NAME));
+ project.convertJDKProperty();
assertNotNull(project.getProperty(AbstractProject.JDK_PROPERTY_NAME));
}
/**
- * Tests unmarshalls FreeStyleProject configuration and checks whether properties
+ * Tests unmarshalls FreeStyleProject configuration and checks whether LogRotator
* from Job are configured
*
* @throws Exception if any.
*/
@Test
- public void testLoadLegacyJob() throws Exception {
+ public void testСonvertLegacyLogRotatorProperty() throws Exception {
Job project = (Job) Items.getConfigFile(config).read();
project.setAllowSave(false);
project.initProjectProperties();
assertNull(project.getProperty(Job.LOG_ROTATOR_PROPERTY_NAME));
- project.buildProjectProperties();
+ project.convertLogRotatorProperty();
assertNotNull(project.getProperty(Job.LOG_ROTATOR_PROPERTY_NAME));
}
}