You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ts...@apache.org on 2022/08/19 18:45:20 UTC

[logging-log4cxx] branch master updated: Revert "LOGCXX-527: mock the clock for tests"

This is an automated email from the ASF dual-hosted git repository.

tschoening pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git


The following commit(s) were added to refs/heads/master by this push:
     new 56e18c79 Revert "LOGCXX-527: mock the clock for tests"
56e18c79 is described below

commit 56e18c79c6bb16e706d2f5d855db4d7d6189912d
Author: Thorsten Schöning <ts...@am-soft.de>
AuthorDate: Fri Aug 19 20:45:16 2022 +0200

    Revert "LOGCXX-527: mock the clock for tests"
    
    This reverts commit b5db5f0ab56955b2b89c2ed2364c048a3514b9c3.
---
 src/examples/cpp/delayedloop.cpp                   |   1 -
 src/main/cpp/aprinitializer.cpp                    |   3 +-
 src/main/cpp/date.cpp                              |  25 +-
 src/main/cpp/filewatchdog.cpp                      |   1 +
 src/main/cpp/hierarchy.cpp                         |   1 -
 src/main/cpp/htmllayout.cpp                        |   4 +-
 src/main/cpp/loggingevent.cpp                      |   4 +-
 src/main/cpp/propertyconfigurator.cpp              |   1 -
 src/main/cpp/timebasedrollingpolicy.cpp            |  21 +-
 src/main/include/log4cxx/helpers/aprinitializer.h  |   5 +-
 src/main/include/log4cxx/helpers/date.h            |  22 +-
 .../log4cxx/rolling/timebasedrollingpolicy.h       |   1 -
 src/test/cpp/rolling/timebasedrollingtest.cpp      | 474 ++++++++++-----------
 src/test/resources/witness/rolling/tbr-test4.0     |   1 -
 src/test/resources/witness/rolling/tbr-test4.3     |   1 -
 src/test/resources/witness/rolling/tbr-test5.0     |   1 -
 src/test/resources/witness/rolling/tbr-test5.3     |   1 -
 src/test/resources/witness/rolling/tbr-test6.0     |   1 -
 .../witness/rolling/{tbr-test4.3 => tbr-test6.3}   |   1 -
 19 files changed, 259 insertions(+), 310 deletions(-)

diff --git a/src/examples/cpp/delayedloop.cpp b/src/examples/cpp/delayedloop.cpp
index d1768135..194473a8 100644
--- a/src/examples/cpp/delayedloop.cpp
+++ b/src/examples/cpp/delayedloop.cpp
@@ -20,7 +20,6 @@
 #include <log4cxx/propertyconfigurator.h>
 #include <apr_general.h>
 #include <apr_time.h>
-#include <apr.h>
 #include <iostream>
 #include <log4cxx/stream.h>
 #include <exception>
diff --git a/src/main/cpp/aprinitializer.cpp b/src/main/cpp/aprinitializer.cpp
index cbaeb77d..0bd91d22 100644
--- a/src/main/cpp/aprinitializer.cpp
+++ b/src/main/cpp/aprinitializer.cpp
@@ -26,7 +26,6 @@
 #include <apr_thread_mutex.h>
 #include <apr_thread_proc.h>
 #include <log4cxx/helpers/filewatchdog.h>
-#include <log4cxx/helpers/date.h>
 
 using namespace log4cxx::helpers;
 using namespace log4cxx;
@@ -47,7 +46,7 @@ APRInitializer::APRInitializer() : p(0), startTime(0), tlsKey(0)
 	apr_initialize();
 	apr_pool_create(&p, NULL);
 	apr_atomic_init(p);
-	startTime = Date::currentTime();
+	startTime = apr_time_now();
 #if APR_HAS_THREADS
 	apr_status_t stat = apr_threadkey_private_create(&tlsKey, tlsDestruct, p);
 	assert(stat == APR_SUCCESS);
diff --git a/src/main/cpp/date.cpp b/src/main/cpp/date.cpp
index 1fb3a836..a1ea7cec 100644
--- a/src/main/cpp/date.cpp
+++ b/src/main/cpp/date.cpp
@@ -17,7 +17,7 @@
 #include <log4cxx/logstring.h>
 #include <log4cxx/helpers/date.h>
 
-#define LOG4CXX_USEC_PER_SEC 1000000LL
+#include <apr_time.h>
 #ifndef INT64_C
 	#define INT64_C(x) x ## LL
 #endif
@@ -27,10 +27,7 @@ using namespace log4cxx::helpers;
 
 IMPLEMENT_LOG4CXX_OBJECT(Date)
 
-
-Date::GetCurrentTimeFn Date::getCurrentTimeFn = Date::getCurrentTimeStd;
-
-Date::Date() : time(getCurrentTimeFn())
+Date::Date() : time(apr_time_now())
 {
 }
 
@@ -44,28 +41,16 @@ Date::~Date()
 
 log4cxx_time_t Date::getMicrosecondsPerDay()
 {
-	return 86400000000ull;
+	return APR_INT64_C(86400000000);
 }
 
 log4cxx_time_t Date::getMicrosecondsPerSecond()
 {
-	return LOG4CXX_USEC_PER_SEC;
+	return APR_USEC_PER_SEC;
 }
 
 
 log4cxx_time_t Date::getNextSecond() const
 {
-	return ((time / LOG4CXX_USEC_PER_SEC) + 1) * LOG4CXX_USEC_PER_SEC;
-}
-
-void Date::setGetCurrentTimeFunction(GetCurrentTimeFn fn){
-	getCurrentTimeFn = fn;
-}
-
-log4cxx_time_t Date::currentTime(){
-	return getCurrentTimeFn();
-}
-
-log4cxx_time_t Date::getCurrentTimeStd(){
-	return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
+	return ((time / APR_USEC_PER_SEC) + 1) * APR_USEC_PER_SEC;
 }
diff --git a/src/main/cpp/filewatchdog.cpp b/src/main/cpp/filewatchdog.cpp
index 42576bb3..f9d0d7f0 100644
--- a/src/main/cpp/filewatchdog.cpp
+++ b/src/main/cpp/filewatchdog.cpp
@@ -18,6 +18,7 @@
 #include <log4cxx/logstring.h>
 #include <log4cxx/helpers/filewatchdog.h>
 #include <log4cxx/helpers/loglog.h>
+#include <apr_time.h>
 #include <apr_thread_proc.h>
 #include <apr_atomic.h>
 #include <log4cxx/helpers/transcoder.h>
diff --git a/src/main/cpp/hierarchy.cpp b/src/main/cpp/hierarchy.cpp
index 91dee598..22caa895 100644
--- a/src/main/cpp/hierarchy.cpp
+++ b/src/main/cpp/hierarchy.cpp
@@ -38,7 +38,6 @@
 #include <log4cxx/defaultconfigurator.h>
 #include <log4cxx/spi/rootlogger.h>
 #include <mutex>
-#include <apr.h>
 #include "assert.h"
 
 
