Improve build and test. Clean jar.

This commit is contained in:
Christian P. MOMON 2013-06-25 02:31:19 +02:00
parent e9db2ca368
commit b70d9e4196
15 changed files with 321 additions and 33 deletions

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="tests"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="lib/log4j-1.2.14.jar"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry exported="true" kind="lib" path="lib/commons-codec-1.4.jar"/>
<classpathentry kind="lib" path="lib/commons-io-1.4.jar"/>
<classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="lib/junit-4.11.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/bin
/dist
/build

View file

@ -88,7 +88,7 @@ org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
org.eclipse.jdt.core.formatter.indentation.size=4
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="devinsy-utils">
<wb-resource deploy-path="/" source-path="/src"/>
<wb-resource deploy-path="/" source-path="/src-xid"/>
<wb-resource deploy-path="/" source-path="/tests"/>
<wb-resource deploy-path="/" source-path="/test"/>
</wb-module>
</project-modules>

3
build.properties Normal file
View file

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

102
build.xml
View file

@ -1,36 +1,96 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="dist" name="Create Jar for Project devinsy-utils">
<!--ANT 1.7 is required -->
<!-- Run Eclipse before to run ant. -->
<property name="product" value="devinsy-utils" />
<buildnumber file="build.num" description="Id of the build"/>
<property name="version" value="0.1.${build.number}" /> <!-- AUTOMATIC MANAGEMENT -->
<property file="build.properties"/>
<property name="build.dir" value="${basedir}/build" />
<property name="dist.name" value="${product}-${version}" />
<property name="dist.jar" value="${basedir}/dist/${dist.name}.jar" />
<property name="dist.srczip" value="${basedir}/dist/${dist.name}-sources.zip" />
<property name="build.src" value="${basedir}/src" />
<property name="build.classes" value="${build.dir}/classes" />
<property name="test.src" value="${basedir}/test" />
<property name="test.classes" value="${build.dir}/test-classes" />
<property name="dist.dir" value="${basedir}/dist" />
<property name="debug" value="on"/>
<path id="build.classpath">
<fileset dir="lib" includes="**/*.jar"/>
</path>
<path id="test.classpath.compile">
<path refid="build.classpath"/>
<pathelement path="${build.classes}"/>
</path>
<path id="test.classpath.run">
<path refid="test.classpath.compile"/>
<pathelement path="${test.classes}"/>
</path>
<!-- Help -->
<target name="help" description="Display detailed usage information">
<echo>Type ant -p</echo>
</target>
<!-- ***** Clean ***** -->
<target name="clean" description="Clean temporary directories">
<delete dir="${build.dir}"/>
</target>
<!-- ***** Compile ***** -->
<target name="compile" description="Compile main code">
<mkdir dir="${build.dir}/classes"/>
<javac srcdir="${build.src}" destdir="${build.classes}" debug="${debug}" deprecation="on" includeantruntime="false">
<classpath refid="test.classpath.compile"/>
</javac>
</target>
<!-- ***** Compile test ***** -->
<target name="compile-test" description="Compile test code">
<mkdir dir="${test.classes}"/>
<javac srcdir="${test.src}" destdir="${test.classes}" debug="${debug}" deprecation="on" includeantruntime="false">
<classpath refid="test.classpath.compile"/>
</javac>
</target>
<!-- ***** Test ***** -->
<target name="test" description="Run unit tests" depends="clean,compile,compile-test">
<mkdir dir="${build.dir}/test-reports"/>
<junit printsummary="yes" haltonfailure="yes">
<classpath refid="test.classpath.run"/>
<formatter type="plain" usefile="true" />
<batchtest fork="yes" todir="${build.dir}/test-reports/">
<fileset dir="test">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- ***** Dist ***** -->
<target name="dist" description="Build distribution" depends="clean,compile">
<!-- -->
<mkdir dir="${dist.dir}"/>
<buildnumber file="build.num" description="Id of the build"/> <!-- AUTOMATIC MANAGEMENT -->
<property name="dist.version" value="${product.revision.major}.${product.revision.minor}.${build.number}" />
<property name="dist.name" value="${product.name}-${dist.version}" />
<!-- Package compiled -->
<property name="dist.jar" value="${dist.dir}/${dist.name}.jar" />
<tstamp>
<format property="TODAY" pattern="dd/MM/yyyy HH:mm:ss" />
<format property="dist.time" pattern="dd/MM/yyyy HH:mm:ss" /> <!-- TODAY -->
</tstamp>
<!-- TARGET DIST -->
<target name="dist" description="Build distribution directory">
<delete file="${dist.zip}" />
<jar destfile="${dist.jar}" >
<manifest>
<attribute name="Built-By" value="${user.name} using DEVINSY-UTILS ANT"/>
<attribute name="Built-Date" value="${TODAY}"/>
<attribute name="Built-By" value="${user.name} using ant"/>
<attribute name="Built-Date" value="${dist.time}"/>
</manifest>
<fileset dir="${basedir}/bin" excludes="TestTree/**" />
<fileset dir="${basedir}/build" excludes="TestTree/**" />
<zipfileset dir="${basedir}/" includes="LICENSE"/>
</jar>
<zip destfile="${dist.srczip}"
update="true"
preserve0permissions="true">
<!-- Package sources -->
<property name="dist.srczip" value="${basedir}/dist/${dist.name}-sources.zip" />
<zip destfile="${dist.srczip}" update="true" preserve0permissions="true">
<fileset dir="${basedir}/src"/>
<zipfileset dir="${basedir}/" includes="LICENSE"/>
</zip>

