aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-23 06:30:51 (EST)
committerWinston Prakash2011-12-01 20:47:08 (EST)
commit8985173d5fdda164f1e2ff9840c8d560553604ea (patch)
tree4dfe61291938acbf487f2dc1851ac285c46e7c31
parent0dab6c0966fad6457bc1721afaf69e2c98a4fdfd (diff)
downloadorg.eclipse.hudson.core-8985173d5fdda164f1e2ff9840c8d560553604ea.zip
org.eclipse.hudson.core-8985173d5fdda164f1e2ff9840c8d560553604ea.tar.gz
org.eclipse.hudson.core-8985173d5fdda164f1e2ff9840c8d560553604ea.tar.bz2
Fixed test which verifies loading of the legacy project matrix configuration
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/matrix/MatrixProject.java4
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractItem.java3
-rw-r--r--hudson-core/src/main/resources/hudson/tasks/LogRotator/config.jelly4
-rw-r--r--hudson-core/src/test/java/hudson/matrix/LegacyMatrixConfigurationTest.java27
4 files changed, 31 insertions, 7 deletions
diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
index 8c8e787..fa25099 100644
--- a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
+++ b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
@@ -95,6 +95,7 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i
public static final String TOUCH_STONE_COMBINATION_FILTER_PROPERTY_NAME = "touchStoneCombinationFilter";
public static final String TOUCH_STONE_RESULT_CONDITION_PROPERTY_NAME = "touchStoneResultCondition";
public static final String AXES_PROPERTY_NAME = "axes";
+ protected static final String AXIS_CONFIGURATIONS_DIR = "configurations";
/**
* Configuration axes.
@@ -559,7 +560,8 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i
}
private File getConfigurationsDir() {
- return new File(getRootDir(),"configurations");
+ return (getRootDir() != null ? new File(getRootDir(), AXIS_CONFIGURATIONS_DIR)
+ : new File(new File("target"), AXIS_CONFIGURATIONS_DIR)); //For the tests
}
/**
diff --git a/hudson-core/src/main/java/hudson/model/AbstractItem.java b/hudson-core/src/main/java/hudson/model/AbstractItem.java
index 6cf1def..c998c31 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractItem.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractItem.java
@@ -105,9 +105,8 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
}
public File getRootDir() {
- return parent.getRootDirFor(this);
+ return (parent != null ? parent.getRootDirFor(this) : null);
}
-
/**
* This bridge method is to maintain binary compatibility with {@link TopLevelItem#getParent()}.
*/
diff --git a/hudson-core/src/main/resources/hudson/tasks/LogRotator/config.jelly b/hudson-core/src/main/resources/hudson/tasks/LogRotator/config.jelly
index c8849b2..e95ab31 100644
--- a/hudson-core/src/main/resources/hudson/tasks/LogRotator/config.jelly
+++ b/hudson-core/src/main/resources/hudson/tasks/LogRotator/config.jelly
@@ -31,8 +31,8 @@
<f:entry title="${%Days to keep artifacts}"
description="${%if not empty, artifacts from builds older than this number of days will be deleted, but the logs, history, reports, etc for the build will be kept}"
isPropertyOverridden="${logRotatorProperty.isOverridden()}">
- <f:textbox clazz="positive-number"
- name="logrotate_artifact_days" value="${ilogRotator.artifactDaysToKeepStr}" />
+ <f:textbox clazz="positive-number"
+ name="logrotate_artifact_days" value="${logRotator.artifactDaysToKeepStr}" />
</f:entry>
<f:entry title="${%Max # of builds to keep with artifacts}"
description="${%if not empty, only up to this number of builds have their artifacts retained}"
diff --git a/hudson-core/src/test/java/hudson/matrix/LegacyMatrixConfigurationTest.java b/hudson-core/src/test/java/hudson/matrix/LegacyMatrixConfigurationTest.java
index c54945c..9b8125e 100644
--- a/hudson-core/src/test/java/hudson/matrix/LegacyMatrixConfigurationTest.java
+++ b/hudson-core/src/test/java/hudson/matrix/LegacyMatrixConfigurationTest.java
@@ -15,10 +15,16 @@
*******************************************************************************/
package hudson.matrix;
+import com.google.common.collect.Lists;
+import hudson.ExtensionList;
+import hudson.init.InitMilestone;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.Items;
+import hudson.model.Node;
import hudson.model.Result;
+import hudson.model.TransientProjectActionFactory;
+import hudson.model.listeners.SaveableListener;
import hudson.tasks.LogRotator;
import java.io.File;
import java.net.URISyntaxException;
@@ -29,6 +35,9 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import static junit.framework.Assert.*;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.powermock.api.easymock.PowerMock.*;
/**
* Test to verify legacy matrix project configuration loading.
@@ -55,10 +64,23 @@ public class LegacyMatrixConfigurationTest {
*/
@Test
public void testLoadLegacyMatrixProject() throws Exception {
+ Hudson hudson = createMock(Hudson.class);
+ expect(hudson.getNodes()).andReturn(Lists.<Node>newArrayList()).anyTimes();
+ expect(hudson.getInitLevel()).andReturn(InitMilestone.STARTED).anyTimes();
+ ExtensionList<TransientProjectActionFactory> actionList = ExtensionList.create(hudson,
+ TransientProjectActionFactory.class);
+ expect(hudson.getExtensionList(TransientProjectActionFactory.class)).andReturn(actionList).anyTimes();
+ ExtensionList<SaveableListener> saveableListenerList = ExtensionList.create(hudson, SaveableListener.class);
+ expect(hudson.getExtensionList(SaveableListener.class)).andReturn(saveableListenerList).anyTimes();
+ expect(hudson.getAllItems(MatrixConfiguration.class)).andReturn(Lists.<MatrixConfiguration>newArrayList()).anyTimes();
+ mockStatic(Hudson.class);
+ expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
+ replayAll();
MatrixProject project = (MatrixProject) Items.getConfigFile(config).read();
project.setAllowSave(false);
project.initProjectProperties();
project.buildProjectProperties();
+ verifyAll();
assertEquals("/tmp/1", project.getProperty(AbstractProject.CUSTOM_WORKSPACE_PROPERTY_NAME).getValue());
assertEquals(new Integer(7), project.getIntegerProperty(AbstractProject.QUIET_PERIOD_PROPERTY_NAME).getValue());
@@ -81,7 +103,8 @@ public class LegacyMatrixConfigurationTest {
assertEquals(2, axes.get(1).getValues().size());
assertEquals("unix", axes.get(1).getValues().get(0));
assertEquals("win", axes.get(1).getValues().get(1));
- //TODO add matrix configuration verification
+ assertEquals(3, project.getActiveConfigurations().size());
+ assertEquals(2, project.getActiveConfigurations().iterator().next().getCombination().size());
}
-}
+} \ No newline at end of file