You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by bi...@apache.org on 2018/04/29 16:12:15 UTC
svn commit: r1830515 [1/2] - in /axis/axis2/c/core/trunk/util/test:
allocator/ date_time/ duration/ link_list/ properties/ rand/ stack/
string_util/ uri/ url/ util/ utils/
Author: billblough
Date: Sun Apr 29 16:12:14 2018
New Revision: 1830515
URL: http://svn.apache.org/viewvc?rev=1830515&view=rev
Log:
Convert all util tests to use gtest
Added:
axis/axis2/c/core/trunk/util/test/allocator/allocator_test.cc
- copied, changed from r1830514, axis/axis2/c/core/trunk/util/test/allocator/allocator_test.c
axis/axis2/c/core/trunk/util/test/date_time/date_time_test.cc
axis/axis2/c/core/trunk/util/test/duration/duration_test.cc
axis/axis2/c/core/trunk/util/test/link_list/link_list_test.cc
axis/axis2/c/core/trunk/util/test/properties/property_test.cc
- copied, changed from r1830514, axis/axis2/c/core/trunk/util/test/properties/property_test.c
axis/axis2/c/core/trunk/util/test/rand/rand_test.cc
axis/axis2/c/core/trunk/util/test/stack/stack_test.cc
axis/axis2/c/core/trunk/util/test/string_util/string_util_test.cc
axis/axis2/c/core/trunk/util/test/uri/uri_test.cc
axis/axis2/c/core/trunk/util/test/url/url_test.cc
axis/axis2/c/core/trunk/util/test/util/test_log.cc
- copied, changed from r1830514, axis/axis2/c/core/trunk/util/test/util/test_log.c
axis/axis2/c/core/trunk/util/test/util/test_md5.cc
- copied, changed from r1830514, axis/axis2/c/core/trunk/util/test/util/test_md5.c
axis/axis2/c/core/trunk/util/test/util/test_string.cc
axis/axis2/c/core/trunk/util/test/util/test_thread.cc
- copied, changed from r1830514, axis/axis2/c/core/trunk/util/test/util/test_thread.c
axis/axis2/c/core/trunk/util/test/util/test_util.cc
axis/axis2/c/core/trunk/util/test/utils/utils_test.cc
Removed:
axis/axis2/c/core/trunk/util/test/allocator/allocator_test.c
axis/axis2/c/core/trunk/util/test/date_time/date_time_test.c
axis/axis2/c/core/trunk/util/test/duration/duration_test.c
axis/axis2/c/core/trunk/util/test/link_list/link_list_test.c
axis/axis2/c/core/trunk/util/test/properties/property_test.c
axis/axis2/c/core/trunk/util/test/rand/rand_test.c
axis/axis2/c/core/trunk/util/test/stack/stack_test.c
axis/axis2/c/core/trunk/util/test/string_util/string_util_test.c
axis/axis2/c/core/trunk/util/test/uri/uri_test.c
axis/axis2/c/core/trunk/util/test/url/url_test.c
axis/axis2/c/core/trunk/util/test/util/test_log.c
axis/axis2/c/core/trunk/util/test/util/test_md5.c
axis/axis2/c/core/trunk/util/test/util/test_string.c
axis/axis2/c/core/trunk/util/test/util/test_thread.c
axis/axis2/c/core/trunk/util/test/util/test_util.c
axis/axis2/c/core/trunk/util/test/utils/utils_test.c
Modified:
axis/axis2/c/core/trunk/util/test/allocator/Makefile.am
axis/axis2/c/core/trunk/util/test/date_time/Makefile.am
axis/axis2/c/core/trunk/util/test/duration/Makefile.am
axis/axis2/c/core/trunk/util/test/link_list/Makefile.am
axis/axis2/c/core/trunk/util/test/properties/Makefile.am
axis/axis2/c/core/trunk/util/test/rand/Makefile.am
axis/axis2/c/core/trunk/util/test/stack/Makefile.am
axis/axis2/c/core/trunk/util/test/string_util/Makefile.am
axis/axis2/c/core/trunk/util/test/uri/Makefile.am
axis/axis2/c/core/trunk/util/test/url/Makefile.am
axis/axis2/c/core/trunk/util/test/util/Makefile.am
axis/axis2/c/core/trunk/util/test/utils/Makefile.am
Modified: axis/axis2/c/core/trunk/util/test/allocator/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/allocator/Makefile.am?rev=1830515&r1=1830514&r2=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/allocator/Makefile.am (original)
+++ axis/axis2/c/core/trunk/util/test/allocator/Makefile.am Sun Apr 29 16:12:14 2018
@@ -4,9 +4,9 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,14 +15,17 @@
TESTS = allocator_test
check_PROGRAMS = allocator_test
noinst_PROGRAMS = allocator_test
-allocator_test_SOURCES = allocator_test.c ../util/create_env.c
+allocator_test_SOURCES = allocator_test.cc
allocator_test_LDADD = \
- $(top_builddir)/src/libaxutil.la
+ $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
+
INCLUDES = -I$(top_builddir)/include \
-I ../../../axiom/include \
-I ../../../include \
- -I ../../../test/cutest/include
+ -I $(GTEST_DIR)/include
Copied: axis/axis2/c/core/trunk/util/test/allocator/allocator_test.cc (from r1830514, axis/axis2/c/core/trunk/util/test/allocator/allocator_test.c)
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/allocator/allocator_test.cc?p2=axis/axis2/c/core/trunk/util/test/allocator/allocator_test.cc&p1=axis/axis2/c/core/trunk/util/test/allocator/allocator_test.c&r1=1830514&r2=1830515&rev=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/allocator/allocator_test.c (original)
+++ axis/axis2/c/core/trunk/util/test/allocator/allocator_test.cc Sun Apr 29 16:12:14 2018
@@ -15,17 +15,48 @@
* limitations under the License.
*/
+#include <gtest/gtest.h>
+
#include <axutil_log_default.h>
#include <axutil_error_default.h>
#include <axiom_node.h>
#include <stdio.h>
-#include <cut_defs.h>
#include "../util/create_env.h"
unsigned char buffer[1024];
-void test_base64(axutil_env_t *env)
-{
+class TestAllocator: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+
+TEST_F(TestAllocator, test_base64)
+{
+
axis2_status_t status = AXIS2_FAILURE;
axutil_base64_binary_t *base64_binary;
axutil_base64_binary_t *plain_base64_binary;
@@ -34,74 +65,48 @@ void test_base64(axutil_env_t *env)
int plain_binary_len, b_len;
unsigned char * plain_binary = NULL;
FILE *in = fopen("test","rb");
- CUT_ASSERT(in != NULL);
- if (!in) return;
-
+ ASSERT_NE(in, nullptr);
+
plain_binary_len = fread(buffer,1,sizeof(buffer),in);
fclose(in);
plain_binary = buffer;
- CUT_ASSERT(plain_binary_len != 0);
- if (plain_binary_len == 0 ) return;
-
- base64_binary = axutil_base64_binary_create(env);
- CUT_ASSERT(base64_binary != NULL);
+ ASSERT_NE(plain_binary_len, 0);
- plain_base64_binary = axutil_base64_binary_create_with_plain_binary(env,
+ base64_binary = axutil_base64_binary_create(m_env);
+ ASSERT_NE(base64_binary, nullptr);
+
+ plain_base64_binary = axutil_base64_binary_create_with_plain_binary(m_env,
plain_binary,
plain_binary_len);
- CUT_ASSERT(plain_base64_binary != NULL);
+ ASSERT_NE(plain_base64_binary, nullptr);
- encoded_binary = axutil_base64_binary_get_encoded_binary(plain_base64_binary,env);
- CUT_ASSERT(encoded_binary != NULL);
+ encoded_binary = axutil_base64_binary_get_encoded_binary(plain_base64_binary, m_env);
+ ASSERT_NE(encoded_binary, nullptr);
- status = axutil_base64_binary_set_plain_binary(base64_binary,env,plain_binary,
+ status = axutil_base64_binary_set_plain_binary(base64_binary,m_env,plain_binary,
plain_binary_len);
- CUT_ASSERT(status == AXIS2_SUCCESS);
- plain_binary = axutil_base64_binary_get_plain_binary(base64_binary,env,&b_len);
- CUT_ASSERT(plain_binary != NULL);
- status = axutil_base64_binary_set_encoded_binary(base64_binary,env,encoded_binary);
- CUT_ASSERT(status == AXIS2_SUCCESS);
- get_binary = (unsigned char *) axutil_base64_binary_get_encoded_binary(base64_binary,env);
- CUT_ASSERT(get_binary != NULL);
- b_len = axutil_base64_binary_get_encoded_binary_len(base64_binary,env);
- CUT_ASSERT(b_len != 0);
-
- axutil_base64_binary_free(base64_binary, env);
- base64_binary = axutil_base64_binary_create_with_encoded_binary(env, encoded_binary);
- CUT_ASSERT(base64_binary != NULL);
- if (base64_binary != NULL)
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ plain_binary = axutil_base64_binary_get_plain_binary(base64_binary,m_env,&b_len);
+ ASSERT_NE(plain_binary, nullptr);
+ status = axutil_base64_binary_set_encoded_binary(base64_binary,m_env,encoded_binary);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ get_binary = (unsigned char *) axutil_base64_binary_get_encoded_binary(base64_binary,m_env);
+ ASSERT_NE(get_binary, nullptr);
+ b_len = axutil_base64_binary_get_encoded_binary_len(base64_binary,m_env);
+ ASSERT_NE(b_len, 0);
+
+ axutil_base64_binary_free(base64_binary, m_env);
+ base64_binary = axutil_base64_binary_create_with_encoded_binary(m_env, encoded_binary);
+ ASSERT_NE(base64_binary, nullptr);
+ if (base64_binary != nullptr)
{
int binary_len;
- get_binary = axutil_base64_binary_get_plain_binary(base64_binary,env, &binary_len);
- CUT_ASSERT(binary_len == plain_binary_len);
- CUT_ASSERT(memcmp(get_binary, plain_binary, plain_binary_len) == 0);
- axutil_base64_binary_free(base64_binary, env);
+ get_binary = axutil_base64_binary_get_plain_binary(base64_binary,m_env, &binary_len);
+ ASSERT_EQ(binary_len, plain_binary_len);
+ ASSERT_EQ(memcmp(get_binary, plain_binary, plain_binary_len), 0);
+ axutil_base64_binary_free(base64_binary, m_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);
- axutil_base64_binary_free(plain_base64_binary, env);
+ axutil_base64_binary_free(plain_base64_binary, m_env);
}
-int main()
-{
- axutil_env_t *env = cut_setup_env("Base64");
- CUT_ASSERT(env != NULL);
- test_base64(env);
- axutil_env_free(env);
- CUT_RETURN_ON_FAILURE(-1);
- return 0;
-}
-
-
-
-
-
-
-
-
Modified: axis/axis2/c/core/trunk/util/test/date_time/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/date_time/Makefile.am?rev=1830515&r1=1830514&r2=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/date_time/Makefile.am (original)
+++ axis/axis2/c/core/trunk/util/test/date_time/Makefile.am Sun Apr 29 16:12:14 2018
@@ -4,9 +4,9 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,15 +15,16 @@
TESTS = date_time_test
noinst_PROGRAMS = date_time_test
check_PROGRAMS = date_time_test
-date_time_test_SOURCES = date_time_test.c ../util/create_env.c
+date_time_test_SOURCES = date_time_test.cc
date_time_test_LDADD = \
- $(top_builddir)/src/libaxutil.la
+ $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
-INCLUDES = -I$(top_builddir)/include \
- -I$(CUTEST_HOME)/include \
+AM_CPPFLAGS = -I$(top_builddir)/include \
-I ../../../axiom/include \
-I ../../../include \
- -I ../../../test/cutest/include
+ -I $(GTEST_DIR)/include
Added: axis/axis2/c/core/trunk/util/test/date_time/date_time_test.cc
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/date_time/date_time_test.cc?rev=1830515&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/util/test/date_time/date_time_test.cc (added)
+++ axis/axis2/c/core/trunk/util/test/date_time/date_time_test.cc Sun Apr 29 16:12:14 2018
@@ -0,0 +1,127 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <gtest/gtest.h>
+
+#include <axutil_date_time.h>
+#include <time.h>
+#include <axutil_date_time_util.h>
+#include <stdio.h>
+#include <axutil_env.h>
+#include "../util/create_env.h"
+
+class TestDateTime: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+
+/** @brief test_rand
+ * * deserialize and serialize the time
+ * */
+
+TEST_F(TestDateTime, test_date_time) {
+
+ axutil_date_time_t *date_time = NULL;
+ axutil_date_time_t *ref = NULL;
+ axutil_date_time_t *date_time_offset = NULL;
+ axis2_char_t *time_str = "22:45:12";
+ axis2_char_t *date_str = "2000-12-12";
+ axis2_char_t *date_time_str = "2000-11-11T12:30:24";
+ axis2_status_t status = AXIS2_FAILURE;
+ axutil_date_time_comp_result_t compare_res = AXIS2_DATE_TIME_COMP_RES_FAILURE;
+ axis2_char_t *t_str = NULL, *d_str = NULL, *dt_str = NULL;
+ int year , month , day, hour , min , sec , msec;
+
+ date_time_offset = axutil_date_time_create_with_offset(m_env, 100);
+ ASSERT_NE(date_time_offset, nullptr);
+ if (date_time_offset != nullptr) axutil_date_time_free(date_time_offset, m_env);
+ date_time = axutil_date_time_create(m_env);
+ ASSERT_NE(date_time, nullptr);
+ if(date_time)
+ {
+ status = axutil_date_time_deserialize_time(date_time, m_env, time_str);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ status = axutil_date_time_deserialize_date(date_time, m_env, date_str);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ status = axutil_date_time_deserialize_date_time(date_time, m_env, date_time_str);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+
+ ref = axutil_date_time_create(m_env);
+ ASSERT_NE(ref, nullptr);
+ if(ref)
+ {
+ compare_res = axutil_date_time_compare(date_time, m_env, ref);
+ ASSERT_NE(compare_res, AXIS2_DATE_TIME_COMP_RES_FAILURE);
+
+ status = axutil_date_time_deserialize_date_time(ref, m_env, date_time_str);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ compare_res = axutil_date_time_compare(date_time, m_env, ref);
+ ASSERT_EQ(compare_res, AXIS2_DATE_TIME_COMP_RES_EQUAL);
+ axutil_date_time_free(ref, m_env);
+ }
+ status = axutil_date_time_set_date_time(date_time, m_env, 2008, 1, 8, 12, 18, 57, 799);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+
+ t_str = axutil_date_time_serialize_time(date_time, m_env);
+ ASSERT_NE(t_str, nullptr);
+ d_str = axutil_date_time_serialize_date(date_time, m_env);
+ ASSERT_NE(d_str, nullptr);
+ dt_str = axutil_date_time_serialize_date_time(date_time, m_env);
+ ASSERT_NE(dt_str, nullptr);
+ year = axutil_date_time_get_year(date_time, m_env);
+ month=axutil_date_time_get_month(date_time, m_env);
+ day = axutil_date_time_get_day(date_time, m_env);
+ hour = axutil_date_time_get_hour(date_time, m_env);
+ min = axutil_date_time_get_minute(date_time, m_env);
+ sec = axutil_date_time_get_second(date_time, m_env);
+ msec = axutil_date_time_get_msec(date_time, m_env);
+ ASSERT_EQ(year, 2008);
+ ASSERT_EQ(month, 1);
+ ASSERT_EQ(day, 8);
+ ASSERT_EQ(hour, 12);
+ ASSERT_EQ(min, 18);
+ ASSERT_EQ(sec, 57);
+ ASSERT_EQ(msec, 799);
+
+ axutil_date_time_free(date_time,m_env);
+ }
+}
+
Modified: axis/axis2/c/core/trunk/util/test/duration/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/duration/Makefile.am?rev=1830515&r1=1830514&r2=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/duration/Makefile.am (original)
+++ axis/axis2/c/core/trunk/util/test/duration/Makefile.am Sun Apr 29 16:12:14 2018
@@ -4,9 +4,9 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,15 +15,16 @@
TESTS = duration_test
check_PROGRAMS = duration_test
noinst_PROGRAMS = duration_test
-duration_test_SOURCES = duration_test.c ../util/create_env.c
+duration_test_SOURCES = duration_test.cc
duration_test_LDADD = \
- $(top_builddir)/src/libaxutil.la
+ $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
-INCLUDES = -I$(top_builddir)/include \
- -I$(CUTEST_HOME)/include \
+AM_CPPFLAGS = -I$(top_builddir)/include \
-I ../../../axiom/include \
-I ../../../include \
- -I ../../../test/cutest/include
+ -I $(GTEST_DIR)/include
Added: axis/axis2/c/core/trunk/util/test/duration/duration_test.cc
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/duration/duration_test.cc?rev=1830515&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/util/test/duration/duration_test.cc (added)
+++ axis/axis2/c/core/trunk/util/test/duration/duration_test.cc Sun Apr 29 16:12:14 2018
@@ -0,0 +1,162 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <gtest/gtest.h>
+
+#include <axutil_duration.h>
+#include "../util/create_env.h"
+
+
+class TestDuration: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+
+/** @brief test duration
+ * create duration from values and retrieve values
+ */
+
+TEST_F(TestDuration, test_duration) {
+
+ axis2_status_t status = AXIS2_FAILURE;
+ axis2_char_t * duration_str = "P3Y12M23DT11H45M45.000000S";
+ axis2_char_t * duration_str1 = "-P3Y12M23DT11H45M45.000000S";
+ int year,month,day,hour,minute;
+ double second;
+ axutil_duration_t * duration;
+ axutil_duration_t * duration_one;
+ axutil_duration_t * duration_two;
+ axutil_duration_t * duration_three;
+ axutil_duration_t * duration_four;
+ axis2_bool_t is_negative = AXIS2_FALSE;
+ axis2_char_t *serialize, *serialize1;
+
+ duration = axutil_duration_create_from_values(m_env,AXIS2_TRUE,3,12,23,11,45,45.00);
+ ASSERT_NE(duration, nullptr);
+ duration_one = axutil_duration_create_from_values(m_env,AXIS2_FALSE,7,11,2,23,11,50.00);
+ ASSERT_NE(duration_one, nullptr);
+ duration_two = axutil_duration_create_from_string(m_env,duration_str);
+ ASSERT_NE(duration_two, nullptr);
+ duration_three = axutil_duration_create(m_env);
+ ASSERT_NE(duration_three, nullptr);
+ duration_four = axutil_duration_create(m_env);
+ ASSERT_NE(duration_four, nullptr);
+
+ year = axutil_duration_get_years(duration, m_env);
+ month = axutil_duration_get_months(duration, m_env);
+ day = axutil_duration_get_days(duration, m_env);
+ hour = axutil_duration_get_hours(duration, m_env);
+ minute = axutil_duration_get_mins(duration, m_env);
+ second = axutil_duration_get_seconds(duration, m_env);
+ is_negative = axutil_duration_get_is_negative(duration, m_env);
+
+ status = axutil_duration_deserialize_duration(duration_three, m_env,duration_str);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ status = axutil_duration_deserialize_duration(duration_four, m_env,duration_str1);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ serialize = axutil_duration_serialize_duration(duration_three, m_env);
+ ASSERT_NE(serialize, nullptr);
+ ASSERT_STREQ(duration_str, serialize);
+ serialize1 = axutil_duration_serialize_duration(duration_four, m_env);
+ ASSERT_NE(serialize1, nullptr);
+ ASSERT_STREQ(duration_str1, serialize1);
+ status = axutil_duration_set_duration(duration,m_env,AXIS2_TRUE,3,12,23,11,45,56.00);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+
+
+ axutil_duration_free(duration, m_env);
+ axutil_duration_free(duration_one, m_env);
+ axutil_duration_free(duration_two, m_env);
+ axutil_duration_free(duration_three, m_env);
+ axutil_duration_free(duration_four, m_env);
+}
+
+/** @brief set values
+ * set values for the duration and get the values
+ */
+TEST_F(TestDuration, test_set_values) {
+
+ axis2_status_t status;
+ axutil_duration_t * duration;
+ axutil_duration_t * duration_one;
+ int get_year,get_month,get_day,get_hour,get_minute;
+ axis2_bool_t is_negative;
+ double get_second;
+
+ duration = axutil_duration_create(m_env);
+ ASSERT_NE(duration, nullptr);
+ duration_one = axutil_duration_create_from_values(m_env,AXIS2_TRUE,5,9,29,59,21,49);
+ ASSERT_NE(duration_one, nullptr);
+
+ status = axutil_duration_set_is_negative(duration,m_env,AXIS2_TRUE);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+
+ is_negative = axutil_duration_get_is_negative(duration, m_env);
+ ASSERT_EQ(is_negative, AXIS2_TRUE);
+
+ status = axutil_duration_set_years(duration, m_env,5);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ get_year = axutil_duration_get_years(duration, m_env);
+ ASSERT_EQ(get_year, 5);
+ status = axutil_duration_set_months(duration, m_env,9);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ get_month = axutil_duration_get_months(duration, m_env);
+ ASSERT_EQ(get_month, 9);
+ status = axutil_duration_set_days(duration, m_env,29);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ get_day = axutil_duration_get_days(duration, m_env);
+ ASSERT_EQ(get_day, 29);
+ status = axutil_duration_set_hours(duration, m_env,59);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ get_hour = axutil_duration_get_hours(duration, m_env);
+ ASSERT_EQ(get_hour, 59);
+ status = axutil_duration_set_mins(duration, m_env,21);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ get_minute = axutil_duration_get_mins(duration, m_env);
+ ASSERT_EQ(get_minute, 21);
+ status = axutil_duration_set_seconds(duration, m_env,49);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ get_second = axutil_duration_get_seconds(duration, m_env);
+ ASSERT_EQ(get_second, 49);
+ ASSERT_TRUE(axutil_duration_compare(duration_one,duration, m_env));
+ axutil_duration_free(duration, m_env);
+ axutil_duration_free(duration_one, m_env);
+}
Modified: axis/axis2/c/core/trunk/util/test/link_list/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/link_list/Makefile.am?rev=1830515&r1=1830514&r2=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/link_list/Makefile.am (original)
+++ axis/axis2/c/core/trunk/util/test/link_list/Makefile.am Sun Apr 29 16:12:14 2018
@@ -4,9 +4,9 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,15 +15,16 @@
TESTS = link_list_test
check_PROGRAMS = link_list_test
noinst_PROGRAMS = link_list_test
-link_list_test_SOURCES = link_list_test.c ../util/create_env.c
+link_list_test_SOURCES = link_list_test.cc
link_list_test_LDADD = \
- $(top_builddir)/src/libaxutil.la
+ $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
-INCLUDES = -I$(top_builddir)/include \
- -I$(CUTEST_HOME)/include \
+AM_CPPFLAGS = -I$(top_builddir)/include \
-I ../../../axiom/include \
-I ../../../include \
- -I ../../../test/cutest/include
+ -I $(GTEST_DIR)/include
Added: axis/axis2/c/core/trunk/util/test/link_list/link_list_test.cc
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/link_list/link_list_test.cc?rev=1830515&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/util/test/link_list/link_list_test.cc (added)
+++ axis/axis2/c/core/trunk/util/test/link_list/link_list_test.cc Sun Apr 29 16:12:14 2018
@@ -0,0 +1,114 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <gtest/gtest.h>
+
+#include <axutil_linked_list.h>
+#include "../util/create_env.h"
+
+
+class TestLinkedList: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+
+TEST_F(TestLinkedList, test_link_list)
+{
+ char *first_item = "first entry";
+ char *second_item = "secnd entry";
+ char *third_item = "third entry";
+ char *last_item = "last entry";
+ char *array = "test";
+
+ axutil_linked_list_t * linked_list = NULL;
+ int index_of_item;
+ int index_of_last_item;
+ entry_t * entry;
+ void *get_item;
+ axis2_status_t status;
+ axis2_bool_t bresult;
+ void **array_from_list;
+
+ linked_list = axutil_linked_list_create(m_env);
+ ASSERT_NE(linked_list, nullptr);
+ status = axutil_linked_list_add_first(linked_list,m_env,(void *)first_item);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ bresult = axutil_linked_list_contains(linked_list,m_env,(void *)second_item);
+ ASSERT_EQ(bresult, AXIS2_FALSE);
+ status = axutil_linked_list_add(linked_list,m_env,(void *)third_item);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ status = axutil_linked_list_add_last(linked_list,m_env,(void *)last_item);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ ASSERT_EQ(axutil_linked_list_size(linked_list,m_env), 3);
+ index_of_item = axutil_linked_list_index_of(linked_list,m_env,third_item);
+ ASSERT_EQ(index_of_item, 1);
+ index_of_last_item = axutil_linked_list_last_index_of(linked_list,m_env,last_item);
+ ASSERT_EQ(index_of_last_item, 2);
+ entry = axutil_linked_list_get_entry(linked_list,m_env,0);
+ ASSERT_NE(entry, nullptr);
+ get_item = axutil_linked_list_get(linked_list,m_env,1);
+ ASSERT_NE(get_item, nullptr);
+ ASSERT_EQ(strcmp((char*)get_item, third_item), 0);
+ get_item = axutil_linked_list_set(linked_list,m_env,1,(void *)array);
+ ASSERT_NE(get_item, nullptr);
+ ASSERT_EQ(strcmp((char*)get_item, third_item), 0);
+ array_from_list = axutil_linked_list_to_array(linked_list,m_env);
+ ASSERT_NE(array_from_list, nullptr);
+ status = axutil_linked_list_add_at_index(linked_list,m_env,1,(void *)second_item);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ get_item = axutil_linked_list_remove_at_index(linked_list,m_env,1);
+ ASSERT_NE(get_item, nullptr);
+ bresult = axutil_linked_list_check_bounds_inclusive(linked_list,m_env,1);
+ ASSERT_EQ(bresult, AXIS2_TRUE);
+ status = axutil_linked_list_remove_entry(linked_list,m_env,entry);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ get_item = axutil_linked_list_remove_first(linked_list,m_env);
+ ASSERT_NE(get_item, nullptr);
+ get_item = axutil_linked_list_remove_last(linked_list,m_env);
+ ASSERT_NE(get_item, nullptr);
+ ASSERT_EQ(axutil_linked_list_size(linked_list,m_env), 0);
+
+ bresult = axutil_linked_list_remove(linked_list,m_env,(void *)third_item);
+ ASSERT_EQ(bresult, AXIS2_FALSE);
+
+ axutil_linked_list_free(linked_list,m_env);
+}
+
Modified: axis/axis2/c/core/trunk/util/test/properties/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/properties/Makefile.am?rev=1830515&r1=1830514&r2=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/properties/Makefile.am (original)
+++ axis/axis2/c/core/trunk/util/test/properties/Makefile.am Sun Apr 29 16:12:14 2018
@@ -4,25 +4,26 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TESTS = property_test
-check_PROGRAMS = property_test
-noinst_PROGRAMS = property_test
-property_test_SOURCES = property_test.c ../util/create_env.c
+check_PROGRAMS = property_test
+noinst_PROGRAMS = property_test
+property_test_SOURCES = property_test.cc
property_test_LDADD = \
- $(top_builddir)/src/libaxutil.la
+ $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
-INCLUDES = -I$(top_builddir)/include \
+AM_CPPFLAGS = -I$(top_builddir)/include \
-I ../../../axiom/include \
-I ../../../include \
- -I ../../../cutest/include
-
+ -I $(GTEST_DIR)/include
Copied: axis/axis2/c/core/trunk/util/test/properties/property_test.cc (from r1830514, axis/axis2/c/core/trunk/util/test/properties/property_test.c)
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/properties/property_test.cc?p2=axis/axis2/c/core/trunk/util/test/properties/property_test.cc&p1=axis/axis2/c/core/trunk/util/test/properties/property_test.c&r1=1830514&r2=1830515&rev=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/properties/property_test.c (original)
+++ axis/axis2/c/core/trunk/util/test/properties/property_test.cc Sun Apr 29 16:12:14 2018
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+#include <gtest/gtest.h>
+
#include <axutil_env.h>
#include "../util/create_env.h"
#include <axutil_string.h>
@@ -31,23 +33,53 @@ void printProperties(axutil_properties_t
axis2_char_t *value = NULL;
for(hi = axutil_hash_first(all_properties, env); hi; hi = axutil_hash_next(env, hi))
{
- axutil_hash_this(hi, (void *)&key, NULL, (void *)&value);
+ axutil_hash_this(hi, (const void **)&key, NULL, (void **)&value);
if(key)
{
if(!value)
{
- value = axutil_strdup(env, "");
+ value = (axis2_char_t *) axutil_strdup(env, "");
}
printf("%s=%s\n", key, value);
}
}
}
}
+
+class TestProperties: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+
/** @brief test properties
* read file and give the output
*/
-axis2_status_t test_properties(axutil_env_t *env)
-{
+TEST_F(TestProperties, test_properties)
+{
axutil_hash_t* all_properties = NULL;
axis2_status_t status = AXIS2_FAILURE;
axis2_char_t* input_filename = "test.doc";
@@ -58,34 +90,18 @@ axis2_status_t test_properties(axutil_en
axis2_char_t * value = "value";
FILE *input = fopen("input.doc","rb");
FILE *output = fopen("output.doc","wb");
-
- if (!input)
- {
- printf("Can't open input.doc\n");
- return AXIS2_FAILURE;
- }
- if (!output)
- {
- printf("Can't open output.doc\n");
- return AXIS2_FAILURE;
- }
- properties = axutil_properties_create(env);
- if(!properties)
- {
- printf("Properties are not created\n");
- axutil_properties_free(properties,env);
- return AXIS2_FAILURE;
- }
- else
- printf("The the axutil_properties_create is successfull\n");
- status = axutil_properties_set_property(properties,env, key, value);
- if (status == AXIS2_SUCCESS)
- printf("The test axutil_properties_set_property is successful\n");
- else
- printf("The test axutil_properties_set_property failed\n") ;
-
- printProperties(properties, env);
+ ASSERT_NE(input, nullptr);
+ ASSERT_NE(output, nullptr);
+
+ properties = axutil_properties_create(m_env);
+ ASSERT_NE(properties, nullptr);
+
+ status = axutil_properties_set_property(properties,m_env, key, value);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+
+ printProperties(properties, m_env);
+
store_properties = AXIS2_SUCCESS;
/* Not used, program aborts on Windows with MSVC (Visual Studio 2008 Express Edition)
store_properties = axutil_properties_store(properties,env,output);
@@ -97,54 +113,16 @@ axis2_status_t test_properties(axutil_en
}
else
printf("The test axutil_properties_store is successfull\n");
-*/
- load_properties = axutil_properties_load(properties,env,input_filename);
- if(!load_properties)
- {
- printf("Properties can't be loaded\n");
- axutil_properties_free(properties,env);
- return AXIS2_FAILURE;
- }
- else
- printf("The test axutil_properties_load is successfull\n");
- printProperties(properties, env);
-
- all_properties = axutil_properties_get_all(properties,env);
- if(!all_properties)
- {
- printf("Can't call properties_get_all\n");
- axutil_properties_free(properties,env);
- return AXIS2_FAILURE;
- }
- else
- printf("The test axutil_properties_get_all is successfull\n");
-
- axutil_properties_free(properties,env);
-
- return AXIS2_SUCCESS;
-}
-
-int main()
-{
- axutil_env_t *env = NULL;
- int status = AXIS2_SUCCESS;
- env = create_environment();
- status = test_properties(env);
-
- if(status == AXIS2_FAILURE)
- {
- printf(" The test is failed\n");
- }
-
- axutil_env_free(env);
- return 0;
-}
-
-
-
-
+*/
+ load_properties = axutil_properties_load(properties,m_env,input_filename);
+ ASSERT_NE(load_properties, 0);
+ printProperties(properties, m_env);
+ all_properties = axutil_properties_get_all(properties,m_env);
+ ASSERT_NE(all_properties, nullptr);
+ axutil_properties_free(properties,m_env);
+}
Modified: axis/axis2/c/core/trunk/util/test/rand/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/rand/Makefile.am?rev=1830515&r1=1830514&r2=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/rand/Makefile.am (original)
+++ axis/axis2/c/core/trunk/util/test/rand/Makefile.am Sun Apr 29 16:12:14 2018
@@ -4,9 +4,9 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,15 +15,16 @@
TESTS = rand_test
check_PROGRAMS = rand_test
noinst_PROGRAMS = rand_test
-rand_test_SOURCES = rand_test.c ../util/create_env.c
+rand_test_SOURCES = rand_test.cc
rand_test_LDADD = \
- $(top_builddir)/src/libaxutil.la
+ $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
-INCLUDES = -I$(top_builddir)/include \
- -I$(CUTEST_HOME)/include \
+AM_CPPFLAGS = -I$(top_builddir)/include \
-I ../../../axiom/include \
-I ../../../include \
- -I ../../../test/cutest/include
+ -I $(GTEST_DIR)/include
Added: axis/axis2/c/core/trunk/util/test/rand/rand_test.cc
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/rand/rand_test.cc?rev=1830515&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/util/test/rand/rand_test.cc (added)
+++ axis/axis2/c/core/trunk/util/test/rand/rand_test.cc Sun Apr 29 16:12:14 2018
@@ -0,0 +1,73 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <gtest/gtest.h>
+
+#include "../util/create_env.h"
+#include <axutil_rand.h>
+
+class TestRand: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+
+/** @brief test_rand
+ * create random variable and get it's value
+ */
+
+TEST_F(TestRand, test_rand)
+{
+
+ int rand_number,rand_value,start = 2,end = 8,rand_range;
+ unsigned seed = 10;
+
+ rand_number = axutil_rand(&seed);
+ printf("rand_number : %d\n", rand_number);
+ rand_range = axutil_rand_with_range(&seed,start,end);
+ printf("rand_range : %d\n", rand_range);
+ ASSERT_NE(rand_range, -1);
+ ASSERT_GE(rand_range, start);
+ ASSERT_LE(rand_range, end);
+ rand_value = axutil_rand_get_seed_value_based_on_time(m_env);
+ printf("rand_based_on_time : %d\n", rand_value);
+
+
+}
Modified: axis/axis2/c/core/trunk/util/test/stack/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/stack/Makefile.am?rev=1830515&r1=1830514&r2=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/stack/Makefile.am (original)
+++ axis/axis2/c/core/trunk/util/test/stack/Makefile.am Sun Apr 29 16:12:14 2018
@@ -4,26 +4,27 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TESTS = stack_test
-check_PROGRAMS = stack_test
-noinst_PROGRAMS = stack_test
-stack_test_SOURCES = stack_test.c ../util/create_env.c
+check_PROGRAMS = stack_test
+noinst_PROGRAMS = stack_test
+stack_test_SOURCES = stack_test.cc
stack_test_LDADD = \
- $(top_builddir)/src/libaxutil.la
+ $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
-INCLUDES = -I$(top_builddir)/include \
- -I$(CUTEST_HOME)/include \
+AM_CPPFLAGS = -I$(top_builddir)/include \
-I ../../../axiom/include \
-I ../../../include \
- -I ../../../test/cutest/include
+ -I $(GTEST_DIR)/include
Added: axis/axis2/c/core/trunk/util/test/stack/stack_test.cc
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/stack/stack_test.cc?rev=1830515&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/util/test/stack/stack_test.cc (added)
+++ axis/axis2/c/core/trunk/util/test/stack/stack_test.cc Sun Apr 29 16:12:14 2018
@@ -0,0 +1,71 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <gtest/gtest.h>
+
+#include "../util/create_env.h"
+#include <axutil_stack.h>
+
+class TestStack: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+TEST_F(TestStack, test_om_build)
+{
+ axutil_stack_t * stack = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+ void * get_value = NULL;
+ char value[10] = "test\n";
+
+ stack = axutil_stack_create(m_env);
+ ASSERT_NE(stack, nullptr);
+ status = axutil_stack_push(stack,m_env,(void *)value);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ ASSERT_EQ(axutil_stack_size(stack,m_env), 1);
+ ASSERT_EQ(value, (char *)axutil_stack_get(stack,m_env));
+ get_value = axutil_stack_get_at(stack,m_env,0);
+ ASSERT_STREQ(value,(const char *)get_value);
+ ASSERT_STREQ(value,(char *)axutil_stack_pop(stack,m_env));
+ ASSERT_EQ(axutil_stack_size(stack,m_env), 0);
+
+ axutil_stack_free(stack,m_env);
+}
+
Modified: axis/axis2/c/core/trunk/util/test/string_util/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/string_util/Makefile.am?rev=1830515&r1=1830514&r2=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/string_util/Makefile.am (original)
+++ axis/axis2/c/core/trunk/util/test/string_util/Makefile.am Sun Apr 29 16:12:14 2018
@@ -4,26 +4,27 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TESTS = string_util_test
-noinst_PROGRAMS = string_util_test
-check_PROGRAMS = string_util_test
-string_util_test_SOURCES = string_util_test.c ../util/create_env.c
+noinst_PROGRAMS = string_util_test
+check_PROGRAMS = string_util_test
+string_util_test_SOURCES = string_util_test.cc
string_util_test_LDADD = \
- $(top_builddir)/src/libaxutil.la
+ $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
-INCLUDES = -I$(top_builddir)/include \
- -I$(CUTEST_HOME)/include \
+AM_CPPFLAGS = -I$(top_builddir)/include \
-I ../../../axiom/include \
-I ../../../include \
- -I ../../../test/cutest/include
+ -I $(GTEST_DIR)/include
Added: axis/axis2/c/core/trunk/util/test/string_util/string_util_test.cc
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/string_util/string_util_test.cc?rev=1830515&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/util/test/string_util/string_util_test.cc (added)
+++ axis/axis2/c/core/trunk/util/test/string_util/string_util_test.cc Sun Apr 29 16:12:14 2018
@@ -0,0 +1,92 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <gtest/gtest.h>
+
+#include <string.h>
+#include "../util/create_env.h"
+#include <axutil_string_util.h>
+#include <axutil_array_list.h>
+
+class TestString: public ::testing::Test
+{
+
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+
+/** @brief test string
+ * tokenize a string
+ */
+
+TEST_F(TestString, test_string)
+{
+ int delim = ' ';
+ void *token = NULL;
+ void *last_token_string = NULL;
+ void *first_token_string = NULL;
+ axutil_array_list_t * first_token, * last_token;
+ axis2_char_t * in = "this is a test string";
+
+ axutil_array_list_t * tokenize = axutil_tokenize(m_env, in, delim);
+ ASSERT_NE(tokenize, nullptr);
+ token = axutil_array_list_get(tokenize,m_env,4);
+ ASSERT_NE(token, nullptr);
+ ASSERT_STREQ((const char *)token, "string");
+
+ first_token = axutil_first_token(m_env,in,delim);
+ ASSERT_NE(first_token, nullptr);
+ if(first_token)
+ {
+ first_token_string = axutil_array_list_get(first_token,m_env,1);
+ ASSERT_NE(first_token_string, nullptr);
+ ASSERT_STREQ((const char *)first_token_string, "is a test string");
+ }
+
+ last_token = axutil_last_token(m_env,in,delim);
+ ASSERT_NE(last_token, nullptr);
+ if(last_token)
+ {
+ last_token_string = axutil_array_list_get(last_token,m_env,1);
+ ASSERT_NE(last_token_string, nullptr);
+ ASSERT_STREQ((const char *)last_token_string, "string");
+ }
+
+}
Modified: axis/axis2/c/core/trunk/util/test/uri/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/uri/Makefile.am?rev=1830515&r1=1830514&r2=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/uri/Makefile.am (original)
+++ axis/axis2/c/core/trunk/util/test/uri/Makefile.am Sun Apr 29 16:12:14 2018
@@ -4,26 +4,27 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TESTS = uri_test
-check_PROGRAMS = uri_test
-noinst_PROGRAMS = uri_test
-uri_test_SOURCES = uri_test.c ../util/create_env.c
+check_PROGRAMS = uri_test
+noinst_PROGRAMS = uri_test
+uri_test_SOURCES = uri_test.cc
uri_test_LDADD = \
- $(top_builddir)/src/libaxutil.la
+ $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
-INCLUDES = -I$(top_builddir)/include \
- -I$(CUTEST_HOME)/include \
+AM_CPPFLAGS = -I$(top_builddir)/include \
-I ../../../axiom/include \
-I ../../../include \
- -I ../../../test/cutest/include
+ -I $(GTEST_DIR)/include
Added: axis/axis2/c/core/trunk/util/test/uri/uri_test.cc
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/uri/uri_test.cc?rev=1830515&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/util/test/uri/uri_test.cc (added)
+++ axis/axis2/c/core/trunk/util/test/uri/uri_test.cc Sun Apr 29 16:12:14 2018
@@ -0,0 +1,112 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <gtest/gtest.h>
+
+#include <axutil_uri.h>
+#include "../util/create_env.h"
+
+class TestURI: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+/** @brief test uri
+ * * create URI and get the values of it's components
+ * */
+TEST_F(TestURI, test_uri)
+{
+ axis2_char_t * uri_str = "http://user:pass@example.com:80/foo?bar#item5";
+ axis2_char_t * host = "home.netscape.com:443";
+ axis2_char_t * uri_str_base = "http://user:pass@example.com:80/foo?bar";
+ axis2_char_t * scheme_str = "http";
+ axutil_uri_t * base = NULL;
+ axutil_uri_t * hostinfo = NULL;
+ axutil_uri_t * uri = NULL;
+ axutil_uri_t * clone = NULL;
+ axutil_uri_t * rel = NULL;
+ axis2_port_t scheme_port;
+ axis2_port_t port;
+ axis2_char_t * str;
+
+ hostinfo = axutil_uri_parse_hostinfo(m_env,host);
+ ASSERT_NE(hostinfo, nullptr);
+
+ scheme_port = axutil_uri_port_of_scheme(scheme_str);
+ ASSERT_NE(scheme_port, 0);
+
+ uri = axutil_uri_parse_string(m_env,uri_str);
+ ASSERT_NE(uri, nullptr);
+ str = axutil_uri_get_protocol(uri,m_env);
+ ASSERT_STREQ(str, "http");
+ port = axutil_uri_get_port(uri,m_env);
+ ASSERT_EQ(port, 80);
+ str = axutil_uri_get_path(uri,m_env);
+ ASSERT_STREQ(str, "/foo");
+ str = axutil_uri_get_host(uri,m_env);
+ ASSERT_STREQ(str, "example.com");
+
+ base = axutil_uri_parse_string(m_env,uri_str_base);
+ ASSERT_NE(base, nullptr);
+ if (base)
+ {
+ str = axutil_uri_to_string(base,m_env,0);
+ ASSERT_STREQ(str, "http://user:XXXXXXXX@example.com/foo?bar");
+ }
+
+ clone = axutil_uri_clone(uri,m_env);
+ ASSERT_NE(clone, nullptr);
+ if (clone)
+ {
+ str = axutil_uri_to_string(clone,m_env,0);
+ ASSERT_STREQ(str, "http://user:XXXXXXXX@example.com/foo?bar#item5");
+ axutil_uri_free(clone,m_env);
+ }
+
+ rel = axutil_uri_resolve_relative(m_env,base,uri);
+ ASSERT_NE(rel, nullptr);
+ if (rel)
+ {
+ str = axutil_uri_to_string(rel,m_env,0);
+ ASSERT_STREQ(str, "http://user:XXXXXXXX@example.com/foo?bar#item5");
+ }
+
+ axutil_uri_free(uri,m_env);
+}
Modified: axis/axis2/c/core/trunk/util/test/url/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/url/Makefile.am?rev=1830515&r1=1830514&r2=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/url/Makefile.am (original)
+++ axis/axis2/c/core/trunk/util/test/url/Makefile.am Sun Apr 29 16:12:14 2018
@@ -4,26 +4,27 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TESTS = url_test
-noinst_PROGRAMS = url_test
-check_PROGRAMS = url_test
-url_test_SOURCES = url_test.c ../util/create_env.c
+noinst_PROGRAMS = url_test
+check_PROGRAMS = url_test
+url_test_SOURCES = url_test.cc
url_test_LDADD = \
- $(top_builddir)/src/libaxutil.la
+ $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
-INCLUDES = -I$(top_builddir)/include \
- -I$(CUTEST_HOME)/include \
+AM_CPPFLAGS = -I$(top_builddir)/include \
-I ../../../axiom/include \
-I ../../../include \
- -I ../../../test/cutest/include
+ -I $(GTEST_DIR)/include
Added: axis/axis2/c/core/trunk/util/test/url/url_test.cc
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/url/url_test.cc?rev=1830515&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/util/test/url/url_test.cc (added)
+++ axis/axis2/c/core/trunk/util/test/url/url_test.cc Sun Apr 29 16:12:14 2018
@@ -0,0 +1,96 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <gtest/gtest.h>
+
+#include <axutil_url.h>
+#include "../util/create_env.h"
+
+class TestURL: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+
+
+/** @brief test url
+ * create URL and get the values of it's components
+ */
+TEST_F(TestURL, test_url)
+{
+ 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(m_env,url_str);
+ ASSERT_NE(url, nullptr);
+
+ status = axutil_url_set_protocol(url,m_env,set_protocol);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ status = axutil_url_set_server(url,m_env,set_server);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ status = axutil_url_set_port(url,m_env,set_port);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+ status = axutil_url_set_path(url,m_env,set_path);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+
+ get_protocol = axutil_url_get_protocol(url,m_env);
+ ASSERT_STREQ(get_protocol, set_protocol);
+
+ get_server = axutil_url_get_server(url,m_env);
+ ASSERT_STREQ(get_server, "www.yahoo.com:80");
+
+ get_port = axutil_url_get_port(url,m_env);
+ ASSERT_EQ(get_port,set_port);
+
+ get_path = axutil_url_get_path(url,m_env);
+ ASSERT_STREQ(get_path, set_path);
+
+ axutil_url_free(url,m_env);
+}
+
Modified: axis/axis2/c/core/trunk/util/test/util/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/util/Makefile.am?rev=1830515&r1=1830514&r2=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/util/Makefile.am (original)
+++ axis/axis2/c/core/trunk/util/test/util/Makefile.am Sun Apr 29 16:12:14 2018
@@ -4,30 +4,43 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TESTS = test_thread test_util
-noinst_PROGRAMS = test_util test_thread
+noinst_PROGRAMS = test_util test_thread test_md5 test_string
noinst_HEADERS = test_log.h \
test_thread.h \
create_env.h\
test_md5.h
check_PROGRAMS = test_util test_thread
SUBDIRS =
-test_util_SOURCES = test_util.c test_log.c test_md5.c create_env.c
-test_thread_SOURCES = test_thread.c
+test_util_SOURCES = test_util.cc test_log.cc
+test_thread_SOURCES = test_thread.cc
+test_md5_SOURCES = test_md5.cc
+test_string_SOURCES = test_string.cc
-test_util_LDADD = $(top_builddir)/src/libaxutil.la
+test_util_LDADD = $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
-test_thread_LDADD = $(top_builddir)/src/libaxutil.la
+test_thread_LDADD = $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
+
+test_md5_LDADD = $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
+
+test_string_LDADD = $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
+
+AM_CPPFLAGS = -I$(top_builddir)/include \
+ -I $(GTEST_DIR)/include
-INCLUDES = -I$(top_builddir)/include \
- -I$(CUTEST_HOME)/include \
- -I ../../../test/cutest/include
-EXTRA_DIST = test_string.c
Copied: axis/axis2/c/core/trunk/util/test/util/test_log.cc (from r1830514, axis/axis2/c/core/trunk/util/test/util/test_log.c)
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/util/test_log.cc?p2=axis/axis2/c/core/trunk/util/test/util/test_log.cc&p1=axis/axis2/c/core/trunk/util/test/util/test_log.c&r1=1830514&r2=1830515&rev=1830515&view=diff
==============================================================================
(empty)
Copied: axis/axis2/c/core/trunk/util/test/util/test_md5.cc (from r1830514, axis/axis2/c/core/trunk/util/test/util/test_md5.c)
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/util/test_md5.cc?p2=axis/axis2/c/core/trunk/util/test/util/test_md5.cc&p1=axis/axis2/c/core/trunk/util/test/util/test_md5.c&r1=1830514&r2=1830515&rev=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/util/test_md5.c (original)
+++ axis/axis2/c/core/trunk/util/test/util/test_md5.cc Sun Apr 29 16:12:14 2018
@@ -16,10 +16,15 @@
* limitations under the License.
*/
+#include <gtest/gtest.h>
+
#include "test_md5.h"
#include <stdio.h>
#include <axutil_string.h>
#include <axutil_md5.h>
+#include <axutil_log_default.h>
+#include <axutil_log.h>
+#include <axutil_error_default.h>
/* Digests a string and prints the result.
*/
@@ -41,15 +46,44 @@ static void MDString (char * string, con
printf ("\n");
}
-void test_md5(const axutil_env_t *env)
+class TestMD5: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+TEST_F(TestMD5, test_md5)
{
+
printf ("\nMD5 test suite:\n");
printf ("test confirmation: Rivest, R., \"The MD5 Message-Digest Algorithm\", RFC 1321, April 1992.\n");
- MDString ("", env);
- MDString ("a", env);
- MDString ("abc", env);
- MDString ("message digest", env);
- MDString ("abcdefghijklmnopqrstuvwxyz", env);
- MDString ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", env);
- MDString ("12345678901234567890123456789012345678901234567890123456789012345678901234567890", env);
+ MDString ("", m_env);
+ MDString ("a", m_env);
+ MDString ("abc", m_env);
+ MDString ("message digest", m_env);
+ MDString ("abcdefghijklmnopqrstuvwxyz", m_env);
+ MDString ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", m_env);
+ MDString ("12345678901234567890123456789012345678901234567890123456789012345678901234567890", m_env);
}
Added: axis/axis2/c/core/trunk/util/test/util/test_string.cc
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/util/test_string.cc?rev=1830515&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/util/test/util/test_string.cc (added)
+++ axis/axis2/c/core/trunk/util/test/util/test_string.cc Sun Apr 29 16:12:14 2018
@@ -0,0 +1,92 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <stdio.h>
+#include <axutil_error_default.h>
+#include <axutil_log.h>
+#include <axutil_log_default.h>
+#include <axutil_string.h>
+
+class TestString: public ::testing::Test
+{
+
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+
+TEST_F(TestString, test_strltrim)
+{
+
+ axis2_char_t *s = (axis2_char_t*) axutil_strdup(m_env, " abcd efgh ");
+ axis2_char_t *trimmed = NULL;
+ trimmed = axutil_strltrim(m_env, s, " \t\r\n");
+ ASSERT_STREQ(trimmed, "abcd efgh ");
+ if (trimmed)
+ AXIS2_FREE(m_env->allocator, trimmed);
+ if (s)
+ AXIS2_FREE(m_env->allocator, s);
+}
+
+TEST_F(TestString, test_strrtrim)
+{
+ axis2_char_t *s = (axis2_char_t*) axutil_strdup(m_env, " abcd efgh ");
+ axis2_char_t *trimmed = NULL;
+ trimmed = axutil_strrtrim(m_env, s, " \t\r\n");
+ ASSERT_STREQ(trimmed, " abcd efgh");
+ if (trimmed)
+ AXIS2_FREE(m_env->allocator, trimmed);
+ if (s)
+ AXIS2_FREE(m_env->allocator, s);
+}
+
+TEST_F(TestString, test_strtrim)
+{
+ axis2_char_t *s = (axis2_char_t*) axutil_strdup(m_env, " abcd efgh ");
+ axis2_char_t *trimmed = NULL;
+ trimmed = axutil_strtrim(m_env, s, " \t\r\n");
+ ASSERT_STREQ(trimmed, "abcd efgh");
+ if (trimmed)
+ AXIS2_FREE(m_env->allocator, trimmed);
+ if (s)
+ AXIS2_FREE(m_env->allocator, s);
+}
Copied: axis/axis2/c/core/trunk/util/test/util/test_thread.cc (from r1830514, axis/axis2/c/core/trunk/util/test/util/test_thread.c)
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/util/test_thread.cc?p2=axis/axis2/c/core/trunk/util/test/util/test_thread.cc&p1=axis/axis2/c/core/trunk/util/test/util/test_thread.c&r1=1830514&r2=1830515&rev=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/util/test_thread.c (original)
+++ axis/axis2/c/core/trunk/util/test/util/test_thread.cc Sun Apr 29 16:12:14 2018
@@ -16,6 +16,8 @@
* limitations under the License.
*/
+#include <gtest/gtest.h>
+
#include <stdio.h>
#include <string.h>
#include <axutil_error_default.h>
@@ -24,7 +26,6 @@
#include <axutil_allocator.h>
#include <axutil_utils.h>
#include "test_thread.h"
-#include <cut_defs.h>
const axutil_env_t *env = NULL;
static axutil_thread_mutex_t *thread_lock = NULL;
@@ -56,14 +57,11 @@ test_thread_init(
allocator = env->allocator;
control = axutil_thread_once_init(allocator);
- CUT_ASSERT_PTR_NOT_EQUAL(control, NULL, 0);
+ ASSERT_NE(control, nullptr);
thread_lock =
axutil_thread_mutex_create(allocator, AXIS2_THREAD_MUTEX_DEFAULT);
- CUT_ASSERT_PTR_NOT_EQUAL(thread_lock, NULL, 0);
- /* To avoid warning of not using cut_str_equal */
- CUT_ASSERT_STR_EQUAL("", "", 0);
-
+ ASSERT_NE(thread_lock, nullptr);
}
void *AXIS2_CALL
@@ -74,9 +72,9 @@ test_function(
int i = *((int *) param);
printf("thread data = %d \n", i);
param_data = i;
-
+
axutil_thread_once(control, init_func);
- CUT_ASSERT(value==1);
+ EXPECT_EQ(value, 1);
axutil_thread_mutex_lock(thread_lock);
printf("x = %d \n", ++x);
axutil_thread_mutex_unlock(thread_lock);
@@ -96,28 +94,28 @@ test_axutil_thread_create(
*j = NULL;
allocator = env->allocator;
- i = AXIS2_MALLOC(allocator, sizeof(int));
+ i = (int*)AXIS2_MALLOC(allocator, sizeof(int));
*i = 5;
param_data = -1;
t1 = axutil_thread_create(allocator, NULL, test_function, (void *) i);
- CUT_ASSERT_PTR_NOT_EQUAL(t1, NULL, 0);
+ ASSERT_NE(t1, nullptr);
AXIS2_SLEEP(1);
- CUT_ASSERT_INT_EQUAL(param_data, *i, 0);
+ ASSERT_EQ(param_data, *i);
- j = AXIS2_MALLOC(allocator, sizeof(int));
+ j = (int*)AXIS2_MALLOC(allocator, sizeof(int));
*j = 25;
param_data = -1;
t2 = axutil_thread_create(allocator, NULL, test_function, (void *) j);
- CUT_ASSERT_PTR_NOT_EQUAL(t2, NULL, 0);
+ ASSERT_NE(t2, nullptr);
AXIS2_SLEEP(1);
- CUT_ASSERT_INT_EQUAL(param_data, *j, 0);
+ ASSERT_EQ(param_data, *j);
rv = axutil_thread_join(t1);
- CUT_ASSERT_INT_EQUAL(rv, AXIS2_SUCCESS, 0);
+ ASSERT_EQ(rv, AXIS2_SUCCESS);
rv = axutil_thread_join(t2);
- CUT_ASSERT_INT_EQUAL(rv, AXIS2_SUCCESS, 0);
+ ASSERT_EQ(rv, AXIS2_SUCCESS);
}
@@ -140,17 +138,17 @@ test_axutil_thread_detach(
allocator = env->allocator;
attr = axutil_threadattr_create(allocator);
- CUT_ASSERT_PTR_NOT_EQUAL(attr, NULL, 1);
+ ASSERT_NE(attr, nullptr);
rv = axutil_threadattr_detach_set(attr, 1);
- CUT_ASSERT_INT_EQUAL(rv, AXIS2_SUCCESS, 1);
+ ASSERT_EQ(rv, AXIS2_SUCCESS);
t3 = axutil_thread_create(allocator, attr, test_function2, NULL);
- CUT_ASSERT_PTR_NOT_EQUAL(t3, NULL, 1);
+ ASSERT_NE(t3, nullptr);
/*
* thread is already detached - should return AXIS2_FAILURE
*/
rv = axutil_thread_detach(t3);
- CUT_ASSERT_INT_EQUAL(rv, AXIS2_FAILURE, 1);
+ ASSERT_EQ(rv, AXIS2_FAILURE);
}
void
@@ -163,41 +161,69 @@ test_axutil_thread_detach2(
allocator = env->allocator;
attr = axutil_threadattr_create(allocator);
- CUT_ASSERT_PTR_NOT_EQUAL(attr, NULL, 1);
+ ASSERT_NE(attr, nullptr);
t4 = axutil_thread_create(allocator, attr, test_function2, NULL);
- CUT_ASSERT_PTR_NOT_EQUAL(t4, NULL, 1);
+ ASSERT_NE(t4, nullptr);
/*
* thread is not detached yet - should return AXIS2_SUCCESS
*/
rv = axutil_thread_detach(t4);
- CUT_ASSERT_INT_EQUAL(rv, AXIS2_SUCCESS, 1);
+ ASSERT_EQ(rv, AXIS2_SUCCESS);
}
void
check_locks(
)
{
- CUT_ASSERT_INT_EQUAL(x, 2, 0);
+ ASSERT_EQ(x, 2);
}
void
check_thread_once(
)
{
- CUT_ASSERT_INT_EQUAL(value, 1, 0);
+ ASSERT_EQ(value, 1);
}
-void
-run_test_thread(
- const axutil_env_t * env)
+class TestThread: public ::testing::Test
{
- test_thread_init(env);
- test_axutil_thread_create(env);
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+
+TEST_F(TestThread, test_thread)
+{
+
+ test_thread_init(m_env);
+ test_axutil_thread_create(m_env);
check_locks();
check_thread_once();
- test_axutil_thread_detach(env);
- test_axutil_thread_detach2(env);
+ test_axutil_thread_detach(m_env);
+ test_axutil_thread_detach2(m_env);
#if defined (WIN32)
Sleep(1000); /*to give time for detached threads to execute */
@@ -207,17 +233,3 @@ run_test_thread(
axutil_thread_mutex_destroy(thread_lock);
}
-
-int
-main(
- void)
-{
- axutil_env_t *env = cut_setup_env("util thread");
- CUT_ASSERT(env != NULL);
- if (env) {
- run_test_thread(env);
- axutil_env_free(env);
- }
- CUT_RETURN_ON_FAILURE(-1);
- return 0;
-}
Added: axis/axis2/c/core/trunk/util/test/util/test_util.cc
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/util/test_util.cc?rev=1830515&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/util/test/util/test_util.cc (added)
+++ axis/axis2/c/core/trunk/util/test/util/test_util.cc Sun Apr 29 16:12:14 2018
@@ -0,0 +1,261 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <stdio.h>
+#include <axutil_hash.h>
+#include <axutil_string.h>
+#include <axutil_error_default.h>
+#include <axutil_array_list.h>
+#include <platforms/axutil_platform_auto_sense.h>
+#include <axutil_uuid_gen.h>
+#include <axutil_log_default.h>
+#include <axutil_log.h>
+#include <axutil_dir_handler.h>
+#include <axutil_file.h>
+#include "axutil_log.h"
+#include "test_thread.h"
+#include "test_log.h"
+#include "test_md5.h"
+
+extern void
+run_test_string(
+ axutil_env_t * env);
+
+typedef struct a
+{
+ axis2_char_t *value;
+}
+a;
+
+class TestUtil: public ::testing::Test
+{
+
+ protected:
+ void SetUp()
+ {
+
+ m_allocator = axutil_allocator_init(NULL);
+ m_axis_log = axutil_log_create(m_allocator, NULL, NULL);
+ m_error = axutil_error_create(m_allocator);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+ }
+
+ void TearDown()
+ {
+ axutil_env_free(m_env);
+ }
+
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_axis_log = NULL;
+
+};
+
+
+TEST_F(TestUtil, test_hash_get)
+{
+
+ axutil_hash_t *ht;
+ a *a1,
+ *a2,
+ *a3,
+ *a4;
+
+ axutil_hash_index_t *i = 0;
+ void *v = NULL;
+
+ char *key1 = "key1";
+ char *key2 = "key2";
+ char *key3 = "key3";
+ char *key4 = "key4";
+
+ a1 = (a *) AXIS2_MALLOC(m_env->allocator, sizeof(a));
+ a2 = (a *) AXIS2_MALLOC(m_env->allocator, sizeof(a));
+ a3 = (a *) AXIS2_MALLOC(m_env->allocator, sizeof(a));
+ a4 = (a *) AXIS2_MALLOC(m_env->allocator, sizeof(a));
+
+ a1->value = (axis2_char_t*) axutil_strdup(m_env, "value1");
+ a2->value = (axis2_char_t*) axutil_strdup(m_env, "value2");
+ a3->value = (axis2_char_t*) axutil_strdup(m_env, "value3");
+ a4->value = (axis2_char_t*) axutil_strdup(m_env, "value4");
+
+ ht = axutil_hash_make(m_env);
+
+ axutil_hash_set(ht, key1, AXIS2_HASH_KEY_STRING, a1);
+ axutil_hash_set(ht, key2, AXIS2_HASH_KEY_STRING, a2);
+ axutil_hash_set(ht, key3, AXIS2_HASH_KEY_STRING, a3);
+ axutil_hash_set(ht, key4, AXIS2_HASH_KEY_STRING, a4);
+
+ axutil_hash_set(ht, key2, AXIS2_HASH_KEY_STRING, NULL);
+ axutil_hash_set(ht, key2, AXIS2_HASH_KEY_STRING, a2);
+ for (i = axutil_hash_first(ht, m_env); i; i = axutil_hash_next(m_env, i))
+ {
+ axutil_hash_this(i, NULL, NULL, &v);
+ printf("\n %s \n", ((a *) v)->value);
+ }
+
+ ASSERT_STREQ(((a *) axutil_hash_get(ht, key1, AXIS2_HASH_KEY_STRING))->value, "value1");
+ ASSERT_STREQ(((a *) axutil_hash_get(ht, key2, AXIS2_HASH_KEY_STRING))->value, "value2");
+ ASSERT_STREQ(((a *) axutil_hash_get(ht, key3, AXIS2_HASH_KEY_STRING))->value, "value3");
+ ASSERT_STREQ(((a *) axutil_hash_get(ht, key4, AXIS2_HASH_KEY_STRING))->value, "value4");
+
+ axutil_hash_free(ht, m_env);
+ AXIS2_FREE(m_env->allocator, a1->value);
+ AXIS2_FREE(m_env->allocator, a2->value);
+ AXIS2_FREE(m_env->allocator, a3->value);
+ AXIS2_FREE(m_env->allocator, a4->value);
+ AXIS2_FREE(m_env->allocator, a1);
+ AXIS2_FREE(m_env->allocator, a2);
+ AXIS2_FREE(m_env->allocator, a3);
+ AXIS2_FREE(m_env->allocator, a4);
+}
+
+TEST_F(TestUtil, test_axutil_dir_handler_list_service_or_module_dirs)
+{
+ int i,
+ isize;
+ axutil_file_t *file = NULL;
+ axis2_char_t *filename = NULL;
+
+ axis2_char_t *pathname = (axis2_char_t*) axutil_strdup(m_env, "/tmp/test/");
+
+ axutil_array_list_t *arr_folders =
+ axutil_dir_handler_list_service_or_module_dirs(m_env, pathname);
+ if (arr_folders == NULL)
+ {
+ printf("List of folders is NULL\n");
+ return;
+ }
+
+ isize = axutil_array_list_size(arr_folders, m_env);
+ printf("Folder array size = %d \n", isize);
+
+ for (i = 0; i < isize; ++i)
+ {
+ file = (axutil_file_t *) axutil_array_list_get(arr_folders, m_env, i);
+ filename = axutil_file_get_name(file, m_env);
+ printf("filename = %s \n", filename);
+ }
+ printf
+ ("----end of test_axutil_dir_handler_list_service_or_module_dirs----\n");
+
+}
+
+/**
+ * This test is intended to test whether given two files are equal or not.
+ * Spaces and new lines are ignored in comparing
+ */
+TEST_F(TestUtil, test_file_diff)
+{
+ /* TODO */
+}
+
+TEST_F(TestUtil, test_array_list)
+{
+
+ axutil_array_list_t *al;
+ a *entry = NULL;
+ int size;
+
+ al = axutil_array_list_create(m_env, 1);
+ ASSERT_NE(al, nullptr);
+ ASSERT_EQ(axutil_array_list_size(al, m_env), 0);
+
+ entry = (a *) AXIS2_MALLOC(m_env->allocator, sizeof(a));
+ entry->value = (axis2_char_t*) axutil_strdup(m_env, "value1");
+ axutil_array_list_add(al, m_env, (void *) entry);
+
+ entry = (a *) AXIS2_MALLOC(m_env->allocator, sizeof(a));
+ entry->value = (axis2_char_t*) axutil_strdup(m_env, "value2");
+ axutil_array_list_add(al, m_env, (void *) entry);
+
+ entry = (a *) AXIS2_MALLOC(m_env->allocator, sizeof(a));
+ entry->value = (axis2_char_t*) axutil_strdup(m_env, "value3");
+ axutil_array_list_add(al, m_env, (void *) entry);
+
+ entry = (a *) AXIS2_MALLOC(m_env->allocator, sizeof(a));
+ entry->value = (axis2_char_t*) axutil_strdup(m_env, "value4");
+ axutil_array_list_add(al, m_env, (void *) entry);
+
+ entry = (a *) AXIS2_MALLOC(m_env->allocator, sizeof(a));
+ entry->value = (axis2_char_t*) axutil_strdup(m_env, "value5");
+ axutil_array_list_add(al, m_env, (void *) entry);
+
+ entry = (a *) AXIS2_MALLOC(m_env->allocator, sizeof(a));
+ entry->value = (axis2_char_t*) axutil_strdup(m_env, "value6");
+ axutil_array_list_add(al, m_env, (void *) entry);
+
+ entry = (a *) AXIS2_MALLOC(m_env->allocator, sizeof(a));
+ entry->value = (axis2_char_t*) axutil_strdup(m_env, "value7");
+ axutil_array_list_set(al, m_env, 3, (void *) entry);
+ axutil_array_list_remove(al, m_env, 2);
+
+ entry = (a *) axutil_array_list_get(al, m_env, 0);
+ ASSERT_STREQ(entry->value, "value1");
+
+ entry = (a *) axutil_array_list_get(al, m_env, 2);
+ ASSERT_STREQ(entry->value, "value7");
+ size = axutil_array_list_size(al, m_env);
+ ASSERT_EQ(size, 5);
+}
+
+
+TEST_F(TestUtil, test_uuid_gen)
+{
+ char *uuid = NULL;
+ printf("starting uuid_gen test...\n");
+ uuid = axutil_uuid_gen(m_env);
+ printf("Generated UUID 1:%s\n", uuid);
+ AXIS2_FREE(m_env->allocator, uuid);
+ uuid = axutil_uuid_gen(m_env);
+ printf("Generated UUID 2:%s\n", uuid);
+ AXIS2_FREE(m_env->allocator, uuid);
+ printf("finished uuid_gen test...\n");
+}
+
+
+TEST_F(TestUtil, test_log_write)
+{
+ axutil_error_t *error = NULL;
+ axutil_log_t *log22 = NULL;
+ axutil_env_t *env = NULL;
+ axutil_allocator_t *allocator = axutil_allocator_init(NULL);
+ ASSERT_NE(allocator, nullptr);
+ error = axutil_error_create(allocator);
+ ASSERT_NE(error, nullptr);
+ log22 = axutil_log_create(allocator, NULL, NULL);
+ ASSERT_NE(log22, nullptr);
+ log22->level = AXIS2_LOG_LEVEL_DEBUG;
+ env = axutil_env_create_with_error_log(allocator, error, log22);
+ ASSERT_NE(env, nullptr);
+
+ AXIS2_LOG_CRITICAL(env->log, AXIS2_LOG_SI, "log1 %s", "test1");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "log2 %d", 2);
+ AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "log3 %s", "test3");
+ AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, "log4 %s %s", "info1", "info2");
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "log5 %s %d", "test", 5);
+ axutil_env_free(env);
+
+}
+
Modified: axis/axis2/c/core/trunk/util/test/utils/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/test/utils/Makefile.am?rev=1830515&r1=1830514&r2=1830515&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/test/utils/Makefile.am (original)
+++ axis/axis2/c/core/trunk/util/test/utils/Makefile.am Sun Apr 29 16:12:14 2018
@@ -4,26 +4,27 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TESTS = utils_test
-check_PROGRAMS = utils_test
-noinst_PROGRAMS = utils_test
-utils_test_SOURCES = utils_test.c ../util/create_env.c
+check_PROGRAMS = utils_test
+noinst_PROGRAMS = utils_test
+utils_test_SOURCES = utils_test.cc
utils_test_LDADD = \
- $(top_builddir)/src/libaxutil.la
+ $(top_builddir)/src/libaxutil.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a
-INCLUDES = -I$(top_builddir)/include \
- -I$(CUTEST_HOME)/include \
+AM_CPPFLAGS = -I$(top_builddir)/include \
-I ../../../axiom/include \
-I ../../../include \
- -I ../../../test/cutest/include
+ -I $(GTEST_DIR)/include