kiss4web/test/FooSandbox.java

118 lines
3.2 KiB
Java
Raw Normal View History

2021-11-27 15:46:54 +01:00
/**
* Copyright (C) 2006-2023 Christian Pierre MOMON
2014-02-04 18:43:47 +01:00
*
* This file is part of Kiss4web.
2014-02-04 18:43:47 +01:00
*
* Kiss4web is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
2014-02-04 18:43:47 +01:00
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Kiss4web is distributed in the hope that it will be useful,
2014-02-04 18:43:47 +01:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
2014-02-04 18:43:47 +01:00
*
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see <http://www.gnu.org/licenses/>
*/
2021-12-28 18:26:02 +01:00
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.slf4j.Logger;
2021-12-28 18:26:02 +01:00
2021-07-10 19:46:31 +02:00
import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils;
/**
2014-02-04 18:43:47 +01:00
* Kiss4Web tests.
*/
2016-10-03 05:48:51 +02:00
public class FooSandbox
{
private static Logger logger;
2016-09-08 03:45:06 +02:00
static
{
// Initialize logger.
2021-12-28 18:26:02 +01:00
org.apache.logging.log4j.Logger logger = null;
2021-12-28 18:26:02 +01:00
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.INFO);
logger = LogManager.getLogger(FooSandbox.class.getName());
2016-09-08 03:45:06 +02:00
logger.info("Enter");
2016-09-08 03:45:06 +02:00
//
logger.info("Set the log file format...");
2016-09-08 03:45:06 +02:00
logger.info("... done.");
2016-09-08 03:45:06 +02:00
logger.debug("Exit");
}
2016-09-08 03:45:06 +02:00
/**
* Check.
2021-11-27 15:46:54 +01:00
*
* @param title
* the title
* @param source
* the source
* @param model
* the model
* @return the string
2021-11-27 15:46:54 +01:00
*/
2016-09-08 03:45:06 +02:00
public static String check(final String title, final StringBuffer source, final String model)
{
logger.info("test");
2016-09-08 03:45:06 +02:00
String result;
2016-09-08 03:45:06 +02:00
if (source.indexOf(model) == -1)
{
result = String.format("%-40s -> KO <-", title) + "\nGet:\n" + source + "\nWaiting:\n" + model;
2016-09-08 03:45:06 +02:00
}
else
{
result = String.format("%-40s [ OK ] ", title);
}
2016-09-08 03:45:06 +02:00
//
return (result);
}
2016-09-08 03:45:06 +02:00
/**
* The main method.
2021-11-27 15:46:54 +01:00
*
* @param args
* the arguments
2021-11-27 15:46:54 +01:00
*/
2016-09-08 03:45:06 +02:00
public static void main(final String[] args)
{
System.out.println("----------------------------");
System.out.println(testCaller("/", "fr.devinsy.website"));
System.out.println(testCaller("/good/", "fr.devinsy.website"));
System.out.println(testCaller("/good/morning", "fr.devinsy.website"));
System.out.println(testCaller("/good/day_day", "fr.devinsy.website"));
System.out.println(testCaller("/good/day.xhtml", "fr.devinsy.website"));
}
/**
* Test caller.
*
* @param pathInfo
* the path info
* @param prefix
* the prefix
* @return the string
2021-11-27 15:46:54 +01:00
*/
2016-09-08 03:45:06 +02:00
public static String testCaller(final String pathInfo, final String prefix)
{
String result;
2013-06-20 03:04:07 +02:00
result = "[" + pathInfo + "]=>[" + KissDispatcherUtils.pathInfoToClassName(pathInfo, prefix) + "]";
2013-06-20 03:04:07 +02:00
2016-09-08 03:45:06 +02:00
//
return (result);
}
}