Skip to content

Commit

Permalink
missing from last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Apr 5, 2024
1 parent b1dfc39 commit f76eda3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 30 deletions.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

<body>
<release version="4.1.0" date="April xx, 2024" description="Bugfixes">
<action type="fix" dev="rbri">
Wrong script encoding was uses in some cases (regression in 4.0.0).
</action>
<action type="update" dev="rbri">
keyboard-howto updated and enhanced. Some documentation about clipboard handling added.
</action>
Expand Down
44 changes: 14 additions & 30 deletions src/test/java/org/htmlunit/NoHttpResponseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,16 @@ public void submit() throws Exception {
expandExpectedAlertsVariables(URL_FIRST);
final WebDriver driver = getWebDriver();

final MiniServer miniServer = new MiniServer(PORT, mockWebConnection);
miniServer.start();
try {
try (MiniServer miniServer = new MiniServer(PORT, mockWebConnection)) {
miniServer.start();

driver.get(URL_FIRST.toString());
driver.findElement(By.id("inputSubmit")).click();
assertEquals(getExpectedAlerts()[0], driver.getCurrentUrl());
}
catch (final WebDriverException e) {
assertEquals(getExpectedAlerts()[0], "WebDriverException");
}
finally {
miniServer.shutDown();
}
}

/**
Expand All @@ -113,16 +110,13 @@ public void callSubmitInButtonAndReturnTrue() throws Exception {

final WebDriver driver = getWebDriver();

final MiniServer miniServer = new MiniServer(PORT, mockWebConnection);
miniServer.start();
try {
try (MiniServer miniServer = new MiniServer(PORT, mockWebConnection)) {
miniServer.start();

driver.get(URL_FIRST.toString());
driver.findElement(By.id("jsSubmit")).click();
assertTitle(driver, getExpectedAlerts()[0]);
}
finally {
miniServer.shutDown();
}
}
}

Expand Down Expand Up @@ -150,17 +144,13 @@ public void submit() throws Throwable {

expandExpectedAlertsVariables(URL_FIRST);

final MiniServer miniServer = new MiniServer(PORT, mockWebConnection);
miniServer.start();
try (MiniServer miniServer = new MiniServer(PORT, mockWebConnection)) {
miniServer.start();

try {
HtmlPage page = getWebClient().getPage(URL_FIRST);
page = page.getElementById("inputSubmit").click();
assertEquals(getExpectedAlerts()[0], page.getUrl());
}
finally {
miniServer.shutDown();
}
}

/**
Expand All @@ -174,16 +164,13 @@ public void callSubmitInButtonAndReturnTrue() throws Throwable {
final URL urlRightSubmit = new URL(URL_FIRST, "page2?textfield=new+value");
mockWebConnection.setResponse(urlRightSubmit, "<html><head><title>right submit</title></head></html>");

final MiniServer miniServer = new MiniServer(PORT, mockWebConnection);
miniServer.start();
try {
try (MiniServer miniServer = new MiniServer(PORT, mockWebConnection)) {
miniServer.start();

HtmlPage page = getWebClient().getPage(URL_FIRST);
page = page.getElementById("jsSubmit").click();
assertEquals("right submit", page.getTitleText());
}
finally {
miniServer.shutDown();
}
}

/**
Expand All @@ -194,9 +181,9 @@ public void htmlUnitDriverUsesGetPage() throws Exception {
final MockWebConnection mockWebConnection = getMockWebConnection();
MiniServer.configureDropRequest(URL_FIRST);

final MiniServer miniServer = new MiniServer(PORT, mockWebConnection);
miniServer.start();
try {
try (MiniServer miniServer = new MiniServer(PORT, mockWebConnection)) {
miniServer.start();

final WebRequest request = new WebRequest(new URL(URL_FIRST.toString()),
getBrowserVersion().getHtmlAcceptHeader(), getBrowserVersion().getAcceptEncodingHeader());
request.setCharset(StandardCharsets.UTF_8);
Expand All @@ -211,9 +198,6 @@ public void htmlUnitDriverUsesGetPage() throws Exception {
assertEquals("0 No HTTP Response for " + URL_FIRST.toString(), e.getMessage());
}
}
finally {
miniServer.shutDown();
}
}
}
}

0 comments on commit f76eda3

Please sign in to comment.