Skip to content

Commit

Permalink
Merge pull request #14 from ikedam/feature/JENKINS-28841_NpeForValida…
Browse files Browse the repository at this point in the history
…teButtonOfFileChoice

[JENKINS-28841] Absence of emptyFileType in the validate buttun causes NPE.
  • Loading branch information
ikedam committed Jun 20, 2015
2 parents ddb0d2c + 553735e commit acde8e8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Expand Up @@ -44,6 +44,6 @@ THE SOFTWARE.
method="test"
title="${%List Files Now}"
progress="${%Checking...}"
with="baseDirPath,includePattern,excludePattern,scanType,reverseOrder"
with="baseDirPath,includePattern,excludePattern,scanType,reverseOrder,emptyChoiceType"
/>
</j:jelly>
Expand Up @@ -37,6 +37,11 @@
import org.apache.commons.lang.SystemUtils;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.JenkinsRule.WebClient;

import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

/**
* Tests for FilenameChoiceListProvider, concerned with Jenkins.
Expand Down Expand Up @@ -303,4 +308,35 @@ public void testDescriptor_doCheckExcludePattern() throws IOException
);
}
}

@Bug(28841)
@Test
public void testDoTest() throws Exception
{
FreeStyleProject p = j.createFreeStyleProject();
p.addProperty(new ParametersDefinitionProperty(new ExtensibleChoiceParameterDefinition(
"Choice",
new FilenameChoiceListProvider(
".",
"*",
"",
FilenameChoiceListProvider.ScanType.File,
false,
FilenameChoiceListProvider.EmptyChoiceType.None
),
false,
""
)));

WebClient wc = j.createWebClient();
HtmlPage page = wc.getPage(p, "configure");

// find the button to call doTest
//List<HtmlElement> elements = page.getElementsByName("choiceListProvider");
//assertEquals(1, elements.size());
//HtmlElement choiceListProviderBlock = elements.get(0);
HtmlElement button = page.<HtmlElement>getFirstByXPath("//*[@name='choiceListProvider']//button|//*[@name='choiceListProvider']//input[@type='button']");
assertNotNull(button);
button.click();
}
}

0 comments on commit acde8e8

Please sign in to comment.