diff --git a/.classpath b/.classpath index 53930f2..559d6c7 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - - + + diff --git a/.gitignore b/.gitignore index 21d8609..226b5e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /bin /dist +/build diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index c328801..fbb080d 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 9dc916f..d0d29de 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,8 +1,6 @@ - - + - - + diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..a20876c --- /dev/null +++ b/build.properties @@ -0,0 +1,3 @@ +product.name=devinsy-utils +product.revision.major=0 +product.revision.minor=2 diff --git a/build.xml b/build.xml index 166787c..abdbf66 100644 --- a/build.xml +++ b/build.xml @@ -1,38 +1,98 @@ - - - - - + + - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - + + + Type ant -p + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - + + + + - + diff --git a/lib/README b/lib/README new file mode 100644 index 0000000..d64c866 --- /dev/null +++ b/lib/README @@ -0,0 +1,4 @@ +Description of used libraries: +- hamcrest-core: required by junit +- junit: unit tests API +- log4j: log API diff --git a/lib/hamcrest-core-1.3-sources.jar b/lib/hamcrest-core-1.3-sources.jar new file mode 100644 index 0000000..c3c110b Binary files /dev/null and b/lib/hamcrest-core-1.3-sources.jar differ diff --git a/lib/hamcrest-core-1.3.jar b/lib/hamcrest-core-1.3.jar new file mode 100644 index 0000000..9d5fe16 Binary files /dev/null and b/lib/hamcrest-core-1.3.jar differ diff --git a/lib/junit-4.11-sources.jar b/lib/junit-4.11-sources.jar new file mode 100644 index 0000000..bab4cdd Binary files /dev/null and b/lib/junit-4.11-sources.jar differ diff --git a/lib/junit-4.11.jar b/lib/junit-4.11.jar new file mode 100644 index 0000000..aaf7444 Binary files /dev/null and b/lib/junit-4.11.jar differ diff --git a/test/CmdExecPlayer.java b/test/CmdExecPlayer.java new file mode 100644 index 0000000..9a4a0b3 --- /dev/null +++ b/test/CmdExecPlayer.java @@ -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); + } + } +} diff --git a/test/FileIteratorPlayer.java b/test/FileIteratorPlayer.java new file mode 100644 index 0000000..426c1cd --- /dev/null +++ b/test/FileIteratorPlayer.java @@ -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()); + } + } +} diff --git a/test/Foot1Test.java b/test/Foot1Test.java new file mode 100644 index 0000000..dda5c6a --- /dev/null +++ b/test/Foot1Test.java @@ -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."); + } + +} diff --git a/test/one/Foo2Test.java b/test/one/Foo2Test.java new file mode 100644 index 0000000..0b98fdf --- /dev/null +++ b/test/one/Foo2Test.java @@ -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."); + } + +}