From 0425aadc78680e53000fd0108b540d6eca048516 Mon Sep 17 00:00:00 2001 From: gmcdonald Date: Sat, 13 Feb 2010 01:32:03 +0000 Subject: Moving axis svn, part of TLP move INFRA-2441 git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@909681 13f79535-47bb-0310-9956-ffa450edef68 --- util/test/url/Makefile.am | 13 +++++ util/test/url/build.sh | 3 ++ util/test/url/url_test.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+) create mode 100644 util/test/url/Makefile.am create mode 100644 util/test/url/build.sh create mode 100644 util/test/url/url_test.c (limited to 'util/test/url') diff --git a/util/test/url/Makefile.am b/util/test/url/Makefile.am new file mode 100644 index 0000000..ff7b8fb --- /dev/null +++ b/util/test/url/Makefile.am @@ -0,0 +1,13 @@ +TESTS = url_test +noinst_PROGRAMS = url_test +check_PROGRAMS = url_test +url_test_SOURCES = url_test.c ../util/create_env.c + +url_test_LDADD = \ + $(top_builddir)/src/libaxutil.la + +INCLUDES = -I$(top_builddir)/include \ + -I ../../../axiom/include \ + -I ../../../include + + diff --git a/util/test/url/build.sh b/util/test/url/build.sh new file mode 100644 index 0000000..455a8a9 --- /dev/null +++ b/util/test/url/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +gcc url_test.c ../util/create_env.c -g -Werror -I$AXIS2C_HOME/include/axis2-1.3.0 -L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -laxis2_parser -o url_test -ldl -Wl,--rpath -Wl,$AXIS2C_HOME/lib diff --git a/util/test/url/url_test.c b/util/test/url/url_test.c new file mode 100644 index 0000000..65f93da --- /dev/null +++ b/util/test/url/url_test.c @@ -0,0 +1,130 @@ +#include +#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) +{ + axutil_url_t * url; + axis2_char_t *url_str = "https://issues.apache.org/jira/secure/ManageAttachments.jspa?id=12386356"; + axis2_char_t *set_server = "www.yahoo.com"; + axis2_char_t *set_protocol = "file"; + axis2_char_t *set_path = "/bar/"; + axis2_port_t set_port = 80; + axis2_char_t *get_protocol; + axis2_char_t *get_server; + axis2_port_t get_port; + axis2_char_t *get_path; + 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") ; + + 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); + } + + get_server = axutil_url_get_server(url,env); + + 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); + } + + 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); + } + + 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); + + return 0; +} + + + -- cgit v1.1-32-gdbae