예제 #1
0
        public void processHtml1Test()
        {
            String locale_              = "LOCALE";
            String folder_              = "messages";
            String relative_            = "sample/file";
            String content_             = "one=Description one\ntwo=Description two\nthree=desc <{0}>";
            String html_                = "<html><body><ul><c.for var=\"s\" list=\"composite.strings\"><li>{s;}</li></c.for></ul></body></html>";
            Map <String, String> files_ = new Map <String, String>();

            files_.put(folder_ + "/" + locale_ + "/" + relative_ + ".properties", content_);
            BeanOne bean_ = new BeanOne();

            bean_.getComposite().getStrings().Add("FIRST");
            bean_.getComposite().getStrings().Add("SECOND");
            bean_.getComposite().setInteger(5);
            Configuration conf_ = new Configuration();

            conf_.setBeans(new Map <String, Bean>());
            conf_.getBeans().put("bean_one", bean_);
            conf_.setMessagesFolder(folder_);
            conf_.setProperties(new Map <String, String>());
            conf_.getProperties().put("msg_example", relative_);
            conf_.setTranslators(new Map <String, Translator>());
            conf_.getTranslators().put("trans", new MyTranslator());
            XmlDocument doc_    = XmlParser.parseSaxHtml(html_);
            String      render_ = FormatHtml.processHtml(doc_.DocumentElement, conf_, files_, bean_);

            Assert.AreEqual("<html><body><ul><c.tmp><li>FIRST</li></c.tmp><c.tmp><li>SECOND</li></c.tmp></ul></body></html>", render_);
        }
예제 #2
0
        public void processHtml18Test()
        {
            String locale_              = "LOCALE";
            String folder_              = "messages";
            String relative_            = "sample/file";
            String content_             = "one=Description one\ntwo=Description two\nthree=desc &lt;{0}&gt;";
            String html_                = "<html><body><c.select map=\"translations\"/></body></html>";
            Map <String, String> files_ = new Map <String, String>();

            files_.put(folder_ + "/" + locale_ + "/" + relative_ + ".properties", content_);
            BeanOne bean_ = new BeanOne();

            bean_.getComposite().getStrings().Add("FIRST");
            bean_.getComposite().getStrings().Add("SECOND");
            bean_.getComposite().setInteger(5);
            Configuration conf_ = new Configuration();

            conf_.setBeans(new Map <String, Bean>());
            conf_.getBeans().put("bean_one", bean_);
            conf_.setMessagesFolder(folder_);
            conf_.setProperties(new Map <String, String>());
            conf_.getProperties().put("msg_example", relative_);
            conf_.setTranslators(new Map <String, Translator>());
            conf_.getTranslators().put("trans", new MyTranslator());
            XmlDocument doc_    = XmlParser.parseSaxHtml(html_);
            String      render_ = FormatHtml.processHtml(doc_.DocumentElement, conf_, files_, bean_);

            Assert.AreEqual("<html><body><select name=\"\" className=\"\"><option value=\"ONE\">1</option><option value=\"TWO\">2</option><option value=\"THREE\">3</option><option value=\"FOUR\">4</option><option value=\"FIVE\">5</option><option value=\"SIX\">6</option></select></body></html>", render_);
        }