summaryrefslogtreecommitdiffstats
path: root/util/test/url
diff options
context:
space:
mode:
Diffstat (limited to 'util/test/url')
-rw-r--r--util/test/url/Makefile.am13
-rw-r--r--util/test/url/build.sh3
-rw-r--r--util/test/url/url_test.c130
3 files changed, 146 insertions, 0 deletions
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 <axutil_url.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)
+{
+ 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;
+}
+
+
+