From 0b1961eff29db8bdc17619930370582215cc8f1b Mon Sep 17 00:00:00 2001 From: Cinzia Di Giusto Date: Mon, 23 May 2005 12:56:12 +0000 Subject: [PATCH] unit test --- org.glite.wms-utils.exception/test/Makefile.am | 33 +++++++ .../test/exception_cu_main.cpp | 33 +++++++ .../test/exception_cu_suite.cpp | 56 +++++++++++ .../test/exception_cu_suite.h | 29 ++++++ org.glite.wms-utils.jobid/test/Makefile.am | 48 ++++++++++ org.glite.wms-utils.jobid/test/jobid_cu_main.cpp | 33 +++++++ org.glite.wms-utils.jobid/test/jobid_cu_suite.cpp | 102 +++++++++++++++++++++ org.glite.wms-utils.jobid/test/jobid_cu_suite.h | 34 +++++++ .../test/manipulation_cu_main.cpp | 33 +++++++ .../test/manipulation_cu_suite.cpp | 34 +++++++ .../test/manipulation_cu_suite.h | 29 ++++++ 11 files changed, 464 insertions(+) create mode 100755 org.glite.wms-utils.exception/test/Makefile.am create mode 100644 org.glite.wms-utils.exception/test/exception_cu_main.cpp create mode 100644 org.glite.wms-utils.exception/test/exception_cu_suite.cpp create mode 100644 org.glite.wms-utils.exception/test/exception_cu_suite.h create mode 100755 org.glite.wms-utils.jobid/test/Makefile.am create mode 100644 org.glite.wms-utils.jobid/test/jobid_cu_main.cpp create mode 100644 org.glite.wms-utils.jobid/test/jobid_cu_suite.cpp create mode 100644 org.glite.wms-utils.jobid/test/jobid_cu_suite.h create mode 100644 org.glite.wms-utils.jobid/test/manipulation_cu_main.cpp create mode 100644 org.glite.wms-utils.jobid/test/manipulation_cu_suite.cpp create mode 100644 org.glite.wms-utils.jobid/test/manipulation_cu_suite.h diff --git a/org.glite.wms-utils.exception/test/Makefile.am b/org.glite.wms-utils.exception/test/Makefile.am new file mode 100755 index 0000000..a972450 --- /dev/null +++ b/org.glite.wms-utils.exception/test/Makefile.am @@ -0,0 +1,33 @@ +## ********************************************************************* +## * +## * Copyright (c) 2002 CERN and INFN on behalf of the EU DataGrid. +## * For license conditions see LICENSE file or +## * http://www.edg.org/license.html +## * +## ********************************************************************* + +EXCEPTION_LIBS = $(top_builddir)/src/libglite_wmsutils_exception.la + +TESTS = glite-wmsutils-exception + +check_PROGRAMS = $(TESTS) + +glite_wmsutils_exception_SOURCES = exception_cu_suite.cpp \ + exception_cu_suite.h \ + exception_cu_main.cpp + +glite_wmsutils_exception_LDADD = \ + $(GLITE_WMSUTILS_EXCEPTION_LIBS) \ + $(GLOBUS_GSS_THR_LIBS) \ + $(EXCEPTION_LIBS) \ + $(CPPUNIT_LIBS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/test \ + $(GLITE_CFLAGS) \ + $(GLOBUS_THR_CFLAGS) \ + $(CPPUNIT_CFLAGS) + +MAINTAINERCLEANFILES = Makefile.in *~ + diff --git a/org.glite.wms-utils.exception/test/exception_cu_main.cpp b/org.glite.wms-utils.exception/test/exception_cu_main.cpp new file mode 100644 index 0000000..182df4c --- /dev/null +++ b/org.glite.wms-utils.exception/test/exception_cu_main.cpp @@ -0,0 +1,33 @@ +#include +#include + +#include "exception_cu_suite.h" + +#include +#include +#include +#include +#include + +using namespace CppUnit; +using namespace std; + +int main (int argc , char** argv) +{ + std::ofstream xml("./cppUnit_output.xml",ios::app); + + CppUnit::TestResult controller; + CppUnit::TestResultCollector result; + controller.addListener( &result ); + + TestRunner runner; + runner.addTest(Exception_test::suite()); + runner.run(controller); + + CppUnit::XmlOutputter outputter( &result, xml ); + CppUnit::TextOutputter outputter2( &result, std::cerr ); + outputter.write(); + outputter2.write(); + + return result.wasSuccessful() ? 0 : 1 ; +} diff --git a/org.glite.wms-utils.exception/test/exception_cu_suite.cpp b/org.glite.wms-utils.exception/test/exception_cu_suite.cpp new file mode 100644 index 0000000..f749af9 --- /dev/null +++ b/org.glite.wms-utils.exception/test/exception_cu_suite.cpp @@ -0,0 +1,56 @@ +#include "exception_cu_suite.h" +#include "glite/wmsutils/exception/Exception.h" +#include +#include + +using namespace CppUnit; +using namespace std; +using namespace glite::wmsutils::exception; + +void Exception_test::setUp() +{} + +void Exception_test::tearDown() +{} + + +void Exception_test::constructor_case() +{ + + //constructor class name, line number, method name, code, exception name + glite::wmsutils::exception::Exception exc_5("TEST_Class", 3, "test_method", 1, "exception_test"); + + //constructor class name, method name, code, exception name + glite::wmsutils::exception::Exception exc_4("TEST_Class", "test_method", 1, "exception_test"); + + CPPUNIT_ASSERT(exc_5.getExceptionName() == "exception_test"); + CPPUNIT_ASSERT(exc_5.getCode() == 1); +} + +void Exception_test::tostring_case() +{ + cout<<"TEST TO STRING METHODS"< msgvec = exc_5.getStackTrace(); + + for (int i=0; i +#include +#include + +#include + + +class Exception_test : public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE(Exception_test); + CPPUNIT_TEST(constructor_case); + CPPUNIT_TEST(tostring_case); + CPPUNIT_TEST(stackTrace_case); + CPPUNIT_TEST_SUITE_END(); + + +public: + + void setUp(); + void tearDown(); + + void constructor_case(); + void tostring_case(); + void stackTrace_case(); + +}; + + + diff --git a/org.glite.wms-utils.jobid/test/Makefile.am b/org.glite.wms-utils.jobid/test/Makefile.am new file mode 100755 index 0000000..5111c30 --- /dev/null +++ b/org.glite.wms-utils.jobid/test/Makefile.am @@ -0,0 +1,48 @@ +## ********************************************************************* +## * +## * Copyright (c) 2002 CERN and INFN on behalf of the EU DataGrid. +## * For license conditions see LICENSE file or +## * http://www.edg.org/license.html +## * +## ********************************************************************* + +JOBID_LIBS = $(top_builddir)/src/jobid/libglite_wmsutils_jobid.la +CJOBID_LIBS = $(top_builddir)/src/jobid/libglite_wmsutils_cjobid.la + +TESTS = glite-wmsutils-jobid \ + glite-wmsutils-manipulation + +check_PROGRAMS = $(TESTS) + +glite_wmsutils_jobid_SOURCES = jobid_cu_suite.cpp \ + jobid_cu_suite.h \ + jobid_cu_main.cpp + +glite_wmsutils_jobid_LDADD = \ + $(GLITE_WMSUTILS_EXCEPTION_LIBS) \ + $(GLOBUS_GSS_THR_LIBS) \ + $(CPPUNIT_LIBS) \ + $(JOBID_LIBS) \ + $(CJOBID_LIBS) + +glite_wmsutils_manipulation_SOURCES = manipulation_cu_suite.cpp \ + manipulation_cu_suite.h \ + manipulation_cu_main.cpp + +glite_wmsutils_manipulation_LDADD = \ + $(GLITE_WMSUTILS_EXCEPTION_LIBS) \ + $(GLOBUS_GSS_THR_LIBS) \ + $(CPPUNIT_LIBS) \ + $(JOBID_LIBS) \ + $(CJOBID_LIBS) + + +AM_CPPFLAGS = -I$(top_srcdir)/interface \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/test \ + $(GLITE_CFLAGS) \ + $(GLOBUS_THR_CFLAGS) \ + $(CPPUNIT_CFLAGS) + +MAINTAINERCLEANFILES = Makefile.in *~ + diff --git a/org.glite.wms-utils.jobid/test/jobid_cu_main.cpp b/org.glite.wms-utils.jobid/test/jobid_cu_main.cpp new file mode 100644 index 0000000..770e306 --- /dev/null +++ b/org.glite.wms-utils.jobid/test/jobid_cu_main.cpp @@ -0,0 +1,33 @@ +#include +#include + +#include "jobid_cu_suite.h" + +#include +#include +#include +#include +#include + +using namespace CppUnit; +using namespace std; + +int main (int argc , char** argv) +{ + std::ofstream xml("./cppUnit_output.xml",ios::app); + + CppUnit::TestResult controller; + CppUnit::TestResultCollector result; + controller.addListener( &result ); + + TestRunner runner; + runner.addTest(Jobid_test::suite()); + runner.run(controller); + + CppUnit::XmlOutputter outputter( &result, xml ); + CppUnit::TextOutputter outputter2( &result, std::cerr ); + outputter.write(); + outputter2.write(); + + return result.wasSuccessful() ? 0 : 1 ; +} diff --git a/org.glite.wms-utils.jobid/test/jobid_cu_suite.cpp b/org.glite.wms-utils.jobid/test/jobid_cu_suite.cpp new file mode 100644 index 0000000..ebe04da --- /dev/null +++ b/org.glite.wms-utils.jobid/test/jobid_cu_suite.cpp @@ -0,0 +1,102 @@ +#include "jobid_cu_suite.h" + + +using namespace CppUnit; +using namespace std; +using namespace glite::wmsutils::jobid; + + +void Jobid_test::setUp() +{} + +void Jobid_test::tearDown() +{} + +void Jobid_test::Constructor_case() +{ + //EMPTY CONSTRUCTOR + JobId empty; + + CPPUNIT_ASSERT(empty.isSet()==false); + + //create a string with cjobid + string bkserver="grid012g.cnaf.infn.it"; + edg_wlc_JobId jobid; + int bkport=6000; + int ok=edg_wlc_JobIdCreate(bkserver.c_str(), bkport, &jobid); + CPPUNIT_ASSERT(ok == 0); + if (ok==0) + { + string jobstring=edg_wlc_JobIdUnparse(jobid); + + //STRING CONSTRUCTOR + JobId stringCons(jobstring); + + //EDG_WLC CONSTRUCTOR + JobId edg_wlc_Cons(jobid); + + //test copy constructor + JobId copycon(stringCons); + + CPPUNIT_ASSERT(stringCons.isSet()); + CPPUNIT_ASSERT(edg_wlc_Cons.isSet()); + CPPUNIT_ASSERT(copycon.isSet()); + + //test = + JobId testequal; + testequal=stringCons; + CPPUNIT_ASSERT(testequal.isSet()); + + JobId testoperator; + testoperator=jobid; + CPPUNIT_ASSERT(testoperator.isSet()); + + edg_wlc_JobId testget = edg_wlc_Cons.getId(); + char *server; + unsigned int port; + edg_wlc_JobIdGetServerParts(testget, &server, &port); + string serverstring = server; + CPPUNIT_ASSERT(port==bkport); + CPPUNIT_ASSERT(serverstring==bkserver); + } + + CPPUNIT_ASSERT_THROW( JobId stringwrong("grid012"), WrongIdException); +} + +void Jobid_test::Clear_case() +{ + JobId *element; + string jobstring="https://grid012g.cnaf.infn.it:6000/qaKyEoV3G144rmoyXeW6QA"; + CPPUNIT_ASSERT_NO_THROW(element= new JobId(jobstring)); + + CPPUNIT_ASSERT(element->isSet()); + element->clear(); + CPPUNIT_ASSERT(element->isSet()==false); + delete element; +} + +void Jobid_test::SetandGet_case() +{ + JobId element; + string lbserver="grid012g.cnaf.infn.it"; + int port=6000; + string unique ="qaKyEoV3G144rmoyXeW6QA"; + element.setJobId(lbserver, port, unique); + + string server=element.getServer(); + lbserver=lbserver+":6000"; + + CPPUNIT_ASSERT(server==lbserver); + string lonely=element.getUnique(); + CPPUNIT_ASSERT(lonely==unique); + + string descr=element.toString(); + cout << "!!! BEGIN TEST toString() METHOD!!!"<< endl; + cout << descr < +#include +#include + +#include + +#include "glite/wmsutils/jobid/JobId.h" +#include "glite/wmsutils/jobid/cjobid.h" +#include "glite/wmsutils/jobid/JobIdExceptions.h" + +class Jobid_test : public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE(Jobid_test); + + CPPUNIT_TEST(Constructor_case); + CPPUNIT_TEST(Clear_case); + CPPUNIT_TEST(SetandGet_case); + + CPPUNIT_TEST_SUITE_END(); + + +public: + + void setUp(); + void tearDown(); + + void Constructor_case(); + void Clear_case(); + void SetandGet_case(); + +}; + + + diff --git a/org.glite.wms-utils.jobid/test/manipulation_cu_main.cpp b/org.glite.wms-utils.jobid/test/manipulation_cu_main.cpp new file mode 100644 index 0000000..07d2914 --- /dev/null +++ b/org.glite.wms-utils.jobid/test/manipulation_cu_main.cpp @@ -0,0 +1,33 @@ +#include +#include + +#include "manipulation_cu_suite.h" + +#include +#include +#include +#include +#include + +using namespace CppUnit; +using namespace std; + +int main (int argc , char** argv) +{ + std::ofstream xml("./cppUnit_output.xml",ios::app); + + CppUnit::TestResult controller; + CppUnit::TestResultCollector result; + controller.addListener( &result ); + + TestRunner runner; + runner.addTest(Manipulation_test::suite()); + runner.run(controller); + + CppUnit::XmlOutputter outputter( &result, xml ); + CppUnit::TextOutputter outputter2( &result, std::cerr ); + outputter.write(); + outputter2.write(); + + return result.wasSuccessful() ? 0 : 1 ; +} diff --git a/org.glite.wms-utils.jobid/test/manipulation_cu_suite.cpp b/org.glite.wms-utils.jobid/test/manipulation_cu_suite.cpp new file mode 100644 index 0000000..a6a69d8 --- /dev/null +++ b/org.glite.wms-utils.jobid/test/manipulation_cu_suite.cpp @@ -0,0 +1,34 @@ +#include "manipulation_cu_suite.h" + + +using namespace CppUnit; +using namespace std; +using namespace glite::wmsutils::jobid; + + +void Manipulation_test::setUp() +{} + +void Manipulation_test::tearDown() +{} + +void Manipulation_test::to_fromfile_case() +{ + JobId element; + + string lbserver="grid012g.cnaf.infn.it"; + int port=6000; + string unique ="qaKyEoV3G144rmoyXeW6QA"; + element.setJobId(lbserver, port, unique); + + string filename=to_filename(element); + + JobId newelement = from_filename(filename); + + string reduced = get_reduced_part(element, 7); + + string newreduced = get_reduced_part(newelement, 7); + + CPPUNIT_ASSERT(reduced==newreduced); +} + diff --git a/org.glite.wms-utils.jobid/test/manipulation_cu_suite.h b/org.glite.wms-utils.jobid/test/manipulation_cu_suite.h new file mode 100644 index 0000000..287b902 --- /dev/null +++ b/org.glite.wms-utils.jobid/test/manipulation_cu_suite.h @@ -0,0 +1,29 @@ +#include +#include +#include + +#include + +#include "glite/wmsutils/jobid/JobId.h" +#include "glite/wmsutils/jobid/manipulation.h" + +class Manipulation_test : public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE(Manipulation_test); + + CPPUNIT_TEST(to_fromfile_case); + + CPPUNIT_TEST_SUITE_END(); + + +public: + + void setUp(); + void tearDown(); + + void to_fromfile_case(); + +}; + + + -- 1.8.2.3