mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
refactor: renamed getter functions of json node
This commit is contained in:
parent
bf8ba05863
commit
ea15d8c5cf
@ -40,21 +40,21 @@ wfp_impl_json_is_object(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wfp_impl_json_get_bool(
|
wfp_impl_json_bool_get(
|
||||||
struct wfp_json const * json)
|
struct wfp_json const * json)
|
||||||
{
|
{
|
||||||
return (WFP_JSON_BOOL == json->type) ? json->value.b : false;
|
return (WFP_JSON_BOOL == json->type) ? json->value.b : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
wfp_impl_json_get_int(
|
wfp_impl_json_int_get(
|
||||||
struct wfp_json const * json)
|
struct wfp_json const * json)
|
||||||
{
|
{
|
||||||
return (WFP_JSON_INT == json->type) ? json->value.i : 0;
|
return (WFP_JSON_INT == json->type) ? json->value.i : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
wfp_impl_json_get_string(
|
wfp_impl_json_string_get(
|
||||||
struct wfp_json const * json)
|
struct wfp_json const * json)
|
||||||
{
|
{
|
||||||
return (WFP_JSON_STRING == json->type) ? json->value.s : "";
|
return (WFP_JSON_STRING == json->type) ? json->value.s : "";
|
||||||
|
@ -36,15 +36,15 @@ wfp_impl_json_is_object(
|
|||||||
struct wfp_json const * json);
|
struct wfp_json const * json);
|
||||||
|
|
||||||
extern bool
|
extern bool
|
||||||
wfp_impl_json_get_bool(
|
wfp_impl_json_bool_get(
|
||||||
struct wfp_json const * json);
|
struct wfp_json const * json);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
wfp_impl_json_get_int(
|
wfp_impl_json_int_get(
|
||||||
struct wfp_json const * json);
|
struct wfp_json const * json);
|
||||||
|
|
||||||
extern const char *
|
extern const char *
|
||||||
wfp_impl_json_get_string(
|
wfp_impl_json_string_get(
|
||||||
struct wfp_json const * json);
|
struct wfp_json const * json);
|
||||||
|
|
||||||
extern struct wfp_json const *
|
extern struct wfp_json const *
|
||||||
|
@ -34,18 +34,18 @@ wfp_jsonrpc_response_init(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->id = wfp_impl_json_get_int(id_holder);
|
result->id = wfp_impl_json_int_get(id_holder);
|
||||||
result->result = wfp_impl_json_object_get(response, "result");
|
result->result = wfp_impl_json_object_get(response, "result");
|
||||||
if (NULL == result->result)
|
if (NULL == result->result)
|
||||||
{
|
{
|
||||||
struct wfp_json const * error = wfp_impl_json_object_get(response, "error");
|
struct wfp_json const * error = wfp_impl_json_object_get(response, "error");
|
||||||
if ((wfp_impl_json_is_object(error)) && (wfp_impl_json_is_int(wfp_impl_json_object_get(error, "code"))))
|
if ((wfp_impl_json_is_object(error)) && (wfp_impl_json_is_int(wfp_impl_json_object_get(error, "code"))))
|
||||||
{
|
{
|
||||||
int code = wfp_impl_json_get_int(wfp_impl_json_object_get(error, "code"));
|
int code = wfp_impl_json_int_get(wfp_impl_json_object_get(error, "code"));
|
||||||
char const * message = "";
|
char const * message = "";
|
||||||
if (wfp_impl_json_is_string(wfp_impl_json_object_get(error, "message")))
|
if (wfp_impl_json_is_string(wfp_impl_json_object_get(error, "message")))
|
||||||
{
|
{
|
||||||
message = wfp_impl_json_get_string(wfp_impl_json_object_get(error, "message"));
|
message = wfp_impl_json_string_get(wfp_impl_json_object_get(error, "message"));
|
||||||
}
|
}
|
||||||
result->error = wfp_jsonrpc_error_create(code, message);
|
result->error = wfp_jsonrpc_error_create(code, message);
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ void wfp_impl_close(
|
|||||||
wfp_impl_json_is_int(handle_holder) &&
|
wfp_impl_json_is_int(handle_holder) &&
|
||||||
wfp_impl_json_is_int(flags_holder))
|
wfp_impl_json_is_int(flags_holder))
|
||||||
{
|
{
|
||||||
ino_t inode = (ino_t) wfp_impl_json_get_int(inode_holder);
|
ino_t inode = (ino_t) wfp_impl_json_int_get(inode_holder);
|
||||||
uint32_t handle = (uint32_t) (wfp_impl_json_get_int(handle_holder) & UINT32_MAX);
|
uint32_t handle = (uint32_t) (wfp_impl_json_int_get(handle_holder) & UINT32_MAX);
|
||||||
int flags = wfp_impl_json_get_int(flags_holder);
|
int flags = wfp_impl_json_int_get(flags_holder);
|
||||||
|
|
||||||
context->provider->close(inode, handle, flags, context->user_data);
|
context->provider->close(inode, handle, flags, context->user_data);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ void wfp_impl_getattr(
|
|||||||
|
|
||||||
if (wfp_impl_json_is_int(inode_holder))
|
if (wfp_impl_json_is_int(inode_holder))
|
||||||
{
|
{
|
||||||
ino_t inode = (ino_t) wfp_impl_json_get_int(inode_holder);
|
ino_t inode = (ino_t) wfp_impl_json_int_get(inode_holder);
|
||||||
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
||||||
|
|
||||||
context->provider->getattr(request, inode, context->user_data);
|
context->provider->getattr(request, inode, context->user_data);
|
||||||
|
@ -22,8 +22,8 @@ void wfp_impl_lookup(
|
|||||||
if (wfp_impl_json_is_int(inode_holder) &&
|
if (wfp_impl_json_is_int(inode_holder) &&
|
||||||
wfp_impl_json_is_string(name_holder))
|
wfp_impl_json_is_string(name_holder))
|
||||||
{
|
{
|
||||||
ino_t inode = wfp_impl_json_get_int(inode_holder);
|
ino_t inode = wfp_impl_json_int_get(inode_holder);
|
||||||
char const * name = wfp_impl_json_get_string(name_holder);
|
char const * name = wfp_impl_json_string_get(name_holder);
|
||||||
|
|
||||||
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
||||||
context->provider->lookup(request, inode, name, context->user_data);
|
context->provider->lookup(request, inode, name, context->user_data);
|
||||||
|
@ -19,8 +19,8 @@ void wfp_impl_open(
|
|||||||
if (wfp_impl_json_is_int(inode_holder) &&
|
if (wfp_impl_json_is_int(inode_holder) &&
|
||||||
wfp_impl_json_is_int(flags_holder))
|
wfp_impl_json_is_int(flags_holder))
|
||||||
{
|
{
|
||||||
ino_t inode = (ino_t) wfp_impl_json_get_int(inode_holder);
|
ino_t inode = (ino_t) wfp_impl_json_int_get(inode_holder);
|
||||||
int flags = (ino_t) wfp_impl_json_get_int(flags_holder);
|
int flags = (ino_t) wfp_impl_json_int_get(flags_holder);
|
||||||
|
|
||||||
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@ void wfp_impl_read(
|
|||||||
wfp_impl_json_is_int(offset_holder) &&
|
wfp_impl_json_is_int(offset_holder) &&
|
||||||
wfp_impl_json_is_int(length_holder))
|
wfp_impl_json_is_int(length_holder))
|
||||||
{
|
{
|
||||||
ino_t inode = (ino_t) wfp_impl_json_get_int(inode_holder);
|
ino_t inode = (ino_t) wfp_impl_json_int_get(inode_holder);
|
||||||
int handle = wfp_impl_json_get_int(handle_holder);
|
int handle = wfp_impl_json_int_get(handle_holder);
|
||||||
size_t offset = wfp_impl_json_get_int(offset_holder);
|
size_t offset = wfp_impl_json_int_get(offset_holder);
|
||||||
size_t length = wfp_impl_json_get_int(length_holder);
|
size_t length = wfp_impl_json_int_get(length_holder);
|
||||||
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
||||||
|
|
||||||
context->provider->read(request, inode, handle, offset, length, context->user_data);
|
context->provider->read(request, inode, handle, offset, length, context->user_data);
|
||||||
|
@ -18,7 +18,7 @@ void wfp_impl_readdir(
|
|||||||
|
|
||||||
if (wfp_impl_json_is_int(inode_holder))
|
if (wfp_impl_json_is_int(inode_holder))
|
||||||
{
|
{
|
||||||
ino_t inode = (ino_t) wfp_impl_json_get_int(inode_holder);
|
ino_t inode = (ino_t) wfp_impl_json_int_get(inode_holder);
|
||||||
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
struct wfp_request * request = wfp_impl_request_create(context->request, id);
|
||||||
|
|
||||||
context->provider->readdir(request, inode, context->user_data);
|
context->provider->readdir(request, inode, context->user_data);
|
||||||
|
@ -97,8 +97,8 @@ void wfp_impl_provider_invoke(
|
|||||||
|
|
||||||
if ((wfp_impl_json_is_string(method_holder)) && (wfp_impl_json_is_array(params)))
|
if ((wfp_impl_json_is_string(method_holder)) && (wfp_impl_json_is_array(params)))
|
||||||
{
|
{
|
||||||
char const * method = wfp_impl_json_get_string(method_holder);
|
char const * method = wfp_impl_json_string_get(method_holder);
|
||||||
int id = wfp_impl_json_is_int(id_holder) ? wfp_impl_json_get_int(id_holder) : 0;
|
int id = wfp_impl_json_is_int(id_holder) ? wfp_impl_json_int_get(id_holder) : 0;
|
||||||
|
|
||||||
wfp_impl_provider_invoke_method(context, method, params, id);
|
wfp_impl_provider_invoke_method(context, method, params, id);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ TEST(json_parser, parse_true)
|
|||||||
ASSERT_NE(nullptr, doc);
|
ASSERT_NE(nullptr, doc);
|
||||||
wfp_json const * root = wfp_impl_json_doc_root(doc);
|
wfp_json const * root = wfp_impl_json_doc_root(doc);
|
||||||
ASSERT_TRUE(wfp_impl_json_is_bool(root));
|
ASSERT_TRUE(wfp_impl_json_is_bool(root));
|
||||||
ASSERT_TRUE(wfp_impl_json_get_bool(root));
|
ASSERT_TRUE(wfp_impl_json_bool_get(root));
|
||||||
|
|
||||||
wfp_impl_json_doc_dispose(doc);
|
wfp_impl_json_doc_dispose(doc);
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ TEST(json_parser, parse_false)
|
|||||||
ASSERT_NE(nullptr, doc);
|
ASSERT_NE(nullptr, doc);
|
||||||
wfp_json const * root = wfp_impl_json_doc_root(doc);
|
wfp_json const * root = wfp_impl_json_doc_root(doc);
|
||||||
ASSERT_TRUE(wfp_impl_json_is_bool(root));
|
ASSERT_TRUE(wfp_impl_json_is_bool(root));
|
||||||
ASSERT_FALSE(wfp_impl_json_get_bool(root));
|
ASSERT_FALSE(wfp_impl_json_bool_get(root));
|
||||||
|
|
||||||
wfp_impl_json_doc_dispose(doc);
|
wfp_impl_json_doc_dispose(doc);
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ TEST(json_parser, parse_int)
|
|||||||
ASSERT_NE(nullptr, doc);
|
ASSERT_NE(nullptr, doc);
|
||||||
wfp_json const * root = wfp_impl_json_doc_root(doc);
|
wfp_json const * root = wfp_impl_json_doc_root(doc);
|
||||||
ASSERT_TRUE(wfp_impl_json_is_int(root));
|
ASSERT_TRUE(wfp_impl_json_is_int(root));
|
||||||
ASSERT_EQ(42, wfp_impl_json_get_int(root));
|
ASSERT_EQ(42, wfp_impl_json_int_get(root));
|
||||||
|
|
||||||
wfp_impl_json_doc_dispose(doc);
|
wfp_impl_json_doc_dispose(doc);
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ TEST(json_parser, parse_negative_int)
|
|||||||
ASSERT_NE(nullptr, doc);
|
ASSERT_NE(nullptr, doc);
|
||||||
wfp_json const * root = wfp_impl_json_doc_root(doc);
|
wfp_json const * root = wfp_impl_json_doc_root(doc);
|
||||||
ASSERT_TRUE(wfp_impl_json_is_int(root));
|
ASSERT_TRUE(wfp_impl_json_is_int(root));
|
||||||
ASSERT_EQ(-1234, wfp_impl_json_get_int(root));
|
ASSERT_EQ(-1234, wfp_impl_json_int_get(root));
|
||||||
|
|
||||||
wfp_impl_json_doc_dispose(doc);
|
wfp_impl_json_doc_dispose(doc);
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ TEST(json_parser, parse_string)
|
|||||||
ASSERT_NE(nullptr, doc);
|
ASSERT_NE(nullptr, doc);
|
||||||
wfp_json const * root = wfp_impl_json_doc_root(doc);
|
wfp_json const * root = wfp_impl_json_doc_root(doc);
|
||||||
ASSERT_TRUE(wfp_impl_json_is_string(root));
|
ASSERT_TRUE(wfp_impl_json_is_string(root));
|
||||||
ASSERT_STREQ("brummni", wfp_impl_json_get_string(root));
|
ASSERT_STREQ("brummni", wfp_impl_json_string_get(root));
|
||||||
|
|
||||||
wfp_impl_json_doc_dispose(doc);
|
wfp_impl_json_doc_dispose(doc);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ TEST(wfp_json_response, init_result)
|
|||||||
|
|
||||||
ASSERT_EQ(nullptr, response.error);
|
ASSERT_EQ(nullptr, response.error);
|
||||||
ASSERT_TRUE(wfp_impl_json_is_int(response.result));
|
ASSERT_TRUE(wfp_impl_json_is_int(response.result));
|
||||||
ASSERT_EQ(47, wfp_impl_json_get_int(response.result));
|
ASSERT_EQ(47, wfp_impl_json_int_get(response.result));
|
||||||
ASSERT_EQ(11, response.id);
|
ASSERT_EQ(11, response.id);
|
||||||
|
|
||||||
wfp_jsonrpc_response_cleanup(&response);
|
wfp_jsonrpc_response_cleanup(&response);
|
||||||
|
@ -24,7 +24,7 @@ static void webfuse_test_MockRequest_respond(
|
|||||||
wfp_json const * id_holder = wfp_impl_json_object_get(response, "id");
|
wfp_json const * id_holder = wfp_impl_json_object_get(response, "id");
|
||||||
if (wfp_impl_json_is_int(id_holder))
|
if (wfp_impl_json_is_int(id_holder))
|
||||||
{
|
{
|
||||||
id = wfp_impl_json_get_int(id_holder);
|
id = wfp_impl_json_int_get(id_holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nullptr != result)
|
if (nullptr != result)
|
||||||
@ -40,7 +40,7 @@ static void webfuse_test_MockRequest_respond(
|
|||||||
wfp_json const * error_code_holder = wfp_impl_json_object_get(response, "error");
|
wfp_json const * error_code_holder = wfp_impl_json_object_get(response, "error");
|
||||||
if (wfp_impl_json_is_int(error_code_holder))
|
if (wfp_impl_json_is_int(error_code_holder))
|
||||||
{
|
{
|
||||||
error_code = wfp_impl_json_get_int(error_code_holder);
|
error_code = wfp_impl_json_int_get(error_code_holder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,21 +21,21 @@ public:
|
|||||||
MATCHER_P3(StatMatcher, inode, mode, file_type, "")
|
MATCHER_P3(StatMatcher, inode, mode, file_type, "")
|
||||||
{
|
{
|
||||||
wfp_json const * inode_holder = wfp_impl_json_object_get(arg, "inode");
|
wfp_json const * inode_holder = wfp_impl_json_object_get(arg, "inode");
|
||||||
if ((!wfp_impl_json_is_int(inode_holder)) || (inode != wfp_impl_json_get_int(inode_holder)))
|
if ((!wfp_impl_json_is_int(inode_holder)) || (inode != wfp_impl_json_int_get(inode_holder)))
|
||||||
{
|
{
|
||||||
*result_listener << "missing inode";
|
*result_listener << "missing inode";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wfp_json const * mode_holder = wfp_impl_json_object_get(arg, "mode");
|
wfp_json const * mode_holder = wfp_impl_json_object_get(arg, "mode");
|
||||||
if ((!wfp_impl_json_is_int(mode_holder)) || (mode != wfp_impl_json_get_int(mode_holder)))
|
if ((!wfp_impl_json_is_int(mode_holder)) || (mode != wfp_impl_json_int_get(mode_holder)))
|
||||||
{
|
{
|
||||||
*result_listener << "missing mode";
|
*result_listener << "missing mode";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wfp_json const * type_holder = wfp_impl_json_object_get(arg, "type");
|
wfp_json const * type_holder = wfp_impl_json_object_get(arg, "type");
|
||||||
if ((!wfp_impl_json_is_string(type_holder)) || (0 != strcmp(file_type, wfp_impl_json_get_string(type_holder))))
|
if ((!wfp_impl_json_is_string(type_holder)) || (0 != strcmp(file_type, wfp_impl_json_string_get(type_holder))))
|
||||||
{
|
{
|
||||||
*result_listener << "missing type";
|
*result_listener << "missing type";
|
||||||
return false;
|
return false;
|
||||||
@ -47,7 +47,7 @@ MATCHER_P3(StatMatcher, inode, mode, file_type, "")
|
|||||||
MATCHER_P(OpenMatcher, handle, "")
|
MATCHER_P(OpenMatcher, handle, "")
|
||||||
{
|
{
|
||||||
wfp_json const * handle_holder = wfp_impl_json_object_get(arg, "handle");
|
wfp_json const * handle_holder = wfp_impl_json_object_get(arg, "handle");
|
||||||
if ((!wfp_impl_json_is_int(handle_holder)) || (handle != wfp_impl_json_get_int(handle_holder)))
|
if ((!wfp_impl_json_is_int(handle_holder)) || (handle != wfp_impl_json_int_get(handle_holder)))
|
||||||
{
|
{
|
||||||
*result_listener << "missing handle";
|
*result_listener << "missing handle";
|
||||||
return false;
|
return false;
|
||||||
@ -59,23 +59,23 @@ MATCHER_P(OpenMatcher, handle, "")
|
|||||||
MATCHER_P3(ReadResultMatcher, data, format, count, "")
|
MATCHER_P3(ReadResultMatcher, data, format, count, "")
|
||||||
{
|
{
|
||||||
wfp_json const * format_holder = wfp_impl_json_object_get(arg, "format");
|
wfp_json const * format_holder = wfp_impl_json_object_get(arg, "format");
|
||||||
if ((!wfp_impl_json_is_string(format_holder)) || (0 != strcmp(format, wfp_impl_json_get_string(format_holder))))
|
if ((!wfp_impl_json_is_string(format_holder)) || (0 != strcmp(format, wfp_impl_json_string_get(format_holder))))
|
||||||
{
|
{
|
||||||
*result_listener << "invalid or missing format: " << wfp_impl_json_get_string(format_holder);
|
*result_listener << "invalid or missing format: " << wfp_impl_json_string_get(format_holder);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wfp_json const * count_holder = wfp_impl_json_object_get(arg, "count");
|
wfp_json const * count_holder = wfp_impl_json_object_get(arg, "count");
|
||||||
if ((!wfp_impl_json_is_int(count_holder)) || (count != wfp_impl_json_get_int(count_holder)))
|
if ((!wfp_impl_json_is_int(count_holder)) || (count != wfp_impl_json_int_get(count_holder)))
|
||||||
{
|
{
|
||||||
*result_listener << "invalid or missing count: " << wfp_impl_json_get_int(count_holder);
|
*result_listener << "invalid or missing count: " << wfp_impl_json_int_get(count_holder);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wfp_json const * data_holder = wfp_impl_json_object_get(arg, "data");
|
wfp_json const * data_holder = wfp_impl_json_object_get(arg, "data");
|
||||||
if ((!wfp_impl_json_is_string(data_holder)) || (0 != strcmp(data, wfp_impl_json_get_string(data_holder))))
|
if ((!wfp_impl_json_is_string(data_holder)) || (0 != strcmp(data, wfp_impl_json_string_get(data_holder))))
|
||||||
{
|
{
|
||||||
*result_listener << "invalid or missing data: " << wfp_impl_json_get_string(data_holder);
|
*result_listener << "invalid or missing data: " << wfp_impl_json_string_get(data_holder);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ MATCHER_P(ReaddirMatcher, contained_elements , "")
|
|||||||
wfp_json const * value = wfp_impl_json_array_get(arg, j);
|
wfp_json const * value = wfp_impl_json_array_get(arg, j);
|
||||||
wfp_json const * name = wfp_impl_json_object_get(value, "name");
|
wfp_json const * name = wfp_impl_json_object_get(value, "name");
|
||||||
|
|
||||||
found = (0 == strcmp(element, wfp_impl_json_get_string(name)));
|
found = (0 == strcmp(element, wfp_impl_json_string_get(name)));
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -155,13 +155,13 @@ TEST(Client, Lookup)
|
|||||||
wfp_json const * result = wfp_impl_json_object_get(response, "result");
|
wfp_json const * result = wfp_impl_json_object_get(response, "result");
|
||||||
|
|
||||||
wfp_json const * inode = wfp_impl_json_object_get(result, "inode");
|
wfp_json const * inode = wfp_impl_json_object_get(result, "inode");
|
||||||
ASSERT_EQ(42, wfp_impl_json_get_int(inode));
|
ASSERT_EQ(42, wfp_impl_json_int_get(inode));
|
||||||
|
|
||||||
wfp_json const * mode = wfp_impl_json_object_get(result, "mode");
|
wfp_json const * mode = wfp_impl_json_object_get(result, "mode");
|
||||||
ASSERT_EQ(0644, wfp_impl_json_get_int(mode));
|
ASSERT_EQ(0644, wfp_impl_json_int_get(mode));
|
||||||
|
|
||||||
wfp_json const * type = wfp_impl_json_object_get(result, "type");
|
wfp_json const * type = wfp_impl_json_object_get(result, "type");
|
||||||
ASSERT_STREQ("file", wfp_impl_json_get_string(type));
|
ASSERT_STREQ("file", wfp_impl_json_string_get(type));
|
||||||
|
|
||||||
client.Disconnect();
|
client.Disconnect();
|
||||||
ASSERT_EQ(std::future_status::ready, disconnected.get_future().wait_for(TIMEOUT));
|
ASSERT_EQ(std::future_status::ready, disconnected.get_future().wait_for(TIMEOUT));
|
||||||
@ -203,7 +203,7 @@ TEST(Client, LookupFail)
|
|||||||
wfp_json const * error = wfp_impl_json_object_get(response, "error");
|
wfp_json const * error = wfp_impl_json_object_get(response, "error");
|
||||||
|
|
||||||
wfp_json const * code = wfp_impl_json_object_get(error, "code");
|
wfp_json const * code = wfp_impl_json_object_get(error, "code");
|
||||||
ASSERT_NE(0, wfp_impl_json_get_int(code));
|
ASSERT_NE(0, wfp_impl_json_int_get(code));
|
||||||
|
|
||||||
client.Disconnect();
|
client.Disconnect();
|
||||||
ASSERT_EQ(std::future_status::ready, disconnected.get_future().wait_for(TIMEOUT));
|
ASSERT_EQ(std::future_status::ready, disconnected.get_future().wait_for(TIMEOUT));
|
||||||
@ -245,7 +245,7 @@ TEST(Client, Open)
|
|||||||
wfp_json const * result = wfp_impl_json_object_get(response, "result");
|
wfp_json const * result = wfp_impl_json_object_get(response, "result");
|
||||||
|
|
||||||
wfp_json const * handle = wfp_impl_json_object_get(result, "handle");
|
wfp_json const * handle = wfp_impl_json_object_get(result, "handle");
|
||||||
ASSERT_EQ(4711, wfp_impl_json_get_int(handle));
|
ASSERT_EQ(4711, wfp_impl_json_int_get(handle));
|
||||||
|
|
||||||
client.Disconnect();
|
client.Disconnect();
|
||||||
ASSERT_EQ(std::future_status::ready, disconnected.get_future().wait_for(TIMEOUT));
|
ASSERT_EQ(std::future_status::ready, disconnected.get_future().wait_for(TIMEOUT));
|
||||||
@ -288,13 +288,13 @@ TEST(Client, Read)
|
|||||||
wfp_json const * result = wfp_impl_json_object_get(response, "result");
|
wfp_json const * result = wfp_impl_json_object_get(response, "result");
|
||||||
|
|
||||||
wfp_json const * format = wfp_impl_json_object_get(result, "format");
|
wfp_json const * format = wfp_impl_json_object_get(result, "format");
|
||||||
ASSERT_STREQ("base64", wfp_impl_json_get_string(format));
|
ASSERT_STREQ("base64", wfp_impl_json_string_get(format));
|
||||||
|
|
||||||
wfp_json const * count = wfp_impl_json_object_get(result, "count");
|
wfp_json const * count = wfp_impl_json_object_get(result, "count");
|
||||||
ASSERT_EQ(1, wfp_impl_json_get_int(count));
|
ASSERT_EQ(1, wfp_impl_json_int_get(count));
|
||||||
|
|
||||||
wfp_json const * data = wfp_impl_json_object_get(result, "data");
|
wfp_json const * data = wfp_impl_json_object_get(result, "data");
|
||||||
ASSERT_STREQ("Kg==", wfp_impl_json_get_string(data));
|
ASSERT_STREQ("Kg==", wfp_impl_json_string_get(data));
|
||||||
|
|
||||||
client.Disconnect();
|
client.Disconnect();
|
||||||
ASSERT_EQ(std::future_status::ready, disconnected.get_future().wait_for(TIMEOUT));
|
ASSERT_EQ(std::future_status::ready, disconnected.get_future().wait_for(TIMEOUT));
|
||||||
|
@ -109,7 +109,7 @@ public:
|
|||||||
|
|
||||||
wfp_json const * method = wfp_impl_json_object_get(request, "method");
|
wfp_json const * method = wfp_impl_json_object_get(request, "method");
|
||||||
ASSERT_TRUE(wfp_impl_json_is_string(method));
|
ASSERT_TRUE(wfp_impl_json_is_string(method));
|
||||||
ASSERT_STREQ("authenticate", wfp_impl_json_get_string(method));
|
ASSERT_STREQ("authenticate", wfp_impl_json_string_get(method));
|
||||||
|
|
||||||
wfp_json const * id = wfp_impl_json_object_get(request, "id");
|
wfp_json const * id = wfp_impl_json_object_get(request, "id");
|
||||||
ASSERT_TRUE(wfp_impl_json_is_int(id));
|
ASSERT_TRUE(wfp_impl_json_is_int(id));
|
||||||
@ -120,21 +120,21 @@ public:
|
|||||||
|
|
||||||
wfp_json const * type = wfp_impl_json_array_get(params, 0);
|
wfp_json const * type = wfp_impl_json_array_get(params, 0);
|
||||||
ASSERT_TRUE(wfp_impl_json_is_string(type));
|
ASSERT_TRUE(wfp_impl_json_is_string(type));
|
||||||
ASSERT_STREQ("username", wfp_impl_json_get_string(type));
|
ASSERT_STREQ("username", wfp_impl_json_string_get(type));
|
||||||
|
|
||||||
wfp_json const * credentials = wfp_impl_json_array_get(params, 1);
|
wfp_json const * credentials = wfp_impl_json_array_get(params, 1);
|
||||||
ASSERT_TRUE(wfp_impl_json_is_object(credentials));
|
ASSERT_TRUE(wfp_impl_json_is_object(credentials));
|
||||||
|
|
||||||
wfp_json const * username = wfp_impl_json_object_get(credentials, "username");
|
wfp_json const * username = wfp_impl_json_object_get(credentials, "username");
|
||||||
ASSERT_TRUE(wfp_impl_json_is_string(username));
|
ASSERT_TRUE(wfp_impl_json_is_string(username));
|
||||||
ASSERT_STREQ(expected_username.c_str(), wfp_impl_json_get_string(username));
|
ASSERT_STREQ(expected_username.c_str(), wfp_impl_json_string_get(username));
|
||||||
|
|
||||||
wfp_json const * password = wfp_impl_json_object_get(credentials, "password");
|
wfp_json const * password = wfp_impl_json_object_get(credentials, "password");
|
||||||
ASSERT_TRUE(wfp_impl_json_is_string(password));
|
ASSERT_TRUE(wfp_impl_json_is_string(password));
|
||||||
ASSERT_STREQ(expected_password.c_str(), wfp_impl_json_get_string(password));
|
ASSERT_STREQ(expected_password.c_str(), wfp_impl_json_string_get(password));
|
||||||
|
|
||||||
std::ostringstream response;
|
std::ostringstream response;
|
||||||
response << "{\"result\": {}, \"id\": " << wfp_impl_json_get_int(id) << "}";
|
response << "{\"result\": {}, \"id\": " << wfp_impl_json_int_get(id) << "}";
|
||||||
SendToClient(response.str());
|
SendToClient(response.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ public:
|
|||||||
|
|
||||||
wfp_json const * method = wfp_impl_json_object_get(request, "method");
|
wfp_json const * method = wfp_impl_json_object_get(request, "method");
|
||||||
ASSERT_TRUE(wfp_impl_json_is_string(method));
|
ASSERT_TRUE(wfp_impl_json_is_string(method));
|
||||||
ASSERT_STREQ("add_filesystem", wfp_impl_json_get_string(method));
|
ASSERT_STREQ("add_filesystem", wfp_impl_json_string_get(method));
|
||||||
|
|
||||||
wfp_json const * params = wfp_impl_json_object_get(request, "params");
|
wfp_json const * params = wfp_impl_json_object_get(request, "params");
|
||||||
ASSERT_TRUE(wfp_impl_json_is_array(params));
|
ASSERT_TRUE(wfp_impl_json_is_array(params));
|
||||||
@ -159,7 +159,7 @@ public:
|
|||||||
ASSERT_TRUE(wfp_impl_json_is_int(id));
|
ASSERT_TRUE(wfp_impl_json_is_int(id));
|
||||||
|
|
||||||
std::ostringstream response;
|
std::ostringstream response;
|
||||||
response << "{\"result\": {\"id\": \"" << wfp_impl_json_get_string(filesystem) << "\"}, \"id\": " << wfp_impl_json_get_int(id) << "}";
|
response << "{\"result\": {\"id\": \"" << wfp_impl_json_string_get(filesystem) << "\"}, \"id\": " << wfp_impl_json_int_get(id) << "}";
|
||||||
|
|
||||||
SendToClient(response.str());
|
SendToClient(response.str());
|
||||||
}
|
}
|
||||||
|
@ -205,13 +205,13 @@ public:
|
|||||||
wfp_json const * method = wfp_impl_json_object_get(message, "method");
|
wfp_json const * method = wfp_impl_json_object_get(message, "method");
|
||||||
if (wfp_impl_json_is_string(method))
|
if (wfp_impl_json_is_string(method))
|
||||||
{
|
{
|
||||||
if (0 == strcmp("add_filesystem", wfp_impl_json_get_string(method)))
|
if (0 == strcmp("add_filesystem", wfp_impl_json_string_get(method)))
|
||||||
{
|
{
|
||||||
wfp_json const * id = wfp_impl_json_object_get(message, "id");
|
wfp_json const * id = wfp_impl_json_object_get(message, "id");
|
||||||
|
|
||||||
std::ostringstream response;
|
std::ostringstream response;
|
||||||
response << "{\"result\": {\"id\": \"" << GetFilesystem() << "\"}, "
|
response << "{\"result\": {\"id\": \"" << GetFilesystem() << "\"}, "
|
||||||
<< "\"id\": " << wfp_impl_json_get_int(id) << "}";
|
<< "\"id\": " << wfp_impl_json_int_get(id) << "}";
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(mutex);
|
std::unique_lock<std::mutex> lock(mutex);
|
||||||
write_queue.push(response.str());
|
write_queue.push(response.str());
|
||||||
|
Loading…
Reference in New Issue
Block a user