use of hudson.tasks.LogRotator in project hudson-2.x by hudson.
the class ProjectPropertyTest method testLogRotatorProjectPropertyGetOriginalValue.
@Test
public void testLogRotatorProjectPropertyGetOriginalValue() {
LogRotator value = new LogRotator(1, 1, 1, 1);
BaseProjectProperty property = new LogRotatorProjectProperty(project);
property.setKey(propertyKey);
property.setValue(value);
assertEquals(value, property.getOriginalValue());
}
use of hudson.tasks.LogRotator in project hudson-2.x by hudson.
the class Job method submit.
/**
* Derived class can override this to perform additional config submission
* work.
*/
protected void submit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
JSONObject json = req.getSubmittedForm();
description = req.getParameter("description");
keepDependencies = req.getParameter("keepDependencies") != null;
properties.clear();
setCascadingProjectName(StringUtils.trimToNull(req.getParameter("cascadingProjectName")));
CopyOnWriteList parameterDefinitionProperties = new CopyOnWriteList();
int i = 0;
for (JobPropertyDescriptor d : JobPropertyDescriptor.getPropertyDescriptors(Job.this.getClass())) {
if (!CascadingUtil.isCascadableJobProperty(d)) {
String name = "jobProperty" + i;
JSONObject config = json.getJSONObject(name);
JobProperty prop = d.newInstance(req, config);
if (null != prop) {
prop.setOwner(this);
if (prop instanceof AuthorizationMatrixProperty) {
properties.add(prop);
} else if (prop instanceof ParametersDefinitionProperty) {
parameterDefinitionProperties.add(prop);
}
}
} else {
BaseProjectProperty property = CascadingUtil.getBaseProjectProperty(this, d.getJsonSafeClassName());
JobProperty prop = d.newInstance(req, json.getJSONObject(d.getJsonSafeClassName()));
if (null != prop) {
prop.setOwner(this);
}
property.setValue(prop);
addCascadingJobProperty(property);
}
i++;
}
setParameterDefinitionProperties(parameterDefinitionProperties);
LogRotator logRotator = null;
if (null != req.getParameter("logrotate")) {
logRotator = LogRotator.DESCRIPTOR.newInstance(req, json.getJSONObject("logrotate"));
}
setLogRotator(logRotator);
}
use of hudson.tasks.LogRotator in project hudson-2.x by hudson.
the class FreeStyleProjectTest method testSetLogRotatorValueEqualsWithParent.
@Test
public void testSetLogRotatorValueEqualsWithParent() {
FreeStyleProject parentProject = new FreeStyleProjectMock("parent");
parentProject.setLogRotator(new LogRotator(10, 11, 12, 13));
FreeStyleProjectMock childProject1 = new FreeStyleProjectMock("child1");
childProject1.setCascadingProject(parentProject);
childProject1.setLogRotator(new LogRotator(10, 11, 12, 13));
// else log rotator will be taken from parent
childProject1.setCascadingProject(null);
assertNull(childProject1.getLogRotator());
}
use of hudson.tasks.LogRotator in project hudson-2.x by hudson.
the class FreeStyleProjectTest method testGetLogRotatorFromParent.
@Test
public void testGetLogRotatorFromParent() {
FreeStyleProject parentProject = new FreeStyleProjectMock("parent");
parentProject.setLogRotator(new LogRotator(10, 11, 12, 13));
FreeStyleProjectMock childProject1 = new FreeStyleProjectMock("child1");
childProject1.setCascadingProject(parentProject);
LogRotator result = childProject1.getLogRotator();
assertNotNull(result);
assertEquals(result.getDaysToKeep(), 10);
}
use of hudson.tasks.LogRotator in project hudson-2.x by hudson.
the class LegacyMatrixConfigurationTest method testLoadLegacyMatrixProject.
/**
* Tests unmarshalls MatrixProject configuration and checks whether properties are loaded correctly.
*
* @throws Exception if any.
*/
@Test
@Ignore
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();
expect(hudson.getRootDir()).andReturn(new File("./target/matrix")).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), CascadingUtil.getIntegerProjectProperty(project, AbstractProject.QUIET_PERIOD_PROPERTY_NAME).getValue());
assertTrue(CascadingUtil.getBooleanProjectProperty(project, MatrixProject.RUN_SEQUENTIALLY_PROPERTY_NAME).getValue());
assertEquals("!(label==\"win\" && DB==\"oracle\")", project.getProperty(MatrixProject.COMBINATION_FILTER_PROPERTY_NAME).getValue());
assertEquals("label==\"unix\" && DB==\"mysql\"", project.getProperty(MatrixProject.TOUCH_STONE_COMBINATION_FILTER_PROPERTY_NAME).getValue());
assertEquals(Result.SUCCESS, CascadingUtil.getResultProjectProperty(project, MatrixProject.TOUCH_STONE_RESULT_CONDITION_PROPERTY_NAME).getValue());
assertEquals(new LogRotator(7, 7, 7, 7), CascadingUtil.getLogRotatorProjectProperty(project, MatrixProject.LOG_ROTATOR_PROPERTY_NAME).getValue());
AxisList axes = CascadingUtil.getAxesListProjectProperty(project, MatrixProject.AXES_PROPERTY_NAME).getValue();
assertEquals(2, axes.size());
assertEquals("DB", axes.get(0).getName());
assertEquals(2, axes.get(0).getValues().size());
assertEquals("oracle", axes.get(0).getValues().get(0));
assertEquals("mysql", axes.get(0).getValues().get(1));
assertEquals("label", axes.get(1).getName());
assertEquals(2, axes.get(1).getValues().size());
assertEquals("unix", axes.get(1).getValues().get(0));
assertEquals("win", axes.get(1).getValues().get(1));
assertEquals(3, project.getActiveConfigurations().size());
assertEquals(2, project.getActiveConfigurations().iterator().next().getCombination().size());
}
Aggregations