diff --git a/src/main/cpp/htmllayout.cpp b/src/main/cpp/htmllayout.cpp
index 8c18d950..f63e78ee 100644
--- a/src/main/cpp/htmllayout.cpp
+++ b/src/main/cpp/htmllayout.cpp
@@ -24,8 +24,8 @@
 #include <log4cxx/helpers/iso8601dateformat.h>
 #include <log4cxx/helpers/stringhelper.h>
 #include <log4cxx/helpers/transcoder.h>
-#include <log4cxx/helpers/date.h>
 
+#include <apr_time.h>
 #include <apr_strings.h>
 #include <string.h>
 
@@ -185,7 +185,7 @@ void HTMLLayout::appendHeader(LogString& output, Pool& p)
 	output.append(LOG4CXX_EOL);
 	output.append(LOG4CXX_STR("Log session start time "));
 
-	dateFormat.format(output, Date::currentTime(), p);
+	dateFormat.format(output, apr_time_now(), p);
 
 	output.append(LOG4CXX_STR("<br>"));
 	output.append(LOG4CXX_EOL);
diff --git a/src/main/cpp/loggingevent.cpp b/src/main/cpp/loggingevent.cpp
index 46a7f671..eb59e2fb 100644
--- a/src/main/cpp/loggingevent.cpp
+++ b/src/main/cpp/loggingevent.cpp
@@ -29,6 +29,7 @@
 #include <log4cxx/helpers/threadspecificdata.h>
 #include <log4cxx/helpers/transcoder.h>
 
+#include <apr_time.h>
 #include <apr_portable.h>
 #include <apr_strings.h>
 #include <log4cxx/helpers/stringhelper.h>
@@ -36,7 +37,6 @@
 #include <log4cxx/helpers/bytebuffer.h>
 #include <log4cxx/logger.h>
 #include <log4cxx/private/log4cxx_private.h>
-#include <log4cxx/helpers/date.h>
 
 using namespace log4cxx;
 using namespace log4cxx::spi;
@@ -75,7 +75,7 @@ LoggingEvent::LoggingEvent(
 	ndcLookupRequired(true),
 	mdcCopyLookupRequired(true),
 	message(message1),
-	timeStamp(Date::currentTime()),
+	timeStamp(apr_time_now()),
 	locationInfo(locationInfo1),
 	threadName(getCurrentThreadName()),
 	threadUserName(getCurrentThreadUserName())
diff --git a/src/main/cpp/propertyconfigurator.cpp b/src/main/cpp/propertyconfigurator.cpp
index 1edd2e45..65efadc2 100644
--- a/src/main/cpp/propertyconfigurator.cpp
+++ b/src/main/cpp/propertyconfigurator.cpp
@@ -40,7 +40,6 @@
 
 #define LOG4CXX 1
 #include <log4cxx/helpers/aprinitializer.h>
-#include <apr.h>
 
 
 using namespace log4cxx;
diff --git a/src/main/cpp/timebasedrollingpolicy.cpp b/src/main/cpp/timebasedrollingpolicy.cpp
index cd1fe908..c81f09d5 100644
--- a/src/main/cpp/timebasedrollingpolicy.cpp
+++ b/src/main/cpp/timebasedrollingpolicy.cpp
@@ -34,6 +34,12 @@
 #include <log4cxx/rolling/rollingfileappenderskeleton.h>
 #include<iostream>
 
+#ifndef INT64_C
+	#define INT64_C(x) x ## LL
+#endif
+
+#include <apr_time.h>
+
 using namespace log4cxx;
 using namespace log4cxx::rolling;
 using namespace log4cxx::helpers;
@@ -196,8 +202,9 @@ void TimeBasedRollingPolicy::activateOptions(log4cxx::helpers::Pool& pool)
 		throw IllegalStateException();
 	}
 
+	apr_time_t n = apr_time_now();
 	LogString buf;
-	ObjectPtr obj(new Date());
+	ObjectPtr obj(new Date(n));
 	formatFileName(obj, buf, pool);
 	lastFileName = buf;
 
