use of com.gargoylesoftware.htmlunit.html.HtmlPage in project javaee7-samples by javaee-samples.
the class FormTest method testGetWithCorrectCredentials.
@Test
public void testGetWithCorrectCredentials() throws Exception {
loginForm.getInputByName("j_username").setValueAttribute("u1");
loginForm.getInputByName("j_password").setValueAttribute("p1");
HtmlSubmitInput submitButton = loginForm.getInputByName("submitButton");
HtmlPage page2 = submitButton.click();
assertEquals("Form-based Security - Success", page2.getTitleText());
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project javaee7-samples by javaee-samples.
the class FormTest method setup.
@Before
public void setup() throws IOException {
@SuppressWarnings("resource") WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage(base + "SecureServlet");
loginForm = page.getForms().get(0);
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project promoted-builds-plugin by jenkinsci.
the class ManualConditionBug22005 method testPromotionProcessViaWebClient.
@Test
public void testPromotionProcessViaWebClient() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
ExtensionList<Descriptor> list = j.jenkins.getExtensionList(Descriptor.class);
list.add(new JobPropertyImpl.DescriptorImpl(JobPropertyImpl.class));
JobPropertyImpl base = new JobPropertyImpl(p);
p.addProperty(base);
createPromotionProcess(base, "PROM0");
createPromotionProcess(base, "PROM1");
createPromotionProcess(base, "PROM2");
FreeStyleBuild b1 = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
assertNull(b1.getAction(ManualApproval.class));
HtmlPage page = j.createWebClient().getPage(b1, "promotion");
// Approve Promotion
List<HtmlForm> forms = ManualConditionTest.getFormsByName(page, "approve");
assertFalse(forms.isEmpty());
assertEquals(3, forms.size());
for (HtmlForm form : forms) {
submit(form);
}
// reload promotions page
page = j.createWebClient().getPage(b1, "promotion");
forms = ManualConditionTest.getFormsByName(page, "build");
for (HtmlForm form : forms) {
List<HtmlElement> parameters = ManualConditionTest.getFormParameters(form);
assertEquals(2, parameters.size());
}
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project promoted-builds-plugin by jenkinsci.
the class PromotedBuildActionTest method testDeletedPromotionProcess.
@Test
public void testDeletedPromotionProcess() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
JobPropertyImpl base = new JobPropertyImpl(p);
p.addProperty(base);
PromotionProcess foo = base.addProcess("foo");
// promote a build
FreeStyleBuild b1 = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
foo.promote(b1, new UserCause(), new ManualPromotionBadge());
// now delete the promotion process
p.removeProperty(base);
p.addProperty(base = new JobPropertyImpl(p));
assertTrue(base.getActiveItems().isEmpty());
// make sure that the page renders OK without any error
HtmlPage page = j.createWebClient().getPage(p);
List<?> candidates = page.getByXPath("//IMG");
for (Object candidate : candidates) {
if (!(candidate instanceof HtmlImage)) {
continue;
}
HtmlImage img = (HtmlImage) candidate;
try {
assertEquals("Failed to load " + img.getSrcAttribute(), 200, img.getWebResponse(true).getStatusCode());
} catch (IOException e) {
throw new AssertionError("Failed to load " + img.getSrcAttribute());
}
}
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project promoted-builds-plugin by jenkinsci.
the class ConfigurationDoCheckTest method testCheckInvalidProcessName.
@Issue("JENKINS-7972")
@Test
public void testCheckInvalidProcessName() throws Exception {
FreeStyleProject down = j.createFreeStyleProject();
FreeStyleProject p = j.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";
JenkinsRule.WebClient client = j.createWebClient();
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
HtmlPage page = (HtmlPage) submit(client.getPage(p, "configure").getFormByName("config"));
assertTrue(page.getVisibleText().contains("unsafe character"));
}
Aggregations