4
lib/README Normal file
View file

@ -0,0 +1,4 @@
Description of used libraries:
- hamcrest-core: required by junit
- junit: unit tests API
- log4j: log API

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.

90
test/CmdExecPlayer.java Normal file
View file

@ -0,0 +1,90 @@
import fr.devinsy.util.cmdexec.CmdExec;
import fr.devinsy.util.cmdexec.StreamGobbler;
/**
*
*/
class CmdExecPlayer
{
static private org.apache.log4j.Logger logger;
static
{
// Initialize logger.
org.apache.log4j.Logger logger = null;
org.apache.log4j.BasicConfigurator.configure();
logger = org.apache.log4j.Logger.getRootLogger();
// logger.setLevel (org.apache.log4j.Level.INFO);
logger.setLevel(org.apache.log4j.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 = org.apache.log4j.Logger.getLogger(CmdExecPlayer.class);
}
/**
*
*/
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("Automatic test action for CmdExec!");
test1();
}
/**
*
*/
public static void test1()
{
try
{
System.out.println("Launch ...");
// String command = "/bin/sort -r /etc/passwd";
String[] command = { "/bin/sort", "-r", "/etc/passwd" };
CmdExec cmd = new CmdExec(command, StreamGobbler.BUFFER, StreamGobbler.BUFFER);
System.out.println("exitVal=[" + cmd.getExitValue() + "]");
System.out.println("out=[" + cmd.getOutStream() + "]");
System.out.println("err=[" + cmd.getErrStream() + "]");
}
catch (Exception exception)
{
exception.printStackTrace();
logger.info("ERRRO=" + exception);
}
}
}

View file

@ -0,0 +1,92 @@
import java.io.File;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import fr.devinsy.util.FileIterator;
/**
*
*/
public class FileIteratorPlayer
{
static private org.apache.log4j.Logger logger;
static
{
// Initialize logger.
BasicConfigurator.configure();
Logger defaultLogger = org.apache.log4j.Logger.getRootLogger();
defaultLogger.setLevel(org.apache.log4j.Level.DEBUG);
defaultLogger.removeAllAppenders();
defaultLogger.addAppender(new ConsoleAppender(new PatternLayout("%d{ISO8601} - FIT [%-5p] %34.34c.%-25M - %m%n")));
defaultLogger.debug("Log initialized.");
logger = org.apache.log4j.Logger.getLogger(FileIteratorPlayer.class.getName());
}
/**
*
*/
public static void main(final String[] args)
{
test();
}
/**
*
*/
protected static void test()
{
System.out.println("user.dir=" + System.getProperty("user.dir"));
try
{
// File f = new File("TestTree/DirectoryOne/titi2");
// File f = new File("/home/cpm/.kde//cache-cpmstar");
File f = new File("tests/TestTree/xine.jpg");
System.out.println("exists=" + f.exists());
System.out.println("canonical path = " + f.getCanonicalPath());
System.out.println("absolute path = " + f.getAbsolutePath());
System.out.println("name = " + f.getName());
System.out.println("parent = " + f.getParent());
System.out.println("path = " + f.getPath());
System.out.println("path = " + f.lastModified());
System.out.println("path = " + f.length());
System.out.println("path = " + f.isFile());
System.out.println("path = " + f.isDirectory());
System.out.println("list = " + f.list());
System.out.println("----");
// FileIterator i = new FileIterator(new File("tests/TestTree"));
FileIterator i = new FileIterator(new File("tests/TestTree/xine.jpg"), null, true);
// FileIterator i = new FileIterator(new
// File("/home/cpm/.kde/cache-cpmstar"), ".*cache.*", false);
// FileIterator i = new FileIterator(new File("tests/TestTree"),
// ".*dsc.*", false);
// FileIterator i = new FileIterator(new
// File("/home/cpm/Images/Photos/"));
// FileIterator i = new FileIterator(new
// File("/home/cpm/Images/Photos/"), ".*\\.(JPG|jpg)", false);
// FileIterator i = new FileIterator(new
// File("/home/cpm/Images/Photos/"), ".*anni_moi.*", false);
while (i.hasNext())
{
// System.out.println(i.toString());
System.out.println("File=[" + i.next().getPath() + "]");
}
i.reset();
System.out.println("Cardinal=" + i.finalCountdown());
}
catch (Exception exception)
{
System.out.println("ERROR:" + exception.getMessage());
}
}
}

19
test/Foot1Test.java Normal file
View file

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

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.");
}
}