aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAhmed Ashour <asashour@yahoo.com>2017-09-29 14:11:59 +0200
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-09-29 15:11:59 +0300
commit3c7a9514117b348336b89306de735d92c8e9f463 (patch)
tree8f0eccfc3afa3cc47a97f565719295dd28926951 /server
parent241b7fadca23259f300ed0e09cb2c27c8b55dcaf (diff)
downloadvaadin-framework-3c7a9514117b348336b89306de735d92c8e9f463.tar.gz
vaadin-framework-3c7a9514117b348336b89306de735d92c8e9f463.zip
Use StandardCharsets.UTF_8 (#10113)
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/server/BootstrapHandler.java10
-rw-r--r--server/src/main/java/com/vaadin/server/ResourceReference.java4
-rw-r--r--server/src/main/java/com/vaadin/server/VaadinService.java4
-rw-r--r--server/src/main/java/com/vaadin/server/VaadinServlet.java20
-rw-r--r--server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java10
-rw-r--r--server/src/main/java/com/vaadin/server/communication/PortletDummyRequestHandler.java4
-rw-r--r--server/src/main/java/com/vaadin/server/communication/UIInitHandler.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/CustomLayout.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/UI.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/declarative/Design.java9
-rw-r--r--server/src/main/java/com/vaadin/util/EncodeUtil.java5
-rw-r--r--server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java21
-rw-r--r--server/src/test/java/com/vaadin/tests/design/DesignReadInConstructorTest.java6
-rw-r--r--server/src/test/java/com/vaadin/tests/design/FieldNameWhichConflictsWithGettersTest.java4
-rw-r--r--server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java10
-rw-r--r--server/src/test/java/com/vaadin/tests/design/ParseLayoutTest.java3
-rw-r--r--server/src/test/java/com/vaadin/tests/design/nested/NestedCustomLayoutsTest.java3
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java6
18 files changed, 74 insertions, 57 deletions
diff --git a/server/src/main/java/com/vaadin/server/BootstrapHandler.java b/server/src/main/java/com/vaadin/server/BootstrapHandler.java
index 6b43dc3a64..ed6778bf53 100644
--- a/server/src/main/java/com/vaadin/server/BootstrapHandler.java
+++ b/server/src/main/java/com/vaadin/server/BootstrapHandler.java
@@ -16,6 +16,8 @@
package com.vaadin.server;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
@@ -323,7 +325,8 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler {
protected String encodeQueryStringParameterValue(String queryString) {
String encodedString = null;
try {
- encodedString = URLEncoder.encode(queryString, "UTF-8");
+ encodedString = URLEncoder.encode(queryString,
+ UTF_8.name());
} catch (UnsupportedEncodingException e) {
// should never happen
throw new RuntimeException("Could not find UTF-8", e);
@@ -495,7 +498,7 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler {
response.setContentType(
ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8);
try (BufferedWriter writer = new BufferedWriter(
- new OutputStreamWriter(response.getOutputStream(), "UTF-8"))) {
+ new OutputStreamWriter(response.getOutputStream(), UTF_8))) {
writer.append(html);
}
}
@@ -517,7 +520,8 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler {
"content", ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8);
// Force IE 11 to use IE 11 mode.
- head.appendElement("meta").attr("http-equiv", "X-UA-Compatible").attr("content", "IE=11");
+ head.appendElement("meta").attr("http-equiv", "X-UA-Compatible")
+ .attr("content", "IE=11");
Class<? extends UI> uiClass = context.getUIClass();
diff --git a/server/src/main/java/com/vaadin/server/ResourceReference.java b/server/src/main/java/com/vaadin/server/ResourceReference.java
index 1ff5f13706..a5a3520eae 100644
--- a/server/src/main/java/com/vaadin/server/ResourceReference.java
+++ b/server/src/main/java/com/vaadin/server/ResourceReference.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.server;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
@@ -102,7 +104,7 @@ public class ResourceReference extends URLReference {
static String urlEncode(String filename) {
try {
- return URLEncoder.encode(filename, "UTF-8");
+ return URLEncoder.encode(filename, UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(
"UTF-8 charset not available (\"this should never happen\")",
diff --git a/server/src/main/java/com/vaadin/server/VaadinService.java b/server/src/main/java/com/vaadin/server/VaadinService.java
index ba1ecf6740..509b29f9d3 100644
--- a/server/src/main/java/com/vaadin/server/VaadinService.java
+++ b/server/src/main/java/com/vaadin/server/VaadinService.java
@@ -16,6 +16,8 @@
package com.vaadin.server;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
@@ -1664,7 +1666,7 @@ public abstract class VaadinService implements Serializable {
final OutputStream out = response.getOutputStream();
try (PrintWriter outWriter = new PrintWriter(
- new BufferedWriter(new OutputStreamWriter(out, "UTF-8")))) {
+ new BufferedWriter(new OutputStreamWriter(out, UTF_8)))) {
outWriter.print(reponseString);
}
}
diff --git a/server/src/main/java/com/vaadin/server/VaadinServlet.java b/server/src/main/java/com/vaadin/server/VaadinServlet.java
index 7f2edbfbfd..62bfeb0207 100644
--- a/server/src/main/java/com/vaadin/server/VaadinServlet.java
+++ b/server/src/main/java/com/vaadin/server/VaadinServlet.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.server;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
@@ -306,12 +308,13 @@ public class VaadinServlet extends HttpServlet implements Constants {
* @return the created deployment configuration
*
* @throws ServletException
- * if construction of the {@link Properties} for
- * {@link #createDeploymentConfiguration(Properties)} fails
+ * if construction of the {@link Properties} for
+ * {@link #createDeploymentConfiguration(Properties)} fails
*
* @since 8.2
*/
- protected DeploymentConfiguration createDeploymentConfiguration() throws ServletException {
+ protected DeploymentConfiguration createDeploymentConfiguration()
+ throws ServletException {
Properties initParameters = new Properties();
readUiFromEnclosingClass(initParameters);
@@ -363,9 +366,9 @@ public class VaadinServlet extends HttpServlet implements Constants {
* @return the created vaadin servlet service
*
* @throws ServletException
- * if creating a deployment configuration fails
+ * if creating a deployment configuration fails
* @throws ServiceException
- * if creating the vaadin servlet service fails
+ * if creating the vaadin servlet service fails
*
* @since 8.2
*/
@@ -383,7 +386,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
* @return the created vaadin servlet service
*
* @throws ServiceException
- * if creating the vaadin servlet service fails
+ * if creating the vaadin servlet service fails
*
* @since 7.0.0
*/
@@ -667,7 +670,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
final OutputStream out = response.getOutputStream();
try ( // Set the response type
PrintWriter outWriter = new PrintWriter(new BufferedWriter(
- new OutputStreamWriter(out, "UTF-8")))) {
+ new OutputStreamWriter(out, UTF_8)))) {
outWriter.print(output);
outWriter.flush();
}
@@ -1396,7 +1399,8 @@ public class VaadinServlet extends HttpServlet implements Constants {
+ request.getServerName()
+ (request.isSecure() && request.getServerPort() == 443
|| !request.isSecure() && request.getServerPort() == 80
- ? "" : ":" + request.getServerPort())
+ ? ""
+ : ":" + request.getServerPort())
+ request.getRequestURI());
String servletPath = "";
if (request
diff --git a/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java b/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java
index fb02819c23..1323bb1eaa 100644
--- a/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java
+++ b/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java
@@ -16,6 +16,8 @@
package com.vaadin.server.communication;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -226,8 +228,6 @@ public class FileUploadHandler implements RequestHandler {
private static final String CRLF = "\r\n";
- private static final String UTF8 = "UTF-8";
-
private static final String DASHDASH = "--";
/*
@@ -315,7 +315,7 @@ public class FileUploadHandler implements RequestHandler {
readByte = stream.read();
}
byte[] bytes = bout.toByteArray();
- return new String(bytes, 0, bytes.length - 1, UTF8);
+ return new String(bytes, 0, bytes.length - 1, UTF_8);
}
/**
@@ -368,7 +368,7 @@ public class FileUploadHandler implements RequestHandler {
*/
while (!atStart) {
String readLine = readLine(inputStream);
- contentLength -= (readLine.getBytes(UTF8).length + CRLF.length());
+ contentLength -= (readLine.getBytes(UTF_8).length + CRLF.length());
if (readLine.startsWith("Content-Disposition:")
&& readLine.indexOf("filename=") > 0) {
rawfilename = readLine.replaceAll(".*filename=", "");
@@ -686,7 +686,7 @@ public class FileUploadHandler implements RequestHandler {
ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8);
try (OutputStream out = response.getOutputStream()) {
final PrintWriter outWriter = new PrintWriter(
- new BufferedWriter(new OutputStreamWriter(out, "UTF-8")));
+ new BufferedWriter(new OutputStreamWriter(out, UTF_8)));
outWriter.print("<html><body>download handled</body></html>");
outWriter.flush();
}
diff --git a/server/src/main/java/com/vaadin/server/communication/PortletDummyRequestHandler.java b/server/src/main/java/com/vaadin/server/communication/PortletDummyRequestHandler.java
index a3e3fac898..3ff0cf0c65 100644
--- a/server/src/main/java/com/vaadin/server/communication/PortletDummyRequestHandler.java
+++ b/server/src/main/java/com/vaadin/server/communication/PortletDummyRequestHandler.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.server.communication;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
@@ -61,7 +63,7 @@ public class PortletDummyRequestHandler implements RequestHandler {
final OutputStream out = ((ResourceResponse) response)
.getPortletOutputStream();
try (PrintWriter outWriter = new PrintWriter(
- new BufferedWriter(new OutputStreamWriter(out, "UTF-8")))) {
+ new BufferedWriter(new OutputStreamWriter(out, UTF_8)))) {
outWriter.print("<html><body>dummy page</body></html>");
}
diff --git a/server/src/main/java/com/vaadin/server/communication/UIInitHandler.java b/server/src/main/java/com/vaadin/server/communication/UIInitHandler.java
index 02b0637af8..c2992fc29c 100644
--- a/server/src/main/java/com/vaadin/server/communication/UIInitHandler.java
+++ b/server/src/main/java/com/vaadin/server/communication/UIInitHandler.java
@@ -16,6 +16,8 @@
package com.vaadin.server.communication;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringWriter;
@@ -111,7 +113,7 @@ public abstract class UIInitHandler extends SynchronizedRequestHandler {
// iOS 6 Safari requires this (#9732)
response.setHeader("Cache-Control", "no-cache");
- byte[] b = json.getBytes("UTF-8");
+ byte[] b = json.getBytes(UTF_8);
response.setContentLength(b.length);
OutputStream outputStream = response.getOutputStream();
diff --git a/server/src/main/java/com/vaadin/ui/CustomLayout.java b/server/src/main/java/com/vaadin/ui/CustomLayout.java
index 76107d7992..2026038316 100644
--- a/server/src/main/java/com/vaadin/ui/CustomLayout.java
+++ b/server/src/main/java/com/vaadin/ui/CustomLayout.java
@@ -16,6 +16,8 @@
package com.vaadin.ui;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -113,7 +115,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
protected void initTemplateContentsFromInputStream(
InputStream templateStream) throws IOException {
BufferedReader reader = new BufferedReader(
- new InputStreamReader(templateStream, "UTF-8"));
+ new InputStreamReader(templateStream, UTF_8));
StringBuilder builder = new StringBuilder(BUFFER_SIZE);
try {
char[] cbuf = new char[BUFFER_SIZE];
diff --git a/server/src/main/java/com/vaadin/ui/UI.java b/server/src/main/java/com/vaadin/ui/UI.java
index 5c89c7f040..5a8c87f48f 100644
--- a/server/src/main/java/com/vaadin/ui/UI.java
+++ b/server/src/main/java/com/vaadin/ui/UI.java
@@ -16,6 +16,8 @@
package com.vaadin.ui;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
@@ -249,7 +251,7 @@ public abstract class UI extends AbstractSingleComponentContainer
Design.write((Component) connector, baos);
getLogger().info("Design for " + connector
+ " requested from debug window:\n"
- + baos.toString("UTF-8"));
+ + baos.toString(UTF_8.name()));
} catch (IOException e) {
getLogger().log(Level.WARNING,
"Error producing design for " + connector, e);
diff --git a/server/src/main/java/com/vaadin/ui/declarative/Design.java b/server/src/main/java/com/vaadin/ui/declarative/Design.java
index 761ce3c355..65565eb47a 100644
--- a/server/src/main/java/com/vaadin/ui/declarative/Design.java
+++ b/server/src/main/java/com/vaadin/ui/declarative/Design.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.ui.declarative;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.beans.IntrospectionException;
import java.io.IOException;
import java.io.InputStream;
@@ -67,8 +69,6 @@ import com.vaadin.util.ReflectTools;
*/
public class Design implements Serializable {
- private static final String UTF8 = "UTF-8";
-
/**
* Callback for creating instances of a given component class when reading
* designs. The default implementation, {@link DefaultComponentFactory} will
@@ -392,7 +392,8 @@ public class Design implements Serializable {
*/
private static Document parse(InputStream html) {
try {
- Document doc = Jsoup.parse(html, UTF8, "", Parser.htmlParser());
+ Document doc = Jsoup.parse(html, UTF_8.name(), "",
+ Parser.htmlParser());
return doc;
} catch (IOException e) {
throw new DesignException("The html document cannot be parsed.");
@@ -808,7 +809,7 @@ public class Design implements Serializable {
doc.outputSettings().indentAmount(4);
doc.outputSettings().syntax(Syntax.html);
doc.outputSettings().prettyPrint(true);
- outputStream.write(doc.html().getBytes(UTF8));
+ outputStream.write(doc.html().getBytes(UTF_8));
}
private Design() {
diff --git a/server/src/main/java/com/vaadin/util/EncodeUtil.java b/server/src/main/java/com/vaadin/util/EncodeUtil.java
index 68cdb600e1..19cade5a47 100644
--- a/server/src/main/java/com/vaadin/util/EncodeUtil.java
+++ b/server/src/main/java/com/vaadin/util/EncodeUtil.java
@@ -15,7 +15,7 @@
*/
package com.vaadin.util;
-import java.nio.charset.Charset;
+import static java.nio.charset.StandardCharsets.UTF_8;
/**
* Utilities related to various encoding schemes.
@@ -24,7 +24,6 @@ import java.nio.charset.Charset;
* @since 7.7.7
*/
public final class EncodeUtil {
- private static final Charset UTF8 = Charset.forName("UTF-8");
private EncodeUtil() {
// Static utils only
@@ -49,7 +48,7 @@ public final class EncodeUtil {
// Create string from a single code point
String cpAsString = new String(new int[] { cp }, 0, 1);
- appendHexBytes(builder, cpAsString.getBytes(UTF8));
+ appendHexBytes(builder, cpAsString.getBytes(UTF_8));
}
// Advance to the next code point
diff --git a/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java b/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java
index 323238266e..a3b6fbeeeb 100644
--- a/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java
+++ b/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java
@@ -15,9 +15,10 @@
*/
package com.vaadin.tests.design;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -59,21 +60,13 @@ public abstract class DeclarativeTestBaseBase<T extends Component> {
}
protected T read(String design) {
- try {
- return (T) Design
- .read(new ByteArrayInputStream(design.getBytes("UTF-8")));
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
+ return (T) Design
+ .read(new ByteArrayInputStream(design.getBytes(UTF_8)));
}
protected DesignContext readAndReturnContext(String design) {
- try {
- return Design.read(
- new ByteArrayInputStream(design.getBytes("UTF-8")), null);
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
+ return Design.read(new ByteArrayInputStream(design.getBytes(UTF_8)),
+ null);
}
protected String write(T object, boolean writeData) {
@@ -90,7 +83,7 @@ public abstract class DeclarativeTestBaseBase<T extends Component> {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
context.setRootComponent(object);
Design.write(context, outputStream);
- return outputStream.toString("UTF-8");
+ return outputStream.toString(UTF_8.name());
} catch (Exception e) {
throw new RuntimeException(e);
}
diff --git a/server/src/test/java/com/vaadin/tests/design/DesignReadInConstructorTest.java b/server/src/test/java/com/vaadin/tests/design/DesignReadInConstructorTest.java
index 86fb273841..b870e55f13 100644
--- a/server/src/test/java/com/vaadin/tests/design/DesignReadInConstructorTest.java
+++ b/server/src/test/java/com/vaadin/tests/design/DesignReadInConstructorTest.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.tests.design;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashSet;
@@ -44,11 +46,11 @@ public class DesignReadInConstructorTest {
DesignReadInConstructor dric = new DesignReadInConstructor();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Design.write(dric, baos);
- Document doc = Jsoup.parse(baos.toString("UTF-8"));
+ Document doc = Jsoup.parse(baos.toString(UTF_8.name()));
Document d = Jsoup.parse(
getClass().getResourceAsStream("DesignReadInConstructor.html"),
- "UTF-8", "");
+ UTF_8.name(), "");
assertJsoupTreeEquals(d.body().child(0), doc.body().child(0));
}
diff --git a/server/src/test/java/com/vaadin/tests/design/FieldNameWhichConflictsWithGettersTest.java b/server/src/test/java/com/vaadin/tests/design/FieldNameWhichConflictsWithGettersTest.java
index 5f60d407bd..91e7e89627 100644
--- a/server/src/test/java/com/vaadin/tests/design/FieldNameWhichConflictsWithGettersTest.java
+++ b/server/src/test/java/com/vaadin/tests/design/FieldNameWhichConflictsWithGettersTest.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.tests.design;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -65,7 +67,7 @@ public class FieldNameWhichConflictsWithGettersTest {
context.setRootComponent(v);
Design.write(context, baos);
- String str = baos.toString("UTF-8");
+ String str = baos.toString(UTF_8.name());
Document doc = Jsoup.parse(str);
Element body = doc.body();
diff --git a/server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java b/server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java
index ac77795b27..98ca82d646 100644
--- a/server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java
+++ b/server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java
@@ -15,8 +15,9 @@
*/
package com.vaadin.tests.design;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.ByteArrayInputStream;
-import java.io.UnsupportedEncodingException;
import org.junit.Assert;
import org.junit.Test;
@@ -93,11 +94,6 @@ public class InvalidTagNamesTest {
}
private Component readDesign(String string) {
- try {
- return Design
- .read(new ByteArrayInputStream(string.getBytes("UTF-8")));
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
+ return Design.read(new ByteArrayInputStream(string.getBytes(UTF_8)));
}
}
diff --git a/server/src/test/java/com/vaadin/tests/design/ParseLayoutTest.java b/server/src/test/java/com/vaadin/tests/design/ParseLayoutTest.java
index 56e9a44087..0a0676b8f7 100644
--- a/server/src/test/java/com/vaadin/tests/design/ParseLayoutTest.java
+++ b/server/src/test/java/com/vaadin/tests/design/ParseLayoutTest.java
@@ -15,6 +15,7 @@
*/
package com.vaadin.tests.design;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
@@ -110,7 +111,7 @@ public class ParseLayoutTest {
String[] expectedPackageNames = { "com.addon.mypackage" };
int index = 0;
- Document doc = Jsoup.parse(out.toString("UTF-8"));
+ Document doc = Jsoup.parse(out.toString(UTF_8.name()));
Element head = doc.head();
for (Node child : head.childNodes()) {
if ("meta".equals(child.nodeName())) {
diff --git a/server/src/test/java/com/vaadin/tests/design/nested/NestedCustomLayoutsTest.java b/server/src/test/java/com/vaadin/tests/design/nested/NestedCustomLayoutsTest.java
index 341397ff81..7e450cc5f7 100644
--- a/server/src/test/java/com/vaadin/tests/design/nested/NestedCustomLayoutsTest.java
+++ b/server/src/test/java/com/vaadin/tests/design/nested/NestedCustomLayoutsTest.java
@@ -15,6 +15,7 @@
*/
package com.vaadin.tests.design.nested;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
@@ -57,7 +58,7 @@ public class NestedCustomLayoutsTest {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Design.write(rootLayout, out);
- Document doc = Jsoup.parse(out.toString("UTF-8"));
+ Document doc = Jsoup.parse(out.toString(UTF_8.name()));
assertThat(doc.head().child(0).attr("name"), is("package-mapping"));
assertThat(doc.head().child(0).attr("content"), is(PACKAGE_MAPPING));
diff --git a/server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java
index b641f3b249..0ca92e4ed5 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.tests.server.component.gridlayout;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -330,7 +332,7 @@ public class GridLayoutDeclarativeTest
+ "<row><column><vaadin-grid-layout _id=\"marginBottomComponent\" margin-bottom></vaadin-grid-layout></column></row>"
+ "</vaadin-grid-layout>";
DesignContext context = Design
- .read(new ByteArrayInputStream(design.getBytes("UTF-8")), null);
+ .read(new ByteArrayInputStream(design.getBytes(UTF_8)), null);
Assert.assertEquals(null, context.getCustomAttributes(
context.getComponentByLocalId("marginComponent")));
Assert.assertEquals(null, context.getCustomAttributes(
@@ -352,7 +354,7 @@ public class GridLayoutDeclarativeTest
+ "<my-preconfigured-grid-layout></my-preconfigured-grid-layout>";
PreconfiguredGridLayout myLayout = (PreconfiguredGridLayout) Design
- .read(new ByteArrayInputStream(design.getBytes("UTF-8")));
+ .read(new ByteArrayInputStream(design.getBytes(UTF_8)));
Assert.assertEquals(2, myLayout.getRows());
Assert.assertEquals(2, myLayout.getColumns());
}