39 static const char *test_category =
"/stasis/res/";
47 info->name = __func__;
48 info->category = test_category;
49 info->summary =
"Test stasis app invocation.";
50 info->description =
"Test stasis app invocation.";
51 return AST_TEST_NOT_RUN;
57 ast_test_validate(
test, -1 == res);
67 static void app_data_dtor(
void *obj)
72 actual->messages = NULL;
75 static struct app_data *app_data_create(
void)
91 ++(actual->invocations);
106 info->name = __func__;
107 info->category = test_category;
108 info->summary =
"Test stasis app invocation.";
109 info->description =
"Test stasis app invocation.";
110 return AST_TEST_NOT_RUN;
115 app_name =
"test-handler";
124 ast_test_validate(
test, 0 == res);
128 return AST_TEST_PASS;
144 info->name = __func__;
145 info->category = test_category;
146 info->summary =
"Test stasis app invocation.";
147 info->description =
"Test stasis app invocation.";
148 return AST_TEST_NOT_RUN;
153 app_name =
"test-handler";
155 app_data1 = app_data_create();
156 app_data2 = app_data_create();
161 "type",
"ApplicationReplaced",
162 "application", app_name,
168 ast_test_validate(
test, 0 == res);
169 ast_test_validate(
test, 1 == app_data1->invocations);
174 ast_test_validate(
test, 1 == app_data2->invocations);
177 return AST_TEST_PASS;
180 static int unload_module(
void)
182 AST_TEST_UNREGISTER(app_invoke_dne);
183 AST_TEST_UNREGISTER(app_invoke_one);
184 AST_TEST_UNREGISTER(app_replaced);
188 static int load_module(
void)
190 AST_TEST_REGISTER(app_replaced);
191 AST_TEST_REGISTER(app_invoke_one);
192 AST_TEST_REGISTER(app_invoke_dne);
196 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,
"Stasis Core testing",
197 .support_level = AST_MODULE_SUPPORT_CORE,
199 .unload = unload_module,
200 .requires =
"res_stasis",
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Asterisk main include file. File version handling, generic pbx functions.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
char * ast_eid_to_str(char *s, int maxlen, struct ast_eid *eid)
Convert an EID to a string.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
int ast_json_object_del(struct ast_json *object, const char *key)
Delete a field from a JSON object.
struct ast_json * ast_json_null(void)
Get the JSON null value.
void stasis_app_unregister(const char *app_name)
Unregister a Stasis application.
struct ast_json * ast_json_array_create(void)
Create a empty JSON array.
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
const char * app_name(struct ast_app *app)
int stasis_app_register(const char *app_name, stasis_app_cb handler, void *data)
Register a new Stasis application.
int stasis_app_send(const char *app_name, struct ast_json *message)
Send a message to the given Stasis application.
struct ast_eid ast_eid_default
Global EID.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
int ast_json_equal(const struct ast_json *lhs, const struct ast_json *rhs)
Compare two JSON objects.
#define AST_TEST_DEFINE(hdr)
Abstract JSON element (object, array, string, int, ...).
Stasis Application API. See Stasis Application API for detailed documentation.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
struct ast_json * ast_json_copy(const struct ast_json *value)
Copy a JSON value, but not its children.