Skip to content
Permalink
Browse files
Merge pull request #4 from olivergondza/register-descriptor
[FIXED JENKINS-25424] Register the descriptor
  • Loading branch information
olivergondza committed Dec 11, 2014
2 parents 2cb6669 + c68619d commit 9cde893ced088cfe6e8ff40150163832ea7a2de4
Showing 2 changed files with 34 additions and 3 deletions.
@@ -1,13 +1,14 @@
package hudson.plugins.xvnc;

import hudson.Extension;
import hudson.model.Node;
import hudson.slaves.NodeProperty;
import hudson.slaves.NodePropertyDescriptor;

import java.util.HashSet;
import java.util.Random;
import java.util.Set;

import hudson.slaves.NodePropertyDescriptor;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

@@ -83,10 +84,11 @@ private Object readResolve() {
return this;
}

@Extension
public static class DescriptorImpl extends NodePropertyDescriptor {

@Override
public String getDisplayName() { return ""; }
public String getDisplayName() { return null; }
}
}
}
@@ -23,13 +23,16 @@
*/
package hudson.plugins.xvnc;

import static org.junit.Assert.assertTrue;
import hudson.Launcher;
import hudson.model.BuildListener;
import hudson.model.FreeStyleBuild;
import hudson.model.Result;
import hudson.model.AbstractBuild;
import hudson.model.Descriptor;
import hudson.model.FreeStyleProject;
import hudson.model.Hudson;
import hudson.model.Node;
import hudson.plugins.xvnc.Xvnc.DescriptorImpl;
import hudson.slaves.DumbSlave;
import hudson.tasks.Builder;
@@ -73,7 +76,7 @@ public void distinctDisplaySpaceForSlaves() throws Exception {
public void reuseDisplayNumberOnSameSlave() throws Exception {
FreeStyleProject p = j.jenkins.createProject(FreeStyleProject.class, "project");

runXvnc(p).cleanUp = true;;
runXvnc(p).cleanUp = true;

j.buildAndAssertSuccess(p);
j.buildAndAssertSuccess(p);
@@ -125,6 +128,32 @@ public void avoidNpeAfterDeserialiation() throws Exception {
j.buildAndAssertSuccess(p);
}

@Test @Bug(25424)
public void jenkins25424() {
Descriptor<?> desc = j.jenkins.getDescriptorOrDie(DisplayAllocator.Property.class);
assertTrue(desc instanceof DisplayAllocator.Property.DescriptorImpl);
}

@Test @Bug(25424)
public void saveComputerWithDisplayAllocatorProperty() throws Exception {
DumbSlave slave = j.createOnlineSlave();

configRoundtrip(slave); // Without property

FreeStyleProject p = j.jenkins.createProject(FreeStyleProject.class, "project");
p.setAssignedNode(slave);
runXvnc(p).cleanUp = true;
j.buildAndAssertSuccess(p);

configRoundtrip(slave); // With property
}

// TODO available since 1.479 in JenkinsRule
private <N extends Node> N configRoundtrip(N node) throws Exception {
j.submit(j.createWebClient().goTo("/computer/" + node.getNodeName() + "/configure").getFormByName("config"));
return (N)j.jenkins.getNode(node.getNodeName());
}

private Xvnc fakeXvncRun(FreeStyleProject p) throws Exception {
final Xvnc xvnc = new Xvnc(false, false);
p.getBuildWrappersList().add(xvnc);

0 comments on commit 9cde893

Please sign in to comment.