Exemple #1
0
// Initialize mock JSONRPC server for NQM log
// You may use "test.mockrpc.port" to customize port of HTTP for it
func StartMockJsonRpcServer(c *C, jsonrpcServiceSetupFunc func(*rpc.Server)) {
	if testHttpServer != nil {
		return
	}

	flag.Parse()

	jsonrpcService := rpc.NewServer()
	jsonrpcService.RegisterCodec(json2.NewCodec(), "application/json")
	jsonrpcServiceSetupFunc(jsonrpcService)

	/**
	 * Set-up HTTP server for testing
	 */
	testHttpServer = httptest.NewUnstartedServer(jsonrpcService)
	listener, err := net.Listen("tcp", "127.0.0.1:"+*mockRpcPort)
	if err != nil {
		panic(err)
	}
	testHttpServer.Listener = listener
	testHttpServer.Start()
	// :~)

	rpcServiceCaller = jsonrpc.NewService(testHttpServer.URL)

	c.Logf("Test HTTP Server: \"%v\"", testHttpServer.URL)
}
Exemple #2
0
func initIcmp() {
	config := g.Config()
	rpcServiceCaller = jsonrpc.NewService(config.NqmLog.JsonrpcUrl)
}