axis-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billblo...@apache.org
Subject svn commit: r1830485 - in /axis/axis2/c/core/trunk/neethi/test: Makefile.am test.c test.cc
Date Sun, 29 Apr 2018 01:57:10 GMT
Author: billblough
Date: Sun Apr 29 01:57:10 2018
New Revision: 1830485

URL: http://svn.apache.org/viewvc?rev=1830485&view=rev
Log:
Convert neethi test to use gtest

Added:
    axis/axis2/c/core/trunk/neethi/test/test.cc
      - copied, changed from r1830483, axis/axis2/c/core/trunk/neethi/test/test.c
Removed:
    axis/axis2/c/core/trunk/neethi/test/test.c
Modified:
    axis/axis2/c/core/trunk/neethi/test/Makefile.am

Modified: axis/axis2/c/core/trunk/neethi/test/Makefile.am
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/neethi/test/Makefile.am?rev=1830485&r1=1830484&r2=1830485&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/neethi/test/Makefile.am (original)
+++ axis/axis2/c/core/trunk/neethi/test/Makefile.am Sun Apr 29 01:57:10 2018
@@ -12,18 +12,23 @@
 # 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 = 
+TESTS = test
 noinst_PROGRAMS = test
+check_PROGRAMS = test
+SUBDIRS =
 
-test_SOURCES = test.c
+test_SOURCES = test.cc
 
-INCLUDES = -I$(top_builddir)/include \
-			-I ../../util/include \
-			-I ../../axiom/include \
-		    -I ../../include
+AM_CPPFLAGS = -I$(top_builddir)/include \
+				-I ../../util/include \
+				-I ../../axiom/include \
+				-I ../../include \
+				-I $(GTEST_DIR)/include
 
 test_LDADD = $(top_builddir)/src/libneethi.la \
 			../../axiom/src/om/libaxis2_axiom.la \
 			../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
 			../../util/src/libaxutil.la \
-			../src/libneethi.la
+			../src/libneethi.la \
+			$(top_builddir)/$(GTEST)/libgtest.a \
+			$(top_builddir)/$(GTEST)/libgtest_main.a

Copied: axis/axis2/c/core/trunk/neethi/test/test.cc (from r1830483, axis/axis2/c/core/trunk/neethi/test/test.c)
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/neethi/test/test.cc?p2=axis/axis2/c/core/trunk/neethi/test/test.cc&p1=axis/axis2/c/core/trunk/neethi/test/test.c&r1=1830483&r2=1830485&rev=1830485&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/neethi/test/test.c (original)
+++ axis/axis2/c/core/trunk/neethi/test/test.cc Sun Apr 29 01:57:10 2018
@@ -15,6 +15,8 @@
 * limitations under the License.
 */
 
+#include <gtest/gtest.h>
+
 #include <axiom.h>
 #include <axutil_utils.h>
 #include <axutil_env.h>
@@ -29,88 +31,87 @@ axis2_status_t AXIS2_CALL om_node_serial
     axiom_node_t * node,
     const axutil_env_t * env);
 
-int
-main(
-    int argc,
-    char **argv)
+class TestNeethi: public ::testing::Test
 {
-    /*axutil_allocator_t *allocator = axutil_allocator_init(NULL);
-    axutil_error_t *error = axutil_error_create(allocator);
-    const axutil_env_t *env = axutil_env_create_with_error(allocator, error);*/
-    const axutil_env_t *env = NULL;
+
+    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_environment = axutil_env_create_with_error_log(m_allocator, m_error, m_axis_log);
+
+        }
+
+        void TearDown()
+        {
+            axutil_env_free(m_environment);
+        }
+
+
+        axutil_allocator_t *m_allocator = NULL;
+        axutil_env_t *m_environment = NULL;
+        axutil_error_t *m_error = NULL;
+        axutil_log_t *m_axis_log = NULL;
+
+};
+
+
+TEST_F(TestNeethi, test_get_policy)
+{
+
     axiom_xml_reader_t *reader = NULL;
     axiom_stax_builder_t *builder = NULL;
     axiom_document_t *document = NULL;
     axiom_node_t *root = NULL;
     axiom_element_t *root_ele = NULL;
 
-    env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE);
+    char *filename = "policies/symmetric_binding_policy.xml";
 
