From 3c7a9514117b348336b89306de735d92c8e9f463 Mon Sep 17 00:00:00 2001 From: Ahmed Ashour Date: Fri, 29 Sep 2017 14:11:59 +0200 Subject: Use StandardCharsets.UTF_8 (#10113) --- .../tests/components/browserframe/BrowserFrameIsVisible.java | 11 +++-------- .../components/customlayout/CustomLayoutWithMissingSlot.java | 4 +++- .../vaadin/tests/components/window/WindowCloseShortcuts.java | 4 +++- .../java/com/vaadin/tests/declarative/DeclarativeEditor.java | 5 +++-- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'uitest') diff --git a/uitest/src/main/java/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.java b/uitest/src/main/java/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.java index 898e01cb0c..e6fd9791b4 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.java +++ b/uitest/src/main/java/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.java @@ -1,8 +1,9 @@ package com.vaadin.tests.components.browserframe; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.io.UnsupportedEncodingException; import com.vaadin.server.StreamResource; import com.vaadin.tests.components.TestBase; @@ -100,13 +101,7 @@ public class BrowserFrameIsVisible extends TestBase { sb.append("\n"); } - try { - return new ByteArrayInputStream( - sb.toString().getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - return null; - } + return new ByteArrayInputStream(sb.toString().getBytes(UTF_8)); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/customlayout/CustomLayoutWithMissingSlot.java b/uitest/src/main/java/com/vaadin/tests/components/customlayout/CustomLayoutWithMissingSlot.java index ba5c468a44..d108e2b457 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/customlayout/CustomLayoutWithMissingSlot.java +++ b/uitest/src/main/java/com/vaadin/tests/components/customlayout/CustomLayoutWithMissingSlot.java @@ -15,6 +15,8 @@ */ package com.vaadin.tests.components.customlayout; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.ByteArrayInputStream; import java.io.IOException; @@ -34,7 +36,7 @@ public class CustomLayoutWithMissingSlot extends AbstractTestUIWithLog { try { cl = new CustomLayout(new ByteArrayInputStream( "
First:

Second:

" - .getBytes("UTF-8"))); + .getBytes(UTF_8))); cl.addComponent(new TextField("This should be visible"), "first"); Button button = new Button( "This button is visible, together with one label"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowCloseShortcuts.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowCloseShortcuts.java index c2b7cbf91c..43307223ad 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowCloseShortcuts.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowCloseShortcuts.java @@ -15,6 +15,8 @@ */ package com.vaadin.tests.components.window; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.Collections; @@ -145,7 +147,7 @@ public class WindowCloseShortcuts extends AbstractTestUI { DesignContext dc = new DesignContext(); dc.setRootComponent(window); Design.write(dc, outputStream); - design = outputStream.toString("UTF-8"); + design = outputStream.toString(UTF_8.name()); } catch (Exception e) { return; } diff --git a/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeEditor.java b/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeEditor.java index e0c5c899b2..cab0e68f06 100644 --- a/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeEditor.java +++ b/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeEditor.java @@ -15,6 +15,8 @@ */ package com.vaadin.tests.declarative; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -95,12 +97,11 @@ public class DeclarativeEditor extends UI { try { Design.write(treeHolder.getComponent(0), o); disableEvents = true; - editor.setValue(o.toString("UTF-8")); + editor.setValue(o.toString(UTF_8.name())); disableEvents = false; } catch (IOException e1) { e1.printStackTrace(); } - } private void addValueChangeListeners(Component component) { -- cgit v1.2.3