From cf1ed4ce54d78aca98c05ef8b280faa62a21336b Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 12 Aug 2020 00:20:00 +0200 Subject: [PATCH] [DEV] start basic test --- src/module-info.java | 1 - test/src/test/scenarium/logger/Log.java | 59 +++++++++++++++++++ .../test/scenarium/logger/TestBasicLog.java | 44 ++++++++++++++ 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 test/src/test/scenarium/logger/Log.java create mode 100644 test/src/test/scenarium/logger/TestBasicLog.java diff --git a/src/module-info.java b/src/module-info.java index 460751c..1dc2c8e 100644 --- a/src/module-info.java +++ b/src/module-info.java @@ -1,5 +1,4 @@ open module io.scenarium.logger { exports io.scenarium.logger; - } diff --git a/test/src/test/scenarium/logger/Log.java b/test/src/test/scenarium/logger/Log.java new file mode 100644 index 0000000..e09e572 --- /dev/null +++ b/test/src/test/scenarium/logger/Log.java @@ -0,0 +1,59 @@ +package test.scenarium.logger; + +import io.scenarium.logger.LogLevel; +import io.scenarium.logger.Logger; + +public class Log { + private static final String LIB_NAME = "sc-log-test"; + private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME); + private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL); + private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR); + private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING); + private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO); + private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG); + private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE); + private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO); + private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT); + + private Log() {} + + public static void print(String data) { + if (PRINT_PRINT) + Logger.error(LIB_NAME_DRAW, data); + } + + public static void critical(String data) { + if (PRINT_CRITICAL) + Logger.critical(LIB_NAME_DRAW, data); + } + + public static void error(String data) { + if (PRINT_ERROR) + Logger.error(LIB_NAME_DRAW, data); + } + + public static void warning(String data) { + if (PRINT_WARNING) + Logger.warning(LIB_NAME_DRAW, data); + } + + public static void info(String data) { + if (PRINT_INFO) + Logger.info(LIB_NAME_DRAW, data); + } + + public static void debug(String data) { + if (PRINT_DEBUG) + Logger.debug(LIB_NAME_DRAW, data); + } + + public static void verbose(String data) { + if (PRINT_VERBOSE) + Logger.verbose(LIB_NAME_DRAW, data); + } + + public static void todo(String data) { + if (PRINT_TODO) + Logger.todo(LIB_NAME_DRAW, data); + } +} diff --git a/test/src/test/scenarium/logger/TestBasicLog.java b/test/src/test/scenarium/logger/TestBasicLog.java new file mode 100644 index 0000000..8570bc8 --- /dev/null +++ b/test/src/test/scenarium/logger/TestBasicLog.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Contributors: + * Revilloud Marc - initial API and implementation + ******************************************************************************/ +package test.scenarium.logger; + +import org.junit.Test; + +public class TestBasicLog { + + // TODO REFACTO REMOVE this and set it in the Test of the logger. + public static String getAAAAAAA(int dfsdf) { + int hhh = 0; + for (int kkk = 0; kkk < dfsdf; kkk++) + for (int iii = 0; iii < 10000; iii++) + for (int jjj = 0; jjj < 100000; jjj++) + for (int lll = 0; lll < 100000; lll++) + hhh++; + return "kkk" + hhh; + } + + public static void testLog() { + Log.print("test direct [START]"); + // test de 10 secondes contre 0.0?? second quand le niveau n'est pas assez grand ... + for (int iii = 0; iii < 1000000; iii++) + Log.debug("test direct"); + Log.print("test direct [END]"); + Log.print("test concat [START]"); + // C'est très long dans les 2 cas ... + for (int iii = 0; iii < 10000; iii++) + Log.debug("test concat: non fonctionnel, il applelle le get a chaque log ... " + getAAAAAAA(iii)); + Log.print("test concat [END]"); + } + + @Test + public void testSimpleLog() { + testLog(); + } + +}