@@ -261,9 +268,8 @@ RolloverDescriptionPtr TimeBasedRollingPolicy::initialize(
 	const   bool        append,
 	Pool&       pool)
 {
-	Date now;
-	log4cxx_time_t n = now.getTime();
-	nextCheck = now.getNextSecond();
+	apr_time_t n = apr_time_now();
+	nextCheck = ((n / APR_USEC_PER_SEC) + 1) * APR_USEC_PER_SEC;
 
 	File currentFile(currentActiveFile);
 
@@ -293,9 +299,8 @@ RolloverDescriptionPtr TimeBasedRollingPolicy::rollover(
 	const   bool        append,
 	Pool&       pool)
 {
-	Date now;
-	log4cxx_time_t n = now.getTime();
-	nextCheck = now.getNextSecond();
+	apr_time_t n = apr_time_now();
+	nextCheck = ((n / APR_USEC_PER_SEC) + 1) * APR_USEC_PER_SEC;
 
 	LogString buf;
 	ObjectPtr obj(new Date(n));
@@ -414,6 +419,6 @@ bool TimeBasedRollingPolicy::isTriggeringEvent(
 
 	return ((apr_time_now()) > nextCheck) || (!bAlreadyInitialized);
 #else
-	return Date::currentTime() > nextCheck;
+	return apr_time_now() > nextCheck;
 #endif
 }
diff --git a/src/main/include/log4cxx/helpers/aprinitializer.h b/src/main/include/log4cxx/helpers/aprinitializer.h
index 9fcdd5ca..fccd18e0 100644
--- a/src/main/include/log4cxx/helpers/aprinitializer.h
+++ b/src/main/include/log4cxx/helpers/aprinitializer.h
@@ -23,14 +23,13 @@
 #endif
 
 #include <list>
-#include <log4cxx/helpers/date.h>
 
 extern "C" {
 	typedef struct apr_thread_mutex_t apr_thread_mutex_t;
 	typedef struct apr_threadkey_t apr_threadkey_t;
-	struct apr_pool_t;
 }
 
+#include <apr_time.h>
 #include <mutex>
 
 namespace log4cxx
@@ -62,7 +61,7 @@ class APRInitializer
 		apr_pool_t* p;
 		std::mutex mutex;
 		std::list<FileWatchdog*> watchdogs;
-		log4cxx_time_t startTime;
+		apr_time_t startTime;
 		apr_threadkey_t* tlsKey;
 		static APRInitializer& getInstance();
 
diff --git a/src/main/include/log4cxx/helpers/date.h b/src/main/include/log4cxx/helpers/date.h
index c031531d..facace72 100644
--- a/src/main/include/log4cxx/helpers/date.h
+++ b/src/main/include/log4cxx/helpers/date.h
@@ -20,7 +20,7 @@
 
 #include <log4cxx/helpers/object.h>
 #include <log4cxx/log4cxx.h>
-#include <functional>
+
 
 namespace log4cxx
 {
@@ -36,13 +36,6 @@ class LOG4CXX_EXPORT Date : public Object
 {
 		const log4cxx_time_t time;
 
-		/**
-		 * A function that will return the current time(in microseconds) when called
-		 */
-		typedef std::function<log4cxx_time_t()> GetCurrentTimeFn;
-
-		static log4cxx_time_t getCurrentTimeStd();
-
 	public:
 		DECLARE_LOG4CXX_OBJECT(Date)
 		BEGIN_LOG4CXX_CAST_MAP()
@@ -67,19 +60,6 @@ class LOG4CXX_EXPORT Date : public Object
 		static log4cxx_time_t getMicrosecondsPerDay();
 		static log4cxx_time_t getMicrosecondsPerSecond();
 
-		static log4cxx_time_t currentTime();
-
-		static GetCurrentTimeFn getCurrentTimeFn;
-
-		/**
-		 * Set the function that is used to get the current time.
-		 * This is used only for testing purposes and should never be called
-		 * under normal circumstances.
-		 *
-		 * @param fn
-		 */
-		static void setGetCurrentTimeFunction(GetCurrentTimeFn fn);
-
 };
 
 LOG4CXX_PTR_DEF(Date);
diff --git a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
index 7c82e3d8..ddeacf5e 100755
--- a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
+++ b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
@@ -25,7 +25,6 @@
 #include <log4cxx/writerappender.h>
 #include <log4cxx/helpers/outputstream.h>
 #include <apr_mmap.h>
-#include <functional>
 
 #if defined(_MSC_VER)
 	#pragma warning ( push )
diff --git a/src/test/cpp/rolling/timebasedrollingtest.cpp b/src/test/cpp/rolling/timebasedrollingtest.cpp
index 7825d947..706cb3df 100644
--- a/src/test/cpp/rolling/timebasedrollingtest.cpp
+++ b/src/test/cpp/rolling/timebasedrollingtest.cpp
@@ -24,7 +24,6 @@
 #include <log4cxx/patternlayout.h>
 #include <log4cxx/rolling/timebasedrollingpolicy.h>
 #include <log4cxx/helpers/simpledateformat.h>
-#include <log4cxx/helpers/date.h>
 #include <iostream>
 #include <log4cxx/helpers/stringhelper.h>
 #include "../util/compare.h"
@@ -41,12 +40,9 @@
 // into other string literals or as an object. While macros are hard to debug, embedding into string
 // literals is easier this way, because the compiler can automatically collaps them, and if we have
 // one macro already, a second for a similar purpose shouldn't hurt as well.
-#define DATE_PATTERN		"yyyy-MM-dd_HH_mm_ss"
-#define DATE_PATTERN_STR	LogString(LOG4CXX_STR("yyyy-MM-dd_HH_mm_ss"))
-#define PATTERN_LAYOUT		LOG4CXX_STR("%c{1} - %m%n")
-
-#define DIR_PRE_OUTPUT	"output/rolling/tbr-"
-#define DIR_PRE_WITNESS	"witness/rolling/tbr-"
+#define DATE_PATTERN        "yyyy-MM-dd_HH_mm_ss"
+#define DATE_PATTERN_STR    LogString(LOG4CXX_STR("yyyy-MM-dd_HH_mm_ss"))
+#define PATTERN_LAYOUT      LOG4CXX_STR("%c{1} - %m%n")
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
@@ -81,12 +77,19 @@ LOGUNIT_CLASS(TimeBasedRollingTest)
 	LOGUNIT_TEST(test5);
 	LOGUNIT_TEST(test6);
 	LOGUNIT_TEST(test7);
-	LOGUNIT_TEST(rollIntoDir);
+//	LOGUNIT_TEST(create_directories);
 	LOGUNIT_TEST_SUITE_END();
 
 private:
-	static	LoggerPtr		logger;
-			log4cxx_time_t	current_time;
+	static LoggerPtr logger;
+
+	/**
+	 * Currently running test.
+	 * <p>
+	 * Number of currently running test, used e.g. for some generic code in {@link setUp()}.
+	 * </p>
+	 */
+	size_t num_test;
 
 	/**
 	 * Build file names with timestamps.
@@ -110,31 +113,30 @@ private:
 	 * therefore "now" could have easily past and the first file name will never be found, because
 	 * the rolling appender creates it with a newer "now", at least one second in the future.
 	 * </p>
-	 * @param[in,out]	pool
-	 * @param[in]		prefix
-	 * @param[in]		fnames
-	 * @param[in,opt]	compressed
-	 * @param[in,opt]	startInFuture
+	 * @param[in,out]   pool
+	 * @param[in]       prefix
+	 * @param[in]       fileNames
+	 * param[in,opt]    withCompression
+	 * param[in,opt]    startInFuture
 	 */
 	template<size_t N>
-	void buildTsFnames(
-				Pool&		pool,
-		const	logchar*	prefix,
-				LogString	(&fnames)[N],
-				bool		compressed		= false,
-				bool		startInFuture	= false)
+	void buildTsFileNames(          Pool &       pool,
+		const   logchar *    prefix,
+		LogString   (&fileNames)[N],
+		bool        withCompression = false,
+		bool        startInFuture   = false)
 	{
-		SimpleDateFormat	sdf(DATE_PATTERN_STR);
-		log4cxx_time_t		now(current_time);
-		LogString			ext(compressed ? LOG4CXX_STR(".gz") : LOG4CXX_STR(""));
+		SimpleDateFormat    sdf(DATE_PATTERN_STR);
+		apr_time_t          now(apr_time_now());
+		LogString           ext(withCompression ? LOG4CXX_STR(".gz") : LOG4CXX_STR(""));
 
 		now += startInFuture ? APR_USEC_PER_SEC : 0;
 
 		for (size_t i = 0; i < N; ++i)
 		{
-			fnames[i].assign(LogString(LOG4CXX_STR("" DIR_PRE_OUTPUT)) + prefix);
-			sdf.format(fnames[i], now, pool);
-			fnames[i].append(ext);
+			fileNames[i].assign(LogString(LOG4CXX_STR("output/")) + prefix);
+			sdf.format(fileNames[i], now, pool);
+			fileNames[i].append(ext);
 
 			now += APR_USEC_PER_SEC;
 		}
@@ -168,26 +170,25 @@ private:
 	 * We had macro wrappers around this method dealing with such things in the past, but as args
 	 * where added, those become more and more difficult to maintain properly and therefore removed.
 	 * </p>
-	 * @param[in,out]	pool
-	 * @param[in]		howOften
-	 * @param[in]		srcFunc
-	 * @param[in]		srcLine
-	 * @param[in,opt]	startWith
-	 * @param[in]		waitFactor
+	 * @param[in,out]   pool
+	 * @param[in]       howOften
+	 * @param[in]       srcFunc
+	 * @param[in]       srcLine
+	 * @param[in,opt]   startWith
+	 * @param[in]       waitFactor
 	 */
-	void logMsgAndSleep(
-		Pool&		pool,
-		size_t		howOften,
-		std::string	srcFunc,
-		size_t		srcLine,
-		size_t		startWith	= 0,
-		float		waitFactor	= 0.5)
+	void logMsgAndSleep(Pool &       pool,
+		size_t      howOften,
+		std::string srcFunc,
+		size_t      srcLine,
+		size_t      startWith   = 0,
+		float       waitFactor  = 0.5)
 	{
 #undef  LOG4CXX_LOCATION
-#define LOG4CXX_LOCATION ::log4cxx::spi::LocationInfo( \
-	__FILE__,			\
-	__FILE__,			\
-	srcFunc.c_str(),	\
+#define LOG4CXX_LOCATION ::log4cxx::spi::LocationInfo(  \
+	__FILE__,                   \
+	__FILE__,                   \
+	srcFunc.c_str(),            \
 	srcLine)
 
 		for (size_t i = startWith; i < startWith + howOften; ++i)
@@ -196,14 +197,14 @@ private:
 			message.append(pool.itoa(i));
 
 			LOG4CXX_DEBUG(logger, message);
-			current_time += (APR_USEC_PER_SEC * waitFactor);
+			apr_sleep(APR_USEC_PER_SEC * waitFactor);
 		}
 
 #undef  LOG4CXX_LOCATION
-#define LOG4CXX_LOCATION ::log4cxx::spi::LocationInfo( \
-	__FILE__,			\
-	__FILE__,			\
-	__LOG4CXX_FUNC__,	\
+#define LOG4CXX_LOCATION ::log4cxx::spi::LocationInfo(  \
+	__FILE__,                   \
+	__FILE__,                   \
+	__LOG4CXX_FUNC__,           \
 	__LINE__)
 	}
 
@@ -219,26 +220,23 @@ private:
 	 * We don't use a wrapper macro this time because the src line should have the same name in all
 	 * compilers and is easily to add for the caller.
 	 * </p>
-	 * @param[in,out]	pool
-	 * @param[in]		prefix
-	 * @param[in]		fname
-	 * @param[in]		witnessIdx
-	 * @param[in]		srcLine
+	 * @param[in,out]   pool
+	 * @param[in]       prefix
+	 * @param[in]       fileName
+	 * @param[in]       witnessIdx
+	 * @param[in]       srcLine
 	 */
-	void compareWitness(
-				Pool&		pool,
-		const	logchar*	prefix,
-		const	LogString&	fname,
-				size_t		witnessIdx,
-				size_t		srcLine)
+	void compareWitness(        Pool &       pool,
+		const   logchar *    prefix,
+		const   LogString &  fileName,
+		size_t      witnessIdx,
+		size_t      srcLine)
 	{
-		LogString witness(LOG4CXX_STR("" DIR_PRE_WITNESS));
+		LogString   witness(LOG4CXX_STR("witness/rolling/tbr-"));
 		witness.append(prefix);
-		StringHelper::toString(witnessIdx, pool, witness);
 
-		//std::wcerr << L"Comparing file:    " << fname	<< L"\n";
-		//std::wcerr << L"Comparing witness: " << witness	<< L"\n";
-		LOGUNIT_ASSERT_SRCL(Compare::compare(fname, File(witness)), srcLine);
+		StringHelper::toString(witnessIdx, pool, witness);
+		LOGUNIT_ASSERT_SRCL(Compare::compare(fileName, File(witness)), srcLine);
 	}
 
 	/**
@@ -247,21 +245,20 @@ private:
 	 * This method is a wrapper around {@link compareWitness}, used to iterate over all files from a
 	 * given test.
 	 * </p>
-	 * @param[in,out]	pool
-	 * @param[in]		prefix
-	 * @param[in]		fnames
-	 * @param[in]		srcLine
+	 * @param[in,out]   pool
+	 * @param[in]       prefix
+	 * @param[in]       fileNames
+	 * @param[in]       srcLine
 	 */
 	template<size_t N>
-	void compareWitnesses(
-				Pool&		pool,
-		const	logchar*	prefix,
-				LogString	(&fnames)[N],
-				size_t		srcLine)
+	void compareWitnesses(          Pool &       pool,
+		const   logchar *    prefix,
+		LogString   (&fileNames)[N],
+		size_t      srcLine)
 	{
 		for (int i = 0; i < N; ++i)
 		{
-			this->compareWitness(pool, prefix, fnames[i], i, srcLine);
+			this->compareWitness(pool, prefix, fileNames[i], i, srcLine);
 		}
 	}
 
@@ -272,30 +269,26 @@ private:
 	 * the last one by content to some witness.
 	 * </p>
 	 * <p>
-	 * We don't use a wrapper macro this time because the src line should have the same name in all
+	 * We don't use a wrapper macro this time because the src line schould have the same name in all
 	 * compilers and is easily to add for the caller.
 	 * </p>
-	 * @param[in,out]	pool
-	 * @param[in]		prefix
-	 * @param[in]		fnames
-	 * @param[in]		witnessIdx
-	 * @param[in]		srcLine
+	 * @param[in,out]   pool
+	 * @param[in]       prefix
+	 * @param[in]       fileNames
+	 * @param[in]       srcLine
 	 */
 	template<size_t N>
-	void checkFilesExist(
-				Pool&		pool,
-		const	logchar*	prefix,
-				LogString	(&fnames)[N],
-				size_t		witnessIdx,
-				size_t		srcLine)
+	void checkFilesExist(           Pool &       pool,
+		const   logchar *    prefix,
+		LogString   (&fileNames)[N],
+		size_t      srcLine)
 	{
 		for (int i = 0; i < N - 1; ++i)
 		{
-			//std::wcerr << L"Check: " << fnames[i] << L"\n";
-			LOGUNIT_ASSERT_EQUAL_SRCL(true, File(fnames[i]).exists(pool), srcLine);
+			LOGUNIT_ASSERT_EQUAL_SRCL(true, File(fileNames[0]).exists(pool), srcLine);
 		}
 
-		this->compareWitness(pool, prefix, fnames[witnessIdx], witnessIdx, srcLine);
+		this->compareWitness(pool, prefix, fileNames[N - 1], N - 1, srcLine);
 	}
 
 	/**
@@ -306,9 +299,12 @@ private:
 	 * </p>
 	 * @param[in,opt] millis
 	 */
-	void delayUntilNextSecond()
+	void delayUntilNextSecond(size_t millis = 100)
 	{
-		current_time += APR_USEC_PER_SEC;
+		apr_time_t now  = apr_time_now();
+		apr_time_t next = ((now / APR_USEC_PER_SEC) + 1) * APR_USEC_PER_SEC + millis * 1000L;
+
+		apr_sleep(next - now);
 	}
 
 	/**
@@ -319,53 +315,74 @@ private:
 	 * </p>
 	 * @param[in,opt] millis
 	 */
-	void delayUntilNextSecondWithMsg()
+	void delayUntilNextSecondWithMsg(size_t millis = 100)
 	{
-		std::cout << "Advancing one second\n";
-		delayUntilNextSecond();
+		std::cout << "Waiting until next second and " << millis << " millis.";
+		delayUntilNextSecond(millis);
+		std::cout << "Done waiting." << std::endl;
 	}
 
 	/**
-	 * Delete generic log file.
+	 * Delete generic log files.
 	 * <p>
 	 * Some tests use generic log file names which may already be available during subsequent calls
 	 * to the test and influence their behavior, e.g. because RollingFileAppender uses the last
-	 * modification time of already existing files to create its internal name. Such a date might be
-	 * from the arbitrary past, but most of the tests assume operations like rollovers within a few
-	 * seconds around "new". Those assumptions will fail for older existing files. This method can
-	 * be used to delete those files, while documenting the problem at the same time.
+	 * modification time of already existing files to create their internal names. Such a date may
+	 * be from the arbitrary past, but ost of the test assumes operations like rollovers within few
+	 * seconds around "new". Thos assumptions will fail for older existing files. So this method can
+	 * be called during {@link setUp()} of an test to clear such generically named files for each
+	 * test. We currently only care about {@code output/testxy.log}.
 	 * </p>
-	 * @param[in,out]	pool
-	 * @param[in]		path
+	 * @param[in] num_test
 	 */
-	void delGenericLogFile(
-			Pool&		pool,
-			LogString	path)
+	void deleteGenericLogFilePerTest(size_t num_test)
 	{
+		Pool        pool;
+		LogString   path(LOG4CXX_STR("output/test"));
+
+		StringHelper::toString(num_test, pool, path);
+		path.append(LOG4CXX_STR(".log"));
+
 		File(path).deleteFile(pool);
 	}
 
 	/**
-	 * Set the current time for each individual test methhod run.
+	 * Setup for internal test call.
+	 * <p>
+	 * This method has a similar intention like {@link setUp()}, only that it focusses on internal
+	 * calls of the tests, where we don't need to create some loggers and such, but may need to
+	 * delete some files etc. to make tests work.
+	 * </p>
+	 * @param[in] num_test
+	 */
+	void internalSetUp(size_t num_test)
+	{
+		this->deleteGenericLogFilePerTest(num_test);
+	}
+
+	/**
+	 * Counterpart for {@like internalSetUp(size_t)}.
 	 * <p>
-	 * There's at least one test running multiple other tests WITHIN the same lifecycle of
-	 * {@code setUp} and {@code tearDown}, but each of the test methods need the same current time
-	 * to start with. So this method can be used to set that and is simply used by {@code setUp}
-	 * as well.
+	 * Counterpart for {@like internalSetUp(size_t)}.
 	 * </p>
 	 */
-	void setUpCurrTime()
+	void internalTearDown()
 	{
-		//current_time = log4cxx::helpers::Date::currentTime(); // Start at "about" now.
-		//current_time -= (current_time % APR_USEC_PER_SEC); // Go to the top of the second
-		//current_time++; // Need to not be at the top of a second for rollover logic to work correctly
-		current_time = 1; // Start at about unix epoch
+		// Nothing to do currently.
 	}
 
 public:
-	log4cxx_time_t currentTime()
+	/**
+	 * Extract number of current test.
+	 * <p>
+	 * {@code setUp()} needs the number of the current runnign test for some generic work and this
+	 * is the only place where we can extract and save it in the instance.
+	 * </p>
+	 */
+	void setCase(abts_case * tc)
 	{
-		return current_time;
+		LogUnit::TestFixture::setCase(tc);
+		this->num_test = tc->suite->num_test;
 	}
 
 	void setUp()
@@ -375,240 +392,216 @@ public:
 			ConsoleAppenderPtr(new ConsoleAppender(
 					PatternLayoutPtr(new PatternLayout(
 							LOG4CXX_STR("%d{ABSOLUTE} [%t] %level %c{2}#%M:%L - %m%n"))))));
