From a37d76fdcd4cd1433ca37bd35f6f523ecbf777c7 Mon Sep 17 00:00:00 2001 From: Ronald Brill Date: Sun, 11 Aug 2024 12:57:34 +0200 Subject: [PATCH] adjust test - setValueAttribute has changed the behavior because the deprecated impl is gone --- .../org/htmlunit/html/HtmlFileInput2Test.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/test/java/org/htmlunit/html/HtmlFileInput2Test.java b/src/test/java/org/htmlunit/html/HtmlFileInput2Test.java index a62f86cbe8b..101b32250dd 100644 --- a/src/test/java/org/htmlunit/html/HtmlFileInput2Test.java +++ b/src/test/java/org/htmlunit/html/HtmlFileInput2Test.java @@ -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 @@ -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")); } } @@ -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 @@ -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\"")); } }