Migrate to SLF4J. Add test support.

This commit is contained in:
Christian P. MOMON 2013-06-26 18:13:50 +02:00
parent 4712fcb709
commit 401f366104
22 changed files with 106 additions and 56 deletions

View file

@ -11,5 +11,9 @@
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/> <classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.7.5.jar"/>
<classpathentry kind="lib" path="lib/slf4j-log4j12-1.7.5.jar"/>
<classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="lib/junit-4.11.jar"/>
<classpathentry kind="output" path="build/classes"/> <classpathentry kind="output" path="build/classes"/>
</classpath> </classpath>

View file

@ -1,3 +1,3 @@
product.name=xidyn product.name=xidyn
product.revision.major=0 product.revision.major=1
product.revision.minor=2 product.revision.minor=0

View file

@ -3,6 +3,8 @@
*/ */
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.xidyn.SimpleTagData; import fr.devinsy.xidyn.SimpleTagData;
import fr.devinsy.xidyn.StringPresenter; import fr.devinsy.xidyn.StringPresenter;
@ -13,15 +15,12 @@ import fr.devinsy.xidyn.TagDataManager;
*/ */
class XidynDemo class XidynDemo
{ {
static private Logger logger = LoggerFactory.getLogger(XidynDemo.class);
static static
{ {
// Initialize logger. // Initialize logger.
org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.BasicConfigurator.configure();
org.apache.log4j.Logger.getRootLogger().setLevel(Level.INFO);
org.apache.log4j.Logger logger = null;
logger = org.apache.log4j.Logger.getRootLogger();
logger.setLevel(Level.INFO);
logger = org.apache.log4j.Logger.getLogger(XidynDemo.class);
} }
/** /**

8
lib/README Normal file
View file

@ -0,0 +1,8 @@
Description of used libraries:
- activation: STU
- hamcrest-core: required by junit
- junit: unit tests API
- log4j: log API
- servlet-api: servlet API
- slf4j-api: facade log API
- slf4j-log4j12: adaptation layer between slf4j and log4j

Binary file not shown.

BIN
lib/hamcrest-core-1.3.jar Normal file

Binary file not shown.

BIN
lib/junit-4.11-sources.jar Normal file

Binary file not shown.

BIN
lib/junit-4.11.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/slf4j-api-1.7.5.jar Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/slf4j-log4j12-1.7.5.jar Normal file

Binary file not shown.

13
rundemo
View file

@ -1,2 +1,11 @@
#$JAVA_HOME/bin/java -classpath lib/activation.jar:lib/log4j-1.2.14.jar:lib/mail.jar:servlet-api.jar:dist/xid.jar:dist/demo.jar XidDemo $JAVA_HOME/bin/java -classpath \
$JAVA_HOME/bin/java -classpath lib/activation.jar:lib/log4j-1.2.17.jar:lib/mail.jar:servlet-api.jar:build/classes:build/demo-classes/:demo.jar:xidyn*.jar XidynDemo lib/activation.jar:\
lib/log4j-1.2.17.jar:\
lib/slf4j-api-1.7.5.jar:\
lib/slf4j-log4j-1.2.5.jar:\
lib/mail.jar:\
servlet-api.jar:\
build/classes:\
build/demo-classes/:\
demo.jar\
XidynDemo

View file

@ -2,6 +2,8 @@ package fr.devinsy.xidyn;
import java.io.StringWriter; import java.io.StringWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
/** /**
@ -11,7 +13,7 @@ public class DomPresenter extends Presenter
{ {
static final public char INDEX_SEPARATOR = '_'; static final public char INDEX_SEPARATOR = '_';
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(DomPresenter.class); static private Logger logger = LoggerFactory.getLogger(DomPresenter.class);
protected Document doc; protected Document doc;
/** /**

View file

@ -5,12 +5,15 @@ import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.StringWriter; import java.io.StringWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
*/ */
public class FilePresenter extends DomPresenter public class FilePresenter extends DomPresenter
{ {
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(FilePresenter.class); static private Logger logger = LoggerFactory.getLogger(FilePresenter.class);
private String sourceFilePathname; private String sourceFilePathname;
private long sourceFileTime; private long sourceFileTime;
@ -38,15 +41,6 @@ public class FilePresenter extends DomPresenter
this.doctype = ""; this.doctype = "";
} }
/**
*
*/
@Override
public StringBuffer dynamize(final TagDataManager datas) throws Exception
{
return (dynamize(datas.getIdsDataById()));
}
/** /**
* No need to be synchronized. * No need to be synchronized.
*/ */
@ -90,6 +84,15 @@ public class FilePresenter extends DomPresenter
return (result); return (result);
} }
/**
*
*/
@Override
public StringBuffer dynamize(final TagDataManager datas) throws Exception
{
return (dynamize(datas.getIdsDataById()));
}
/** /**
* *
*/ */

