From: Yurii R. <yr...@us...> - 2003-02-04 04:17:18
|
Update of /cvsroot/eas-dev/eas-dev/components/logger/tests In directory sc8-pr-cvs1:/tmp/cvs-serv16940/components/logger/tests Added Files: .cvsignore ConsoleLoggerTest.h Makefile.am component.hxx Log Message: Almost complete (still has one compilation error :-( ) test for early `logger' component --- NEW FILE: .cvsignore --- Makefile Makefile.in runTests.cxx runTests .deps .libs --- NEW FILE: ConsoleLoggerTest.h --- /* $Id: ConsoleLoggerTest.h,v 1.1 2003/02/04 04:17:14 yrashk Exp $ */ #ifndef _CONSOLELOGGERTEST_H_ #define _CONSOLELOGGERTEST_H_ #include <iostream> #include <sstream> #include <string> #include <cstring> #include <cxxtest/TestSuite.h> #include "component.hxx" using namespace std; class ConsoleLoggerTest: public CxxTest::TestSuite { public: void setUp() { } void tearDown() { } void test_log() { Reference< XSimpleRegistry > xReg = createSimpleRegistry(); OSL_ENSURE( xReg.is(), "### cannot get service instance of \"com.sun.star.regiystry.SimpleRegistry\"!" ); xReg->open(OUString::createFromAscii(OPENEAS_RDB), sal_False, sal_False); OSL_ENSURE( xReg->isValid(), "### cannot open test registry!" ); Reference< XComponentContext > xContext = bootstrap_InitialComponentContext(xReg); OSL_ENSURE( xContext.is(), "### cannot creage intial component context!" ); Reference< XMultiComponentFactory > xMgr = xContext->getServiceManager(); OSL_ENSURE( xContext.is(), "### cannot get initial service manager!" ); // register logger component Reference< XImplementationRegistration > xImplReg( xMgr->createInstanceWithContext(OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration"), xContext), UNO_QUERY); OSL_ENSURE( xImplReg.is(), "### cannot get service instance of \"com.sun.star.registry.ImplementationRegistration\"!" ); if (xImplReg.is()) { xImplReg->registerImplementation( OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), // loader for component OUString::createFromAscii(COMPONENT_DLL), // component location Reference< XSimpleRegistry >() // registry omitted, // defaulting to service manager registry used ); // get a logger instance Reference< XInterface > xx ; xx = xMgr->createInstanceWithContext(OUString::createFromAscii("org.openeas.util.Logger"), xContext); Reference< XLogger > xLogger( xx, UNO_QUERY ); Reference< XConsoleLogger > xConsoleLogger ( xx, UNO_QUERY ); OSL_ENSURE( xLogger.is(), "### cannot get service instance of \"org.openeas.util.Logger\"!" ); OSL_ENSURE( xConsoleLogger.is(), "### cannot get service instance of \"org.openeas.util.Logger\"!" ); if (xLogger.is()) { xLogger->setHandler( static_cast< Reference< XLoggerHandler > > xConsoleLogger); xLogger->log(logLevel_INFO, OUString::createFromAscii("Test log")); } } Reference< XComponent >::query( xContext )->dispose(); } }; #endif /* _CONSOLELOGGERTEST_H_ */ --- NEW FILE: Makefile.am --- PRJ = @ODK_PATH@ CPPUHELPERLIB = CPPULIB = SALHELPERLIB = SALLIB = STLPORTLIB = @INCLUDE@ @ODK_PATH@/settings/settings.mk @INCLUDE@ @ODK_PATH@/settings/dk.mk @INCLUDE@ @ODK_PATH@/settings/std.mk bin_PROGRAMS = runTests runTests_SOURCES = runTests.cxx runTests_LDFLAGS = -L../src/ -L/opt/openoffice/program/ -L@ODK_PATH@/linux/lib runTests_LDADD = $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) -lstdc++ CXXFLAGS = -DOPENEAS_RDB=\"../../openeas.rdb\" -DCOMPONENT_DLL=\"../src/.libs/liblogger.so\" -include config.h CLEANFILES = runTests.cxx INCLUDES = -I@ODK_PATH@/include -I$(top_srcdir) -I../../.include TESTS = runTests runTests.cxx: ConsoleLoggerTest.h $(top_srcdir)/../../tools/test/cxxtestgen.py --error-printer --exit-code -o runTests.cxx \ ConsoleLoggerTest.h --- NEW FILE: component.hxx --- #include <config.h> #include <rtl/ustring.hxx> #include <osl/diagnose.h> #include <cppuhelper/bootstrap.hxx> #include <cppuhelper/servicefactory.hxx> // generated interfaces #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/registry/XImplementationRegistration.hpp> #include <org/openeas/util/logLevel.hpp> #include <org/openeas/util/XLogger.hpp> #include <org/openeas/util/XConsoleLogger.hpp> using namespace org::openeas::util; using namespace cppu; using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::registry; using namespace ::rtl; |