Skip to content

Commit

Permalink
adjust test - setValueAttribute has changed the behavior because the …
Browse files Browse the repository at this point in the history
…deprecated impl is gone
  • Loading branch information
rbri committed Aug 11, 2024
1 parent 0792332 commit a37d76f
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/test/java/org/htmlunit/html/HtmlFileInput2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private void testFileInput(final File file) throws Exception {
}

/**
* Tests setData method.
* Tests setValueAttribute method.
* @throws Exception if the test fails
*/
@Test
Expand Down Expand Up @@ -152,16 +152,14 @@ public void setValueAttributeAndSetDataDummyFile() throws Exception {
firstPage.getHtmlElementById("mySubmit").click();
final KeyDataPair pair = (KeyDataPair) webConnection.getLastParameters().get(0);

assertNotNull(pair.getData());
assertTrue(pair.getData().length > 10);
assertNull(pair.getData());

final HttpEntity httpEntity = post(client, webConnection);

try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
httpEntity.writeTo(out);

assertTrue(out.toString().contains(
"Content-Disposition: form-data; name=\"image\"; filename=\"dummy.txt\""));
assertFalse(out.toString().contains("dummy.txt"));
}
}

Expand Down Expand Up @@ -204,13 +202,12 @@ public void setValueAndSetDataDummyFile() throws Exception {
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
httpEntity.writeTo(out);

assertTrue(out.toString().contains(
"Content-Disposition: form-data; name=\"image\"; filename=\"dummy.txt\""));
assertTrue(out.toString().contains("dummy.txt"));
}
}

/**
* Tests setData method.
* Tests setValueAttribute method.
* @throws Exception if the test fails
*/
@Test
Expand Down Expand Up @@ -240,15 +237,14 @@ public void setValueAttributeAndSetDataRealFile() throws Exception {
firstPage.getHtmlElementById("mySubmit").click();
final KeyDataPair pair = (KeyDataPair) webConnection.getLastParameters().get(0);

assertNotNull(pair.getData());
assertTrue(pair.getData().length > 10);
assertNull(pair.getData());

final HttpEntity httpEntity = post(client, webConnection);

try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
httpEntity.writeTo(out);

assertTrue(out.toString()
assertFalse(out.toString()
.contains("Content-Disposition: form-data; name=\"image\"; filename=\"tiny-png.img\""));
}
}
Expand Down

0 comments on commit a37d76f

Please sign in to comment.