View file

@ -8,13 +8,16 @@ package fr.devinsy.xidyn;
import java.util.Vector; import java.util.Vector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
*/ */
public class FilePresenters extends Vector<FilePresenter> public class FilePresenters extends Vector<FilePresenter>
{ {
private static final long serialVersionUID = 7058868685681354293L; private static final long serialVersionUID = 7058868685681354293L;
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(FilePresenters.class); static private Logger logger = LoggerFactory.getLogger(FilePresenters.class);
/** /**
* *

View file

@ -1,11 +1,14 @@
package fr.devinsy.xidyn; package fr.devinsy.xidyn;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
*/ */
public class FilePresentersProxy public class FilePresentersProxy
{ {
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(FilePresentersProxy.class); static private Logger logger = LoggerFactory.getLogger(FilePresentersProxy.class);
private static FilePresentersProxy instance = null; private static FilePresentersProxy instance = null;
private FilePresenters presenters = null; private FilePresenters presenters = null;

View file

@ -14,6 +14,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.validation.Schema; import javax.xml.validation.Schema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.DocumentType; import org.w3c.dom.DocumentType;
@ -27,14 +29,9 @@ import org.xml.sax.SAXException;
*/ */
public class Presenter public class Presenter
{ {
static private Logger logger = LoggerFactory.getLogger(Presenter.class);
static final public char INDEX_SEPARATOR = '_'; static final public char INDEX_SEPARATOR = '_';
static private org.apache.log4j.Logger logger;
static
{
logger = org.apache.log4j.Logger.getLogger(Presenter.class);
}
/** /**
* *
*/ */

View file

@ -3,16 +3,15 @@ package fr.devinsy.xidyn;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.StringWriter; import java.io.StringWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
*/ */
public class StringPresenter extends DomPresenter public class StringPresenter extends DomPresenter
{ {
static private org.apache.log4j.Logger logger; static private Logger logger = LoggerFactory.getLogger(StringPresenter.class);
static
{
logger = org.apache.log4j.Logger.getLogger(StringPresenter.class);
}
private String html; private String html;
@ -35,15 +34,6 @@ public class StringPresenter extends DomPresenter
this.html = html; this.html = html;
} }
/**
*
*/
@Override
public StringBuffer dynamize(final TagDataManager datas) throws Exception
{
return (dynamize(datas.getIdsDataById()));
}
/** /**
* *
*/ */
@ -105,6 +95,15 @@ public class StringPresenter extends DomPresenter
return (result); return (result);
} }
/**
*
*/
@Override
public StringBuffer dynamize(final TagDataManager datas) throws Exception
{
return (dynamize(datas.getIdsDataById()));
}
/** /**
* *
*/ */
@ -128,14 +127,6 @@ public class StringPresenter extends DomPresenter
return (result); return (result);
} }
/**
*
*/
static public StringBuffer dynamize(final String html, final TagDataManager datas) throws Exception
{
return (dynamize(html, datas.getIdsDataById()));
}
/** /**
* Xid a string with html in. * Xid a string with html in.
*/ */
@ -150,4 +141,12 @@ public class StringPresenter extends DomPresenter
// //
return (result); return (result);
} }
/**
*
*/
static public StringBuffer dynamize(final String html, final TagDataManager datas) throws Exception
{
return (dynamize(html, datas.getIdsDataById()));
}
} }

View file

@ -2,28 +2,30 @@
* XidTest. * XidTest.
*/ */
import fr.devinsy.xidyn.TagDataManager; import org.apache.log4j.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.xidyn.SimpleTagData; import fr.devinsy.xidyn.SimpleTagData;
import fr.devinsy.xidyn.StringPresenter; import fr.devinsy.xidyn.StringPresenter;
import fr.devinsy.xidyn.TagDataManager;
/** /**
* *
*/ */
class XidTest class XidynTest
{ {
public enum MONTHS public enum MONTHS
{ {
JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBRE, DECEMBRE JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBRE, DECEMBRE
} }
static private Logger logger = LoggerFactory.getLogger(XidynTest.class);
static static
{ {
// Initialize logger. // Initialize logger.
org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.BasicConfigurator.configure();
org.apache.log4j.Logger.getRootLogger().setLevel(Level.INFO);
org.apache.log4j.Logger log = null;
log = org.apache.log4j.Logger.getRootLogger();
log = org.apache.log4j.Logger.getLogger(XidTest.class);
} }
/** /**

21
test/one/Foo2Test.java Normal file
View file

@ -0,0 +1,21 @@
package one;
import org.junit.Test;
public class Foo2Test
{
// private Logger logger =
// LoggerFactory.getLogger(PdfGenerationAmqpServiceInjectedTest.class);
/**
*
*/
@Test
public void test2a()
{
// logger.debug("===== test starting...");
// logger.debug("===== test done.");
}
}