-
-		this->setUpCurrTime();
-		log4cxx::helpers::Date::setGetCurrentTimeFunction( std::bind( &TimeBasedRollingTest::currentTime, this ) );
+		this->internalSetUp(this->num_test);
 	}
 
 	void tearDown()
 	{
+		this->internalTearDown();
 		LogManager::shutdown();
 	}
 
 	/**
-	 * Test rolling without compression, activeFileName left blank, no stop/start.
+	 * Test rolling without compression, activeFileName left blank, no stop/start
 	 */
 	void test1()
 	{
-				Pool		pool;
-		const	size_t		nrOfFnames(4);
-				LogString	fnames[nrOfFnames];
+		Pool        pool;
+		const   size_t      nrOfFileNames = 4;
+		LogString   fileNames[nrOfFileNames];
 
-		PatternLayoutPtr		layout(	new PatternLayout(PATTERN_LAYOUT));
-		RollingFileAppenderPtr	rfa(	new RollingFileAppender());
-		rfa->setAppend(false);
+		PatternLayoutPtr        layout( new PatternLayout(PATTERN_LAYOUT));
+		RollingFileAppenderPtr  rfa(    new RollingFileAppender());
 		rfa->setLayout(layout);
 
 		TimeBasedRollingPolicyPtr tbrp(new TimeBasedRollingPolicy());
-		tbrp->setFileNamePattern(LOG4CXX_STR("" DIR_PRE_OUTPUT "test1-%d{" DATE_PATTERN "}"));
+		tbrp->setFileNamePattern(LOG4CXX_STR("output/test1-%d{" DATE_PATTERN "}"));
 		tbrp->activateOptions(pool);
 		rfa->setRollingPolicy(tbrp);
 		rfa->activateOptions(pool);
 		logger->addAppender(rfa);
 
-		this->buildTsFnames(pool, LOG4CXX_STR("test1-"), fnames);
+		this->buildTsFileNames(pool, LOG4CXX_STR("test1-"), fileNames);
 		this->delayUntilNextSecondWithMsg();
-		this->logMsgAndSleep(	pool, nrOfFnames + 1, __LOG4CXX_FUNC__, __LINE__);
-		this->compareWitnesses(	pool, LOG4CXX_STR("test1."), fnames, __LINE__);
+		this->logMsgAndSleep(   pool, nrOfFileNames + 1, __LOG4CXX_FUNC__, __LINE__);
+		this->compareWitnesses( pool, LOG4CXX_STR("test1."), fileNames, __LINE__);
 	}
 
