kiss4web/test/FooSandbox.java

101 lines
2.9 KiB
Java

/**
* Copyright (C) 2006-2010, 2013-2016 Christian Pierre MOMON
*
* This file is part of Kiss4web.
*
* 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
* 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,
* 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.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see <http://www.gnu.org/licenses/>
*/
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 fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils;
/**
* Kiss4Web tests.
*/
public class FooSandbox
{
private static org.apache.logging.log4j.Logger logger;
static
{
// Initialize logger.
org.apache.logging.log4j.Logger logger = null;
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.INFO);
logger.info("Enter");
//
logger.info("Set the log file format...");
// log =
// org.apache.log4j.Category.getInstance(Application.class.getName());
logger.info("... done.");
logger.debug("Exit");
logger = LogManager.getLogger(FooSandbox.class.getName());
}
/**
*
*/
public static String check(final String title, final StringBuffer source, final String model)
{
String result;
if (source.indexOf(model) == -1)
{
result = String.format("%-40s -> KO <-", title) + "\nGet:\n" + source + "\nWaiting:\n" + model;
}
else
{
result = String.format("%-40s [ OK ] ", title);
}
//
return (result);
}
/**
*
*/
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"));
}
/**
*
*/
public static String testCaller(final String pathInfo, final String prefix)
{
String result;
result = "[" + pathInfo + "]=>[" + KissDispatcherUtils.pathInfoToClassName(pathInfo, prefix) + "]";
//
return (result);
}
}