summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/addr/Makefile.am7
-rw-r--r--test/core/addr/test_addr.c147
-rw-r--r--test/core/clientapi/Makefile.am67
-rw-r--r--test/core/clientapi/test_client.c79
-rw-r--r--test/core/clientapi/test_clientapi.c3
-rw-r--r--test/core/clientapi/test_svc_client_handler_count.c2
-rw-r--r--test/core/context/Makefile.am7
-rw-r--r--test/core/context/test_context.c55
-rw-r--r--test/core/deployment/Makefile.am22
-rw-r--r--test/core/deployment/test_deployment.c133
-rw-r--r--test/core/description/Makefile.am4
-rw-r--r--test/core/description/test_description.c141
-rw-r--r--test/core/engine/Makefile.am6
-rw-r--r--test/core/engine/test_engine.c61
-rw-r--r--test/core/transport/http/Makefile.am49
-rw-r--r--test/core/transport/http/test_http_transport.c106
16 files changed, 405 insertions, 484 deletions
diff --git a/test/core/addr/Makefile.am b/test/core/addr/Makefile.am
index 02352b8..a04ad8d 100644
--- a/test/core/addr/Makefile.am
+++ b/test/core/addr/Makefile.am
@@ -11,11 +11,12 @@ test_addr_LDADD = \
../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
$(top_builddir)/neethi/src/libneethi.la \
$(top_builddir)/src/core/engine/libaxis2_engine.la \
- $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la
+ $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la
-INCLUDES = -I${CUTEST_HOME}/include \
+INCLUDES = -I$(CUTEST_HOME)/include \
-I$(top_builddir)/src/xml/guththila \
-I$(top_builddir)/include \
-I ../../../util/include \
- -I ../../../axiom/include
+ -I ../../../axiom/include \
+ -I ../../../cutest/include
diff --git a/test/core/addr/test_addr.c b/test/core/addr/test_addr.c
index c013a57..ad75511 100644
--- a/test/core/addr/test_addr.c
+++ b/test/core/addr/test_addr.c
@@ -21,10 +21,10 @@
#include <axutil_allocator.h>
#include <axis2_endpoint_ref.h>
#include <stdio.h>
+#include <cut_defs.h>
-int
-axis2_test_msg_info_headers(
- )
+void
+axis2_test_msg_info_headers(axutil_env_t *env)
{
axis2_endpoint_ref_t *to = NULL;
axis2_endpoint_ref_t *from = NULL;
@@ -33,9 +33,7 @@ axis2_test_msg_info_headers(
axis2_endpoint_ref_t *axis2_endpoint_ref = NULL;
axis2_status_t status = AXIS2_FAILURE;
axis2_msg_info_headers_t *axis2_msg_info_headers = NULL;
- axutil_allocator_t *allocator = axutil_allocator_init(NULL);
- const axutil_env_t *env = axutil_env_create(allocator);
- const axis2_char_t *action = "test action";
+ axis2_char_t *action = "test action";
const axis2_char_t *get_action = NULL;
to = axis2_endpoint_ref_create(env, "to");
from = axis2_endpoint_ref_create(env, "from");
@@ -43,140 +41,57 @@ axis2_test_msg_info_headers(
fault_to = axis2_endpoint_ref_create(env, "fault to");
axis2_msg_info_headers = axis2_msg_info_headers_create(env, NULL, action);
- if (axis2_msg_info_headers)
- printf("SUCCESS axis2_msg_info_headers_create\n");
- else
- {
- printf("ERROR AXIS2_MSG_INFO_HEADERS_CREATE\n");
- return -1;
- }
-
+ CUT_ASSERT_PTR_NOT_EQUAL(axis2_msg_info_headers, NULL, 1);
status = axis2_msg_info_headers_set_to(axis2_msg_info_headers, env, to);
-
- if (status == AXIS2_SUCCESS)
- printf("SUCCESS axis2_msg_info_headers_set_to\n");
- else
- {
- printf("ERROR axis2_msg_info_headers_set_to");
- return -1;
- }
+ CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 1);
axis2_endpoint_ref =
axis2_msg_info_headers_get_to(axis2_msg_info_headers, env);
+ CUT_ASSERT_PTR_NOT_EQUAL(axis2_endpoint_ref, NULL, 1);
- if (axis2_endpoint_ref)
- printf("SUCCESS axis2_msg_info_headers_get_to\n");
- else
- {
- printf("ERROR axis2_msg_info_headers_get_to\n");
- return -1;
- }
-
- status = AXIS2_FAILURE;
status = axis2_msg_info_headers_set_from(axis2_msg_info_headers, env, from);
+ CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 1);
- if (status)
- printf("SUCCESS axis2_msg_info_headers_set_from\n");
- else
- {
- printf("ERROR axis2_msg_info_headers_set_from\n");
- return -1;
- }
-
- axis2_endpoint_ref = NULL;
axis2_endpoint_ref =
axis2_msg_info_headers_get_from(axis2_msg_info_headers, env);
+ CUT_ASSERT_PTR_NOT_EQUAL(axis2_endpoint_ref, NULL, 1);
- if (axis2_endpoint_ref)
- printf("SUCCESS axis2_msg_info_headers_get_from\n");
- else
- {
- printf("ERROR axis2_msg_info_headers_get_from\n");
- return -1;
- }
-
- axis2_endpoint_ref = NULL;
axis2_endpoint_ref =
axis2_msg_info_headers_get_reply_to(axis2_msg_info_headers, env);
+ CUT_ASSERT_PTR_EQUAL(axis2_endpoint_ref, NULL, 0);
- if (status)
- printf("SUCCESS axis2_msg_info_headers_get_reply_to\n");
- else
- {
- printf("ERROR axis2_msg_info_headers_get_reply_to\n");
- return -1;
- }
-
- status = AXIS2_FAILURE;
status =
- axis2_msg_info_headers_set_reply_to(axis2_msg_info_headers, env,
- reply_to);
-
- if (status)
- printf("SUCCESS axis2_msg_info_headers_set_reply_to\n");
- else
- {
- printf("ERROR axis2_msg_info_headers_set_reply_to\n");
- return -1;
- }
-
- status = AXIS2_FAILURE;
+ axis2_msg_info_headers_set_reply_to(axis2_msg_info_headers, env, reply_to);
+ CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 1);
+ axis2_endpoint_ref =
+ axis2_msg_info_headers_get_reply_to(axis2_msg_info_headers, env);
+ CUT_ASSERT_PTR_NOT_EQUAL(axis2_endpoint_ref, NULL, 1);
status =
- axis2_msg_info_headers_set_fault_to(axis2_msg_info_headers, env,
- fault_to);
- if (status)
- printf("SUCCESS axis2_msg_info_headers_set_fault_to\n");
- else
- {
- printf("ERROR axis2_msg_info_headers_set_fault_to\n");
- return -1;
- }
+ axis2_msg_info_headers_set_fault_to(axis2_msg_info_headers, env, fault_to);
+ CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 0);
- axis2_endpoint_ref = NULL;
axis2_endpoint_ref =
axis2_msg_info_headers_get_fault_to(axis2_msg_info_headers, env);
- if (axis2_endpoint_ref)
- printf("SUCCESS axis2_msg_info_headers_get_fault_to\n");
- else
- {
- printf("ERROR axis2_msg_info_headers_get_fault_to\n");
- return -1;
- }
+ CUT_ASSERT_PTR_NOT_EQUAL(axis2_endpoint_ref, NULL, 0);
get_action = axis2_msg_info_headers_get_action(axis2_msg_info_headers, env);
- if (get_action)
- printf("SUCCESS axis2_msg_info_headers_get_action\n");
- else
- {
- printf("ERROR axis2_msg_info_headers_get_action\n");
- return -1;
- }
-
- status = AXIS2_FAILURE;
+ CUT_ASSERT_STR_EQUAL(get_action, action, 0);
+
status =
axis2_msg_info_headers_set_action(axis2_msg_info_headers, env, action);
- if (status)
- printf("SUCCESS axis2_msg_info_headers_set_action\n");
- else
- {
- printf("ERROR axis2_msg_info_headers_set_action\n");
- }
+ CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 0);
- status = AXIS2_FAILURE;
- /* status = axis2_msg_info_headers_free(axis2_msg_info_headers, env); */
- if (status)
- printf("SUCCESS axis2_msg_info_headers_free\n");
- else
- {
- printf("ERROR axis2_msg_info_headers_free\n");
- }
- return 0;
+ axis2_msg_info_headers_free(axis2_msg_info_headers, env);
}
-int
-main(
- )
+int main()
{
- axis2_test_msg_info_headers();
- return 0;
+ axutil_env_t *env = cut_setup_env("Core Addr");
+ CUT_ASSERT(env != NULL);
+ if (env) {
+ axis2_test_msg_info_headers(env);
+ axutil_env_free(env);
+ }
+ CUT_RETURN_ON_FAILURE(-1);
+ return 0;
}
diff --git a/test/core/clientapi/Makefile.am b/test/core/clientapi/Makefile.am
index b47041d..00ab2c4 100644
--- a/test/core/clientapi/Makefile.am
+++ b/test/core/clientapi/Makefile.am
@@ -2,45 +2,52 @@ TESTS = test_client test_clientapi test_svc_client_handler_count
noinst_PROGRAMS = test_client test_clientapi test_svc_client_handler_count
check_PROGRAMS = test_client test_clientapi test_svc_client_handler_count
SUBDIRS =
-AM_CFLAGS = -g
+AM_CFLAGS = -g -pthread
test_client_SOURCES = test_client.c
test_clientapi_SOURCES = test_clientapi.c
test_svc_client_handler_count_SOURCES = test_svc_client_handler_count.c
test_clientapi_LDADD = \
- ../../../util/src/libaxutil.la \
- ../../../axiom/src/om/libaxis2_axiom.la \
- ../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
- $(top_builddir)/neethi/src/libneethi.la \
- $(top_builddir)/src/core/engine/libaxis2_engine.la \
- $(top_builddir)/src/core/transport/http/sender/libaxis2_http_sender.la
+ ../../../util/src/libaxutil.la \
+ ../../../axiom/src/om/libaxis2_axiom.la \
+ ../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
+ $(top_builddir)/neethi/src/libneethi.la \
+ -lpthread \
+ $(top_builddir)/src/core/engine/libaxis2_engine.la \
+ $(top_builddir)/src/core/transport/http/sender/libaxis2_http_sender.la
test_client_LDADD = \
- ../../../util/src/libaxutil.la \
- ../../../axiom/src/om/libaxis2_axiom.la \
- ../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
- $(top_builddir)/neethi/src/libneethi.la \
- $(top_builddir)/src/core/engine/libaxis2_engine.la \
- $(top_builddir)/src/core/transport/http/sender/libaxis2_http_sender.la
+ ../../../util/src/libaxutil.la \
+ ../../../axiom/src/om/libaxis2_axiom.la \
+ ../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
+ $(top_builddir)/neethi/src/libneethi.la \
+ -lpthread \
+ $(top_builddir)/src/core/engine/libaxis2_engine.la \
+ $(top_builddir)/src/core/transport/http/util/libaxis2_http_util.la \
+ $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la \
+ $(top_builddir)/src/core/transport/http/receiver/libaxis2_http_receiver.la \
+ $(top_builddir)/src/core/transport/http/sender/libaxis2_http_sender.la
test_svc_client_handler_count_LDADD = \
- ../../../util/src/libaxutil.la \
- ../../../axiom/src/om/libaxis2_axiom.la \
- ../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
- $(top_builddir)/neethi/src/libneethi.la \
- $(top_builddir)/src/core/engine/libaxis2_engine.la \
- $(top_builddir)/src/core/transport/http/sender/libaxis2_http_sender.la
+ ../../../util/src/libaxutil.la \
+ ../../../axiom/src/om/libaxis2_axiom.la \
+ ../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
+ $(top_builddir)/neethi/src/libneethi.la \
+ -lpthread \
+ $(top_builddir)/src/core/engine/libaxis2_engine.la \
+ $(top_builddir)/src/core/transport/http/sender/libaxis2_http_sender.la
-INCLUDES = -I${CUTEST_HOME}/include \
- -I$(top_builddir)/include \
- -I$(top_builddir)/src/core/description \
- -I$(top_builddir)/src/core/context \
- -I$(top_builddir)/src/core/phaseresolver \
- -I$(top_builddir)/src/core/deployment \
- -I$(top_builddir)/src/core/engine \
- -I$(top_builddir)/src/core/clientapi \
- -I ../../../util/include \
- -I ../../../neethi/include \
- -I ../../../axiom/include
+INCLUDES = -I$(CUTEST_HOME)/include \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/src/core/description \
+ -I$(top_builddir)/src/core/context \
+ -I$(top_builddir)/src/core/phaseresolver \
+ -I$(top_builddir)/src/core/deployment \
+ -I$(top_builddir)/src/core/engine \
+ -I$(top_builddir)/src/core/clientapi \
+ -I ../../../util/include \
+ -I ../../../neethi/include \
+ -I ../../../axiom/include \
+ -I ../../../cutest/include
diff --git a/test/core/clientapi/test_client.c b/test/core/clientapi/test_client.c
index 83a417e..5eb6788 100644
--- a/test/core/clientapi/test_client.c
+++ b/test/core/clientapi/test_client.c
@@ -16,19 +16,15 @@
* limitations under the License.
*/
-#include <stdio.h>
-#include <strings.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
+#include <platforms/axutil_platform_auto_sense.h>
#include <axis2_const.h>
-#include <stdlib.h>
+#include <cut_defs.h>
+#include <cut_http_server.h>
+
+#if defined (WIN32)
+#define bcopy(s, d, n) memcpy(d, s, n)
+#define bzero(s, n) memset(s, 0, n)
+#endif
/* Function prototypes */
int write_to_socket(
@@ -44,7 +40,18 @@ error(
const char *msg)
{
perror(msg);
- exit(0);
+ exit(-1);
+}
+
+void
+axis2_test_temp(axutil_env_t *env)
+{
+ /* To avoid warning of not using cut_ptr_equal */
+ CUT_ASSERT_PTR_EQUAL(NULL, NULL, 0);
+ /* To avoid warning of not using cut_int_equal */
+ CUT_ASSERT_INT_EQUAL(0, 0, 0);
+ /* To avoid warning of not using cut_str_equal */
+ CUT_ASSERT_STR_EQUAL("", "", 0);
}
int
@@ -56,6 +63,9 @@ main(
const axis2_char_t *port = "9090";
const axis2_char_t *filename = "echo.xml";
const axis2_char_t *endpoint = "/axis2/services/echo/echo";
+ axutil_env_t *env = NULL;
+
+#ifndef WIN32
int c;
extern char *optarg;
@@ -77,11 +87,19 @@ main(
break;
}
}
-
- write_to_socket(hostname, port, filename, endpoint);
- return 0;
+#endif
+ env = cut_setup_env("test HTTP server");
+ CUT_ASSERT(env != NULL);
+ if ( ut_start_http_server(env) != 0 ) return -1;
+ write_to_socket(hostname, port, filename, endpoint);
+ ut_stop_http_server(env);
+
+ axis2_test_temp(env);
+ CUT_RETURN_ON_FAILURE(-1);
+ return 0;
}
+#define TEST_BUF_LEN 4999
int
write_to_socket(
const char *address,
@@ -89,17 +107,16 @@ write_to_socket(
const char *filename,
const char *endpoint)
{
- axis2_char_t buffer_l[4999];
- int sockfd,
- portno,
- n,
- i;
+ axis2_char_t buffer_l[TEST_BUF_LEN];
+ int sockfd, portno, n, i, fd;
struct sockaddr_in serv_addr;
struct hostent *server;
struct stat buf;
axis2_char_t *buffer;
axis2_char_t tmpstr[10];
int bufsize = 0;
+ int reste;
+ axis2_char_t *pbuf;
portno = atoi(port);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
@@ -123,7 +140,7 @@ write_to_socket(
stat(filename, &buf);
bufsize = (buf.st_size + 1) * sizeof(char);
buffer = (char *) malloc(bufsize);
- int fd = open(filename, O_RDONLY, 0);
+ fd = open(filename, O_RDONLY, 0);
if (fd == -1)
{
printf("can't open file %s\n", filename);
@@ -154,22 +171,25 @@ write_to_socket(
strcat(buffer_l, "\r\n");
printf("Writing buffer_1...\n%s", buffer_l);
- n = write(sockfd, buffer_l, strlen(buffer_l));
+ n = send(sockfd, buffer_l, strlen(buffer_l), 0);
- n = write(sockfd, buffer, strlen(buffer));
+ n = send(sockfd, buffer, strlen(buffer), 0);
if (n < 0)
error("ERROR writing to socket");
printf("Done writing to server\n");
buffer[0] = '\0';
-
- printf("Reading the reply from server :\n");
- while ((n = read(sockfd, buffer, bufsize - 1)) > 0)
+ pbuf = buffer_l;
+ reste = TEST_BUF_LEN - 1;
+ printf("Read server response %s\n", filename);
+ while ((n = recv(sockfd, pbuf, reste, 0)) > 0)
{
- buffer[n] = '\0';
- printf("%s", buffer);
+ pbuf += n;
+ reste -= n;
}
+ buffer_l[pbuf - buffer_l] = '\0';
+
printf("\nReading from server done ...\n");
if (n < 0)
@@ -177,6 +197,7 @@ write_to_socket(
error("ERROR reading from socket");
buffer[0] = '\0';
}
+
free(buffer);
return 0;
}
diff --git a/test/core/clientapi/test_clientapi.c b/test/core/clientapi/test_clientapi.c
index e20d44a..ccd8709 100644
--- a/test/core/clientapi/test_clientapi.c
+++ b/test/core/clientapi/test_clientapi.c
@@ -42,11 +42,11 @@ axis2_test_svc_client_blocking(
axis2_endpoint_ref_t *endpoint_ref = NULL;
axutil_allocator_t *allocator = axutil_allocator_init(NULL);
- env = axutil_env_create(allocator);
axiom_element_t *result_ele = NULL;
const axis2_char_t *echo_text = "echo_text";
axis2_char_t *result = NULL;
+ env = axutil_env_create(allocator);
address = "http://localhost:9090/axis2/services/echo/echo";
endpoint_ref = axis2_endpoint_ref_create(env, address);
client_home = AXIS2_GETENV("AXIS2C_HOME");
@@ -83,6 +83,7 @@ axis2_test_svc_client_blocking(
printf("axis2_test SVC_CLIENT_SEND_RECEIVE FAILURE\n");
}
}
+
axis2_svc_client_free(svc_client, env);
}
diff --git a/test/core/clientapi/test_svc_client_handler_count.c b/test/core/clientapi/test_svc_client_handler_count.c
index a4904dd..0a05567 100644
--- a/test/core/clientapi/test_svc_client_handler_count.c
+++ b/test/core/clientapi/test_svc_client_handler_count.c
@@ -12,10 +12,10 @@ main(
int i;
for (i = 1; i <= TIMES; ++i)
{
- printf("%d\n", i);
axis2_svc_client_t *svc_client =
axis2_svc_client_create(env, AXIS2_GETENV("AXIS2C_HOME"));
axis2_svc_client_free(svc_client, env);
+ printf("%d\n", i);
}
axutil_env_free(env);
return 0;
diff --git a/test/core/context/Makefile.am b/test/core/context/Makefile.am
index 52bf04a..b205f3f 100644
--- a/test/core/context/Makefile.am
+++ b/test/core/context/Makefile.am
@@ -11,11 +11,12 @@ test_context_LDADD = ../../../util/src/libaxutil.la \
../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
$(top_builddir)/src/core/engine/libaxis2_engine.la \
$(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la \
- $(top_builddir)/neethi/src/libneethi.la
+ $(top_builddir)/neethi/src/libneethi.la
-INCLUDES = -I${CUTEST_HOME}/include \
+INCLUDES = -I$(CUTEST_HOME)/include \
-I$(top_builddir)/src/xml/guththila/src \
-I$(top_builddir)/include \
-I$(top_builddir)/src/core/description \
-I ../../../util/include \
- -I ../../../axiom/include
+ -I ../../../axiom/include \
+ -I ../../../cutest/include
diff --git a/test/core/context/test_context.c b/test/core/context/test_context.c
index 253691a..2066ac5 100644
--- a/test/core/context/test_context.c
+++ b/test/core/context/test_context.c
@@ -22,9 +22,10 @@
#include <axutil_allocator.h>
#include <axutil_env.h>
#include <stdio.h>
+#include <cut_defs.h>
void
-axis2_test_conf_ctx_init(
+axis2_test_conf_ctx_init(axutil_env_t *env
)
{
struct axis2_conf *conf = NULL;
@@ -45,38 +46,50 @@ axis2_test_conf_ctx_init(
struct axutil_hash_t *op_ctx_map = NULL;
struct axutil_hash_t *svc_ctx_map = NULL;
struct axutil_hash_t *svc_grp_ctx_map = NULL;
-
axis2_status_t status = AXIS2_FAILURE;
- axutil_allocator_t *allocator = axutil_allocator_init(NULL);
- const axutil_env_t *env = axutil_env_create(allocator);
conf = axis2_conf_create(env);
-
- op = axis2_op_create(env);
+ CUT_ASSERT_PTR_NOT_EQUAL(conf, NULL, 1);
conf_ctx = axis2_conf_ctx_create(env, conf);
-
+ CUT_ASSERT_PTR_NOT_EQUAL(conf_ctx, NULL, 1);
+
svc_grp1 = axis2_svc_grp_create(env);
+ CUT_ASSERT_PTR_NOT_EQUAL(svc_grp1, NULL, 0);
svc_grp2 = axis2_svc_grp_create(env);
+ CUT_ASSERT_PTR_NOT_EQUAL(svc_grp2, NULL, 0);
svc_grp_ctx1 = axis2_svc_grp_ctx_create(env, svc_grp1, conf_ctx);
+ CUT_ASSERT_PTR_NOT_EQUAL(svc_grp_ctx1, NULL, 0);
svc_grp_ctx2 = axis2_svc_grp_ctx_create(env, svc_grp2, conf_ctx);
+ CUT_ASSERT_PTR_NOT_EQUAL(svc_grp_ctx2, NULL, 0);
qname1 = axutil_qname_create(env, "name1", NULL, NULL);
+ CUT_ASSERT_PTR_NOT_EQUAL(qname1, NULL, 0);
qname2 = axutil_qname_create(env, "name2", NULL, NULL);
+ CUT_ASSERT_PTR_NOT_EQUAL(qname2, NULL, 0);
svc1 = axis2_svc_create_with_qname(env, qname1);
+ CUT_ASSERT_PTR_NOT_EQUAL(svc1, NULL, 0);
svc2 = axis2_svc_create_with_qname(env, qname2);
+ CUT_ASSERT_PTR_NOT_EQUAL(svc2, NULL, 0);
svc_ctx1 = axis2_svc_ctx_create(env, svc1, svc_grp_ctx1);
+ CUT_ASSERT_PTR_NOT_EQUAL(svc_ctx1, NULL, 0);
svc_ctx2 = axis2_svc_ctx_create(env, svc2, svc_grp_ctx2);
+ CUT_ASSERT_PTR_NOT_EQUAL(svc_ctx1, NULL, 0);
op = axis2_op_create(env);
+ CUT_ASSERT_PTR_NOT_EQUAL(op, NULL, 0);
+
op_ctx1 = axis2_op_ctx_create(env, op, svc_ctx1);
+ CUT_ASSERT_PTR_NOT_EQUAL(op_ctx1, NULL, 0);
+
op_ctx2 = axis2_op_ctx_create(env, op, svc_ctx2);
+ CUT_ASSERT_PTR_NOT_EQUAL(op_ctx2, NULL, 0);
op_ctx_map = axis2_conf_ctx_get_op_ctx_map(conf_ctx, env);
-
+ CUT_ASSERT_PTR_NOT_EQUAL(op_ctx_map, NULL, 0);
if (op_ctx_map)
{
axutil_hash_set(op_ctx_map, "op_ctx1", AXIS2_HASH_KEY_STRING, op_ctx1);
@@ -84,7 +97,7 @@ axis2_test_conf_ctx_init(
}
svc_ctx_map = axis2_conf_ctx_get_svc_ctx_map(conf_ctx, env);
-
+ CUT_ASSERT_PTR_NOT_EQUAL(svc_ctx_map, NULL, 0);
if (svc_ctx_map)
{
axutil_hash_set(svc_ctx_map, "svc_ctx1", AXIS2_HASH_KEY_STRING,
@@ -94,6 +107,7 @@ axis2_test_conf_ctx_init(
}
svc_grp_ctx_map = axis2_conf_ctx_get_svc_grp_ctx_map(conf_ctx, env);
+ CUT_ASSERT_PTR_NOT_EQUAL(svc_grp_ctx_map, NULL, 0);
if (svc_grp_ctx_map)
{
@@ -104,13 +118,14 @@ axis2_test_conf_ctx_init(
}
status = axis2_conf_ctx_init(conf_ctx, env, conf);
-
- if (status != AXIS2_SUCCESS)
- {
- printf("ERROR %d\n", status);
- }
- else
- printf("SUCCESS\n");
+ CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 0);
+ printf("Error code : %d\n", env->error->error_number);
+ /*
+ CUT_ASSERT_INT_EQUAL(env->error->status_code, AXIS2_SUCCESS, 0);
+ */
+
+ /* To avoid warning of not using cut_str_equal */
+ CUT_ASSERT_STR_EQUAL("", "", 0);
axis2_conf_ctx_free(conf_ctx, env);
}
@@ -119,6 +134,12 @@ int
main(
)
{
- axis2_test_conf_ctx_init();
+ axutil_env_t *env = cut_setup_env("Context");
+ CUT_ASSERT(env != NULL);
+ if (env) {
+ axis2_test_conf_ctx_init(env);
+ axutil_env_free(env);
+ }
+ CUT_RETURN_ON_FAILURE(-1);
return 0;
}
diff --git a/test/core/deployment/Makefile.am b/test/core/deployment/Makefile.am
index ff0cfb8..539ea0f 100644
--- a/test/core/deployment/Makefile.am
+++ b/test/core/deployment/Makefile.am
@@ -10,16 +10,18 @@ test_deployment_LDADD = \
../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
$(top_builddir)/neethi/src/libneethi.la \
$(top_builddir)/src/core/engine/libaxis2_engine.la \
- $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la
+ $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la
-INCLUDES = -I$(top_builddir)/include \
- -I$(top_builddir)/src/core/description \
- -I$(top_builddir)/src/core/context \
- -I$(top_builddir)/src/core/phaseresolver \
- -I$(top_builddir)/src/core/deployment \
- -I$(top_builddir)/src/core/engine \
- -I$(top_builddir)/src/core/clientapi \
- -I$(top_builddir)/src/core/util \
+INCLUDES = -I ../../../include \
+ -I$(CUTEST_HOME)/include \
+ -I ../../../src/core/description \
+ -I ../../../src/core/context \
+ -I ../../../src/core/phaseresolver \
+ -I ../../../src/core/deployment \
+ -I ../../../src/core/engine \
+ -I ../../../src/core/clientapi \
+ -I ../../../src/core/util \
-I ../../../util/include \
-I ../../../axiom/include \
- -I ../../../neethi/include
+ -I ../../../neethi/include \
+ -I ../../../cutest/include
diff --git a/test/core/deployment/test_deployment.c b/test/core/deployment/test_deployment.c
index d0730d8..761f398 100644
--- a/test/core/deployment/test_deployment.c
+++ b/test/core/deployment/test_deployment.c
@@ -31,11 +31,10 @@
#include <axis2_transport_sender.h>
#include <axis2_transport_receiver.h>
#include <axis2_core_utils.h>
+#include <cut_defs.h>
-const axutil_env_t *env = NULL;
-
-int
-axis2_test_dep_engine_load(
+void
+axis2_test_dep_engine_load(axutil_env_t *env
)
{
axis2_dep_engine_t *dep_engine = NULL;
@@ -44,35 +43,19 @@ axis2_test_dep_engine_load(
axutil_array_list_t *in_phases = NULL;
axis2_char_t *axis2c_home = NULL;
- printf("******************************************\n");
- printf("testing dep_engine_load method \n");
- printf("******************************************\n");
-
axis2c_home = AXIS2_GETENV("AXIS2C_HOME");
dep_engine = axis2_dep_engine_create_with_repos_name(env, axis2c_home);
- if (!dep_engine)
- {
- printf("dep engine is not created \n");
- return -1;
- }
+ CUT_ASSERT_PTR_NOT_EQUAL(dep_engine, NULL, 1);
conf = axis2_dep_engine_load(dep_engine, env);
axis2_conf_set_dep_engine(conf, env, dep_engine);
- if (!conf)
- {
- printf("conf is NULL\n)");
- return -1;
- }
-
+ CUT_ASSERT_PTR_NOT_EQUAL(conf, NULL, 1);
svc_map = axis2_conf_get_all_svcs(conf, env);
- if (svc_map)
- printf("svc_map count = %d\n", axutil_hash_count(svc_map));
- else
- printf("svc_map count = zero\n");
-
+ CUT_ASSERT_PTR_NOT_EQUAL(svc_map, NULL, 0);
if (svc_map)
{
axutil_hash_index_t *hi = NULL;
void *service = NULL;
+ printf("svc_map count = %d\n", axutil_hash_count(svc_map));
for (hi = axutil_hash_first(svc_map, env);
hi; hi = axutil_hash_next(env, hi))
{
@@ -91,12 +74,11 @@ axis2_test_dep_engine_load(
ops = axis2_svc_get_all_ops(svc, env);
if (ops)
{
- printf("ops count = %d\n", axutil_hash_count(ops));
-
axutil_hash_index_t *hi2 = NULL;
void *op = NULL;
axis2_char_t *oname = NULL;
-
+ printf("ops count = %d\n", axutil_hash_count(ops));
+
for (hi2 = axutil_hash_first(ops, env); hi2;
hi2 = axutil_hash_next(env, hi2))
{
@@ -119,21 +101,18 @@ axis2_test_dep_engine_load(
in_phases =
axis2_conf_get_in_phases_upto_and_including_post_dispatch(conf, env);
- if (!in_phases)
- {
- printf("in phases up to and including post dispatch is NULL\n");
- }
- else
- {
- printf("dep engine load is successfull\n");
- }
+ CUT_ASSERT_PTR_NOT_EQUAL(in_phases, NULL, 0);
+ CUT_ASSERT_INT_EQUAL(env->error->status_code, AXIS2_SUCCESS, 0);
+
+ /* To avoid warning of not using cut_str_equal */
+ CUT_ASSERT_STR_EQUAL("", "", 0);
+
axis2_conf_free(conf, env);
- return 0;
}
int
-axis2_test_transport_receiver_load(
+axis2_test_transport_receiver_load(axutil_env_t *env
)
{
axutil_dll_desc_t *dll_desc = NULL;
@@ -169,7 +148,7 @@ axis2_test_transport_receiver_load(
}
int
-axis2_test_transport_sender_load(
+axis2_test_transport_sender_load(axutil_env_t *env
)
{
axutil_dll_desc_t *dll_desc = NULL;
@@ -203,8 +182,8 @@ axis2_test_transport_sender_load(
return 0;
}
-int
-axis2_test_default_module_version(
+void
+axis2_test_default_module_version(axutil_env_t *env
)
{
@@ -226,9 +205,6 @@ axis2_test_default_module_version(
axis2_bool_t found2 = AXIS2_FALSE;
axis2_bool_t found3 = AXIS2_FALSE;
- printf("******************************************\n");
- printf("testing axis2_default_module_version\n");
- printf("******************************************\n");
axis_conf = axis2_conf_create(env);
mod_qname1 = axutil_qname_create(env, "module1", NULL, NULL);
@@ -256,24 +232,13 @@ axis2_test_default_module_version(
(axis_conf, env),
axis_conf);
def_mod = axis2_conf_get_default_module(axis_conf, env, "module1");
- if (def_mod != module1)
- {
- printf("axis2_default_module_version (module1) .. FAILED\n");
- return AXIS2_FAILURE;
- }
- def_mod = axis2_conf_get_default_module(axis_conf, env, "module2");
- if (def_mod != module3)
- {
- printf("axis2_default_module_version (module2) .. FAILED\n");
- return AXIS2_FAILURE;
- }
- def_mod = axis2_conf_get_default_module(axis_conf, env, "test_module");
- if (def_mod != module5)
- {
- printf("axis2_default_module_version (test_module) .. FAILED\n");
- return AXIS2_FAILURE;
- }
- engage_qname = axutil_qname_create(env, "module2", NULL, NULL);
+ CUT_ASSERT_PTR_EQUAL(def_mod, module1, 0);
+ def_mod = axis2_conf_get_default_module(axis_conf, env, "module2-0.92");
+ CUT_ASSERT_PTR_EQUAL(def_mod, module3, 0);
+ def_mod = axis2_conf_get_default_module(axis_conf, env, "test_module-1.92");
+ CUT_ASSERT_PTR_EQUAL(def_mod, module5, 0);
+
+ engage_qname = axutil_qname_create(env, "module2-0.92", NULL, NULL);
axis2_conf_engage_module(axis_conf, env, engage_qname);
axutil_qname_free(engage_qname, env);
engage_qname = NULL;
@@ -287,12 +252,13 @@ axis2_test_default_module_version(
"1.92");
engaged_modules = axis2_conf_get_all_engaged_modules(axis_conf, env);
-
+ CUT_ASSERT_PTR_NOT_EQUAL(engaged_modules, NULL, 0);
if (engaged_modules)
{
int list_size = 0;
int i = 0;
list_size = axutil_array_list_size(engaged_modules, env);
+ CUT_ASSERT_INT_EQUAL(list_size, 3, 0);
for (i = 0; i < list_size; i++)
{
axutil_qname_t *engaged_mod_qname = NULL;
@@ -318,43 +284,24 @@ axis2_test_default_module_version(
}
}
- if (AXIS2_FALSE == found1)
- {
- printf("axis2_default_module_version (module2 engaging) .. FAILED\n");
- return AXIS2_FAILURE;
- }
- if (AXIS2_FALSE == found2)
- {
- printf("axis2_default_module_version (module1 engaging) .. FAILED\n");
- return AXIS2_FAILURE;
- }
- if (AXIS2_FALSE == found3)
- {
- printf
- ("axis2_default_module_version (test_module engaging) .. FAILED\n");
- return AXIS2_FAILURE;
- }
- printf("axis2_default_module_version .. SUCCESS\n");
+ CUT_ASSERT_INT_NOT_EQUAL(found1, AXIS2_FALSE, 0);
+ CUT_ASSERT_INT_NOT_EQUAL(found2, AXIS2_FALSE, 0);
+ CUT_ASSERT_INT_NOT_EQUAL(found3, AXIS2_FALSE, 0);
axis2_conf_free(axis_conf, env);
- return AXIS2_SUCCESS;
+ CUT_ASSERT_INT_EQUAL(env->error->status_code, AXIS2_SUCCESS, 0);
}
int
main(
)
{
- axutil_allocator_t *allocator = NULL;
- axutil_error_t *error = NULL;
- axutil_log_t *log = NULL;
-
- allocator = axutil_allocator_init(NULL);
- error = axutil_error_create(allocator);
- log = axutil_log_create(allocator, NULL, "test_deployment.log");
- env = axutil_env_create_with_error_log(allocator, error, log);
- env->log->level = AXIS2_LOG_LEVEL_INFO;
- /*axis2_test_transport_receiver_load();
- axis2_test_transport_sender_load(); */
- axis2_test_dep_engine_load();
- axis2_test_default_module_version();
+ axutil_env_t *env = cut_setup_env("Context");
+ CUT_ASSERT(env != NULL);
+ if (env) {
+ axis2_test_dep_engine_load(env);
+ axis2_test_default_module_version(env);
+ axutil_env_free(env);
+ }
+ CUT_RETURN_ON_FAILURE(-1);
return 0;
}
diff --git a/test/core/description/Makefile.am b/test/core/description/Makefile.am
index 4208ddf..2ac48ed 100644
--- a/test/core/description/Makefile.am
+++ b/test/core/description/Makefile.am
@@ -13,6 +13,7 @@ test_description_LDADD = \
$(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la
INCLUDES = -I$(top_builddir)/include \
+ -I$(CUTEST_HOME)/include \
-I$(top_builddir)/src/core/description \
-I$(top_builddir)/src/core/context \
-I$(top_builddir)/src/core/phaseresolver \
@@ -21,5 +22,6 @@ INCLUDES = -I$(top_builddir)/include \
-I$(top_builddir)/src/core/engine \
-I$(top_builddir)/src/core/clientapi \
-I ../../../util/include \
- -I ../../../axiom/include
+ -I ../../../axiom/include \
+ -I ../../../cutest/include
diff --git a/test/core/description/test_description.c b/test/core/description/test_description.c
index 17675ba..f3ce7d3 100644
--- a/test/core/description/test_description.c
+++ b/test/core/description/test_description.c
@@ -1,4 +1,3 @@
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -23,119 +22,100 @@
#include <axis2_phases_info.h>
#include <axutil_env.h>
#include <axutil_allocator.h>
+#include <cut_defs.h>
-struct axis2_module_desc *create_module_desc(
- const axutil_env_t * env);
-
-int
-axis2_test_op_engage_module(
+void
+axis2_test_op_engage_module(axutil_env_t *env
)
{
struct axis2_module_desc *moduleref = NULL;
axis2_conf_t *conf = NULL;
-
+ struct axutil_qname *qname = NULL;
+ axis2_op_t *op = NULL;
axis2_status_t status = AXIS2_FAILURE;
- printf("******************************************\n");
- printf("testing axis2_op_engage_module\n");
- printf("******************************************\n");
-
- axutil_allocator_t *allocator = axutil_allocator_init(NULL);
- axutil_env_t *env = axutil_env_create(allocator);
- axis2_op_t *op = axis2_op_create(env);
+ qname = axutil_qname_create(env, "op1", NULL, NULL);
+ CUT_ASSERT_PTR_NOT_EQUAL(qname, NULL, 0);
+ CUT_ASSERT_INT_EQUAL(env->error->status_code, AXIS2_SUCCESS, 0);
+ op = axis2_op_create_with_qname(env, qname);
+ CUT_ASSERT_PTR_NOT_EQUAL(op, NULL, 0);
+ CUT_ASSERT(env->error->status_code == AXIS2_SUCCESS);
moduleref = axis2_module_desc_create(env);
+ CUT_ASSERT(moduleref != NULL);
+ CUT_ASSERT(env->error->status_code == AXIS2_SUCCESS);
conf = axis2_conf_create(env);
+ CUT_ASSERT(conf != NULL);
+ CUT_ASSERT(env->error->status_code == AXIS2_SUCCESS);
status = axis2_op_engage_module(op, env, moduleref, conf);
- moduleref = NULL;
- if (status != AXIS2_SUCCESS)
- {
- axis2_op_free(op, env);
- printf("ERROR %d\n", status);
- }
+ CUT_ASSERT(status == AXIS2_SUCCESS);
+ CUT_ASSERT(env->error->status_code == AXIS2_SUCCESS);
+
+ /* To avoid warning of not using cut_str_equal */
+ CUT_ASSERT_STR_EQUAL("", "", 0);
axis2_op_free(op, env);
- axutil_env_free(env);
- return 0;
}
-int
-axis2_test_svc_add_module_ops(
+void
+axis2_test_svc_add_module_ops(axutil_env_t *env
)
{
struct axis2_svc *svc = NULL;
struct axutil_qname *qname = NULL;
+ struct axutil_qname *qname1 = NULL;
struct axis2_module_desc *module_desc = NULL;
struct axis2_conf *axis2_config = NULL;
axis2_status_t status = AXIS2_FAILURE;
- printf("******************************************\n");
- printf("testing axis2_svc_add_module_ops\n");
- printf("******************************************\n");
-
- axutil_allocator_t *allocator = axutil_allocator_init(NULL);
- const axutil_env_t *env = axutil_env_create(allocator);
- qname = axutil_qname_create(env, "name1", NULL, NULL);
+ qname = axutil_qname_create(env, "svc1", NULL, NULL);
svc = axis2_svc_create_with_qname(env, qname);
- module_desc = axis2_module_desc_create(env);
+ CUT_ASSERT(svc != NULL);
+ CUT_ASSERT(env->error->status_code == AXIS2_SUCCESS);
+ qname1 = axutil_qname_create(env, "mod1", NULL, NULL);
+ module_desc = axis2_module_desc_create_with_qname(env, qname1);
+ CUT_ASSERT(module_desc != NULL);
+ CUT_ASSERT(env->error->status_code == AXIS2_SUCCESS);
axis2_config = axis2_conf_create(env);
+ CUT_ASSERT(axis2_config != NULL);
+ CUT_ASSERT(env->error->status_code == AXIS2_SUCCESS);
status = axis2_svc_add_module_ops(svc, env, module_desc, axis2_config);
- if (status != AXIS2_SUCCESS)
- {
- printf("axis2_test_description_add_module_ops ERROR %d\n", status);
- }
- else
- printf("axis2_test_add_module_ops SUCCESS\n");
+ CUT_ASSERT(status == AXIS2_SUCCESS);
+ CUT_ASSERT(env->error->status_code == AXIS2_SUCCESS);
axis2_svc_free(svc, env);
- axutil_qname_free(qname, env);
axis2_module_desc_free(module_desc, env);
axis2_conf_free(axis2_config, env);
-
- return 0;
}
-int
-axis2_test_svc_engage_module(
+void axis2_test_svc_engage_module(axutil_env_t *env
)
{
axis2_svc_t *svc = NULL;
axutil_qname_t *qname = NULL;
+ axutil_qname_t *qname1 = NULL;
axis2_module_desc_t *moduleref = NULL;
axis2_conf_t *axis2_config = NULL;
axis2_status_t status = AXIS2_FAILURE;
- printf("******************************************\n");
- printf("testing axis2_svc_engage_module\n");
- printf("******************************************\n");
-
- axutil_allocator_t *allocator = axutil_allocator_init(NULL);
- const axutil_env_t *env = axutil_env_create(allocator);
- qname = axutil_qname_create(env, "name1", NULL, NULL);
+ qname = axutil_qname_create(env, "svc1", NULL, NULL);
svc = axis2_svc_create_with_qname(env, qname);
- moduleref = axis2_module_desc_create(env);
+ qname1 = axutil_qname_create(env, "mod1", NULL, NULL);
+ moduleref = axis2_module_desc_create_with_qname(env, qname1);
axis2_config = axis2_conf_create(env);
status = axis2_svc_engage_module(svc, env, moduleref, axis2_config);
- moduleref = NULL;
- if (status != AXIS2_SUCCESS)
- {
- printf("axis2_test_description_svc_engage_module ERROR %d\n", status);
- }
- else
- printf("axis2_test_svc_engage_module SUCCESS\n");
+ CUT_ASSERT(status == AXIS2_SUCCESS);
+ CUT_ASSERT(env->error->status_code == AXIS2_SUCCESS);
axis2_svc_free(svc, env);
- axutil_qname_free(qname, env);
axis2_conf_free(axis2_config, env);
-
- return 0;
}
-int
-axis2_test_svc_get_op(
+void
+axis2_test_svc_get_op(axutil_env_t *env
)
{
struct axis2_svc *svc = NULL;
@@ -144,12 +124,6 @@ axis2_test_svc_get_op(
struct axis2_op *op = NULL;
axis2_status_t status = AXIS2_SUCCESS;
- printf("******************************************\n");
- printf("testing axis2_svc_get_op\n");
- printf("******************************************\n");
-
- axutil_allocator_t *allocator = axutil_allocator_init(NULL);
- const axutil_env_t *env = axutil_env_create(allocator);
qname = axutil_qname_create(env, "op1", NULL, NULL);
op = axis2_op_create_with_qname(env, qname);
qname = axutil_qname_create(env, "svc1", NULL, NULL);
@@ -162,23 +136,16 @@ axis2_test_svc_get_op(
status = axis2_svc_add_op(svc, env, op);
ops = axis2_svc_get_all_ops(svc, env);
-
- if (ops)
- printf("SUCCESS AXIS2_SVC_GET_OPS\n");
- else
- {
- printf("ERROR AXIS2_SVC_GET_OPS\n");
- return -1;
- }
+ CUT_ASSERT(ops != NULL);
+ CUT_ASSERT(env->error->status_code == AXIS2_SUCCESS);
if (ops)
{
- printf("ops count = %d\n", axutil_hash_count(ops));
-
axutil_hash_index_t *hi2 = NULL;
void *op2 = NULL;
axis2_char_t *oname = NULL;
int count = 0;
+ printf("ops count = %d\n", axutil_hash_count(ops));
for (hi2 = axutil_hash_first(ops, env); hi2;
hi2 = axutil_hash_next(env, hi2))
@@ -199,17 +166,23 @@ axis2_test_svc_get_op(
}
else
printf("ops count = zero\n");
+ CUT_ASSERT(env->error->status_code == AXIS2_SUCCESS);
- return 0;
}
int
main(
)
{
- axis2_test_op_engage_module();
- axis2_test_svc_add_module_ops();
- axis2_test_svc_engage_module();
- axis2_test_svc_get_op();
+ axutil_env_t *env = cut_setup_env("Core description");
+ CUT_ASSERT(env != NULL);
+ if (env) {
+ axis2_test_op_engage_module(env);
+ axis2_test_svc_add_module_ops(env);
+ axis2_test_svc_engage_module(env);
+ axis2_test_svc_get_op(env);
+ axutil_env_free(env);
+ }
+ CUT_RETURN_ON_FAILURE(-1);
return 0;
}
diff --git a/test/core/engine/Makefile.am b/test/core/engine/Makefile.am
index c7d3b7d..9b2a70a 100644
--- a/test/core/engine/Makefile.am
+++ b/test/core/engine/Makefile.am
@@ -12,14 +12,16 @@ test_engine_LDADD = \
../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
$(top_builddir)/src/core/engine/libaxis2_engine.la \
$(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la \
- $(top_builddir)/neethi/src/libneethi.la
+ $(top_builddir)/neethi/src/libneethi.la
INCLUDES = -I$(top_builddir)/src/xml/guththila \
+ -I$(CUTEST_HOME)/include \
-I$(top_builddir)/include \
-I$(top_builddir)/src/core/description \
-I$(top_builddir)/src/core/deployment \
-I$(top_builddir)/src/core/engine \
-I ../../../util/include \
-I ../../../axiom/include \
- -I ../../../neethi/include
+ -I ../../../neethi/include \
+ -I ../../../cutest/include
diff --git a/test/core/engine/test_engine.c b/test/core/engine/test_engine.c
index 4df5b1d..e189fb3 100644
--- a/test/core/engine/test_engine.c
+++ b/test/core/engine/test_engine.c
@@ -21,17 +21,15 @@
#include <axis2_engine.h>
#include <axis2_conf_ctx.h>
#include <axis2_msg_ctx.h>
-#include <axis2_conf_builder.h>
+#include <cut_defs.h>
+/* #include <axis2_conf_builder.h> */
-int
-axis2_test_engine_send(
+void
+axis2_test_engine_send(axutil_env_t *env
)
{
axis2_status_t status = AXIS2_FAILURE;
- axutil_allocator_t *allocator = axutil_allocator_init(NULL);
- const axutil_env_t *env = axutil_env_create(allocator);
struct axis2_conf *conf = NULL;
- conf = axis2_conf_create(env);
struct axis2_conf_ctx *conf_ctx;
struct axis2_msg_ctx *msg_ctx;
@@ -42,7 +40,9 @@ axis2_test_engine_send(
struct axis2_svc_grp *svc_grp;
struct axis2_svc_grp_ctx *svc_grp_ctx;
struct axutil_qname *qname;
-
+ axis2_engine_t *engine = NULL;
+
+ conf = axis2_conf_create(env);
conf_ctx = axis2_conf_ctx_create(env, conf);
svc_grp = axis2_svc_grp_create(env);
@@ -61,14 +61,15 @@ axis2_test_engine_send(
axis2_msg_ctx_set_op_ctx(msg_ctx, env, op_ctx);
axis2_msg_ctx_set_svc_ctx(msg_ctx, env, svc_ctx);
- axis2_engine_t *engine = axis2_engine_create(env, conf_ctx);
+ engine = axis2_engine_create(env, conf_ctx);
status = axis2_engine_send(engine, env, msg_ctx);
- if (status != AXIS2_SUCCESS)
- {
- printf("axis2_test_engine_send ERROR %d\n", status);
- }
- else
- printf("axis2_test_engine_send SUCCESS\n");
+ CUT_ASSERT_INT_NOT_EQUAL(status, AXIS2_SUCCESS, 0);
+ printf("Error code : %d\n", env->error->error_number);
+
+ /* To avoid warning of not using cut_str_equal */
+ CUT_ASSERT_STR_EQUAL("", "", 0);
+ /* To avoid warning of not using cut_ptr_equal */
+ CUT_ASSERT_PTR_EQUAL("", "", 0);
axis2_conf_ctx_free(conf_ctx, env);
axis2_msg_ctx_free(msg_ctx, env);
@@ -79,45 +80,43 @@ axis2_test_engine_send(
axis2_op_ctx_free(op_ctx, env);
axis2_op_free(op, env);
axis2_engine_free(engine, env);
- return 0;
}
-int
-axis2_test_engine_receive(
+void
+axis2_test_engine_receive(axutil_env_t *env
)
{
axis2_status_t status = AXIS2_FAILURE;
- axutil_allocator_t *allocator = axutil_allocator_init(NULL);
- const axutil_env_t *env = axutil_env_create(allocator);
axis2_conf_t *conf = NULL;
- conf = axis2_conf_create(env);
-
struct axis2_conf_ctx *conf_ctx;
struct axis2_msg_ctx *msg_ctx;
+ axis2_engine_t *engine = NULL;
+
+ conf = axis2_conf_create(env);
conf_ctx = axis2_conf_ctx_create(env, conf);
msg_ctx = axis2_msg_ctx_create(env, conf_ctx, NULL, NULL);
- axis2_engine_t *engine = axis2_engine_create(env, conf_ctx);
+ engine = axis2_engine_create(env, conf_ctx);
status = axis2_engine_receive(engine, env, msg_ctx);
- if (status != AXIS2_SUCCESS)
- {
- printf("axis2_test_engine_receive ERROR %d\n", status);
- }
- else
- printf("axis2_test_engine_receive SUCCESS\n");
+ CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 0);
axis2_conf_ctx_free(conf_ctx, env);
axis2_msg_ctx_free(msg_ctx, env);
axis2_engine_free(engine, env);
- return 0;
}
int
main(
)
{
- axis2_test_engine_send();
- axis2_test_engine_receive();
+ axutil_env_t *env = cut_setup_env("Core engine");
+ CUT_ASSERT(env != NULL);
+ if (env) {
+ axis2_test_engine_send(env);
+ axis2_test_engine_receive(env);
+ axutil_env_free(env);
+ }
+ CUT_RETURN_ON_FAILURE(-1);
return 0;
}
diff --git a/test/core/transport/http/Makefile.am b/test/core/transport/http/Makefile.am
index f709259..2370f6e 100644
--- a/test/core/transport/http/Makefile.am
+++ b/test/core/transport/http/Makefile.am
@@ -1,21 +1,40 @@
-TESTS = test_http_transport
-check_PROGRAMS = test_http_transport
-noinst_PROGRAMS = test_http_transport
+TESTS = test_http_server test_http_transport
+check_PROGRAMS = test_http_transport test_http_server
+noinst_PROGRAMS = test_http_transport test_http_server
SUBDIRS =
-AM_CFLAGS = -g
+AM_CFLAGS = -g -pthread
test_http_transport_SOURCES = test_http_transport.c
+test_http_server_SOURCES = test_http_server.c
test_http_transport_LDADD = \
- $(LDFLAGS) \
- ../../../../util/src/libaxutil.la \
- ../../../../axiom/src/om/libaxis2_axiom.la \
- $(top_builddir)/neethi/src/libneethi.la \
- ../../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
- $(top_builddir)/src/core/engine/libaxis2_engine.la \
- $(top_builddir)/src/core/transport/http/sender/libaxis2_http_sender.la
+ $(LDFLAGS) \
+ ../../../../util/src/libaxutil.la \
+ ../../../../axiom/src/om/libaxis2_axiom.la \
+ $(top_builddir)/neethi/src/libneethi.la \
+ ../../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
+ $(top_builddir)/src/core/engine/libaxis2_engine.la \
+ $(top_builddir)/src/core/transport/http/receiver/libaxis2_http_receiver.la \
+ $(top_builddir)/src/core/transport/http/sender/libaxis2_http_sender.la
-INCLUDES = -I${CUTEST_HOME}/include \
- -I$(top_builddir)/include \
- -I ../../../../util/include \
- -I ../../../../axiom/include
+test_http_server_LDADD = \
+ $(LDFLAGS) \
+ $(top_builddir)/src/core/transport/http/util/libaxis2_http_util.la \
+ $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la \
+ $(top_builddir)/axiom/src/om/libaxis2_axiom.la \
+ $(top_builddir)/util/src/libaxutil.la \
+ $(top_builddir)/axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
+ $(top_builddir)/src/core/description/libaxis2_description.la \
+ $(top_builddir)/src/core/deployment/libaxis2_deployment.la \
+ $(top_builddir)/src/core/context/libaxis2_context.la \
+ $(top_builddir)/src/core/clientapi/libaxis2_clientapi.la \
+ $(top_builddir)/src/core/engine/libaxis2_engine.la \
+ $(top_builddir)/src/core/transport/http/sender/libaxis2_http_sender.la \
+ $(top_builddir)/src/core/transport/http/receiver/libaxis2_http_receiver.la \
+ $(top_builddir)/neethi/src/libneethi.la
+
+INCLUDES = -I$(CUTEST_HOME)/include \
+ -I$(top_builddir)/include \
+ -I ../../../../util/include \
+ -I ../../../../axiom/include \
+ -I ../../../../cutest/include
diff --git a/test/core/transport/http/test_http_transport.c b/test/core/transport/http/test_http_transport.c
index d961316..bee1068 100644
--- a/test/core/transport/http/test_http_transport.c
+++ b/test/core/transport/http/test_http_transport.c
@@ -1,4 +1,3 @@
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -23,29 +22,15 @@
#include <axutil_error_default.h>
#include <axutil_url.h>
#include <axis2_http_client.h>
-
-typedef struct a
-{
- axis2_char_t *value;
-}
-a;
-
-axutil_env_t *
-test_init(
- )
-{
- axutil_allocator_t *allocator = axutil_allocator_init(NULL);
- axutil_error_t *error = axutil_error_create(allocator);
- axutil_env_t *env = axutil_env_create_with_error(allocator, error);
- return env;
-}
+#include <cut_defs.h>
+#include <cut_http_server.h>
void
test_http_request_line(
const axutil_env_t * env)
{
- const char *request_line_str =
- "POST http://ws.apache.org/axis2/c/services/test_svc/test_op?x=1 HTTP/1.1\r\n";
+ char *request_line_str = axutil_strdup(env,
+ "POST http://ws.apache.org/axis2/c/services/test_svc/test_op?x=1 HTTP/1.1\r\n");
axis2_http_request_line_t *request_line;
printf("Starting http_request_line tests\n");
@@ -54,6 +39,14 @@ test_http_request_line(
axis2_http_request_line_get_method(request_line, env),
axis2_http_request_line_get_uri(request_line, env),
axis2_http_request_line_get_http_version(request_line, env));
+
+ /* To avoid warning of not using cut_ptr_equal */
+ CUT_ASSERT_PTR_EQUAL(NULL, NULL, 0);
+ /* To avoid warning of not using cut_int_equal */
+ CUT_ASSERT_INT_EQUAL(0, 0, 0);
+ /* To avoid warning of not using cut_str_equal */
+ CUT_ASSERT_STR_EQUAL("", "", 0);
+
axis2_http_request_line_free(request_line, env);
printf("Finished http_request_line tests ..........\n\n");
}
@@ -85,14 +78,14 @@ test_http_header(
{
const char *header_name = "Content-Type";
const char *header_value = "text/xml";
- const char *str_header = "Content-Type: text/xml; charset=UTF-8\r\n";
+ const char *str_header = axutil_strdup(env,"Content-Type: text/xml; charset=UTF-8\r\n");
axis2_http_header_t *http_header;
axis2_char_t *external_form = NULL;
printf("Starting http_header tests\n");
http_header = axis2_http_header_create(env, header_name, header_value);
external_form = axis2_http_header_to_external_form(http_header, env);
- printf("Heder Name :%s|Header Value:%s|External Form:%s\n",
+ printf("Header Name :%s|Header Value:%s|External Form:%s\n",
axis2_http_header_get_name(http_header, env),
axis2_http_header_get_value(http_header, env), external_form);
AXIS2_FREE(env->allocator, external_form);
@@ -124,46 +117,59 @@ test_url(
void
test_http_client(
- const axutil_env_t * env)
+ axutil_env_t * env)
{
axis2_http_client_t *client = NULL;
axis2_http_simple_request_t *request = NULL;
axis2_http_request_line_t *request_line = NULL;
axutil_url_t *url = NULL;
axis2_http_header_t *header = NULL;
- axutil_stream_t *request_body = NULL;
axis2_http_simple_response_t *response = NULL;
- int status = 0;
+ axis2_status_t status;
char *body_bytes = NULL;
int body_bytes_len = 0;
-
+ char * content ="<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"><soapenv:Body><echoString><text>echo5</text></echoString></soapenv:Body></soapenv:Envelope>";
+ char tmpbuf[100];
printf("Starting http_client tests\n");
- request_line = axis2_http_request_line_create(env, "GET",
- "/axis2/services",
- "HTTP/1.0");
- request_body = axutil_stream_create_basic(env);
+ if ( ut_start_http_server(env) != 0 ) return;
+ request_line = axis2_http_request_line_create(env, "POST",
+ "/axis2/services/echo/echo",
+ "HTTP/1.1");
request = axis2_http_simple_request_create(env, request_line,
NULL, 0, NULL);
- url = axutil_url_create(env, "http", "localhost", 80, NULL);
+ axis2_http_simple_request_set_body_string(request, env, content, strlen(content));
+ url = axutil_url_create(env, "http", "localhost", 9090, NULL);
+ sprintf(tmpbuf,"%s:%d", axutil_url_get_host(url, env), axutil_url_get_port(url, env));
header =
- axis2_http_header_create(env, "Host", axutil_url_get_host(url, env));
+ axis2_http_header_create(env, "Host", tmpbuf);
+ axis2_http_simple_request_add_header(request, env, header);
+ header =
+ axis2_http_header_create(env, "Content-Type", "application/soap+xml");
+ axis2_http_simple_request_add_header(request, env, header);
+ sprintf(tmpbuf,"%d", (int) strlen(content));
+ header =
+ axis2_http_header_create(env, "Content-Length", tmpbuf);
axis2_http_simple_request_add_header(request, env, header);
client = axis2_http_client_create(env, url);
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Trying to call axis2_http_client_send");
status = axis2_http_client_send(client, env, request, NULL);
- if (status < 0)
+ CUT_ASSERT(status == AXIS2_SUCCESS);
+ if (status != AXIS2_SUCCESS)
{
- printf("Test FAILED .........Can't send the request. Status :%d\n",
+ printf("Test FAILED .........Can't send the request. Status : %d\n",
status);
return;
}
- status = axis2_http_client_receive_header(client, env);
- if (status < 0)
+ status = axis2_http_client_recieve_header(client, env);
+ CUT_ASSERT(status == 200);
+ if (status != 200)
{
printf("Test FAILED ......... Can't recieve. Status: %d\n", status);
return;
}
response = axis2_http_client_get_response(client, env);
+ CUT_ASSERT(response != NULL);
if (!response)
{
printf("Test Failed : NULL response");
@@ -180,7 +186,7 @@ test_http_client(
axis2_http_client_free(client, env);
axis2_http_simple_request_free(request, env);
- axutil_stream_free(request_body, env);
+ ut_stop_http_server(env);
AXIS2_FREE(env->allocator, body_bytes);
printf("Finished http_client tests ..........\n\n");
}
@@ -208,7 +214,7 @@ test_https_client(
request_body = axutil_stream_create_basic(env);
request = axis2_http_simple_request_create(env, request_line,
NULL, 0, NULL);
- url = axutil_url_create(env, "https", "localhost", 9090, NULL);
+ url = axutil_url_create(env, "https", "localhost", 9099, NULL);
header =
axis2_http_header_create(env, "Host", axutil_url_get_host(url, env));
@@ -229,10 +235,10 @@ test_https_client(
status);
return;
}
- status = axis2_http_client_receive_header(client, env);
+ status = axis2_http_client_recieve_header(client, env);
if (status < 0)
{
- printf("Test FAILED ......... Can't receive. Status: %d\n", status);
+ printf("Test FAILED ......... Can't recieve. Status: %d\n", status);
return;
}
response = axis2_http_client_get_response(client, env);
@@ -261,14 +267,18 @@ int
main(
void)
{
- axutil_env_t *env = test_init();
- test_http_request_line(env);
- test_http_status_line(env);
- test_http_header(env);
- test_http_client(env);
- test_https_client(env);
- test_url(env);
-
- axutil_env_free(env);
+ axutil_env_t *env = cut_setup_env("test HTTP server");
+ CUT_ASSERT(env != NULL);
+ if ( env != NULL ) {
+ test_http_request_line(env);
+ test_http_status_line(env);
+ test_http_header(env);
+ test_http_client(env);
+ test_https_client(env);
+ test_url(env);
+ axutil_env_free(env);
+ }
+ CUT_RETURN_ON_FAILURE(-1);
return 0;
}
+