-
 	/**
-	 * No compression, with stop/restart, activeFileName left blank.
+	 * No compression, with stop/restart, activeFileName left blank
 	 */
 	void test2()
 	{
-				Pool		pool;
-		const	size_t		nrOfFnames(4);
-				LogString	fnames[nrOfFnames];
+		Pool        pool;
+		const   size_t      nrOfFileNames = 4;
+		LogString   fileNames[nrOfFileNames];
 
-		PatternLayoutPtr		layout1(new PatternLayout(PATTERN_LAYOUT));
-		RollingFileAppenderPtr	rfa1(	new RollingFileAppender());
-		rfa1->setAppend(false);
+		PatternLayoutPtr        layout1(new PatternLayout(PATTERN_LAYOUT));
+		RollingFileAppenderPtr  rfa1(   new RollingFileAppender());
 		rfa1->setLayout(layout1);
 
 		TimeBasedRollingPolicyPtr tbrp1(new TimeBasedRollingPolicy());
-		tbrp1->setFileNamePattern(LOG4CXX_STR("" DIR_PRE_OUTPUT "test2-%d{" DATE_PATTERN "}"));
+		tbrp1->setFileNamePattern(LOG4CXX_STR("output/test2-%d{" DATE_PATTERN "}"));
 		tbrp1->activateOptions(pool);
 		rfa1->setRollingPolicy(tbrp1);
 		rfa1->activateOptions(pool);
 		logger->addAppender(rfa1);
 
-		this->buildTsFnames(pool, LOG4CXX_STR("test2-"), fnames);
+		this->buildTsFileNames(pool, LOG4CXX_STR("test2-"), fileNames);
 		this->delayUntilNextSecondWithMsg();
 		this->logMsgAndSleep(pool, 3, __LOG4CXX_FUNC__, __LINE__);
 
 		logger->removeAppender(rfa1);
 		rfa1->close();
 
-		PatternLayoutPtr		layout2(new PatternLayout(PATTERN_LAYOUT));
-		RollingFileAppenderPtr	rfa2(	new RollingFileAppender());
+		PatternLayoutPtr        layout2(new PatternLayout(PATTERN_LAYOUT));
+		RollingFileAppenderPtr  rfa2(   new RollingFileAppender());
 		rfa2->setLayout(layout2);
 
 		TimeBasedRollingPolicyPtr tbrp2 = TimeBasedRollingPolicyPtr(new TimeBasedRollingPolicy());
-		tbrp2->setFileNamePattern(LOG4CXX_STR("" DIR_PRE_OUTPUT "test2-%d{" DATE_PATTERN "}"));
+		tbrp2->setFileNamePattern(LOG4CXX_STR("output/test2-%d{" DATE_PATTERN "}"));
 		tbrp2->activateOptions(pool);
 		rfa2->setRollingPolicy(tbrp2);
 		rfa2->activateOptions(pool);
-		rfa2->setAppend(false);
 		logger->addAppender(rfa2);
 
-		this->logMsgAndSleep(	pool, 2, __LOG4CXX_FUNC__, __LINE__, 3);
-		this->compareWitnesses(	pool, LOG4CXX_STR("test2."), fnames, __LINE__);
+		this->logMsgAndSleep(   pool, 2, __LOG4CXX_FUNC__, __LINE__, 3);
+		this->compareWitnesses( pool, LOG4CXX_STR("test2."), fileNames, __LINE__);
 	}
 