-    reader = axiom_xml_reader_create_for_file(env, argv[1], NULL);
+    reader = axiom_xml_reader_create_for_file(m_environment, filename, NULL);
+    ASSERT_NE(reader, nullptr);
 
-    if (!reader)
-    {
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_CREATING_XML_STREAM_READER,
-                        AXIS2_FAILURE);
-        printf("xml reader creation failed\n");
-        return 0;
-    }
+    builder = axiom_stax_builder_create(m_environment, reader);
+    ASSERT_NE(builder, nullptr);
 
-    builder = axiom_stax_builder_create(env, reader);
-    if (!builder)
-    {
-        axiom_xml_reader_free(reader, env);
-        printf("Builder creation failed\n");
-        return 0;
-    }
-    document = axiom_stax_builder_get_document(builder, env);
-    if (!document)
-    {
-        axiom_stax_builder_free(builder, env);
-        printf("Document creation failed\n");
-        return 0;
-    }
+    document = axiom_stax_builder_get_document(builder, m_environment);
+    ASSERT_NE(document, nullptr);
 
-    /*root = axiom_document_get_root_element(document, env); */
-    root = axiom_document_build_all(document, env);
-    if (!root)
-    {
-        axiom_stax_builder_free(builder, env);
-        return 0;
-    }
+    root = axiom_document_get_root_element(document, m_environment);
+    /*root = axiom_document_build_all(document, m_environment); */
+    ASSERT_NE(root, nullptr);
 
     if (root)
     {
-        if (axiom_node_get_node_type(root, env) == AXIOM_ELEMENT)
+        if (axiom_node_get_node_type(root, m_environment) == AXIOM_ELEMENT)
         {
             root_ele =
-                (axiom_element_t *) axiom_node_get_data_element(root, env);
+                (axiom_element_t *) axiom_node_get_data_element(root, m_environment);
             if (root_ele)
             {
                 neethi_policy_t *neethi_policy = NULL;
-                neethi_policy = neethi_engine_get_policy(env, root, root_ele);
-                if (!neethi_policy)
-                {
-                    printf("Policy Creation fails\n");
-                    return 0;
-                }
+                neethi_policy = neethi_engine_get_policy(m_environment, root, root_ele);
+                ASSERT_NE(neethi_policy, nullptr);
 
                 if(neethi_policy)
                 {
                     axis2_char_t *id = NULL;
                     axis2_char_t *name = NULL;
 
-                    id = neethi_policy_get_id(neethi_policy, env); 
+                    id = neethi_policy_get_id(neethi_policy, m_environment); 
                     if(id)
                     {
                         printf("Id is : %s\n", id);
                     }   
-                    name = neethi_policy_get_name(neethi_policy, env);
+                    name = neethi_policy_get_name(neethi_policy, m_environment);
                     if(name)
                     {
                         printf("Name is : %s\n", name);
                     }
-                    neethi_policy_free(neethi_policy, env);
+                    neethi_policy_free(neethi_policy, m_environment);
                     neethi_policy = NULL;
 
                     printf("Successful \n");
@@ -134,16 +135,10 @@ main(
 
     if(builder)
     {
-        axiom_stax_builder_free(builder, env);
+        axiom_stax_builder_free(builder, m_environment);
         builder = NULL;
     }
 
-    axutil_env_free((axutil_env_t *)env);
-    env = NULL;    
-
-    printf("Successful\n");
-    return 0;
-
 }
 
 axis2_status_t AXIS2_CALL



Mime
View raw message