|
From: Yurii R. <yr...@us...> - 2003-02-10 20:46:21
|
Update of /cvsroot/eas-dev/eas-dev/components/logger/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv2940/components/logger/tests
Modified Files:
ConsoleLoggerTest.h Makefile.am
Added Files:
suite.cxx
Log Message:
adding Boost, misc changes
--- NEW FILE: suite.cxx ---
/* $Id: suite.cxx,v 1.1 2003/02/10 20:45:47 yrashk Exp $ */
#include <boost/test/unit_test.hpp>
using namespace std;
using boost::unit_test_framework::test_suite;
#define _DEBUG
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include "component.hxx"
#include "ConsoleLoggerTest.h"
test_suite*
init_unit_test_suite( int argc, char * argv[] ) {
test_suite* test= BOOST_TEST_SUITE( "E/AS Components: Logger" );
// Initialization
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 initial 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.XLogger"), xContext);
Reference< XLogger > xLogger( xx, UNO_QUERY );
xx = xMgr->createInstanceWithContext(OUString::createFromAscii("org.openeas.util.XConsoleLogger"), xContext);
Reference< XConsoleLogger > xConsoleLogger ( xx, UNO_QUERY );
OSL_ENSURE( xLogger.is(), "### cannot get service instance of \"org.openeas.util.XLogger\"!" );
OSL_ENSURE( xConsoleLogger.is(), "### cannot get service instance of \"org.openeas.util.XConsoleLogger\"!" );
console_logger_test_context.xLogger = xLogger;
console_logger_test_context.xConsoleLogger = xConsoleLogger;
}
// Reference< XComponent >::query( xContext )->dispose();
test->add( BOOST_TEST_CASE( &console_logger_test));
return test;
}
Index: ConsoleLoggerTest.h
===================================================================
RCS file: /cvsroot/eas-dev/eas-dev/components/logger/tests/ConsoleLoggerTest.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ConsoleLoggerTest.h 7 Feb 2003 11:03:53 -0000 1.3
+++ ConsoleLoggerTest.h 10 Feb 2003 20:45:44 -0000 1.4
@@ -1,88 +1,23 @@
/* $Id$ */
#ifndef _CONSOLELOGGERTEST_H_
#define _CONSOLELOGGERTEST_H_
-#define _DEBUG
-
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <cstring>
-#include <cxxtest/TestSuite.h>
-#include "component.hxx"
+typedef struct {
+ Reference<XLogger> xLogger;
+ Reference<XConsoleLogger> xConsoleLogger;
+} console_logger_test_context_t;
-using namespace std;
+static console_logger_test_context_t console_logger_test_context;
-class ConsoleLoggerTest: public CxxTest::TestSuite
+void console_logger_test()
{
-
- 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 initial 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.XLogger"), xContext);
-
- Reference< XLogger > xLogger( xx, UNO_QUERY );
- xx = xMgr->createInstanceWithContext(OUString::createFromAscii("org.openeas.util.XConsoleLogger"), xContext);
- Reference< XConsoleLogger > xConsoleLogger ( xx, UNO_QUERY );
-
-
- OSL_ENSURE( xLogger.is(), "### cannot get service instance of \"org.openeas.util.XLogger\"!" );
- OSL_ENSURE( xConsoleLogger.is(), "### cannot get service instance of \"org.openeas.util.XConsoleLogger\"!" );
-
-
- if ( xLogger.is() && xConsoleLogger.is() )
- {
- XLoggerHandler * hndlr = dynamic_cast<XLoggerHandler *>(xConsoleLogger.get());
- xLogger->setHandler( Reference <XLoggerHandler> (hndlr));
- cout << endl; // further track the output, to have a real test
- xLogger->log(logLevel_INFO, OUString::createFromAscii("Test log entry"));
- }
-
+ if ( console_logger_test_context.xLogger.is() && console_logger_test_context.xConsoleLogger.is() ) {
+ XLoggerHandler * hndlr = dynamic_cast<XLoggerHandler *>(console_logger_test_context.xConsoleLogger.get());
+ console_logger_test_context.xLogger->setHandler( Reference <XLoggerHandler> (hndlr));
+ console_logger_test_context.xLogger->log(logLevel_INFO, OUString::createFromAscii("Test log entry"));
}
-
- Reference< XComponent >::query( xContext )->dispose();
-
-
- }
+ BOOST_CHECK(true);
};
Index: Makefile.am
===================================================================
RCS file: /cvsroot/eas-dev/eas-dev/components/logger/tests/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile.am 8 Feb 2003 08:23:48 -0000 1.2
+++ Makefile.am 10 Feb 2003 20:45:46 -0000 1.3
@@ -11,17 +11,13 @@
@INCLUDE@ @ODK_PATH@/settings/std.mk
bin_PROGRAMS = runTests
-runTests_SOURCES = runTests.cxx
+runTests_SOURCES = suite.cxx ConsoleLoggerTest.h component.hxx
runTests_LDFLAGS = -L../src/ -L/opt/openoffice/program/ -L@ODK_PATH@/linux/lib
-runTests_LDADD = $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) -lstdc++
+runTests_LDADD = @BOOST_PATH@/libs/test/build/bin/libunit_test_framework.a/gcc/debug/runtime-link-dynamic/threading-multi/libunit_test_framework.a \
+ $(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../../.incs
+INCLUDES = -I@ODK_PATH@/include -I$(top_srcdir) -I../../.incs -I@BOOST_PATH@
TESTS = runTests
-
-runTests.cxx: ConsoleLoggerTest.h
- $(top_srcdir)/../../tools/test/cxxtestgen.py --error-printer --exit-code -o runTests.cxx \
- ConsoleLoggerTest.h
|