-
 	/**
-	 * With compression, activeFileName left blank, no stop/restart.
+	 * With compression, activeFileName left blank, no stop/restart
 	 */
 	void test3()
 	{
-				Pool		pool;
-		const	size_t		nrOfFnames(4);
-				LogString	fnames[nrOfFnames];
+		Pool        pool;
+		const   size_t      nrOfFileNames = 4;
+		LogString   fileNames[nrOfFileNames];
 
-		PatternLayoutPtr		layout(	new PatternLayout(PATTERN_LAYOUT));
-		RollingFileAppenderPtr	rfa(	new RollingFileAppender());
+		PatternLayoutPtr        layout( new PatternLayout(PATTERN_LAYOUT));
+		RollingFileAppenderPtr  rfa(    new RollingFileAppender());
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 
 		TimeBasedRollingPolicyPtr tbrp = TimeBasedRollingPolicyPtr(new TimeBasedRollingPolicy());
-		tbrp->setFileNamePattern(LogString(LOG4CXX_STR("" DIR_PRE_OUTPUT "test3-%d{" DATE_PATTERN "}.gz")));
+		tbrp->setFileNamePattern(LogString(LOG4CXX_STR("output/test3-%d{" DATE_PATTERN "}.gz")));
 		tbrp->activateOptions(pool);
 		rfa->setRollingPolicy(tbrp);
 		rfa->activateOptions(pool);
 		logger->addAppender(rfa);
 
-		this->buildTsFnames(pool, LOG4CXX_STR("test3-"), fnames, true);
-		fnames[nrOfFnames - 1].resize(fnames[nrOfFnames - 1].size() - 3);
+		this->buildTsFileNames(pool, LOG4CXX_STR("test3-"), fileNames, true);
+		fileNames[3].resize(fileNames[3].size() - 3);
 		this->delayUntilNextSecondWithMsg();
-		this->logMsgAndSleep(	pool, nrOfFnames + 1, __LOG4CXX_FUNC__, __LINE__);
-		this->checkFilesExist(	pool, LOG4CXX_STR("test3."), fnames, nrOfFnames - 1, __LINE__);
+		this->logMsgAndSleep(   pool, nrOfFileNames + 1, __LOG4CXX_FUNC__, __LINE__);
+		this->checkFilesExist(  pool, LOG4CXX_STR("test3."), fileNames, __LINE__);
 	}
 
 	/**
 	 * Without compression, activeFileName set,  with stop/restart
-	 *
-	 * Note: because this test stops and restarts, it is not possible to use the
-	 * date pattern in the filenames, as log4cxx will use the file's last modified
-	 * time when rolling over and determining the new filename.
 	 */
 	void test4()
 	{
-				Pool		pool;
-		const	size_t		nrOfFnames(4);
-		const	size_t		nrOfLogMsgs(((nrOfFnames - 1) * 2) - 1);
-				LogString	fnames[nrOfFnames];
+		Pool        pool;
+		const   size_t      nrOfFileNames = 4;
+		LogString   fileNames[nrOfFileNames];
 
-		PatternLayoutPtr		layout1(new PatternLayout(PATTERN_LAYOUT));
-		RollingFileAppenderPtr	rfa1(	new RollingFileAppender());
+		PatternLayoutPtr        layout1(new PatternLayout(PATTERN_LAYOUT));
+		RollingFileAppenderPtr  rfa1(   new RollingFileAppender());
 		rfa1->setLayout(layout1);
 
 		TimeBasedRollingPolicyPtr tbrp1 = TimeBasedRollingPolicyPtr(new TimeBasedRollingPolicy());
-		tbrp1->setFileNamePattern(LOG4CXX_STR("" DIR_PRE_OUTPUT "test4-%d{" DATE_PATTERN "}"));
+		rfa1->setFile(LOG4CXX_STR("output/test4.log"));
+		tbrp1->setFileNamePattern(LOG4CXX_STR("output/test4-%d{" DATE_PATTERN "}"));
 		tbrp1->activateOptions(pool);
-		rfa1->setFile(LOG4CXX_STR("" DIR_PRE_OUTPUT "test4.log"));
 		rfa1->setRollingPolicy(tbrp1);
 		rfa1->activateOptions(pool);
 		logger->addAppender(rfa1);
 
-		this->delGenericLogFile(pool, rfa1->getFile());
-		this->buildTsFnames(pool, LOG4CXX_STR("test4-"), fnames);
-		fnames[0].assign(rfa1->getFile());
+		this->buildTsFileNames(pool, LOG4CXX_STR("test4-"), fileNames);
+		fileNames[3].assign(rfa1->getFile());
 		this->delayUntilNextSecondWithMsg();
-		this->logMsgAndSleep(pool, nrOfLogMsgs, __LOG4CXX_FUNC__, __LINE__);
+		this->logMsgAndSleep(pool, 3, __LOG4CXX_FUNC__, __LINE__);
 
 		logger->removeAppender(rfa1);
 		rfa1->close();
 
-		PatternLayoutPtr		layout2(new PatternLayout(PATTERN_LAYOUT));
-		RollingFileAppenderPtr	rfa2(	new RollingFileAppender());
+		PatternLayoutPtr        layout2(new PatternLayout(PATTERN_LAYOUT));
+		RollingFileAppenderPtr  rfa2(   new RollingFileAppender());
 		rfa2->setLayout(layout2);
 
 		TimeBasedRollingPolicyPtr tbrp2 = TimeBasedRollingPolicyPtr(new TimeBasedRollingPolicy());
-		tbrp2->setFileNamePattern(LOG4CXX_STR("" DIR_PRE_OUTPUT "test4-%d{" DATE_PATTERN "}"));
+		tbrp2->setFileNamePattern(LOG4CXX_STR("output/test4-%d{" DATE_PATTERN "}"));
+		rfa2->setFile(fileNames[3]);
 		tbrp2->activateOptions(pool);
-		rfa2->setFile(rfa1->getFile());
 		rfa2->setRollingPolicy(tbrp2);
 		rfa2->activateOptions(pool);
 		logger->addAppender(rfa2);
 
-		// The one file not checked is the active file from the old appender reused by the new one
-		// and rolled over afterwards. The problem is that because the reused file exists already,
-		// it doesn't get an expected fname, but the last write time instead. Though, should be safe
-		// enough to not check that special file.
-		this->logMsgAndSleep(pool, 2, __LOG4CXX_FUNC__, __LINE__, nrOfLogMsgs);
-		this->compareWitness(pool, LOG4CXX_STR("test4."), fnames[0], 0, __LINE__);
-		this->compareWitness(pool, LOG4CXX_STR("test4."), fnames[1], 1, __LINE__);
-		this->compareWitness(pool, LOG4CXX_STR("test4."), fnames[2], 2, __LINE__);
+		this->logMsgAndSleep(   pool, 2, __LOG4CXX_FUNC__, __LINE__, 3);
+		this->compareWitnesses( pool, LOG4CXX_STR("test4."), fileNames, __LINE__);
 	}
 
 	/**
-	 * No compression, activeFileName set, without stop/restart.
+	 * No compression, activeFileName set,  without stop/restart
 	 */
 	void test5()
 	{
-				Pool		pool;
-		const	size_t		nrOfFnames(4);
-		const	size_t		nrOfLogMsgs((nrOfFnames * 2) - 1);
-				LogString	fnames[nrOfFnames];
+		Pool        pool;
+		const   size_t      nrOfFileNames = 4;
+		LogString   fileNames[nrOfFileNames];
 
-		PatternLayoutPtr		layout(	new PatternLayout(PATTERN_LAYOUT));
-		RollingFileAppenderPtr	rfa(	new RollingFileAppender());
+		PatternLayoutPtr        layout( new PatternLayout(PATTERN_LAYOUT));
+		RollingFileAppenderPtr  rfa(    new RollingFileAppender());
 		rfa->setLayout(layout);
 
 		TimeBasedRollingPolicyPtr tbrp = TimeBasedRollingPolicyPtr(new TimeBasedRollingPolicy());
-		tbrp->setFileNamePattern(LOG4CXX_STR("" DIR_PRE_OUTPUT "test5-%d{" DATE_PATTERN "}"));
-		rfa->setFile(LOG4CXX_STR("" DIR_PRE_OUTPUT "test5.log"));
+		tbrp->setFileNamePattern(LOG4CXX_STR("output/test5-%d{" DATE_PATTERN "}"));
+		rfa->setFile(LOG4CXX_STR("output/test5.log"));
 
 		tbrp->activateOptions(pool);
 		rfa->setRollingPolicy(tbrp);
 		rfa->activateOptions(pool);
 		logger->addAppender(rfa);
 
-		this->delGenericLogFile(pool, rfa->getFile());
-		this->buildTsFnames(pool, LOG4CXX_STR("test5-"), fnames);
-		fnames[0].assign(rfa->getFile());
-
+		this->buildTsFileNames(pool, LOG4CXX_STR("test5-"), fileNames);
+		fileNames[3].assign(rfa->getFile());
 		this->delayUntilNextSecondWithMsg();
-		this->logMsgAndSleep(	pool, nrOfLogMsgs, __LOG4CXX_FUNC__, __LINE__);
-		this->compareWitnesses(	pool, LOG4CXX_STR("test5."), fnames, __LINE__);
+		this->logMsgAndSleep(   pool, nrOfFileNames + 1, __LOG4CXX_FUNC__, __LINE__);
+		this->compareWitnesses( pool, LOG4CXX_STR("test5."), fileNames, __LINE__);
 	}
 
 	/**
-	 * With compression, activeFileName set, no stop/restart.
+	 * With compression, activeFileName set, no stop/restart,
 	 */
 	void test6()
 	{
-				Pool		pool;
-		const	size_t		nrOfFnames(4);
-		const	size_t		nrOfLogMsgs((nrOfFnames * 2) - 1);
-				LogString	fnames[nrOfFnames];
+		Pool        pool;
+		const   size_t      nrOfFileNames = 4;
+		LogString   fileNames[nrOfFileNames];
 
-		PatternLayoutPtr		layout(	new PatternLayout(PATTERN_LAYOUT));
-		RollingFileAppenderPtr	rfa(	new RollingFileAppender());
+		PatternLayoutPtr        layout( new PatternLayout(PATTERN_LAYOUT));
+		RollingFileAppenderPtr  rfa(    new RollingFileAppender());
 		rfa->setAppend(false);
 		rfa->setLayout(layout);
 
 		TimeBasedRollingPolicyPtr tbrp = TimeBasedRollingPolicyPtr(new TimeBasedRollingPolicy());
-		tbrp->setFileNamePattern(LogString(LOG4CXX_STR("" DIR_PRE_OUTPUT "test6-%d{" DATE_PATTERN "}.gz")));
-		rfa->setFile(LOG4CXX_STR("" DIR_PRE_OUTPUT "test6.log"));
+		tbrp->setFileNamePattern(LogString(LOG4CXX_STR("output/test6-%d{" DATE_PATTERN "}.gz")));
+		rfa->setFile(LOG4CXX_STR("output/test6.log"));
 		tbrp->activateOptions(pool);
 		rfa->setRollingPolicy(tbrp);
 		rfa->activateOptions(pool);
 		logger->addAppender(rfa);
 
-		this->delGenericLogFile(pool, rfa->getFile());
-		this->buildTsFnames(pool, LOG4CXX_STR("test6-"), fnames, true);
-		fnames[0].assign(rfa->getFile());
-
+		this->buildTsFileNames(pool, LOG4CXX_STR("test6-"), fileNames, true);
+		fileNames[3].assign(rfa->getFile());
 		this->delayUntilNextSecondWithMsg();
-		this->logMsgAndSleep(	pool, nrOfLogMsgs, __LOG4CXX_FUNC__, __LINE__);
-		this->checkFilesExist(	pool, LOG4CXX_STR("test6."), fnames, 0, __LINE__);
+		this->logMsgAndSleep(   pool, nrOfFileNames + 1, __LOG4CXX_FUNC__, __LINE__);
+		this->checkFilesExist(  pool, LOG4CXX_STR("test6."), fileNames, __LINE__);
 	}
 
 	/**
-	 * Repeat some tests with generic file names.
+	 * Repeat some test with generic file name.s
 	 * <p>
 	 * This test calls some tests which use generic file names and will only work properly if those
 	 * got deleted before running the test during setup.
@@ -619,8 +612,8 @@ public:
 		typedef void (TimeBasedRollingTest::*Test)();
 		typedef std::vector<Test> Tests;
 
-		Tests	tests(10);
-		size_t	numTest = 0;
+		Tests   tests(10);
+		size_t  numTest = 0;
 
 		tests.at(4) = &TimeBasedRollingTest::test4;
 		tests.at(5) = &TimeBasedRollingTest::test5;
@@ -629,40 +622,39 @@ public:
 		for (size_t numTest = 1; numTest < tests.size(); ++numTest)
 		{
 			Test test(tests.at(numTest));
+
 			if (!test)
 			{
 				continue;
 			}
 
-			this->setUpCurrTime();
+			this->internalSetUp(numTest);
 			(this->*test)();
+			this->internalTearDown();
 		}
 	}
 
-	void rollIntoDir()
+	void create_directories()
 	{
-				Pool		pool;
-		const	size_t		nrOfFnames(4);
-		const	size_t		nrOfLogMsgs((nrOfFnames * 2) - 1);
-				LogString	fnames[nrOfFnames];
+		Pool        pool;
+		const   size_t      nrOfFileNames = 4;
+		LogString   fileNames[nrOfFileNames];
 
-		PatternLayoutPtr		layout(	new PatternLayout(PATTERN_LAYOUT));
-		RollingFileAppenderPtr	rfa(	new RollingFileAppender());
+		PatternLayoutPtr        layout( new PatternLayout(PATTERN_LAYOUT));
+		RollingFileAppenderPtr  rfa(    new RollingFileAppender());
 		rfa->setLayout(layout);
-		rfa->setFile(LOG4CXX_STR("" DIR_PRE_OUTPUT "rollIntoDir.log"));
+		rfa->setFile(LOG4CXX_STR("output/timebasedrolling_create_dir.log"));
 
 		std::random_device dev;
 		std::mt19937 rng(dev());
 		std::uniform_int_distribution<std::mt19937::result_type> dist(1,100000);
-		LogString filenamePattern = LOG4CXX_STR("" DIR_PRE_OUTPUT);
+		LogString filenamePattern = LOG4CXX_STR("output/tbrolling-directory-");
 #if LOG4CXX_LOGCHAR_IS_WCHAR
 		LogString dirNumber = std::to_wstring(dist(rng));
 #else
 		LogString dirNumber = std::to_string(dist(rng));
 #endif
-		LogString directoryName = LOG4CXX_STR("tbr-rollIntoDir-");
-		directoryName.append( dirNumber );
-		filenamePattern.append( directoryName );
+		filenamePattern.append( dirNumber );
 		LogString filenamePatternPrefix = filenamePattern;
 		filenamePattern.append( LOG4CXX_STR("/file-%d{" DATE_PATTERN "}") );
 
@@ -673,17 +665,15 @@ public:
 		rfa->activateOptions(pool);
 		logger->addAppender(rfa);
 
-		const logchar* prefix = directoryName.append(LOG4CXX_STR("/file-")).data();
-
-		this->delGenericLogFile(pool, rfa->getFile());
-		this->buildTsFnames(pool, prefix, fnames);
-		fnames[0].assign(rfa->getFile());
-
+		this->buildTsFileNames(pool, filenamePatternPrefix.append(LOG4CXX_STR("/file-")).data(), fileNames);
 		this->delayUntilNextSecondWithMsg();
-		this->logMsgAndSleep(	pool, nrOfLogMsgs, __LOG4CXX_FUNC__, __LINE__);
-		this->checkFilesExist(	pool, LOG4CXX_STR("test6."), fnames, 0, __LINE__);
-	}
+		this->logMsgAndSleep(   pool, nrOfFileNames + 1, __LOG4CXX_FUNC__, __LINE__);
+//		this->compareWitnesses( pool, LOG4CXX_STR("test1."), fileNames, __LINE__);
 
+		for( size_t x = 0; x < nrOfFileNames - 1; x++ ){
+			LOGUNIT_ASSERT_EQUAL(true, File(fileNames[x]).exists(pool));
+		}
+	}
 };
 
 LoggerPtr TimeBasedRollingTest::logger(Logger::getLogger("org.apache.log4j.TimeBasedRollingTest"));
diff --git a/src/test/resources/witness/rolling/tbr-test4.0 b/src/test/resources/witness/rolling/tbr-test4.0
index ae12f7ad..e69de29b 100644
--- a/src/test/resources/witness/rolling/tbr-test4.0
+++ b/src/test/resources/witness/rolling/tbr-test4.0
@@ -1 +0,0 @@
-TimeBasedRollingTest - Hello---6
diff --git a/src/test/resources/witness/rolling/tbr-test4.3 b/src/test/resources/witness/rolling/tbr-test4.3
index 9a81d949..dfc095dc 100644
--- a/src/test/resources/witness/rolling/tbr-test4.3
+++ b/src/test/resources/witness/rolling/tbr-test4.3
@@ -1,2 +1 @@
 TimeBasedRollingTest - Hello---4
-TimeBasedRollingTest - Hello---5
diff --git a/src/test/resources/witness/rolling/tbr-test5.0 b/src/test/resources/witness/rolling/tbr-test5.0
index ae12f7ad..e69de29b 100644
--- a/src/test/resources/witness/rolling/tbr-test5.0
+++ b/src/test/resources/witness/rolling/tbr-test5.0
@@ -1 +0,0 @@
-TimeBasedRollingTest - Hello---6
diff --git a/src/test/resources/witness/rolling/tbr-test5.3 b/src/test/resources/witness/rolling/tbr-test5.3
index 9a81d949..dfc095dc 100644
--- a/src/test/resources/witness/rolling/tbr-test5.3
+++ b/src/test/resources/witness/rolling/tbr-test5.3
@@ -1,2 +1 @@
 TimeBasedRollingTest - Hello---4
-TimeBasedRollingTest - Hello---5
diff --git a/src/test/resources/witness/rolling/tbr-test6.0 b/src/test/resources/witness/rolling/tbr-test6.0
deleted file mode 100644
index ae12f7ad..00000000
--- a/src/test/resources/witness/rolling/tbr-test6.0
+++ /dev/null
@@ -1 +0,0 @@
-TimeBasedRollingTest - Hello---6
diff --git a/src/test/resources/witness/rolling/tbr-test4.3 b/src/test/resources/witness/rolling/tbr-test6.3
similarity index 50%
copy from src/test/resources/witness/rolling/tbr-test4.3
copy to src/test/resources/witness/rolling/tbr-test6.3
index 9a81d949..dfc095dc 100644
--- a/src/test/resources/witness/rolling/tbr-test4.3
+++ b/src/test/resources/witness/rolling/tbr-test6.3
@@ -1,2 +1 @@
 TimeBasedRollingTest - Hello---4
-TimeBasedRollingTest - Hello---5