use of hudson.tasks.JavadocArchiver in project promoted-builds-plugin by jenkinsci.
the class ConfigurationDoCheckTest method testCheckProcessNameRequired.
@Bug(7972)
public void testCheckProcessNameRequired() throws Exception {
FreeStyleProject down = createFreeStyleProject();
FreeStyleProject p = createFreeStyleProject();
JobPropertyImpl pp = new JobPropertyImpl(p);
p.addProperty(pp);
PromotionProcess proc = pp.addProcess("");
assertEquals(1, pp.getItems().size());
proc.conditions.add(new DownstreamPassCondition(down.getName()));
proc.getBuildSteps().add(new JavadocArchiver("somedir", true));
proc.icon = "star-blue";
WebClient client = new WebClient();
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
HtmlPage page = submit(client.getPage(p, "configure").getFormByName("config"));
assertTrue(page.asText().contains("No name is specified"));
}
use of hudson.tasks.JavadocArchiver in project promoted-builds-plugin by jenkinsci.
the class ConfigurationDoCheckTest method testCheckInvalidProcessName.
@Bug(7972)
public void testCheckInvalidProcessName() throws Exception {
FreeStyleProject down = createFreeStyleProject();
FreeStyleProject p = createFreeStyleProject();
JobPropertyImpl pp = new JobPropertyImpl(p);
p.addProperty(pp);
PromotionProcess proc = pp.addProcess("test/");
assertEquals(1, pp.getItems().size());
proc.conditions.add(new DownstreamPassCondition(down.getName()));
proc.getBuildSteps().add(new JavadocArchiver("somedir", true));
proc.icon = "star-blue";
WebClient client = new WebClient();
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
HtmlPage page = submit(client.getPage(p, "configure").getFormByName("config"));
assertTrue(page.asText().contains("unsafe character"));
}
use of hudson.tasks.JavadocArchiver in project promoted-builds-plugin by jenkinsci.
the class ConfigurationRoundtripTest method testRoundtrip.
/**
* Configuration roundtrip test to detect data loss.
*/
public void testRoundtrip() throws Exception {
FreeStyleProject down = createFreeStyleProject();
FreeStyleProject p = createFreeStyleProject();
JobPropertyImpl pp = new JobPropertyImpl(p);
p.addProperty(pp);
PromotionProcess proc = pp.addProcess("test");
assertEquals(1, pp.getItems().size());
proc.conditions.add(new DownstreamPassCondition(down.getName()));
proc.getBuildSteps().add(new JavadocArchiver("somedir", true));
proc.icon = "star-blue";
// round trip
submit(new WebClient().getPage(p, "configure").getFormByName("config"));
// assert that the configuration is still intact
pp = p.getProperty(JobPropertyImpl.class);
assertEquals(1, pp.getItems().size());
proc = pp.getItem("test");
assertEquals(1, proc.conditions.toList().size());
DownstreamPassCondition dcp = proc.conditions.get(DownstreamPassCondition.class);
assertEquals(dcp.getJobs(), down.getName());
assertEquals(1, proc.getBuildSteps().size());
JavadocArchiver ja = (JavadocArchiver) proc.getBuildSteps().get(0);
assertEquals("somedir", ja.getJavadocDir());
assertTrue(ja.isKeepAll());
assertEquals("star-blue", proc.icon);
}
use of hudson.tasks.JavadocArchiver in project hudson-2.x by hudson.
the class CascadingUtilTest method testBuildExternalProperties.
@Test
@PrepareForTest({ Hudson.class, StaplerRequest.class })
public void testBuildExternalProperties() throws Exception {
Job job = new FreeStyleProjectMock("job");
StaplerRequest req = createMock(StaplerRequest.class);
String javadocArchiverKey = "hudson-tasks-JavadocArchiver";
JSONObject archiver = new JSONObject();
archiver.put("javadoc_dir", "dir");
archiver.put("keep_all", true);
JSONObject json = new JSONObject();
json.put(javadocArchiverKey, archiver);
Hudson hudson = createMock(Hudson.class);
Descriptor<Publisher> javadocDescriptor = new JavadocArchiver.DescriptorImpl();
expect(hudson.getDescriptorOrDie(JavadocArchiver.class)).andReturn(javadocDescriptor);
JavadocArchiver javadocArchiver = new JavadocArchiver("dir", true);
expect(req.bindJSON(JavadocArchiver.class, archiver)).andReturn(javadocArchiver).anyTimes();
List<Descriptor<Publisher>> descriptors = new ArrayList<Descriptor<Publisher>>();
descriptors.add(javadocDescriptor);
mockStatic(Hudson.class);
expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
replay(Hudson.class, hudson, req);
assertNull(CascadingUtil.getExternalProjectProperty(job, javadocArchiverKey).getValue());
CascadingUtil.buildExternalProperties(req, archiver, descriptors, job);
assertNull(CascadingUtil.getExternalProjectProperty(job, javadocArchiverKey).getValue());
CascadingUtil.buildExternalProperties(req, json, descriptors, job);
assertNotNull(CascadingUtil.getExternalProjectProperty(job, javadocArchiverKey).getValue());
verifyAll();
}
use of hudson.tasks.JavadocArchiver in project hudson-2.x by hudson.
the class BaseProjectPropertyTest method testAllowOverrideValue.
/**
* Verify {@link BaseProjectProperty#allowOverrideValue(Object, Object)} method.
*/
@Test
public void testAllowOverrideValue() {
assertFalse(property.allowOverrideValue(null, null));
assertTrue(property.allowOverrideValue(new Object(), null));
assertTrue(property.allowOverrideValue(null, new Object()));
//Test properties that don't have correct equals methods
assertFalse(property.allowOverrideValue(new JavadocArchiver("", false), new JavadocArchiver("", false)));
assertTrue(property.allowOverrideValue(new JavadocArchiver("", true), new JavadocArchiver("", false)));
//Object with transient filds should be taken into account
assertTrue(property.allowOverrideValue(new AxisList(new Axis("DB", "mysql")), new AxisList()));
assertTrue(property.allowOverrideValue(new AxisList(new Axis("DB", "mysql")), new AxisList(new Axis("DB", "mysql", "mssql"))));
assertTrue(property.allowOverrideValue(new AxisList(new Axis("DB", "mysql")), new AxisList(new Axis("DB", "mssql"))));
}
Aggregations