From b59663a45f5610752d2d07ff00685d8c5fa04a76 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Fri, 21 Jun 2013 02:55:52 +0200 Subject: [PATCH] Last commit before renaming. --- .classpath | 1 + .gitignore | 4 + build.xml | 20 +-- test/XidTest.java | 387 ++++++++++++++++++++++++---------------------- 4 files changed, 216 insertions(+), 196 deletions(-) create mode 100644 .gitignore diff --git a/.classpath b/.classpath index bc5400f..1e3beac 100644 --- a/.classpath +++ b/.classpath @@ -7,5 +7,6 @@ + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a951636 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/build +/dist +/build_demo +/build_test diff --git a/build.xml b/build.xml index bff954f..d7ab12d 100644 --- a/build.xml +++ b/build.xml @@ -26,7 +26,7 @@ - + @@ -37,19 +37,19 @@ - - + + - + - + @@ -57,8 +57,8 @@ - - + + @@ -78,7 +78,7 @@ - + @@ -90,8 +90,8 @@ - - + + diff --git a/test/XidTest.java b/test/XidTest.java index d005008..ddfeb8f 100644 --- a/test/XidTest.java +++ b/test/XidTest.java @@ -2,244 +2,259 @@ * XidTest. */ - -import fr.devinsy.xid.*; +import fr.devinsy.xid.Data; +import fr.devinsy.xid.IdData; +import fr.devinsy.xid.StringPresenter; /** * */ class XidTest { - static - { - // Initialize logger. - org.apache.log4j.BasicConfigurator.configure (); - - org.apache.log4j.Logger log = null; - log = org.apache.log4j.Logger.getRootLogger (); - log = org.apache.log4j.Logger.getLogger (XidDemo.class); + public enum MONTHS + { + JANUARY, + FEBRUARY, + MARCH, + APRIL, + MAY, + JUNE, + JULY, + AUGUST, + SEPTEMBER, + OCTOBER, + NOVEMBRE, + DECEMBRE } - + static + { + // Initialize logger. + org.apache.log4j.BasicConfigurator.configure(); + + org.apache.log4j.Logger log = null; + log = org.apache.log4j.Logger.getRootLogger(); + log = org.apache.log4j.Logger.getLogger(XidTest.class); + } /** * */ - public static String check (String title, StringBuffer source, String model) + public static String check(final String title, final StringBuffer source, final String model) { String result; - if (source.indexOf (model) == -1) + if (source.indexOf(model) == -1) { - result = String.format ("%-40s -> KO <-", title) + "\nGet:\n" + source + "\nWaiting:\n" + model; + result = String.format("%-40s -> KO <-", title) + "\nGet:\n" + source + "\nWaiting:\n" + model; } else { - result = String.format ("%-40s [ OK ] ", title); + result = String.format("%-40s [ OK ] ", title); } - // return (result); - } - - public enum MONTHS {JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBRE, DECEMBRE}; + }; /** * */ - public static void main(String[] args) + public static void main(final String[] args) { System.out.println("Automatic test action for Xid!"); - Data datas; IdData tag; - String htmlSource; StringBuffer html; // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("name", "Superman"); - try - { - html = StringPresenter.doXid ("
a name
", datas); - } - catch (Exception exception) - { - System.out.println(exception.getMessage()); - html = null; - } - - System.out.println (check ("only content change", html, "
Superman
")); + System.out.println("----------------------------"); + datas = new Data(); + datas.setContent("name", "Superman"); + try + { + html = StringPresenter.doXid("
a name
", datas); + } + catch (Exception exception) + { + System.out.println(exception.getMessage()); + html = null; + } + System.out.println(check("only content change", html, "
Superman
")); // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("lastname", "Spiderman"); - datas.appendAttribute ("lastname", "style", "background: blue;"); - datas.appendAttribute ("lastname", "style", "foreground: red;"); - datas.setAttribute ("lastname", "class", "nameClass"); + System.out.println("----------------------------"); + datas = new Data(); + datas.setContent("lastname", "Spiderman"); + datas.appendAttribute("lastname", "style", "background: blue;"); + datas.appendAttribute("lastname", "style", "foreground: red;"); + datas.setAttribute("lastname", "class", "nameClass"); - try - { - html = StringPresenter.doXid ("
a last name
", datas); - } - catch (Exception exception) - { - System.out.println(exception.getMessage()); - html = null; - } - System.out.println (check ("content and attributes", html, "
Spiderman
")); + try + { + html = StringPresenter.doXid("
a last name
", datas); + } + catch (Exception exception) + { + System.out.println(exception.getMessage()); + html = null; + } + System.out.println(check("content and attributes", html, + "
Spiderman
")); // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("words", 0, "alpha"); - datas.setContent ("words", 1, "bravo"); - datas.setContent ("words", 2, "charlie"); - datas.setContent ("words", 3, "delta"); - datas.setContent ("words", 4, "echo"); - datas.setContent ("words", 5, "fox"); + System.out.println("----------------------------"); + datas = new Data(); + datas.setContent("words", 0, "alpha"); + datas.setContent("words", 1, "bravo"); + datas.setContent("words", 2, "charlie"); + datas.setContent("words", 3, "delta"); + datas.setContent("words", 4, "echo"); + datas.setContent("words", 5, "fox"); - try - { - html = StringPresenter.doXid ("
    \n
  • a word
  • \n
", datas); - } - catch (Exception exception) - { - System.out.println(exception.getMessage()); - html = null; - } + try + { + html = StringPresenter.doXid("
    \n
  • a word
  • \n
", datas); + } + catch (Exception exception) + { + System.out.println(exception.getMessage()); + html = null; + } - System.out.println (check ("list assertion 1", html, "
  • alpha
  • ")); - System.out.println (check ("list assertion 2", html, "
  • bravo
  • ")); - System.out.println (check ("list assertion 3", html, "
  • charlie
  • ")); - System.out.println (check ("list assertion 4", html, "
  • delta
  • ")); - System.out.println (check ("list assertion 5", html, "
  • echo
  • ")); - System.out.println (check ("list assertion 6", html, "
  • fox
  • ")); + System.out.println(check("list assertion 1", html, "
  • alpha
  • ")); + System.out.println(check("list assertion 2", html, "
  • bravo
  • ")); + System.out.println(check("list assertion 3", html, "
  • charlie
  • ")); + System.out.println(check("list assertion 4", html, "
  • delta
  • ")); + System.out.println(check("list assertion 5", html, "
  • echo
  • ")); + System.out.println(check("list assertion 6", html, "
  • fox
  • ")); // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("identity", 0, "nom", "Jemba"); - datas.setContent ("identity", 0, "prenom", "Epo"); - datas.setContent ("identity", 1, "nom", "Momon"); - datas.setContent ("identity", 1, "prenom", "Christian"); - datas.setContent ("identity", 2, "nom", "Tronche"); - datas.setContent ("identity", 2, "prenom", "Christophe"); + System.out.println("----------------------------"); + datas = new Data(); + datas.setContent("identity", 0, "nom", "Jemba"); + datas.setContent("identity", 0, "prenom", "Epo"); + datas.setContent("identity", 1, "nom", "Momon"); + datas.setContent("identity", 1, "prenom", "Christian"); + datas.setContent("identity", 2, "nom", "Tronche"); + datas.setContent("identity", 2, "prenom", "Christophe"); - StringBuffer source = new StringBuffer (); - source.append ("\n"); - source.append (" \n"); - source.append ("
    noidun nomun prenom
    "); - htmlSource = source.toString (); - try - { - html = StringPresenter.doXid (htmlSource, datas); - } - catch (Exception exception) - { - System.out.println(exception.getMessage()); - html = null; - } + StringBuffer source = new StringBuffer(); + source.append("\n"); + source.append(" \n"); + source.append("
    noidun nomun prenom
    "); + htmlSource = source.toString(); + try + { + html = StringPresenter.doXid(htmlSource, datas); + } + catch (Exception exception) + { + System.out.println(exception.getMessage()); + html = null; + } - System.out.println (check ("table 1 assertion 1", html, "noidJembaEpo")); - System.out.println (check ("table 1 assertion 2", html, "noidMomonChristian")); - System.out.println (check ("table 1 assertion 3", html, "noidTroncheChristophe")); + System.out + .println(check("table 1 assertion 1", html, "noidJembaEpo")); + System.out.println(check("table 1 assertion 2", html, + "noidMomonChristian")); + System.out.println(check("table 1 assertion 3", html, + "noidTroncheChristophe")); /* - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("identity", 0, "nom", "Jemba"); - datas.setContent ("identity", 0, "prenom", "Epo"); - datas.setContent ("identity", 1, "nom", "Momon"); - datas.setContent ("identity", 1, "prenom", "Christian"); - datas.setContent ("identity", 2, "nom", "Tronche"); - datas.setContent ("identity", 2, "prenom", "Christophe"); - datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_FIRST_ROW); - //datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID); - //datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID); - //datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ALL_ROWS); - - - errorMessage = new StringBuffer (); - source = new StringBuffer (); - source.append ("\n"); - source.append (" \n"); - source.append (" \n"); - source.append (" \n"); - source.append ("
    noidun nomun prenom
    noidun nomun prenom
    noidun nomun prenom
    "); - htmlSource = source.toString (); - - System.out.println ("datas = new Data ();"); - System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");"); - System.out.println ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");"); - System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");"); - System.out.println ("datas.setContent (\"identity\", 1, \"prenom\", \"Christian\");"); - System.out.println ("datas.setContent (\"identity\", 2, \"nom\", \"Tronche\");"); - System.out.println ("datas.setContent (\"identity\", 2, \"prenom\", \"Christophe\");"); - - System.out.println ("+"); - System.out.println (htmlSource); - System.out.println ("=>"); - - - datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_FIRST_ROW); - System.out.println ("ONLY_FIRST_ROW:"); - html = Presenter.doXid (htmlSource, datas, "", errorMessage); - System.out.println (html); - - datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID); - System.out.println ("ONLY_ROWS_WITH_ID:"); - html = Presenter.doXid (htmlSource, datas, "", errorMessage); - System.out.println (html); - - datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID); - System.out.println ("ONLY_ROWS_WITHOUT_ID:"); - html = Presenter.doXid (htmlSource, datas, "", errorMessage); - System.out.println (html); - - datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ALL_ROWS); - System.out.println ("ALL_ROWS:"); - html = Presenter.doXid (htmlSource, datas, "", errorMessage); - System.out.println (html); - - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setAttribute ("
    ", "class", "aDivClass"); - datas.setAttribute ("
    ", "style", "background-color: #000000;"); - datas.setAttribute ("number", "style", "background-color: #0000FF;"); - - errorMessage = new StringBuffer (); - source = new StringBuffer (); - source.append ("
    \n"); - source.append ("

    one

    \n"); - source.append ("
    \n"); - source.append ("
    \n"); - source.append ("

    three

    \n"); - source.append ("
    "); - htmlSource = source.toString (); - html = Presenter.doXid (htmlSource, datas, "", errorMessage); - - System.out.println (htmlSource); - System.out.println ("+"); - System.out.println ("datas = new Data ();"); - System.out.println ("datas.setAttribute (\"
    \", \"class\", \"aDivClass\");"); - System.out.println ("datas.setAttribute (\"
    \", \"style\", \"background-color: #000000;\");"); - System.out.println ("datas.setAttribute (\"number\", \"style\", \"background-color: #0000FF;\");"); - - System.out.println ("=>"); - System.out.println (html); + * // Populate attributes of Test 03. System.out.println + * ("----------------------------"); datas = new Data (); + * datas.setContent ("identity", 0, "nom", "Jemba"); datas.setContent + * ("identity", 0, "prenom", "Epo"); datas.setContent ("identity", 1, + * "nom", "Momon"); datas.setContent ("identity", 1, "prenom", + * "Christian"); datas.setContent ("identity", 2, "nom", "Tronche"); + * datas.setContent ("identity", 2, "prenom", "Christophe"); + * datas.setIterationStrategy ("identity", + * IdsDataByIndex.IterationStrategy.ONLY_FIRST_ROW); + * //datas.setIterationStrategy ("identity", + * IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID); + * //datas.setIterationStrategy ("identity", + * IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID); + * //datas.setIterationStrategy ("identity", + * IdsDataByIndex.IterationStrategy.ALL_ROWS); + * + * + * errorMessage = new StringBuffer (); source = new StringBuffer (); + * source.append ("\n"); source.append ( + * " \n" + * ); source.append ( + * " \n" + * ); source.append ( + * " \n" + * ); source.append ("
    noidun nomun prenom
    noidun nomun prenom
    noidun nomun prenom
    "); htmlSource = source.toString (); + * + * System.out.println ("datas = new Data ();"); System.out.println + * ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");"); + * System.out.println + * ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");"); + * System.out.println + * ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");"); + * System.out.println + * ("datas.setContent (\"identity\", 1, \"prenom\", \"Christian\");"); + * System.out.println + * ("datas.setContent (\"identity\", 2, \"nom\", \"Tronche\");"); + * System.out.println + * ("datas.setContent (\"identity\", 2, \"prenom\", \"Christophe\");"); + * + * System.out.println ("+"); System.out.println (htmlSource); + * System.out.println ("=>"); + * + * + * datas.setIterationStrategy ("identity", + * IdsDataByIndex.IterationStrategy.ONLY_FIRST_ROW); System.out.println + * ("ONLY_FIRST_ROW:"); html = Presenter.doXid (htmlSource, datas, "", + * errorMessage); System.out.println (html); + * + * datas.setIterationStrategy ("identity", + * IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID); + * System.out.println ("ONLY_ROWS_WITH_ID:"); html = Presenter.doXid + * (htmlSource, datas, "", errorMessage); System.out.println (html); + * + * datas.setIterationStrategy ("identity", + * IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID); + * System.out.println ("ONLY_ROWS_WITHOUT_ID:"); html = Presenter.doXid + * (htmlSource, datas, "", errorMessage); System.out.println (html); + * + * datas.setIterationStrategy ("identity", + * IdsDataByIndex.IterationStrategy.ALL_ROWS); System.out.println + * ("ALL_ROWS:"); html = Presenter.doXid (htmlSource, datas, "", + * errorMessage); System.out.println (html); + * + * + * + * // Populate attributes of Test 03. System.out.println + * ("----------------------------"); datas = new Data (); + * datas.setAttribute ("
    ", "class", "aDivClass"); + * datas.setAttribute ("
    ", "style", "background-color: #000000;"); + * datas.setAttribute ("number", "style", "background-color: #0000FF;"); + * + * errorMessage = new StringBuffer (); source = new StringBuffer (); + * source.append ("
    \n"); source.append ("

    one

    \n"); + * source.append ("
    \n"); source.append ("
    \n"); + * source.append ("

    three

    \n"); source.append ("
    "); + * htmlSource = source.toString (); html = Presenter.doXid (htmlSource, + * datas, "", errorMessage); + * + * System.out.println (htmlSource); System.out.println ("+"); + * System.out.println ("datas = new Data ();"); System.out.println + * ("datas.setAttribute (\"
    \", \"class\", \"aDivClass\");"); + * System.out.println ( + * "datas.setAttribute (\"
    \", \"style\", \"background-color: #000000;\");" + * ); System.out.println ( + * "datas.setAttribute (\"number\", \"style\", \"background-color: #0000FF;\");" + * ); + * + * System.out.println ("=>"); System.out.println (html); */ } }