private void setMode(Request req) {
        dispatchRpcRequest(req, () -> {
            String suppliedMode = req.parameters().get(0).asString();
            String[] s = new String[2];
            try {
                proxyServer.setMode(suppliedMode);
                s[0] = "0";
                s[1] = "success";
            } catch (Exception e) {
                s[0] = "1";
                s[1] = e.getMessage();
            }

            req.returnValues().add(new StringArray(s));
            req.returnRequest();
        });
    }
@Test
    void testRpcMethodUpdateSources() throws ListenFailedException {
        reset();

        Request req = new Request("updateSources");
        String spec1 = "tcp/a:19070";
        String spec2 = "tcp/b:19070";
        req.parameters().add(new StringValue(spec1 + "," + spec2));
        client.invoke(req);
        assertFalse(req.isError(), req.errorMessage());
        assertEquals(1, req.returnValues().size());
        assertEquals("Updated config sources to: " + spec1 + "," + spec2, req.returnValues().get(0).asString());


        server.proxyServer().setMode(Mode.ModeName.MEMORYCACHE.name());

        req = new Request("updateSources");
        req.parameters().add(new StringValue(spec1 + "," + spec2));
        client.invoke(req);
        assertFalse(req.isError(), req.errorMessage());
        assertEquals(1, req.returnValues().size());
        assertEquals("Cannot update sources when in '" + Mode.ModeName.MEMORYCACHE.name().toLowerCase() + "' mode", req.returnValues().get(0).asString());

        // TODO source connections needs to have deterministic order to work
        /*req = new Request("listSourceConnections");
        rpcServer.listSourceConnections(req);
        assertFalse(req.errorMessage(), req.isError());
        final String[] ret = req.returnValues().get(0).asStringArray();
        assertEquals(ret.length, is(2));
        assertEquals(ret[0], is("Current source: " + spec1));
        assertEquals(ret[1], is("All sources:\n" + spec2 + "\n" + spec1 + "\n"));
        */
    }