Search in sources :

Example 1 with JavadocArchiver

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"));
}
Also used : DownstreamPassCondition(hudson.plugins.promoted_builds.conditions.DownstreamPassCondition) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) JavadocArchiver(hudson.tasks.JavadocArchiver) FreeStyleProject(hudson.model.FreeStyleProject) Bug(org.jvnet.hudson.test.Bug)

Example 2 with JavadocArchiver

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"));
}
Also used : DownstreamPassCondition(hudson.plugins.promoted_builds.conditions.DownstreamPassCondition) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) JavadocArchiver(hudson.tasks.JavadocArchiver) FreeStyleProject(hudson.model.FreeStyleProject) Bug(org.jvnet.hudson.test.Bug)

Example 3 with JavadocArchiver

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);
}
Also used : DownstreamPassCondition(hudson.plugins.promoted_builds.conditions.DownstreamPassCondition) JavadocArchiver(hudson.tasks.JavadocArchiver) FreeStyleProject(hudson.model.FreeStyleProject)

Example 4 with JavadocArchiver

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();
}
Also used : FreeStyleProjectMock(hudson.model.FreeStyleProjectMock) Hudson(hudson.model.Hudson) StaplerRequest(org.kohsuke.stapler.StaplerRequest) ArrayList(java.util.ArrayList) Publisher(hudson.tasks.Publisher) JSONObject(net.sf.json.JSONObject) Descriptor(hudson.model.Descriptor) JavadocArchiver(hudson.tasks.JavadocArchiver) Job(hudson.model.Job) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with JavadocArchiver

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"))));
}
Also used : AxisList(hudson.matrix.AxisList) JavadocArchiver(hudson.tasks.JavadocArchiver) Axis(hudson.matrix.Axis) Test(org.junit.Test)

Aggregations

JavadocArchiver (hudson.tasks.JavadocArchiver)5 FreeStyleProject (hudson.model.FreeStyleProject)3 DownstreamPassCondition (hudson.plugins.promoted_builds.conditions.DownstreamPassCondition)3 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)2 Test (org.junit.Test)2 Bug (org.jvnet.hudson.test.Bug)2 Axis (hudson.matrix.Axis)1 AxisList (hudson.matrix.AxisList)1 Descriptor (hudson.model.Descriptor)1 FreeStyleProjectMock (hudson.model.FreeStyleProjectMock)1 Hudson (hudson.model.Hudson)1 Job (hudson.model.Job)1 Publisher (hudson.tasks.Publisher)1 ArrayList (java.util.ArrayList)1 JSONObject (net.sf.json.JSONObject)1 StaplerRequest (org.kohsuke.stapler.StaplerRequest)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1