use of com.gargoylesoftware.htmlunit.html.HtmlPage in project workflow-cps-plugin by jenkinsci.
the class ReplayActionTest method editSimpleDefinition.
@Test
public void editSimpleDefinition() throws Exception {
story.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("echo 'first script'", false));
// Start off with a simple run of the first script.
WorkflowRun b1 = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
story.j.assertLogContains("first script", b1);
// Now will replay with a second script.
WorkflowRun b2;
{
// First time around, verify that UI elements are present and functional.
ReplayAction a = b1.getAction(ReplayAction.class);
assertNotNull(a);
assertTrue(a.isEnabled());
HtmlPage page = story.j.createWebClient().getPage(b1, a.getUrlName());
HtmlForm form = page.getFormByName("config");
HtmlTextArea text = form.getTextAreaByName("_.mainScript");
assertEquals("echo 'first script'", text.getText());
text.setText("echo 'second script'");
// TODO loaded scripts
HtmlPage redirect = story.j.submit(form);
assertEquals(p.getAbsoluteUrl(), redirect.getUrl().toString());
story.j.waitUntilNoActivity();
b2 = p.getBuildByNumber(2);
assertNotNull(b2);
}
// Subsequently can use the faster whitebox method.
story.j.assertLogContains("second script", story.j.assertBuildStatusSuccess(b2));
ReplayCause cause = b2.getCause(ReplayCause.class);
assertNotNull(cause);
assertEquals(1, cause.getOriginalNumber());
assertEquals(b1, cause.getOriginal());
assertEquals(b2, cause.getRun());
// Replay #2 as #3. Note that the diff is going to be from #1 → #3, not #2 → #3.
WorkflowRun b3 = (WorkflowRun) b2.getAction(ReplayAction.class).run("echo 'third script'", Collections.<String, String>emptyMap()).get();
story.j.assertLogContains("third script", story.j.assertBuildStatusSuccess(b3));
String diff = b3.getAction(ReplayAction.class).getDiff();
assertThat(diff, containsString("-echo 'first script'"));
assertThat(diff, containsString("+echo 'third script'"));
System.out.println(diff);
// Make a persistent edit to the script and run, just to make sure there is no lingering effect.
p.setDefinition(new CpsFlowDefinition("echo 'fourth script'", false));
story.j.assertLogContains("fourth script", story.j.assertBuildStatusSuccess(p.scheduleBuild2(0)));
}
});
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project microservices by pwillhan.
the class UserVehicleControllerHtmlUnitTest method getVehicleWhenRequestingTextShouldReturnMakeAndModel.
@Test
public void getVehicleWhenRequestingTextShouldReturnMakeAndModel() throws Exception {
given(this.userVehicleService.getVehicleDetails("donald")).willReturn(new VehicleDetails("Honda", "Civic"));
HtmlPage page = this.webClient.getPage("/donald/vehicle.html");
assertThat(page.getBody().getTextContent()).isEqualTo("Honda Civic");
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class JsfTest method testELWithParameters.
@Test
public void testELWithParameters(@ArquillianResource URL baseURL) throws Exception {
WebClient client = new WebClient();
HtmlPage page = client.getPage(new URL(baseURL, "charlie.jsf"));
page.asXml();
HtmlSpan oldel = getFirstMatchingElement(page, HtmlSpan.class, "oldel");
assertNotNull(oldel);
final String charlie = "Charlie";
assertEquals(charlie, oldel.asText());
HtmlSpan newel = getFirstMatchingElement(page, HtmlSpan.class, "newel");
assertNotNull(newel);
assertEquals(charlie, newel.asText());
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class InvalidateSessionTest method testInvalidateSessionCalled.
/*
* description = "WELD-380, WELD-403"
*/
@Test
public void testInvalidateSessionCalled() throws Exception {
WebClient client = new WebClient();
client.setThrowExceptionOnFailingStatusCode(true);
HtmlPage page = client.getPage(getPath("/storm.jsf"));
HtmlSubmitInput invalidateSessionButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "invalidateSessionButton");
page = invalidateSessionButton.click();
HtmlInput inputField = getFirstMatchingElement(page, HtmlInput.class, "prop");
Assert.assertEquals(Storm.PROPERTY_VALUE, inputField.getValueAttribute());
// Make another request to verify that the session bean value is not the
// one from the previous invalidated session.
page = client.getPage(getPath("/storm.jsf"));
inputField = getFirstMatchingElement(page, HtmlInput.class, "prop");
Assert.assertEquals(SomeBean.DEFAULT_PROPERTY_VALUE, inputField.getValueAttribute());
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class InvalidateSessionTest method testNoDoubleDestructionOnExternalRedirect.
/*
* description = "WELD-461"
*/
@Test
public void testNoDoubleDestructionOnExternalRedirect() throws Exception {
WebClient client = new WebClient();
HtmlPage page = client.getPage(getPath("/storm.jsf"));
HtmlSubmitInput button = getFirstMatchingElement(page, HtmlSubmitInput.class, "redirectButton");
button.click();
}
Aggregations