From fa07f448754c8afaf53a77b09ec394dbc294bf0d Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Wed, 22 Jan 2020 16:42:29 -0500 Subject: [PATCH] add PercentEscaperTest --- .../api/client/util/escape/CharEscapers.java | 1 - .../util/escape/PercentEscaperTest.java | 29 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 google-http-client/src/test/java/com/google/api/client/util/escape/PercentEscaperTest.java diff --git a/google-http-client/src/main/java/com/google/api/client/util/escape/CharEscapers.java b/google-http-client/src/main/java/com/google/api/client/util/escape/CharEscapers.java index b6172cc98..062e082d8 100644 --- a/google-http-client/src/main/java/com/google/api/client/util/escape/CharEscapers.java +++ b/google-http-client/src/main/java/com/google/api/client/util/escape/CharEscapers.java @@ -16,7 +16,6 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; -import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; /** diff --git a/google-http-client/src/test/java/com/google/api/client/util/escape/PercentEscaperTest.java b/google-http-client/src/test/java/com/google/api/client/util/escape/PercentEscaperTest.java new file mode 100644 index 000000000..0d08411a6 --- /dev/null +++ b/google-http-client/src/test/java/com/google/api/client/util/escape/PercentEscaperTest.java @@ -0,0 +1,29 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.api.client.util.escape; + +import org.junit.Assert; +import org.junit.Test; + +public class PercentEscaperTest { + + @Test + public void testEscapeSpace() { + PercentEscaper escaper = + new PercentEscaper(PercentEscaper.SAFE_PLUS_RESERVED_CHARS_URLENCODER, false); + String actual = escaper.escape("Hello there"); + Assert.assertEquals("Hello%20there", actual); + } +}