diff --git a/test/xid/test/Test.java b/test/xid/test/Test.java index 4b6e3bc..7184856 100644 --- a/test/xid/test/Test.java +++ b/test/xid/test/Test.java @@ -37,17 +37,38 @@ class Test } + + /** + * + */ + public static String check (String title, StringBuffer source, 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(String[] args) { - System.out.println("Hello World!"); + System.out.println("Automatic test action for Xid!"); - //test (); - - // - IdsData datas; + Data datas; IdData tag; @@ -58,93 +79,30 @@ class Test // Populate attributes of Test 03. System.out.println ("----------------------------"); - datas = new IdsData (); - tag = new IdData (); - tag.setContent ("Superman"); - datas.put ("name", tag); - - errorMessage = new StringBuffer (); - html = Presenter.doXid ("
a name
", datas, "", errorMessage); - - System.out.println ("datas = new IdsData ();"); - System.out.println ("tag = new IdData ();"); - System.out.println ("tag.setContent (\"Superman\");"); - System.out.println ("datas.put (\"name\", tag););"); - System.out.println ("+"); - System.out.println ("
a name
"); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new IdsData (); + datas = new Data (); datas.setContent ("name", "Superman"); - errorMessage = new StringBuffer (); + html = Presenter.doXid ("
a name
", datas, "", errorMessage); - - System.out.println ("datas = new IdsData ();"); - System.out.println ("datas.setContent (\"name\", \"Superman\");"); - System.out.println ("+"); - System.out.println ("
a name
"); - System.out.println ("=>"); - System.out.println (html); + + System.out.println (check ("only content change", html, "
Superman
")); // Populate attributes of Test 03. System.out.println ("----------------------------"); - datas = new IdsData (); - tag = new IdData (); - tag.setContent ("Spiderman"); - tag.getAttributes ().appendAttribute ("style", "background: blue;"); - tag.getAttributes ().appendAttribute ("style", "foreground: red;"); - tag.getAttributes ().setAttribute ("class", "nameClass"); - datas.put ("lastname", tag); - - - errorMessage = new StringBuffer (); - html = Presenter.doXid ("
a last name
", datas, "", errorMessage); - - System.out.println ("datas = new IdsData ();"); - System.out.println ("tag = new IdData ();"); - System.out.println ("tag.getAttributes ().setAttribute (\"class\", \"lastnameClass\");"); - System.out.println ("tag.getAttributes ().appendAttribute (\"style\", \"background: blue;\");"); - System.out.println ("tag.getAttributes ().appendAttribute (\"style\", \"foreground: red;\");"); - System.out.println ("tag.setContent (\"Spiderman\");"); - System.out.println ("datas.put (\"lastname\", tag););"); - System.out.println ("+"); - System.out.println ("
a last name
"); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new IdsData (); + datas = new Data (); datas.setContent ("lastname", "Spiderman"); datas.appendAttribute ("lastname", "style", "background: blue;"); datas.appendAttribute ("lastname", "style", "foreground: red;"); datas.setAttribute ("lastname", "class", "nameClass"); - errorMessage = new StringBuffer (); html = Presenter.doXid ("
a last name
", datas, "", errorMessage); - - System.out.println ("datas = new IdsData ();"); - System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");"); - System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"background: blue;\");"); - System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\");"); - System.out.println ("datas.setAttribute (\"lastname\", \"class\", \"nameClass\");"); - System.out.println ("+"); - System.out.println ("
a last name
"); - System.out.println ("=>"); - System.out.println (html); - + System.out.println (check ("content and attributes", html, "
Spiderman
")); // Populate attributes of Test 03. System.out.println ("----------------------------"); - datas = new IdsData (); + datas = new Data (); datas.setContent ("words", 0, "alpha"); datas.setContent ("words", 1, "bravo"); datas.setContent ("words", 2, "charlie"); @@ -156,24 +114,16 @@ class Test errorMessage = new StringBuffer (); html = Presenter.doXid ("", datas, "", errorMessage); - System.out.println ("datas = new IdsData ();"); - System.out.println ("datas.setContent (\"words\", 0, \"alpha\");"); - System.out.println ("datas.setContent (\"words\", 1, \"bravo\");"); - System.out.println ("datas.setContent (\"words\", 2, \"charlie\");"); - System.out.println ("datas.setContent (\"words\", 3, \"delta\");"); - System.out.println ("datas.setContent (\"words\", 4, \"echo\");"); - System.out.println ("datas.setContent (\"words\", 5, \"fox\");"); - System.out.println ("+"); - System.out.println (""); - System.out.println ("=>"); - System.out.println (html); - - + 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 IdsData (); + datas = new Data (); datas.setContent ("identity", 0, "nom", "Jemba"); datas.setContent ("identity", 0, "prenom", "Epo"); datas.setContent ("identity", 1, "nom", "Momon"); @@ -190,23 +140,14 @@ class Test htmlSource = source.toString (); html = Presenter.doXid (htmlSource, datas, "", errorMessage); - System.out.println ("datas = new IdsData ();"); - 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 ("=>"); - System.out.println (html); - + 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 IdsData (); + datas = new Data (); datas.setContent ("identity", 0, "nom", "Jemba"); datas.setContent ("identity", 0, "prenom", "Epo"); datas.setContent ("identity", 1, "nom", "Momon"); @@ -228,7 +169,7 @@ class Test source.append (""); htmlSource = source.toString (); - System.out.println ("datas = new IdsData ();"); + 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\");"); @@ -264,14 +205,12 @@ class Test // Populate attributes of Test 03. - /* System.out.println ("----------------------------"); - datas = new IdsData (); + 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"); @@ -285,7 +224,7 @@ class Test System.out.println (htmlSource); System.out.println ("+"); - System.out.println ("datas = new IdsData ();"); + 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;\");"); diff --git a/test/xid/test/Test.java~ b/test/xid/test/Test.java~ deleted file mode 100644 index 816f07b..0000000 --- a/test/xid/test/Test.java~ +++ /dev/null @@ -1,297 +0,0 @@ -package xid.test; - -import java.util.*; -import java.io.*; -import xid.*; - -/** - * - */ -class Test -{ - static private org.apache.log4j.Logger log; - - static - { - // Initialize log. - org.apache.log4j.Logger log = null; - - org.apache.log4j.BasicConfigurator.configure (); - - - log = org.apache.log4j.Logger.getRootLogger (); - //log.setLevel (org.apache.log4j.Level.INFO); - log.setLevel (org.apache.log4j.Level.INFO); - - log.info ("Enter"); - - // - log.info ("Set the log file format..."); - - - // log = org.apache.log4j.Category.getInstance(Application.class.getName()); - log.info ("... done."); - - log.debug ("Exit"); - log = org.apache.log4j.Logger.getLogger (Test.class.getName ()); - } - - - /** - * - */ - public static void main(String[] args) - { - System.out.println("Hello World!"); - - //test (); - - // - TagsData datas; - TagData tag; - - - - String htmlSource; - StringBuffer html; - StringBuffer errorMessage; - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new TagsData (); - tag = new TagData (); - tag.setContent ("Superman"); - datas.put ("name", tag); - - errorMessage = new StringBuffer (); - html = Presenter.doXid ("
    a name
    ", datas, "", errorMessage); - - System.out.println ("datas = new TagsData ();"); - System.out.println ("tag = new TagData ();"); - System.out.println ("tag.setContent (\"Superman\");"); - System.out.println ("datas.put (\"name\", tag););"); - System.out.println ("+"); - System.out.println ("
    a name
    "); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new TagsData (); - datas.setContent ("name", "Superman"); - - errorMessage = new StringBuffer (); - html = Presenter.doXid ("
    a name
    ", datas, "", errorMessage); - - System.out.println ("datas = new TagsData ();"); - System.out.println ("datas.setContent (\"name\", \"Superman\");"); - System.out.println ("+"); - System.out.println ("
    a name
    "); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new TagsData (); - tag = new TagData (); - tag.setContent ("Spiderman"); - tag.getAttributes ().appendAttribute ("style", "background: blue;"); - tag.getAttributes ().appendAttribute ("style", "foreground: red;"); - tag.getAttributes ().setAttribute ("class", "nameClass"); - datas.put ("lastname", tag); - - - errorMessage = new StringBuffer (); - html = Presenter.doXid ("
    a last name
    ", datas, "", errorMessage); - - System.out.println ("datas = new TagsData ();"); - System.out.println ("tag = new TagData ();"); - System.out.println ("tag.getAttributes ().setAttribute (\"class\", \"lastnameClass\");"); - System.out.println ("tag.getAttributes ().appendAttribute (\"style\", \"background: blue;\");"); - System.out.println ("tag.getAttributes ().appendAttribute (\"style\", \"foreground: red;\");"); - System.out.println ("tag.setContent (\"Spiderman\");"); - System.out.println ("datas.put (\"lastname\", tag););"); - System.out.println ("+"); - System.out.println ("
    a last name
    "); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new TagsData (); - datas.setContent ("lastname", "Spiderman"); - datas.appendAttribute ("lastname", "style", "background: blue;"); - datas.appendAttribute ("lastname", "style", "foreground: red;"); - datas.setAttribute ("lastname", "class", "nameClass"); - - - errorMessage = new StringBuffer (); - html = Presenter.doXid ("
    a last name
    ", datas, "", errorMessage); - - System.out.println ("datas = new TagsData ();"); - System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");"); - System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"background: blue;\");"); - System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\");"); - System.out.println ("datas.setAttribute (\"lastname\", \"class\", \"nameClass\");"); - System.out.println ("+"); - System.out.println ("
    a last name
    "); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new TagsData (); - 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"); - - - errorMessage = new StringBuffer (); - html = Presenter.doXid ("
      \n
    • a word
    • \n
    ", datas, "", errorMessage); - - System.out.println ("datas = new TagsData ();"); - System.out.println ("datas.setContent (\"words\", 0, \"alpha\");"); - System.out.println ("datas.setContent (\"words\", 1, \"bravo\");"); - System.out.println ("datas.setContent (\"words\", 2, \"charlie\");"); - System.out.println ("datas.setContent (\"words\", 3, \"delta\");"); - System.out.println ("datas.setContent (\"words\", 4, \"echo\");"); - System.out.println ("datas.setContent (\"words\", 5, \"fox\");"); - System.out.println ("+"); - System.out.println ("
      "); - System.out.println ("
    • a word
    • "); - System.out.println ("
    "); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new TagsData (); - 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"); - - - errorMessage = new StringBuffer (); - StringBuffer source = new StringBuffer (); - source.append ("\n"); - source.append (" \n"); - source.append ("
    noidun nomun prenom
    "); - htmlSource = source.toString (); - html = Presenter.doXid (htmlSource, datas, "", errorMessage); - - System.out.println ("datas = new TagsData ();"); - 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 ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new TagsData (); - 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", TagsDataByIndex.IterationStrategy.ONLY_FIRST_ROW); - //datas.setIterationStrategy ("identity", TagsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID); - //datas.setIterationStrategy ("identity", TagsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID); - //datas.setIterationStrategy ("identity", TagsDataByIndex.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 TagsData ();"); - 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", TagsDataByIndex.IterationStrategy.ONLY_FIRST_ROW); - System.out.println ("ONLY_FIRST_ROW:"); - html = Presenter.doXid (htmlSource, datas, "", errorMessage); - System.out.println (html); - - datas.setIterationStrategy ("identity", TagsDataByIndex.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", TagsDataByIndex.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", TagsDataByIndex.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 TagsData (); - 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 TagsData ();"); - 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); - - - } -}