summaryrefslogtreecommitdiffstats
path: root/util/test/url
diff options
context:
space:
mode:
authorGravatar damitha2010-07-08 06:38:10 +0000
committerGravatar damitha2010-07-08 06:38:10 +0000
commitc8d5aeb5d3048e8a037f1884b59cef8adf7e25b2 (patch)
tree6edd50a5f63708b4c916614809082d9c1090b262 /util/test/url
parent4a01960cba446e046d5687279c024fa60b576d85 (diff)
downloadaxis2c-c8d5aeb5d3048e8a037f1884b59cef8adf7e25b2.tar.gz
axis2c-c8d5aeb5d3048e8a037f1884b59cef8adf7e25b2.tar.bz2
Added the simple test suite suggested in AXIS2C-1412
git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@961590 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'util/test/url')
-rw-r--r--util/test/url/Makefile.am4
-rw-r--r--util/test/url/url_test.c115
2 files changed, 27 insertions, 92 deletions
diff --git a/util/test/url/Makefile.am b/util/test/url/Makefile.am
index ff7b8fb..cade661 100644
--- a/util/test/url/Makefile.am
+++ b/util/test/url/Makefile.am
@@ -7,7 +7,9 @@ url_test_LDADD = \
$(top_builddir)/src/libaxutil.la
INCLUDES = -I$(top_builddir)/include \
+ -I$(CUTEST_HOME)/include \
-I ../../../axiom/include \
- -I ../../../include
+ -I ../../../include \
+ -I ../../../cutest/include
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;
}