Skip to content
Permalink
Browse files

Merge pull request #14 from ikedam/feature/JENKINS-28841_NpeForValida…

…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 acde8e872d9a7f7dcc0570a3537efe1cda4a8d04
@@ -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>
@@ -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.
@@ -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.
You can’t perform that action at this time.