diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile | 2 | ||||
-rw-r--r-- | test/base/image.cpp | 23 | ||||
-rw-r--r-- | test/base/songloading.cpp | 23 | ||||
-rw-r--r-- | test/log4cpp.property | 15 | ||||
-rw-r--r-- | test/log4cxx.xml | 42 |
5 files changed, 39 insertions, 66 deletions
diff --git a/test/Makefile b/test/Makefile index b8cd7cbd..61f92e19 100644 --- a/test/Makefile +++ b/test/Makefile @@ -10,7 +10,7 @@ sources:=$(wildcard *.cpp) $(wildcard */*.cpp) $(wildcard $(TOP)/src/*/*/*.cpp) deps:=$(sources:.cpp=.d) CXXFLAGS:=-Wall -Werror -I$(TOP)/src -I$(TOP)/src/base -I$(TOP)/src/menu -I$(TOP)/src/media -I$(TOP)/src/screens -I$(TOP)/src/frames -I$(TOP)/src/utils $(shell pkg-config ftgl --cflags) -g -LDFLAGS:=-lsqlite3 -lSDL -llog4cxx -lboost_program_options-mt -lboost_filesystem-mt -lboost_thread-mt -lSDL_image -lcppunit -lSDL_gfx -lGL $(shell pkg-config ftgl --libs) +LDFLAGS:=-lsqlite3 -lSDL $(shell log4cpp-config --libs) -lboost_program_options-mt -lboost_filesystem-mt -lboost_thread-mt -lSDL_image -lSDL_gfx -lcppunit -lGL $(shell pkg-config ftgl --libs) TARGET:=$(PROJECT) objects:=$(sources:.cpp=.o) diff --git a/test/base/image.cpp b/test/base/image.cpp index 50fb50b0..e9e9d3d4 100644 --- a/test/base/image.cpp +++ b/test/base/image.cpp @@ -28,7 +28,7 @@ #include <exception> #include <cppunit/extensions/HelperMacros.h> -#include <log4cxx/logger.h> +#include <log4cpp/Category.hh> #include <SDL/SDL.h> @@ -43,7 +43,7 @@ namespace usdx CPPUNIT_TEST_EXCEPTION(testNotAnImage, usdx::ImageLoadException); CPPUNIT_TEST_SUITE_END(); private: - static log4cxx::LoggerPtr log; + static log4cpp::Category& log; public: void setUp() { @@ -57,7 +57,8 @@ namespace usdx { Image img("./testdata/test.bmp"); const SDL_Surface *surface = img.get_surface(); - LOG4CXX_DEBUG(log, "test.bmp: w = " << surface->w << "; h = " << surface->h); + log << log4cpp::Priority::DEBUG << "test.bmp: " << + "w = " << surface->w << "; h = " << surface->h; CPPUNIT_ASSERT(40 == surface->w); CPPUNIT_ASSERT(30 == surface->h); } @@ -66,7 +67,8 @@ namespace usdx { Image img("./testdata/test.jpg"); const SDL_Surface *surface = img.get_surface(); - LOG4CXX_DEBUG(log, "test.jpg: w = " << surface->w << "; h = " << surface->h); + log << log4cpp::Priority::DEBUG << "test.jpg: " << + "w = " << surface->w << "; h = " << surface->h; CPPUNIT_ASSERT(40 == surface->w); CPPUNIT_ASSERT(30 == surface->h); } @@ -75,7 +77,8 @@ namespace usdx { Image img("./testdata/test.png"); const SDL_Surface *surface = img.get_surface(); - LOG4CXX_DEBUG(log, "test.png: w = " << surface->w << "; h = " << surface->h); + log << log4cpp::Priority::DEBUG << "test.png: " << + "w = " << surface->w << "; h = " << surface->h; CPPUNIT_ASSERT(40 == surface->w); CPPUNIT_ASSERT(30 == surface->h); } @@ -84,7 +87,8 @@ namespace usdx { Image img("./testdata/test.gif"); const SDL_Surface *surface = img.get_surface(); - LOG4CXX_DEBUG(log, "test.gif: w = " << surface->w << "; h = " << surface->h); + log << log4cpp::Priority::DEBUG << "test.gif: " << + "w = " << surface->w << "; h = " << surface->h; CPPUNIT_ASSERT(40 == surface->w); CPPUNIT_ASSERT(30 == surface->h); } @@ -93,12 +97,13 @@ namespace usdx { Image img("./testdata/testsong_correct.txt"); const SDL_Surface *surface = img.get_surface(); - LOG4CXX_DEBUG(log, "testsong_correct.txt: w = " << surface->w << "; h = " << surface->h); + log << log4cpp::Priority::DEBUG << "testsong_correct.txt: " << + "w = " << surface->w << "; h = " << surface->h; } }; - log4cxx::LoggerPtr ImageTest::log = - log4cxx::Logger::getLogger("test.usdx.base.image"); + log4cpp::Category& ImageTest::log = + log4cpp::Category::getInstance("test.usdx.base.image"); CPPUNIT_TEST_SUITE_REGISTRATION(ImageTest); }; diff --git a/test/base/songloading.cpp b/test/base/songloading.cpp index ddb2756f..94690cc3 100644 --- a/test/base/songloading.cpp +++ b/test/base/songloading.cpp @@ -28,7 +28,8 @@ #include <cppunit/extensions/HelperMacros.h> #include "song.hpp" #include "songloading/songloader.hpp" -#include <log4cxx/logger.h> +#include <log4cpp/Category.hh> +#include <log4cpp/Priority.hh> namespace usdx { @@ -42,21 +43,19 @@ namespace usdx CPPUNIT_TEST_SUITE_END(); private: - int oldLogLevel; + log4cpp::Priority::Value oldLogLevel; public: void setUp() { // save old loglevel in case we want to disable logging - using namespace log4cxx; - oldLogLevel = Logger::getRootLogger()->getEffectiveLevel()->toInt(); + oldLogLevel = log4cpp::Category::getRoot().getPriority(); } void tearDown() { // set old loglevel in case we did disable logging - using namespace log4cxx; - Logger::getRootLogger()->setLevel(Level::toLevel(oldLogLevel)); + log4cpp::Category::getRoot().setPriority(oldLogLevel); } void testSongloadingTxtHeader() @@ -93,8 +92,7 @@ namespace usdx { // disable logging to avoid logmsgs when the exeption // is thrown - using namespace log4cxx; - Logger::getRootLogger()->setLevel(Level::getOff()); + log4cpp::Category::getRoot().setPriority(log4cpp::Priority::EMERG); Songloader::get_instance()-> load_header("testdata/testsong_missing_artist.txt"); @@ -104,8 +102,7 @@ namespace usdx { // disable logging to avoid logmsgs when the exeption // is thrown - using namespace log4cxx; - Logger::getRootLogger()->setLevel(Level::getOff()); + log4cpp::Category::getRoot().setPriority(log4cpp::Priority::EMERG); Songloader::get_instance()-> load_header("testdata/testsong_missing_title.txt"); @@ -115,8 +112,7 @@ namespace usdx { // disable logging to avoid logmsgs when the exeption // is thrown - using namespace log4cxx; - Logger::getRootLogger()->setLevel(Level::getOff()); + log4cpp::Category::getRoot().setPriority(log4cpp::Priority::EMERG); Songloader::get_instance()-> load_header("testdata/testsong_missing_mp3.txt"); @@ -127,8 +123,7 @@ namespace usdx { // disable logging to avoid logmsgs when the exeption // is thrown - using namespace log4cxx; - Logger::getRootLogger()->setLevel(Level::getOff()); + log4cpp::Category::getRoot().setPriority(log4cpp::Priority::EMERG); Songloader::get_instance()-> load_header("testdata/testsong_missing_bpm.txt"); diff --git a/test/log4cpp.property b/test/log4cpp.property new file mode 100644 index 00000000..4bcad324 --- /dev/null +++ b/test/log4cpp.property @@ -0,0 +1,15 @@ +log4cpp.rootCategory=DEBUG,console +log4cpp.category.usdx=,roll + +log4cpp.appender.console=org.apache.log4j.ConsoleAppender +log4cpp.appender.console.layout=org.apache.log4j.PatternLayout +log4cpp.appender.console.layout.ConversionPattern=%-6r [%-5p] %c - %m%n +log4cpp.appender.console.threshold=ERROR + +log4cpp.appender.roll=org.apache.log4j.rolling.RollingFileAppender +log4cpp.apperder.roll.maximumFileSize=400KB +log4cpp.apperder.roll.maxBackupIndex=4 +log4cpp.appender.roll.fileName=debug.log +log4cpp.appender.roll.append=true +log4cpp.appender.roll.layout=org.apache.log4j.PatternLayout +log4cpp.appender.roll.layout.ConversionPattern=%-6r [%-5p] %c - %m%n diff --git a/test/log4cxx.xml b/test/log4cxx.xml deleted file mode 100644 index 75daba46..00000000 --- a/test/log4cxx.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> - -<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> - - - <appender name="Roll" class="org.apache.log4j.rolling.RollingFileAppender"> - <triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy"> - <param name="MaxFileSize" value="400KB" /> - </triggeringPolicy> - - <rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy"> - <param name="MaxIndex" value="4" /> - <param name="FileNamePattern" value="debug.%i.log" /> - </rollingPolicy> - - <param name="FileName" value="debug.log" /> - - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="%-6r [%-5p] %F:%L - %M - %m%n" /> - </layout> - </appender> - - - <appender name="Console" class="org.apache.log4j.ConsoleAppender"> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="%-6r [%-5p] %F:%-3L - %m%n" /> - </layout> - - <filter class="org.apache.log4j.filter.LevelRangeFilter"> - <param name="LevelMin" value="ERROR" /> - </filter> - </appender> - - - <root> - <priority value ="ALL" /> - <appender-ref ref="Console" /> - <appender-ref ref="Roll"/> - </root> - -</log4j:configuration> |