use of hudson.triggers.TimerTrigger in project hudson-2.x by hudson.
the class LegacyProjectTest method testConvertLegacyTriggers.
/**
* Tests unmarshalling FreeStyleProject configuration and checks whether Triggers properties
* from Job are configured.
*
* @throws Exception if any.
*/
@Test
public void testConvertLegacyTriggers() throws Exception {
AbstractProject project = (AbstractProject) Items.getConfigFile(config).read();
project.setAllowSave(false);
project.initProjectProperties();
Hudson hudson = createMock(Hudson.class);
String scmTriggerPropertyKey = "hudson-trigger-SCMTrigger";
TriggerDescriptor scmTriggerDescriptor = createMock(SCMTrigger.DescriptorImpl.class);
expect(scmTriggerDescriptor.getJsonSafeClassName()).andReturn(scmTriggerPropertyKey);
expect(hudson.getDescriptorOrDie(SCMTrigger.class)).andReturn(scmTriggerDescriptor);
String timerTriggerPropertyKey = "hudson-trigger-TimerTrigger";
TriggerDescriptor timerTriggerDescriptor = createMock(TimerTrigger.DescriptorImpl.class);
expect(timerTriggerDescriptor.getJsonSafeClassName()).andReturn(timerTriggerPropertyKey);
expect(hudson.getDescriptorOrDie(TimerTrigger.class)).andReturn(timerTriggerDescriptor);
mockStatic(Hudson.class);
expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
replayAll();
project.setAllowSave(false);
project.initProjectProperties();
assertNull(project.getProperty(scmTriggerPropertyKey));
assertNull(project.getProperty(timerTriggerPropertyKey));
project.convertTriggerProperties();
assertNotNull(project.getProperty(scmTriggerPropertyKey));
Trigger trigger = (Trigger) project.getProperty(scmTriggerPropertyKey).getValue();
assertEquals("5 * * * *", trigger.getSpec());
assertNotNull(project.getProperty(timerTriggerPropertyKey));
trigger = (Trigger) project.getProperty(timerTriggerPropertyKey).getValue();
assertEquals("*/10 * * * *", trigger.getSpec());
verifyAll();
}
use of hudson.triggers.TimerTrigger in project hudson-2.x by hudson.
the class TriggerProjectPropertyTest method testOnCascadingProjectRemoved.
/**
* Verify {@link TriggerProjectProperty#onCascadingProjectRemoved()} method.
*
* @throws antlr.ANTLRException if any
*/
@Test
public void testOnCascadingProjectRemoved() throws ANTLRException {
Trigger trigger = new TimerTrigger("* * * * *");
property.setOriginalValue(trigger, false);
assertTrue(trigger == property.getOriginalValue());
assertFalse(property.isOverridden());
property.onCascadingProjectRemoved();
assertFalse(property.isOverridden());
assertTrue(trigger == property.getOriginalValue());
}
Aggregations