summaryrefslogtreecommitdiffstats
path: root/util/test/url/url_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/test/url/url_test.c')
-rw-r--r--util/test/url/url_test.c115
1 files changed, 24 insertions, 91 deletions
diff --git a/util/test/url/url_test.c b/util/test/url/url_test.c
index 65f93da..69c88d8 100644
--- a/util/test/url/url_test.c
+++ b/util/test/url/url_test.c
@@ -1,11 +1,12 @@
#include <axutil_url.h>
+#include <cut_defs.h>
#include "../util/create_env.h"
/** @brief test url
* create URL and get the values of it's components
*/
-axis2_status_t test_url(axutil_env_t *env)
+void test_url(axutil_env_t *env)
{
axutil_url_t * url;
axis2_char_t *url_str = "https://issues.apache.org/jira/secure/ManageAttachments.jspa?id=12386356";
@@ -20,109 +21,41 @@ axis2_status_t test_url(axutil_env_t *env)
axis2_status_t status;
url = axutil_url_parse_string(env,url_str);
- if(url)
- {
- printf("The url is created \n");
- }
- else
- {
- return AXIS2_FAILURE;
- }
-
- status = axutil_url_set_protocol(url,env,set_protocol);
-
- if (status == AXIS2_SUCCESS)
- printf("The test 1 is successful\n");
- else
- printf("The test 1 failed\n") ;
-
- status = axutil_url_set_server(url,env,set_server);
-
- if (status == AXIS2_SUCCESS)
- printf("The test 2 is successful\n");
- else
- printf("The test 2 failed\n") ;
-
- status = axutil_url_set_port(url,env,set_port);
-
- if (status == AXIS2_SUCCESS)
- printf("The test 3 is successful\n");
- else
- printf("The test 3 failed\n") ;
-
- status = axutil_url_set_path(url,env,set_path);
-
- if (status == AXIS2_SUCCESS)
- printf("The test 4 is successful\n");
- else
- printf("The test 4 failed\n") ;
-
+ CUT_ASSERT_PTR_NOT_EQUAL(url, NULL, 1);
+
+ status = axutil_url_set_protocol(url,env,set_protocol);
+ CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 0);
+ status = axutil_url_set_server(url,env,set_server);
+ CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 0);
+ status = axutil_url_set_port(url,env,set_port);
+ CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 0);
+ status = axutil_url_set_path(url,env,set_path);
+ CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 0);
+
get_protocol = axutil_url_get_protocol(url,env);
-
- if (!get_protocol)
- {
- axutil_url_free(url,env);
- return AXIS2_FAILURE;
- }
- else
- {
- printf("The protocol is %s\n",get_protocol);
- }
+ CUT_ASSERT_STR_EQUAL(get_protocol, set_protocol, 0);
get_server = axutil_url_get_server(url,env);
+ CUT_ASSERT_STR_EQUAL(get_server, "www.yahoo.com:80", 0);
- if (!get_server)
- {
- axutil_url_free(url,env);
- return AXIS2_FAILURE;
- }
- else
- {
- printf("The server is %s\n",get_server);
- }
-
get_port = axutil_url_get_port(url,env);
-
- if (!get_port)
- {
- axutil_url_free(url,env);
- return AXIS2_FAILURE;
- }
- else
- {
- printf("The port is %d\n",get_port);
- }
+ CUT_ASSERT_INT_EQUAL(get_port,set_port,0);
get_path = axutil_url_get_path(url,env);
-
- if (!get_path)
- {
- axutil_url_free(url,env);
- return AXIS2_FAILURE;
- }
- else
- {
- printf("The path is %s\n",get_path);
- }
+ CUT_ASSERT_STR_EQUAL(get_path, set_path, 0);
axutil_url_free(url,env);
- return AXIS2_SUCCESS;
}
int main()
{
- int status = AXIS2_SUCCESS;
- axutil_env_t *env = NULL;
-
- env = create_environment();
- status = test_url(env);
-
- if(status == AXIS2_FAILURE)
- {
- printf("Test failed");
- }
- axutil_env_free(env);
-
+ axutil_env_t *env = cut_setup_env("Url");
+ CUT_ASSERT(env != NULL);
+ if (env) {
+ test_url(env);
+ axutil_env_free(env);
+ }
+ CUT_RETURN_ON_FAILURE(-1);
return 0;
}