RpcStreamConnection extends RpcConnection { public long putRpcPacket(@Nonnull RpcPacket packet) throws ConnectionException { Validate.notNull(packet); throwP4JavaErrorIfConditionFails(nonNull(packet.getFuncNameString()), "Unmapped / unmappable function in RpcPacket.put()"); int startPos = RpcPacketPreamble.RPC_PREAMBLE_SIZE; RpcPacketSupplier supplier = new RpcPacketSupplier(); supplier.sendBytes(new byte[INITIAL_SENDBUF_SIZE]).sendPos(startPos); processNameArgs(packet, supplier); processStringArgs(packet, supplier); processExternalEnv(packet, supplier); processFuncName(packet, supplier); calculatePreambleBytesAndSendtoDownstream(supplier); return 0; } RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, boolean secure);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, Socket socket);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, RpcSocketPool pool);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, Socket socket, boolean secure);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, RpcSocketPool pool, boolean secure);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, Socket socket, RpcSocketPool pool, boolean secure);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, Socket socket, RpcSocketPool pool, boolean secure,
            String rsh); String getServerIpPort(); String getClientIpPort(); void disconnect(final RpcPacketDispatcher dispatcher); RpcPacket getRpcPacket(); RpcPacket getRpcPacket(final RpcPacketFieldRule fieldRule,
            final IFilterCallback filterCallback); int getSystemRecvBufferSize(); int getSystemSendBufferSize(); long putRpcPackets(@Nonnull RpcPacket[] packets); long putRpcPacket(@Nonnull RpcPacket packet); @Override void useConnectionCompression(); static final String TRACE_PREFIX; }
@Test public void putRpcPacket_null_rpcPacket() { expectThrows(NullPointerException.class, () -> mockConnection.putRpcPacket(null)); }
@Test public void putRpcPacket_nonNull_rpcPacket_but_funcNameString_isNull() throws Exception { RpcPacket rpcPacket = mock(RpcPacket.class); when(rpcPacket.getFuncNameString()).thenReturn(null); expectThrows(P4JavaError.class, () -> mockConnection.putRpcPacket(rpcPacket)); }