예제 #1
0
        public void processAnchorRequest5Test()
        {
            String locale_              = "LOCALE";
            String folder_              = "messages";
            String relative_            = "sample/file";
            String content_             = "one=Description one\ntwo=Description <a href=\"\">two</a>\nthree=desc &lt;{0}&gt;\nfour=''asp''";
            String html_                = "<html bean=\"bean_one\"><body>HEAD<a command=\"$goToPage(4)\" href=\"\"/></body></html>";
            String htmlTwo_             = "<html bean=\"bean_two\"><body> NEXT<!--COMMENT--><form action=\"DELETE\" command=\"go\">{typedInt}</form><form action=\"go\">{typedInt}</form></body></html>";
            Map <String, String> files_ = new Map <String, String>();

            files_.put(folder_ + "/" + locale_ + "/" + relative_ + ".properties", content_);
            files_.put("page1.html", html_);
            files_.put("page2.html", htmlTwo_);
            BeanOne bean_ = new BeanOne();

            //bean_.setClassName(BeanOne.class.getName());
            bean_.setScope("request");
            BeanTwo beanTwo_ = new BeanTwo();

            //beanTwo_.setClassName(BeanTwo.class.getName());
            beanTwo_.setScope("request");
            Configuration conf_ = new Configuration();

            conf_.setBeans(new Map <String, Bean>());
            conf_.getBeans().put("bean_one", bean_);
            conf_.getBeans().put("bean_two", beanTwo_);
            conf_.setMessagesFolder(folder_);
            conf_.setFirstUrl("page1.html");
            conf_.setValidators(new Map <String, Validator>());
            conf_.setProperties(new Map <String, String>());
            conf_.getProperties().put("msg_example", relative_);
            conf_.setTranslators(new Map <String, Translator>());
            conf_.getTranslators().put("trans", new MyTranslator());
            conf_.setNavigation(new Map <String, Map <String, String> >());
            conf_.getNavigation().put("bean_one.goToPage()", new Map <String, String>());
            conf_.getNavigation().getVal("bean_one.goToPage()").put("page4", "page2.html");
            Navigation nav_ = new Navigation();

            nav_.setLanguage(locale_);
            nav_.setSession(conf_);
            nav_.setFiles(files_);
            nav_.initializeSession();
            nav_.processAnchorRequest("$bean_one.goToPage(4)");

            Assert.AreEqual("page2.html", nav_.getCurrentUrl());
            Assert.AreEqual("bean_two", nav_.getCurrentBeanName());
            Assert.AreEqual("<html><body> NEXT<form action=\"\" command=\"go\">0</form><form action=\"go\">0</form></body></html>", nav_.getHtmlText());
            Assert.AreEqual(0, conf_.getBeans().getVal("bean_one").getForms().size());
            Assert.AreEqual(0, conf_.getBeans().getVal("bean_two").getForms().size());
            Assert.AreSame(conf_.getBeans().getVal("bean_one").getForms(), conf_.getBeans().getVal("bean_two").getForms());
            Assert.AreEqual("", nav_.getTitle());
            Assert.AreEqual("", nav_.getReferenceScroll());
            Assert.AreEqual(0, nav_.getTooltips().size());
        }
예제 #2
0
        public void processImports5Test()
        {
            String locale_              = "LOCALE";
            String folder_              = "messages";
            String relative_            = "sample/file";
            String content_             = "one=Description one\ntwo=Description <a href=\"\">two</a>\nthree=desc &lt;{0}&gt;\nfour=''asp''";
            String html_                = "<html bean=\"bean_one\"><body><c.import page=\"page2.html\"><a/><c.package name=\"FormatHtmlTests\"><a/><c.class name=\"BeanTwo\"><a/><c.field name=\"typedString\" value=\"message\"><a/></c.field></c.class></c.package></c.import></body></html>";
            String htmlTwo_             = "<html bean=\"bean_two\"><body><a href=\"DELETE\" command=\"go\">{typedString}</a></body></html>";
            Map <String, String> files_ = new Map <String, String>();

            files_.put(folder_ + "/" + locale_ + "/" + relative_ + ".properties", content_);
            files_.put("page1.html", html_);
            files_.put("page2.html", htmlTwo_);
            BeanOne bean_ = new BeanOne();

            bean_.getComposite().getStrings().Add("FIRST");
            bean_.getComposite().getStrings().Add("SECOND");
            bean_.getComposite().setInteger(5);
            bean_.getTree().put("ONE", 1);
            bean_.getTree().put("TWO", 2);
            bean_.setForms(new Map <String, Object>());
            bean_.getForms().put("key", "sample_value");
            BeanTwo beanTwo_ = new BeanTwo();

            beanTwo_.setTypedString("TITLE");
            beanTwo_.setForms(new Map <String, Object>());
            Configuration conf_ = new Configuration();

            conf_.setAssembly("FormatHtmlTests");
            conf_.setBeans(new Map <String, Bean>());
            conf_.getBeans().put("bean_one", bean_);
            conf_.getBeans().put("bean_two", beanTwo_);
            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());
            String render_ = FormatHtml.processImports(html_, conf_, locale_, files_);

            Assert.AreEqual("<html><body><a href=\"\" command=\"go\">Test {0}2</a></body></html>", render_);

            Assert.AreEqual(1, beanTwo_.getForms().size());
            Assert.AreEqual("key", beanTwo_.getForms().getKeys().get(0));
            Assert.AreEqual("sample_value", beanTwo_.getForms().values().get(0));
        }
예제 #3
0
        public void processHtmlJava1Test()
        {
            String locale_              = "LOCALE";
            String folder_              = "messages";
            String relative_            = "sample/file";
            String content_             = "one=Description one\ntwo=Description <a href=\"\">two</a>\nthree=desc &lt;{0}&gt;\nfour=''asp''";
            String html_                = "<html bean=\"bean_two\"><body><c.a value=\"sample/file,three\" param0=\"$typedString\">Content</c.a></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);
            bean_.getTree().put("ONE", 1);
            bean_.getTree().put("TWO", 2);
            BeanTwo beanTwo_ = new BeanTwo();

            beanTwo_.setTypedString("TITLE");
            Configuration conf_ = new Configuration();

            conf_.setBeans(new Map <String, Bean>());
            conf_.getBeans().put("bean_one", bean_);
            conf_.getBeans().put("bean_two", beanTwo_);
            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());
            String render_ = FormatHtml.processHtmlJava(html_, conf_, locale_, files_);

            Assert.AreEqual("<html><body><a value=\"sample/file,three\" param0=\"$typedString\" title=\"desc &amp;lt;TITLE2&amp;gt;\">Content</a></body></html>", render_);

            Assert.AreEqual("TITLE2", beanTwo_.getTypedString());
        }