@Test public void privateView() throws Exception { j.createFreeStyleProject("project1"); User user = User.get("me", true); // create user WebClient wc = j.createWebClient(); HtmlPage userPage = wc.goTo("user/me"); HtmlAnchor privateViewsLink = userPage.getFirstAnchorByText("My Views"); assertNotNull("My Views link not available", privateViewsLink); HtmlPage privateViewsPage = (HtmlPage) privateViewsLink.click(); Text viewLabel = (Text) privateViewsPage.getFirstByXPath("//div[@class='tabBar']//div[@class='tab active']/a/text()"); assertTrue("'All' view should be selected", viewLabel.getTextContent().contains(Hudson_ViewName())); View listView = listView("listView"); HtmlPage newViewPage = wc.goTo("user/me/my-views/newView"); HtmlForm form = newViewPage.getFormByName("createItem"); form.getInputByName("name").setValueAttribute("proxy-view"); ((HtmlRadioButtonInput) form.getInputByValue("hudson.model.ProxyView")).setChecked(true); HtmlPage proxyViewConfigurePage = j.submit(form); View proxyView = user.getProperty(MyViewsProperty.class).getView("proxy-view"); assertNotNull(proxyView); form = proxyViewConfigurePage.getFormByName("viewConfig"); form.getSelectByName("proxiedViewName").setSelectedAttribute("listView", true); j.submit(form); assertTrue(proxyView instanceof ProxyView); assertEquals(((ProxyView) proxyView).getProxiedViewName(), "listView"); assertEquals(((ProxyView) proxyView).getProxiedView(), listView); }
@Issue("JENKINS-9367") @Test public void allImagesCanBeLoaded() throws Exception { User.get("user", true); WebClient webClient = j.createWebClient(); webClient.setJavaScriptEnabled(false); j.assertAllImageLoadSuccessfully(webClient.goTo("asynchPeople")); }
@Test public void choiceWithLTGT() throws Exception { FreeStyleProject project = j.createFreeStyleProject(); ParametersDefinitionProperty pdp = new ParametersDefinitionProperty( new ChoiceParameterDefinition("choice", "Choice 1\nChoice <2>", "choice description")); project.addProperty(pdp); CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder(); project.getBuildersList().add(builder); WebClient wc = j.createWebClient(); wc.setThrowExceptionOnFailingStatusCode(false); HtmlPage page = wc.goTo("job/" + project.getName() + "/build?delay=0sec"); HtmlForm form = page.getFormByName("parameters"); HtmlElement element = (HtmlElement) form.selectSingleNode(".//tr[td/div/input/@value='choice']"); assertNotNull(element); assertEquals( "choice description", ((HtmlElement) element .getNextSibling() .getNextSibling() .selectSingleNode("td[@class='setting-description']")) .getTextContent()); assertEquals( "choice", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent()); HtmlOption opt = (HtmlOption) element.selectSingleNode("td/div/select/option[@value='Choice <2>']"); assertNotNull(opt); assertEquals("Choice <2>", opt.asText()); opt.setSelected(true); j.submit(form); Queue.Item q = j.jenkins.getQueue().getItem(project); if (q != null) q.getFuture().get(); else Thread.sleep(1000); assertNotNull(builder.getEnvVars()); assertEquals("Choice <2>", builder.getEnvVars().get("CHOICE")); }
@Test @Issue("JENKINS-3539") public void fileParameterNotSet() throws Exception { FreeStyleProject project = j.createFreeStyleProject(); ParametersDefinitionProperty pdp = new ParametersDefinitionProperty(new FileParameterDefinition("filename", "description")); project.addProperty(pdp); WebClient wc = j.createWebClient(); wc.setThrowExceptionOnFailingStatusCode(false); HtmlPage page = wc.goTo("job/" + project.getName() + "/build?delay=0sec"); HtmlForm form = page.getFormByName("parameters"); j.submit(form); Queue.Item q = j.jenkins.getQueue().getItem(project); if (q != null) q.getFuture().get(); else Thread.sleep(1000); assertFalse("file must not exist", project.getSomeWorkspace().child("filename").exists()); }
@Test public void parameterTypes() throws Exception { FreeStyleProject otherProject = j.createFreeStyleProject(); otherProject.scheduleBuild2(0).get(); FreeStyleProject project = j.createFreeStyleProject(); ParametersDefinitionProperty pdp = new ParametersDefinitionProperty( new StringParameterDefinition("string", "defaultValue", "string description"), new BooleanParameterDefinition("boolean", true, "boolean description"), new ChoiceParameterDefinition("choice", "Choice 1\nChoice 2", "choice description"), new RunParameterDefinition("run", otherProject.getName(), "run description", null)); project.addProperty(pdp); CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder(); project.getBuildersList().add(builder); WebClient wc = j.createWebClient(); wc.setThrowExceptionOnFailingStatusCode(false); HtmlPage page = wc.goTo("job/" + project.getName() + "/build?delay=0sec"); HtmlForm form = page.getFormByName("parameters"); HtmlElement element = (HtmlElement) form.selectSingleNode("//tr[td/div/input/@value='string']"); assertNotNull(element); assertEquals( "string description", ((HtmlElement) element .getNextSibling() .getNextSibling() .selectSingleNode("td[@class='setting-description']")) .getTextContent()); HtmlTextInput stringParameterInput = (HtmlTextInput) element.selectSingleNode(".//input[@name='value']"); assertEquals("defaultValue", stringParameterInput.getAttribute("value")); assertEquals( "string", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent()); stringParameterInput.setAttribute("value", "newValue"); element = (HtmlElement) form.selectSingleNode("//tr[td/div/input/@value='boolean']"); assertNotNull(element); assertEquals( "boolean description", ((HtmlElement) element .getNextSibling() .getNextSibling() .selectSingleNode("td[@class='setting-description']")) .getTextContent()); Object o = element.selectSingleNode(".//input[@name='value']"); System.out.println(o); HtmlCheckBoxInput booleanParameterInput = (HtmlCheckBoxInput) o; assertEquals(true, booleanParameterInput.isChecked()); assertEquals( "boolean", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent()); element = (HtmlElement) form.selectSingleNode(".//tr[td/div/input/@value='choice']"); assertNotNull(element); assertEquals( "choice description", ((HtmlElement) element .getNextSibling() .getNextSibling() .selectSingleNode("td[@class='setting-description']")) .getTextContent()); assertEquals( "choice", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent()); element = (HtmlElement) form.selectSingleNode(".//tr[td/div/input/@value='run']"); assertNotNull(element); assertEquals( "run description", ((HtmlElement) element .getNextSibling() .getNextSibling() .selectSingleNode("td[@class='setting-description']")) .getTextContent()); assertEquals( "run", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent()); j.submit(form); Queue.Item q = j.jenkins.getQueue().getItem(project); if (q != null) q.getFuture().get(); else Thread.sleep(1000); assertEquals("newValue", builder.getEnvVars().get("STRING")); assertEquals("true", builder.getEnvVars().get("BOOLEAN")); assertEquals("Choice 1", builder.getEnvVars().get("CHOICE")); assertEquals( j.jenkins.getRootUrl() + otherProject.getLastBuild().getUrl(), builder.getEnvVars().get("RUN")); }