aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-22 07:49:27 (EST)
committerWinston Prakash2011-12-01 20:46:57 (EST)
commitd2b426615cbeeb943e7f1ee24eb8efb75725d353 (patch)
tree026e52643ab4db8270370ac182c6d3d012f472a1
parent86bfe05ee4a7fe4ba4129cd4be43184208da16ab (diff)
downloadorg.eclipse.hudson.core-d2b426615cbeeb943e7f1ee24eb8efb75725d353.zip
org.eclipse.hudson.core-d2b426615cbeeb943e7f1ee24eb8efb75725d353.tar.gz
org.eclipse.hudson.core-d2b426615cbeeb943e7f1ee24eb8efb75725d353.tar.bz2
Improve LegacyConverter test. Implement legacy properties conversion for blockBuildWhenUpstreamBuilding, blockBuildWhenDownstreamBuilding, concurrentBuild, cleanWorkspaceRequired
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractProject.java43
-rw-r--r--hudson-core/src/main/java/hudson/model/FreeStyleProject.java2
-rw-r--r--hudson-core/src/test/java/hudson/model/LegacyProjectTest.java26
3 files changed, 58 insertions, 13 deletions
diff --git a/hudson-core/src/main/java/hudson/model/AbstractProject.java b/hudson-core/src/main/java/hudson/model/AbstractProject.java
index df3a359..ce448a9 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractProject.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractProject.java
@@ -183,14 +183,20 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
protected volatile boolean disabled;
/**
- * True to keep builds of this project in queue when downstream projects are
- * building. False by default to keep from breaking existing behavior.
+ * True to keep builds of this project in queue when downstream projects are building.
+ *
+ * @since 2.2.0
+ * @deprecated don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
+ * Use getter/setter for accessing to this field.
*/
protected volatile boolean blockBuildWhenDownstreamBuilding;
/**
- * True to keep builds of this project in queue when upstream projects are
- * building. False by default to keep from breaking existing behavior.
+ * True to keep builds of this project in queue when upstream projects are building.
+ *
+ * @since 2.2.0
+ * @deprecated don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
+ * Use getter/setter for accessing to this field.
*/
protected volatile boolean blockBuildWhenUpstreamBuilding;
@@ -228,8 +234,20 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
@CopyOnWrite
protected transient volatile List<Action> transientActions = new Vector<Action>();
+ /**
+ * @since 2.2.0
+ * @deprecated don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
+ * Use getter/setter for accessing to this field.
+ */
private boolean concurrentBuild;
+ /**
+ * True to clean the workspace prior to each build.
+ *
+ * @since 2.2.0
+ * @deprecated don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}.
+ * Use getter/setter for accessing to this field.
+ */
private volatile boolean cleanWorkspaceRequired;
protected AbstractProject(ItemGroup parent, String name) {
@@ -286,6 +304,23 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
@Override
+ protected void buildProjectProperties() throws IOException {
+ super.buildProjectProperties();
+ if (null == getProperty(BLOCK_BUILD_WHEN_UPSTREAM_BUILDING_PROPERTY_NAME)) {
+ setBlockBuildWhenUpstreamBuilding(blockBuildWhenUpstreamBuilding);
+ }
+ if (null == getProperty(BLOCK_BUILD_WHEN_DOWNSTREAM_BUILDING_PROPERTY_NAME)) {
+ setBlockBuildWhenDownstreamBuilding(blockBuildWhenDownstreamBuilding);
+ }
+ if (null == getProperty(CONCURRENT_BUILD_PROPERTY_NAME)) {
+ setConcurrentBuild(concurrentBuild);
+ }
+ if (null == getProperty(CLEAN_WORKSPACE_REQUIRED_PROPERTY_NAME)) {
+ setCleanWorkspaceRequired(cleanWorkspaceRequired);
+ }
+ }
+
+ @Override
protected void performDelete() throws IOException, InterruptedException {
// prevent a new build while a delete operation is in progress
makeDisabled(true);
diff --git a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
index 2e9e578..74b3cec 100644
--- a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
+++ b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
@@ -102,7 +102,7 @@ public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> i
@Override
protected void buildProjectProperties() throws IOException {
super.buildProjectProperties();
- //Convert legacy cust omWorkspace property to IProjectProperty logic
+ //Convert legacy customWorkspace property to IProjectProperty logic
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/test/java/hudson/model/LegacyProjectTest.java b/hudson-core/src/test/java/hudson/model/LegacyProjectTest.java
index 1ddccb2..8431693 100644
--- a/hudson-core/src/test/java/hudson/model/LegacyProjectTest.java
+++ b/hudson-core/src/test/java/hudson/model/LegacyProjectTest.java
@@ -35,18 +35,28 @@ import static junit.framework.Assert.assertNull;
public class LegacyProjectTest {
/**
- * Tests unmarshalls FreeStyleProject configuration and checks whether CustomWorkspace property is set,
+ * Tests unmarshalls FreeStyleProject configuration and checks whether properties are configured based
+ * on legacy values,
*
* @throws Exception if any.
*/
@Test
public void testLoadFreeStyleProject() throws Exception {
File freeStyleProjectConfig = new File(FreeStyleProject.class.getResource("/hudson/model/freestyle").toURI());
- FreeStyleProject freeStyleProject = (FreeStyleProject) Items.getConfigFile(freeStyleProjectConfig).read();
- freeStyleProject.setAllowSave(false);
- freeStyleProject.initProjectProperties();
- assertNull(freeStyleProject.getProperty(FreeStyleProject.CUSTOM_WORKSPACE_PROPERTY_NAME));
- freeStyleProject.buildProjectProperties();
- assertNotNull(freeStyleProject.getCustomWorkspace());
+ FreeStyleProject project = (FreeStyleProject) Items.getConfigFile(freeStyleProjectConfig).read();
+ project.setAllowSave(false);
+ project.initProjectProperties();
+ //Checks customWorkspace value
+ assertNull(project.getProperty(FreeStyleProject.CUSTOM_WORKSPACE_PROPERTY_NAME));
+ 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));
+ project.buildProjectProperties();
+ assertNotNull(project.getProperty(FreeStyleProject.CUSTOM_WORKSPACE_PROPERTY_NAME));
+ assertNotNull(project.getProperty(AbstractProject.BLOCK_BUILD_WHEN_UPSTREAM_BUILDING_PROPERTY_NAME));
+ assertNotNull(project.getProperty(AbstractProject.BLOCK_BUILD_WHEN_DOWNSTREAM_BUILDING_PROPERTY_NAME));
+ assertNotNull(project.getProperty(AbstractProject.CONCURRENT_BUILD_PROPERTY_NAME));
+ assertNotNull(project.getProperty(AbstractProject.CLEAN_WORKSPACE_REQUIRED_PROPERTY_NAME));
}
-}
+} \ No newline at end of file