Skip to content

Commit 2cdf276

Browse files
Add GSON parity test and fix field visibility for test inheritance
GsonFieldFilteringMessageFormatterTest extends the Moshi test class and overrides setUp() to use JSONStreamingMessageFormatter as the delegate. All field filtering tests (flat + nested + 127-field + dot-notation) now run against both Moshi and GSON formatters. Parent test class fields changed from private to protected to enable subclass override of setUp(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0ec484b commit 2cdf276

2 files changed

Lines changed: 65 additions & 4 deletions

File tree

modules/json/test/org/apache/axis2/json/streaming/FieldFilteringMessageFormatterTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
*/
5151
public class FieldFilteringMessageFormatterTest {
5252

53-
private MessageContext outMsgContext;
54-
private OMOutputFormat outputFormat;
55-
private ByteArrayOutputStream outputStream;
56-
private FieldFilteringMessageFormatter formatter;
53+
protected MessageContext outMsgContext;
54+
protected OMOutputFormat outputFormat;
55+
protected ByteArrayOutputStream outputStream;
56+
protected FieldFilteringMessageFormatter formatter;
5757

5858
@Before
5959
public void setUp() {
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.axis2.json.streaming;
21+
22+
import org.apache.axiom.om.OMAbstractFactory;
23+
import org.apache.axiom.om.OMOutputFormat;
24+
import org.apache.axiom.soap.SOAPFactory;
25+
import org.apache.axis2.Constants;
26+
import org.apache.axis2.context.MessageContext;
27+
import org.junit.Before;
28+
29+
import java.io.ByteArrayOutputStream;
30+
31+
/**
32+
* Runs the same field filtering tests as
33+
* {@link FieldFilteringMessageFormatterTest} but with the GSON-based
34+
* {@link JSONStreamingMessageFormatter} as the delegate instead of
35+
* {@link MoshiStreamingMessageFormatter}.
36+
*
37+
* <p>This ensures behavioral parity between the two JSON formatters
38+
* for all field filtering features including dot-notation nested
39+
* filtering.</p>
40+
*
41+
* @since 2.0.1
42+
*/
43+
public class GsonFieldFilteringMessageFormatterTest
44+
extends FieldFilteringMessageFormatterTest {
45+
46+
@Override
47+
@Before
48+
public void setUp() {
49+
SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
50+
outputFormat = new OMOutputFormat();
51+
outputStream = new ByteArrayOutputStream();
52+
53+
outMsgContext = new MessageContext();
54+
outMsgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");
55+
56+
// Use GSON delegate instead of Moshi — all inherited tests run
57+
// against the GSON field filtering implementation
58+
formatter = new FieldFilteringMessageFormatter(
59+
new JSONStreamingMessageFormatter());
60+
}
61+
}

0 commit comments

Comments
 (0)