1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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;
}
|