diff options
Diffstat (limited to 'util/test/allocator')
-rw-r--r-- | util/test/allocator/Makefile.am | 13 | ||||
-rw-r--r-- | util/test/allocator/allocator_test.c | 147 | ||||
-rw-r--r-- | util/test/allocator/build.sh | 3 | ||||
-rwxr-xr-x | util/test/allocator/test | bin | 0 -> 15310 bytes | |||
-rw-r--r-- | util/test/allocator/test.doc | bin | 0 -> 15310 bytes |
5 files changed, 163 insertions, 0 deletions
diff --git a/util/test/allocator/Makefile.am b/util/test/allocator/Makefile.am new file mode 100644 index 0000000..02dfa27 --- /dev/null +++ b/util/test/allocator/Makefile.am @@ -0,0 +1,13 @@ +TESTS = allocator_test +check_PROGRAMS = allocator_test +noinst_PROGRAMS = allocator_test +allocator_test_SOURCES = allocator_test.c ../util/create_env.c + +allocator_test_LDADD = \ + $(top_builddir)/src/libaxutil.la + +INCLUDES = -I$(top_builddir)/include \ + -I ../../../axiom/include \ + -I ../../../include + + diff --git a/util/test/allocator/allocator_test.c b/util/test/allocator/allocator_test.c new file mode 100644 index 0000000..70e0bad --- /dev/null +++ b/util/test/allocator/allocator_test.c @@ -0,0 +1,147 @@ +#include <axutil_log_default.h> +#include <axutil_error_default.h> +#include <axiom_node.h> +#include <stdio.h> +#include "../util/create_env.h" + +int plain_binary_len; +unsigned char *plain_binary ; + +/** @brief read binary + * read the binary file + */ + +int read_binary() +{ + unsigned char buffer[1024]; + FILE *in = fopen("test","rb"); + FILE *out = fopen("test.doc","w"); + int fwrite_result = 0; + + if (!(in && out)) + { + fprintf (stderr, "unable to open streams\n"); + return -1; + } + + while((plain_binary_len = fread(buffer,1,sizeof(buffer),in)) > 0) + { + fwrite_result = fwrite(buffer,1,plain_binary_len,out); + } + + fclose(in); + fclose(out); + plain_binary = buffer; + printf("%s",buffer); + return plain_binary_len; +} + +/** @brief test base64 + * create duration from values and retrieve values + */ +axis2_status_t test_base64(axutil_env_t *env) +{ + axis2_status_t status = AXIS2_FAILURE; + axutil_base64_binary_t *base64_binary; + axutil_base64_binary_t *plain_base64_binary; + const char *encoded_binary; + char * get_binary = NULL; + int binary_len; + unsigned char * plain_binary = NULL; + read_binary(); + + base64_binary = axutil_base64_binary_create(env); + if(!base64_binary) + { + printf("The test axutil_base64_binary_create is failed\n"); + axutil_base64_binary_free(base64_binary,env); + return AXIS2_FAILURE; + } + else + printf("The test axutil_base64_binary_create is successfull\n"); + + plain_base64_binary = axutil_base64_binary_create_with_plain_binary(env, + plain_binary, + plain_binary_len); + if(!plain_base64_binary) + { + printf("The test axutil_base64_binary_create_with_plain_binary is failed\n"); + axutil_base64_binary_free(plain_base64_binary,env); + } + else + printf("The test axutil_base64_binary_create_with_plain_binary is successfull\n"); + + encoded_binary = axutil_base64_binary_get_encoded_binary(base64_binary,env); + if(!encoded_binary) + { + printf("The test axutil_base64_binary_get_encoded_binary is failed\n"); + axutil_base64_binary_free(base64_binary,env); + } + else + printf("The test axutil_base64_binary_get_encoded_binary is successfull\n"); + + status = axutil_base64_binary_set_plain_binary(base64_binary,env,plain_binary, + plain_binary_len); + if (status == AXIS2_SUCCESS) + printf("The test axutil_base64_binary_set_plain_binary is successful\n"); + else + printf("The test axutil_base64_binary_set_plain_binary failed\n") ; + + plain_binary = axutil_base64_binary_get_plain_binary(base64_binary,env,&plain_binary_len); + if(!plain_binary) + { + printf("The test axutil_base64_binary_get_plain_binary is failed\n"); + axutil_base64_binary_free(base64_binary,env); + } + else + printf("The test axutil_base64_binary_get_plain_binary is successfull\n" ); + + status = axutil_base64_binary_set_encoded_binary(base64_binary,env,encoded_binary); + if (status == AXIS2_SUCCESS) + printf("The test axutil_base64_binary_set_encoded_binary is successful\n"); + else + printf("The test axutil_base64_binary_set_encoded_binary failed\n"); + + get_binary = axutil_base64_binary_get_encoded_binary(base64_binary,env); + if(!get_binary) + { + printf("The test axutil_base64_binary_get_encoded_binary is failed\n"); + axutil_base64_binary_free(base64_binary,env); + } + else + printf("The test axutil_base64_binary_get_encoded_binary is successfull\n"); + + binary_len = axutil_base64_binary_get_encoded_binary_len(base64_binary,env); + if(!binary_len) + { + printf("The test axutil_base64_binary_get_encoded_binary_len is failed\n"); + axutil_base64_binary_free(base64_binary,env); + } + else + printf("The test axutil_base64_binary_get_encoded_binary_len is successfull\n"); + + return AXIS2_SUCCESS; +} + +int main() +{ + int status = AXIS2_SUCCESS; + axutil_env_t *env = NULL; + env = create_environment(); + status = test_base64(env); + + if(status == AXIS2_FAILURE) + { + printf("build failed"); + } + axutil_env_free(env); + return 0; +} + + + + + + + + diff --git a/util/test/allocator/build.sh b/util/test/allocator/build.sh new file mode 100644 index 0000000..e5dabf2 --- /dev/null +++ b/util/test/allocator/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +gcc allocator_test.c ../util/create_env.c -g -I$AXIS2C_HOME/include/axis2-1.2 -L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -laxis2_parser -o allocator_test diff --git a/util/test/allocator/test b/util/test/allocator/test Binary files differnew file mode 100755 index 0000000..919cd65 --- /dev/null +++ b/util/test/allocator/test diff --git a/util/test/allocator/test.doc b/util/test/allocator/test.doc Binary files differnew file mode 100644 index 0000000..919cd65 --- /dev/null +++ b/util/test/allocator/test.doc |