From 866fdb8af8ea0fefa4dd70ce2231c36c0304ccda Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Wed, 20 Sep 2023 20:26:34 +0200 Subject: [PATCH] Update tests after testing with Java 21 --- .../classlib/java/io/BufferedWriterTest.java | 28 ----------------- .../java/math/BigDecimalConstructorsTest.java | 2 +- .../org/teavm/classlib/java/net/URLTest.java | 30 ++----------------- 3 files changed, 3 insertions(+), 57 deletions(-) diff --git a/tests/src/test/java/org/teavm/classlib/java/io/BufferedWriterTest.java b/tests/src/test/java/org/teavm/classlib/java/io/BufferedWriterTest.java index 2df9d8583..951bf95a4 100644 --- a/tests/src/test/java/org/teavm/classlib/java/io/BufferedWriterTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/io/BufferedWriterTest.java @@ -197,34 +197,6 @@ public class BufferedWriterTest { BufferedWriter bWriter = new BufferedWriter(sw); char[] nullCharArray = null; - try { - bWriter.write(nullCharArray, -1, -1); - fail("should throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - // expected - } - - try { - bWriter.write(nullCharArray, -1, 0); - fail("should throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - // expected - } - - try { - bWriter.write(nullCharArray, 0, -1); - fail("should throw NullPointerException"); - } catch (NullPointerException e) { - // expected - } - - try { - bWriter.write(nullCharArray, 0, 0); - fail("should throw NullPointerException"); - } catch (NullPointerException e) { - // expected - } - char[] testCharArray = testString.toCharArray(); bWriter.write(testCharArray, 0, 0); diff --git a/tests/src/test/java/org/teavm/classlib/java/math/BigDecimalConstructorsTest.java b/tests/src/test/java/org/teavm/classlib/java/math/BigDecimalConstructorsTest.java index fa9f84b3b..7df6a4f23 100644 --- a/tests/src/test/java/org/teavm/classlib/java/math/BigDecimalConstructorsTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/math/BigDecimalConstructorsTest.java @@ -560,7 +560,7 @@ public class BigDecimalConstructorsTest { new BigDecimal(a); fail("NumberFormatException expected"); } catch (NumberFormatException e) { - assertEquals("Improper exception message", "Scale out of range.", e.getMessage()); + // ok } } diff --git a/tests/src/test/java/org/teavm/classlib/java/net/URLTest.java b/tests/src/test/java/org/teavm/classlib/java/net/URLTest.java index 5a40be35d..f65fa0a46 100644 --- a/tests/src/test/java/org/teavm/classlib/java/net/URLTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/net/URLTest.java @@ -437,15 +437,6 @@ public class URLTest { assertEquals(-1, u.getPort()); assertEquals("test.html", u.getFile()); assertEquals("foo", u.getRef()); - - // Strange behavior in reference, the hostname contains a ':' so it gets - // wrapped in '[', ']' - URL testURL = new URL("http", "www.apache.org:8080", "test.html#anch"); - assertEquals("wrong protocol", "http", testURL.getProtocol()); - assertEquals("wrong host", "[www.apache.org:8080]", testURL.getHost()); - assertEquals("wrong port", -1, testURL.getPort()); - assertEquals("wrong file", "test.html", testURL.getFile()); - assertEquals("wrong anchor", "anch", testURL.getRef()); } @Test @@ -577,20 +568,12 @@ public class URLTest { @Test public void test_getFile() throws Exception { // Test for method java.lang.String java.net.URL.getFile() - u = new URL("http", "www.yahoo.com:8080", 1233, "test/!@$%^&*/test.html#foo"); + u = new URL("http", "www.yahoo.com", 1233, "test/!@$%^&*/test.html#foo"); assertEquals("returns a wrong file", "test/!@$%^&*/test.html", u.getFile()); - u = new URL("http", "www.yahoo.com:8080", 1233, ""); + u = new URL("http", "www.yahoo.com", 1233, ""); assertTrue("returns a wrong file", u.getFile().equals("")); } - @Test - public void test_getHost() throws MalformedURLException { - // Regression for HARMONY-60 - String ipv6Host = "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210"; - URL url = new URL("http", ipv6Host, -1, "myfile"); - assertEquals("[" + ipv6Host + "]", url.getHost()); - } - @Test public void test_getPort() throws Exception { // Test for method int java.net.URL.getPort() @@ -643,15 +626,6 @@ public class URLTest { assertEquals("q1", testURL.getQuery()); assertEquals("ref", testURL.getRef()); - testURL = new URL("http", "u:p@home", 80, "/java?q1#ref"); - assertEquals("[u:p@home]:80", testURL.getAuthority()); - assertEquals("[u:p@home]", testURL.getHost()); - assertNull(testURL.getUserInfo()); - assertEquals("/java?q1", testURL.getFile()); - assertEquals("/java", testURL.getPath()); - assertEquals("q1", testURL.getQuery()); - assertEquals("ref", testURL.getRef()); - testURL = new URL("http", "home", -1, "/java"); assertEquals("wrong authority2", "home", testURL.getAuthority()); assertNull("wrong userInfo2", testURL.getUserInfo());