Skip to content

test: add integration tests for JSON serialization in gRPC messages - #515

Open
jmesnil wants to merge 1 commit into
wildfly-extras:mainfrom
jmesnil:json-serialization-tests
Open

jmesnil wants to merge 1 commit into
wildfly-extras:mainfrom
jmesnil:json-serialization-tests

Conversation

@jmesnil

@jmesnil jmesnil commented Oct 8, 2026

Copy link
Copy Markdown
Member

Verify that JsonFormat (from protobuf-java-util, backed by Gson) is accessible from a WildFly deployment, as enabled by the optional com.google.code.gson dependency added to the com.google.protobuf module.

  • JsonGreeterServiceImpl: service impl that uses JsonFormat to round-trip the request through JSON serialization before building the response
  • JsonSerializationTest: Arquillian integration test that deploys the service and verifies the call succeeds over a plaintext connection
  • Add protobuf-java-util as provided dependency to the testsuite pom (it is available in WildFly at runtime; needed only for compilation)

Closes #510

@jmesnil
jmesnil requested a review from hpehl as a code owner October 8, 2026 07:33
@RunAsClient
public class JsonSerializationTest {

private static final String TARGET = "localhost:9555";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a repeating pattern in the tests to define the target host and port and to create channels:

Package org.wildfly.feature.pack.grpc.test.helloworld

HelloWorldParent defines

protected static final String TARGET = "localhost:9555";
protected static final String TARGET_HOST = "localhost";
protected static final int TARGET_PORT = 9555;

which is used in

  • PlaintextHelloWorldTest

    channel = ManagedChannelBuilder.forTarget(TARGET).usePlaintext().build();
  • OnewaySecureHelloWorldTest

    channel = Grpc.newChannelBuilderForAddress(TARGET_HOST, TARGET_PORT, creds).build();
  • TwowaySecureHelloWorldTest

    channel = Grpc.newChannelBuilderForAddress(TARGET_HOST, TARGET_PORT, creds).build();

Package org.wildfly.feature.pack.grpc.test.stream

StreamingTestParent defines

protected static final String TARGET = "localhost:9555";
protected static final String TARGET_HOST = "localhost";
protected static final int TARGET_PORT = 9555;

which is used in

  • PlaintextStreamingTest

    channel = ManagedChannelBuilder.forTarget(TARGET).usePlaintext().build();
  • OnewaySecureStreamingTest

    channel = Grpc.newChannelBuilderForAddress(TARGET_HOST, TARGET_PORT, creds).build();
  • TwowaySecureStreamingTest

  • channel = Grpc.newChannelBuilderForAddress(TARGET_HOST, TARGET_PORT, creds).build();

This is not much repeating code atm, but it might make sense to have at least the constants for the target host and port in one place.

@jmesnil
jmesnil force-pushed the json-serialization-tests branch from e1808f8 to 1195c67 Compare October 13, 2026 08:47
Verify that JsonFormat (from protobuf-java-util, backed by Gson) is
accessible from a WildFly deployment, as enabled by the optional
com.google.code.gson dependency added to the com.google.protobuf module.

- JsonGreeterServiceImpl: service impl that uses JsonFormat to round-trip
  the request through JSON serialization before building the response
- JsonSerializationTest: Arquillian integration test that deploys the
  service and verifies the call succeeds over a plaintext connection
- Add protobuf-java-util as provided dependency to the testsuite pom
  (it is available in WildFly at runtime; needed only for compilation)

Closes wildfly-extras#510

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@jmesnil
jmesnil force-pushed the json-serialization-tests branch from 1195c67 to a40aa72 Compare October 21, 2026 09:30

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tests for JSON serialization

2 participants