Search⌘ K
AI Features

Testing the Server and Bidirectional Streaming RPCs

Explore how to test a gRPC server and implement bidirectional streaming RPCs in Java. Understand synchronous and asynchronous calls for reading files, handling errors, and retrieving file attributes with real-time client-server communication.

We have added the server streaming readFile RPC and the bidirectional streaming getFileAttributes RPC to the ftp-service project created in Setting up the Dev Environment lesson.

The project has a destOnServerdestOnServer at the root which is where the server stores the files when the client invokes the addFile RPC. We will create three test files in the destOnServer directory to test the read and get file attributes RPCs. We have named the files myFile, sample.cpp, and testFile.txt. The files contain dummy text.

After adding the new RPCs we recompile the project from the Terminal in the IDE by executing the following command:

mvn clean install
Recompiling the project

This deletes the target directory from each module and triggers the build process again to recompile the project’s source code. After running this command, the target folder within each module of your project will be updated. The target folder contains the compiled classes, JAR files, and other artifacts generated during the build process.

Start the gRPC server

To start the server we will run the commands from the target folder in the ftp-service project. Navigate to the target directory of the server project ( ...

java -cp ftp-service-1.0.2.jar io.datajek.ftpservice.Application
Running the server
...
io.datajek.ftpservice.server.FTPServer - FTP Server started in IN-secure mode
Server started in IN-secure mode
...