File tree Expand file tree Collapse file tree
main/java/com/google/api/server/spi
test/java/com/google/api/server/spi Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818import com .google .api .server .spi .config .annotationreader .ApiAnnotationIntrospector ;
1919import com .google .api .server .spi .config .model .ApiSerializationConfig ;
2020
21+ import com .fasterxml .jackson .core .Base64Variants ;
2122import com .fasterxml .jackson .core .JsonGenerator ;
2223import com .fasterxml .jackson .core .JsonParser ;
2324import com .fasterxml .jackson .databind .AnnotationIntrospector ;
@@ -76,6 +77,7 @@ public static ObjectMapper createStandardObjectMapper(ApiSerializationConfig con
7677 .configure (JsonParser .Feature .ALLOW_SINGLE_QUOTES , true )
7778 .configure (JsonParser .Feature .ALLOW_UNQUOTED_FIELD_NAMES , true )
7879 .configure (DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES , false )
80+ .setBase64Variant (Base64Variants .MODIFIED_FOR_URL )
7981 .setSerializerFactory (
8082 BeanSerializerFactory .instance .withSerializerModifier (new DeepEmptyCheckingModifier ()));
8183 AnnotationIntrospector pair = AnnotationIntrospector .pair (
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2017 Google Inc. All Rights Reserved.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package com .google .api .server .spi ;
17+
18+ import static com .google .common .truth .Truth .assertThat ;
19+
20+ import com .fasterxml .jackson .databind .ObjectMapper ;
21+
22+ import org .junit .Test ;
23+
24+ /**
25+ * Tests for {@link ObjectMapperUtil}
26+ */
27+ public class ObjectMapperUtilTest {
28+ @ Test
29+ public void createStandardObjectMapper_base64Variant () throws Exception {
30+ byte [] bytes = new byte [] {(byte ) 0xff , (byte ) 0xef };
31+ ObjectMapper mapper = ObjectMapperUtil .createStandardObjectMapper ();
32+ assertThat (mapper .writeValueAsString (bytes )).isEqualTo ("\" _-8\" " );
33+ assertThat (mapper .readValue ("\" _-8\" " , byte [].class )).isEqualTo (bytes );
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments