0001: /*
0002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
0003: * Distributed under the terms of either:
0004: * - the common development and distribution license (CDDL), v1.0; or
0005: * - the GNU Lesser General Public License, v2.1 or later
0006: * $Id: TestTemplateFactory.java 3686 2007-03-09 13:34:16Z gbevin $
0007: */
0008: package com.uwyn.rife.template;
0009:
0010: import com.uwyn.rife.config.RifeConfig;
0011: import com.uwyn.rife.database.Datasources;
0012: import com.uwyn.rife.resources.DatabaseResources;
0013: import com.uwyn.rife.resources.DatabaseResourcesFactory;
0014: import com.uwyn.rife.resources.ResourceFinder;
0015: import com.uwyn.rife.resources.ResourceFinderClasspath;
0016: import com.uwyn.rife.resources.exceptions.ResourceWriterErrorException;
0017: import com.uwyn.rife.template.Template;
0018: import com.uwyn.rife.template.exceptions.AmbiguousTemplateNameException;
0019: import com.uwyn.rife.template.exceptions.TemplateException;
0020: import com.uwyn.rife.tools.ExceptionUtils;
0021: import com.uwyn.rife.tools.FileUtils;
0022: import com.uwyn.rife.tools.Localization;
0023: import com.uwyn.rife.tools.exceptions.FileUtilsErrorException;
0024: import java.io.File;
0025: import java.io.IOException;
0026: import java.net.URL;
0027: import java.util.ArrayList;
0028: import java.util.HashMap;
0029: import java.util.List;
0030: import java.util.ListResourceBundle;
0031: import java.util.Map;
0032:
0033: public class TestTemplateFactory extends TemplateTestCase {
0034: public TestTemplateFactory(String name) {
0035: super (name);
0036: }
0037:
0038: public void testUniqueFactory() {
0039: assertSame(TemplateFactory.ENGINEHTML,
0040: TemplateFactory.ENGINEHTML);
0041: assertSame(TemplateFactory.ENGINEXHTML,
0042: TemplateFactory.ENGINEXHTML);
0043: assertSame(TemplateFactory.ENGINEXML, TemplateFactory.ENGINEXML);
0044: assertSame(TemplateFactory.ENGINETXT, TemplateFactory.ENGINETXT);
0045: assertSame(TemplateFactory.HTML, TemplateFactory.HTML);
0046: assertSame(TemplateFactory.XHTML, TemplateFactory.XHTML);
0047: assertSame(TemplateFactory.XML, TemplateFactory.XML);
0048: assertSame(TemplateFactory.JAVA, TemplateFactory.JAVA);
0049: assertSame(TemplateFactory.SQL, TemplateFactory.SQL);
0050: assertSame(TemplateFactory.TXT, TemplateFactory.TXT);
0051: }
0052:
0053: public void testUniqueParser() {
0054: assertSame(TemplateFactory.ENGINEHTML.getParser(),
0055: TemplateFactory.ENGINEHTML.getParser());
0056: assertSame(TemplateFactory.ENGINEXHTML.getParser(),
0057: TemplateFactory.ENGINEXHTML.getParser());
0058: assertSame(TemplateFactory.ENGINEXML.getParser(),
0059: TemplateFactory.ENGINEXML.getParser());
0060: assertSame(TemplateFactory.ENGINETXT.getParser(),
0061: TemplateFactory.ENGINETXT.getParser());
0062: assertSame(TemplateFactory.HTML.getParser(),
0063: TemplateFactory.HTML.getParser());
0064: assertSame(TemplateFactory.XHTML.getParser(),
0065: TemplateFactory.XHTML.getParser());
0066: assertSame(TemplateFactory.XML.getParser(), TemplateFactory.XML
0067: .getParser());
0068: assertSame(TemplateFactory.JAVA.getParser(),
0069: TemplateFactory.JAVA.getParser());
0070: assertSame(TemplateFactory.SQL.getParser(), TemplateFactory.SQL
0071: .getParser());
0072: assertSame(TemplateFactory.TXT.getParser(), TemplateFactory.TXT
0073: .getParser());
0074: }
0075:
0076: public void testDefaultContentType() {
0077: assertEquals(TemplateFactory.ENGINEHTML.get("testhtml_in")
0078: .getDefaultContentType(), "text/html");
0079: assertEquals(TemplateFactory.ENGINEXHTML.get("testxhtml_in")
0080: .getDefaultContentType(), "text/html");
0081: assertEquals(TemplateFactory.ENGINEXML.get("testxml_in")
0082: .getDefaultContentType(), "application/xml");
0083: assertEquals(TemplateFactory.ENGINETXT.get("testtext_in")
0084: .getDefaultContentType(), "text/plain");
0085: assertEquals(TemplateFactory.HTML.get("testhtml_in")
0086: .getDefaultContentType(), "text/html");
0087: assertEquals(TemplateFactory.XHTML.get("testxhtml_in")
0088: .getDefaultContentType(), "text/html");
0089: assertEquals(TemplateFactory.XML.get("testxml_in")
0090: .getDefaultContentType(), "application/xml");
0091: assertEquals(TemplateFactory.JAVA.get("TestJavaIn")
0092: .getDefaultContentType(), "text/x-java-source");
0093: assertEquals(TemplateFactory.SQL.get("testsql_in")
0094: .getDefaultContentType(), "text/plain");
0095: assertEquals(TemplateFactory.TXT.get("testtext_in")
0096: .getDefaultContentType(), "text/plain");
0097: }
0098:
0099: public void testEngineHtmlTemplate() {
0100: Template template = TemplateFactory.ENGINEHTML
0101: .get("testhtml_in");
0102: template.setValue("first", "first1");
0103: template.setValue("second", "second1");
0104: template.appendBlock("lines", "line");
0105: template.setValue("first", "first2");
0106: template.setValue("second", "second2");
0107: template.appendBlock("lines", "line");
0108: template.setValue("first", "first3");
0109: template.setValue("second", "second3");
0110: template.appendBlock("lines", "line");
0111: assertEquals(template.getContent(), getTemplateContent(
0112: "testhtml_out", TemplateFactory.ENGINEHTML.getParser()));
0113: }
0114:
0115: public void testEngineXhtmlTemplate() {
0116: Template template = TemplateFactory.ENGINEXHTML
0117: .get("testxhtml_in");
0118: template.setValue("first", "first1");
0119: template.setValue("second", "second1");
0120: template.appendBlock("lines", "line");
0121: template.setValue("first", "first2");
0122: template.setValue("second", "second2");
0123: template.appendBlock("lines", "line");
0124: template.setValue("first", "first3");
0125: template.setValue("second", "second3");
0126: template.appendBlock("lines", "line");
0127: assertEquals(template.getContent(), getTemplateContent(
0128: "testxhtml_out", TemplateFactory.ENGINEXHTML
0129: .getParser()));
0130: }
0131:
0132: public void testEngineXmlTemplate() {
0133: Template template = TemplateFactory.ENGINEXML.get("testxml_in");
0134: template.setValue("name", "name1");
0135: template.setValue("value", "value1");
0136: template.appendBlock("params", "param");
0137: template.setValue("name", "name2");
0138: template.setValue("value", "value2");
0139: template.appendBlock("params", "param");
0140: template.setValue("name", "name3");
0141: template.setValue("value", "value3");
0142: template.appendBlock("params", "param");
0143: assertEquals(template.getContent(), getTemplateContent(
0144: "testxml_out", TemplateFactory.ENGINEXML.getParser()));
0145: }
0146:
0147: public void testEngineTextTemplate() {
0148: Template template = TemplateFactory.ENGINETXT
0149: .get("testtext_in");
0150: template.setValue("first", "first1");
0151: template.setValue("second", "second1");
0152: template.appendBlock("lines", "line");
0153: template.setValue("first", "first2");
0154: template.setValue("second", "second2");
0155: template.appendBlock("lines", "line");
0156: template.setValue("first", "first3");
0157: template.setValue("second", "second3");
0158: template.appendBlock("lines", "line");
0159: assertEquals(template.getContent(), getTemplateContent(
0160: "testtext_out", TemplateFactory.ENGINETXT.getParser()));
0161: }
0162:
0163: public void testHtmlTemplate() {
0164: Template template = TemplateFactory.HTML.get("testhtml_in");
0165: template.setValue("first", "first1");
0166: template.setValue("second", "second1");
0167: template.appendBlock("lines", "line");
0168: template.setValue("first", "first2");
0169: template.setValue("second", "second2");
0170: template.appendBlock("lines", "line");
0171: template.setValue("first", "first3");
0172: template.setValue("second", "second3");
0173: template.appendBlock("lines", "line");
0174: assertEquals(template.getContent(), getTemplateContent(
0175: "testhtml_out", TemplateFactory.HTML.getParser()));
0176: }
0177:
0178: public void testXhtmlTemplate() {
0179: Template template = TemplateFactory.XHTML.get("testxhtml_in");
0180: template.setValue("first", "first1");
0181: template.setValue("second", "second1");
0182: template.appendBlock("lines", "line");
0183: template.setValue("first", "first2");
0184: template.setValue("second", "second2");
0185: template.appendBlock("lines", "line");
0186: template.setValue("first", "first3");
0187: template.setValue("second", "second3");
0188: template.appendBlock("lines", "line");
0189: assertEquals(template.getContent(), getTemplateContent(
0190: "testxhtml_out", TemplateFactory.XHTML.getParser()));
0191: }
0192:
0193: public void testXmlTemplate() {
0194: Template template = TemplateFactory.XML.get("testxml_in");
0195: template.setValue("name", "name1");
0196: template.setValue("value", "value1");
0197: template.appendBlock("params", "param");
0198: template.setValue("name", "name2");
0199: template.setValue("value", "value2");
0200: template.appendBlock("params", "param");
0201: template.setValue("name", "name3");
0202: template.setValue("value", "value3");
0203: template.appendBlock("params", "param");
0204: assertEquals(template.getContent(), getTemplateContent(
0205: "testxml_out", TemplateFactory.XML.getParser()));
0206: }
0207:
0208: public void testJavaTemplate() {
0209: Template template = TemplateFactory.JAVA.get("TestJavaIn");
0210: template.setValue("classname", "TestJavaOut");
0211: template.setValue("name", "name1");
0212: template.setValue("value", "value1");
0213: template.appendBlock("members", "member");
0214: template.setValue("name", "name2");
0215: template.setValue("value", "value2");
0216: template.appendBlock("members", "member");
0217: template.setValue("name", "name3");
0218: template.setValue("value", "value3");
0219: template.appendBlock("members", "member");
0220: assertEquals(template.getContent(), getTemplateContent(
0221: "TestJavaOut", TemplateFactory.JAVA.getParser()));
0222: }
0223:
0224: public void testSqlTemplate() {
0225: Template template = TemplateFactory.SQL.get("testsql_in");
0226: template.setValue("first", "first1");
0227: template.setValue("second", "second1");
0228: template.appendBlock("lines", "line");
0229: template.setValue("first", "first2");
0230: template.setValue("second", "second2");
0231: template.appendBlock("lines", "line");
0232: template.setValue("first", "first3");
0233: template.setValue("second", "second3");
0234: template.appendBlock("lines", "line");
0235: assertEquals(template.getContent(), getTemplateContent(
0236: "testsql_out", TemplateFactory.SQL.getParser()));
0237: }
0238:
0239: public void testTextTemplate() {
0240: Template template = TemplateFactory.TXT.get("testtext_in");
0241: template.setValue("first", "first1");
0242: template.setValue("second", "second1");
0243: template.appendBlock("lines", "line");
0244: template.setValue("first", "first2");
0245: template.setValue("second", "second2");
0246: template.appendBlock("lines", "line");
0247: template.setValue("first", "first3");
0248: template.setValue("second", "second3");
0249: template.appendBlock("lines", "line");
0250: assertEquals(template.getContent(), getTemplateContent(
0251: "testtext_out", TemplateFactory.TXT.getParser()));
0252: }
0253:
0254: public void testEngineHtmlTemplatePath() {
0255: Template template = TemplateFactory.ENGINEHTML
0256: .get("testhtml_in.html");
0257: template.setValue("first", "first1");
0258: template.setValue("second", "second1");
0259: template.appendBlock("lines", "line");
0260: template.setValue("first", "first2");
0261: template.setValue("second", "second2");
0262: template.appendBlock("lines", "line");
0263: template.setValue("first", "first3");
0264: template.setValue("second", "second3");
0265: template.appendBlock("lines", "line");
0266: assertEquals(template.getContent(), getTemplateContent(
0267: "testhtml_out", TemplateFactory.ENGINEHTML.getParser()));
0268: }
0269:
0270: public void testEngineXhtmlTemplatePath() {
0271: Template template = TemplateFactory.ENGINEXHTML
0272: .get("testxhtml_in.xhtml");
0273: template.setValue("first", "first1");
0274: template.setValue("second", "second1");
0275: template.appendBlock("lines", "line");
0276: template.setValue("first", "first2");
0277: template.setValue("second", "second2");
0278: template.appendBlock("lines", "line");
0279: template.setValue("first", "first3");
0280: template.setValue("second", "second3");
0281: template.appendBlock("lines", "line");
0282: assertEquals(template.getContent(), getTemplateContent(
0283: "testxhtml_out", TemplateFactory.ENGINEXHTML
0284: .getParser()));
0285: }
0286:
0287: public void testEngineXmlTemplatePath() {
0288: Template template = TemplateFactory.ENGINEXML
0289: .get("testxml_in.xml");
0290: template.setValue("name", "name1");
0291: template.setValue("value", "value1");
0292: template.appendBlock("params", "param");
0293: template.setValue("name", "name2");
0294: template.setValue("value", "value2");
0295: template.appendBlock("params", "param");
0296: template.setValue("name", "name3");
0297: template.setValue("value", "value3");
0298: template.appendBlock("params", "param");
0299: assertEquals(template.getContent(), getTemplateContent(
0300: "testxml_out", TemplateFactory.ENGINEXML.getParser()));
0301: }
0302:
0303: public void testEngineTextTemplatePath() {
0304: Template template = TemplateFactory.ENGINETXT
0305: .get("testtext_in.txt");
0306: template.setValue("first", "first1");
0307: template.setValue("second", "second1");
0308: template.appendBlock("lines", "line");
0309: template.setValue("first", "first2");
0310: template.setValue("second", "second2");
0311: template.appendBlock("lines", "line");
0312: template.setValue("first", "first3");
0313: template.setValue("second", "second3");
0314: template.appendBlock("lines", "line");
0315: assertEquals(template.getContent(), getTemplateContent(
0316: "testtext_out", TemplateFactory.ENGINETXT.getParser()));
0317: }
0318:
0319: public void testHtmlTemplatePath() {
0320: Template template = TemplateFactory.HTML
0321: .get("testhtml_in.html");
0322: template.setValue("first", "first1");
0323: template.setValue("second", "second1");
0324: template.appendBlock("lines", "line");
0325: template.setValue("first", "first2");
0326: template.setValue("second", "second2");
0327: template.appendBlock("lines", "line");
0328: template.setValue("first", "first3");
0329: template.setValue("second", "second3");
0330: template.appendBlock("lines", "line");
0331: assertEquals(template.getContent(), getTemplateContent(
0332: "testhtml_out", TemplateFactory.HTML.getParser()));
0333: }
0334:
0335: public void testXhtmlTemplatePath() {
0336: Template template = TemplateFactory.XHTML
0337: .get("testxhtml_in.xhtml");
0338: template.setValue("first", "first1");
0339: template.setValue("second", "second1");
0340: template.appendBlock("lines", "line");
0341: template.setValue("first", "first2");
0342: template.setValue("second", "second2");
0343: template.appendBlock("lines", "line");
0344: template.setValue("first", "first3");
0345: template.setValue("second", "second3");
0346: template.appendBlock("lines", "line");
0347: assertEquals(template.getContent(), getTemplateContent(
0348: "testxhtml_out", TemplateFactory.XHTML.getParser()));
0349: }
0350:
0351: public void testXmlTemplatePath() {
0352: Template template = TemplateFactory.XML.get("testxml_in.xml");
0353: template.setValue("name", "name1");
0354: template.setValue("value", "value1");
0355: template.appendBlock("params", "param");
0356: template.setValue("name", "name2");
0357: template.setValue("value", "value2");
0358: template.appendBlock("params", "param");
0359: template.setValue("name", "name3");
0360: template.setValue("value", "value3");
0361: template.appendBlock("params", "param");
0362: assertEquals(template.getContent(), getTemplateContent(
0363: "testxml_out", TemplateFactory.XML.getParser()));
0364: }
0365:
0366: public void testJavaTemplatePath() {
0367: Template template = TemplateFactory.JAVA.get("TestJavaIn.java");
0368: template.setValue("classname", "TestJavaOut");
0369: template.setValue("name", "name1");
0370: template.setValue("value", "value1");
0371: template.appendBlock("members", "member");
0372: template.setValue("name", "name2");
0373: template.setValue("value", "value2");
0374: template.appendBlock("members", "member");
0375: template.setValue("name", "name3");
0376: template.setValue("value", "value3");
0377: template.appendBlock("members", "member");
0378: assertEquals(template.getContent(), getTemplateContent(
0379: "TestJavaOut", TemplateFactory.JAVA.getParser()));
0380: }
0381:
0382: public void testSqlTemplatePath() {
0383: Template template = TemplateFactory.SQL.get("testsql_in.sql");
0384: template.setValue("first", "first1");
0385: template.setValue("second", "second1");
0386: template.appendBlock("lines", "line");
0387: template.setValue("first", "first2");
0388: template.setValue("second", "second2");
0389: template.appendBlock("lines", "line");
0390: template.setValue("first", "first3");
0391: template.setValue("second", "second3");
0392: template.appendBlock("lines", "line");
0393: assertEquals(template.getContent(), getTemplateContent(
0394: "testsql_out", TemplateFactory.SQL.getParser()));
0395: }
0396:
0397: public void testTextTemplatePath() {
0398: Template template = TemplateFactory.TXT.get("testtext_in.txt");
0399: template.setValue("first", "first1");
0400: template.setValue("second", "second1");
0401: template.appendBlock("lines", "line");
0402: template.setValue("first", "first2");
0403: template.setValue("second", "second2");
0404: template.appendBlock("lines", "line");
0405: template.setValue("first", "first3");
0406: template.setValue("second", "second3");
0407: template.appendBlock("lines", "line");
0408: assertEquals(template.getContent(), getTemplateContent(
0409: "testtext_out", TemplateFactory.TXT.getParser()));
0410: }
0411:
0412: public void testEngineHtmlTemplateAmbiguous() {
0413: try {
0414: TemplateFactory.ENGINEHTML.get("html.html");
0415: fail("exception not thrown");
0416: } catch (AmbiguousTemplateNameException e) {
0417: assertEquals(e.getName(), "html.html");
0418: }
0419: }
0420:
0421: public void testEngineXHtmlTemplateAmbiguous() {
0422: try {
0423: TemplateFactory.ENGINEXHTML.get("xhtml.xhtml");
0424: fail("exception not thrown");
0425: } catch (AmbiguousTemplateNameException e) {
0426: assertEquals(e.getName(), "xhtml.xhtml");
0427: }
0428: }
0429:
0430: public void testEngineXmlTemplateAmbiguous() {
0431: try {
0432: TemplateFactory.ENGINEXML.get("xml.xml");
0433: fail("exception not thrown");
0434: } catch (AmbiguousTemplateNameException e) {
0435: assertEquals(e.getName(), "xml.xml");
0436: }
0437: }
0438:
0439: public void testEngineTxtTemplateAmbiguous() {
0440: try {
0441: TemplateFactory.ENGINETXT.get("txt.txt");
0442: fail("exception not thrown");
0443: } catch (AmbiguousTemplateNameException e) {
0444: assertEquals(e.getName(), "txt.txt");
0445: }
0446: }
0447:
0448: public void testHtmlTemplateAmbiguous() {
0449: try {
0450: TemplateFactory.HTML.get("html.html");
0451: fail("exception not thrown");
0452: } catch (AmbiguousTemplateNameException e) {
0453: assertEquals(e.getName(), "html.html");
0454: }
0455: }
0456:
0457: public void testXHtmlTemplateAmbiguous() {
0458: try {
0459: TemplateFactory.XHTML.get("xhtml.xhtml");
0460: fail("exception not thrown");
0461: } catch (AmbiguousTemplateNameException e) {
0462: assertEquals(e.getName(), "xhtml.xhtml");
0463: }
0464: }
0465:
0466: public void testXmlTemplateAmbiguous() {
0467: try {
0468: TemplateFactory.XML.get("xml.xml");
0469: fail("exception not thrown");
0470: } catch (AmbiguousTemplateNameException e) {
0471: assertEquals(e.getName(), "xml.xml");
0472: }
0473: }
0474:
0475: public void testJavaTemplateAmbiguous() {
0476: try {
0477: TemplateFactory.JAVA.get("java.java");
0478: fail("exception not thrown");
0479: } catch (AmbiguousTemplateNameException e) {
0480: assertEquals(e.getName(), "java.java");
0481: }
0482: }
0483:
0484: public void testSqlTemplateAmbiguous() {
0485: try {
0486: TemplateFactory.SQL.get("sql.sql");
0487: fail("exception not thrown");
0488: } catch (AmbiguousTemplateNameException e) {
0489: assertEquals(e.getName(), "sql.sql");
0490: }
0491: }
0492:
0493: public void testTxtTemplateAmbiguous() {
0494: try {
0495: TemplateFactory.TXT.get("txt.txt");
0496: fail("exception not thrown");
0497: } catch (AmbiguousTemplateNameException e) {
0498: assertEquals(e.getName(), "txt.txt");
0499: }
0500: }
0501:
0502: public void testXsltTransformation() {
0503: TemplateTransformerXslt transformer = new TemplateTransformerXslt();
0504: transformer.addFilter("testxslt_stylesheet2.xsl");
0505: transformer.addFilter("testxslt_stylesheet3.xsl");
0506: Template template = TemplateFactory.XML.get("testxslt_in",
0507: transformer);
0508: template.appendBlock("out", "out");
0509: template.appendBlock("out", "out");
0510: String version_string = System.getProperty("java.version");
0511: int first_point = version_string.indexOf(".");
0512: int second_point = version_string.indexOf(".", first_point + 1);
0513: double version;
0514: if (second_point != -1) {
0515: version = Double.parseDouble(version_string.substring(0,
0516: second_point));
0517: } else {
0518: version = Double.parseDouble(version_string);
0519: }
0520: // line handling is different in 1.4 and 1.5
0521: if (version < 1.5) {
0522: assertEquals(template.getContent(), getTemplateContent(
0523: "testxslt_out", TemplateFactory.XML.getParser()));
0524: } else {
0525: assertEquals(template.getContent(),
0526: getTemplateContent("testxslt_out_5_0",
0527: TemplateFactory.XML.getParser()));
0528: }
0529: }
0530:
0531: public void testTemplateInitializer() {
0532: TemplateFactory factory = null;
0533: Template template = null;
0534:
0535: factory = new TemplateFactory(
0536: ResourceFinderClasspath.getInstance(),
0537: "html",
0538: new Parser.Config[] { TemplateFactory.CONFIG_INVISIBLE_XML },
0539: "text/html", ".html", null, null, null, null, null);
0540: template = factory.get("testhtml_in", null, null);
0541: assertFalse(template.getContent().equals(
0542: getTemplateContent("testhtml_out", TemplateFactory.HTML
0543: .getParser())));
0544:
0545: factory = new TemplateFactory(
0546: ResourceFinderClasspath.getInstance(),
0547: "html",
0548: new Parser.Config[] { TemplateFactory.CONFIG_INVISIBLE_XML },
0549: "text/html", ".html", null, null, null, null,
0550: new TemplateInitializer() {
0551: public void initialize(Template template) {
0552: template.setValue("first", "first1");
0553: template.setValue("second", "second1");
0554: template.appendBlock("lines", "line");
0555: template.setValue("first", "first2");
0556: template.setValue("second", "second2");
0557: template.appendBlock("lines", "line");
0558: template.setValue("first", "first3");
0559: template.setValue("second", "second3");
0560: template.appendBlock("lines", "line");
0561: }
0562: });
0563: template = factory.get("testhtml_in", null, null);
0564: assertEquals(template.getContent(), getTemplateContent(
0565: "testhtml_out", TemplateFactory.HTML.getParser()));
0566: template.setValue("first", "otherfirst1");
0567: template.setValue("second", "othersecond1");
0568: template.appendBlock("lines", "line");
0569: assertFalse(template.getContent().equals(
0570: getTemplateContent("testhtml_out", TemplateFactory.HTML
0571: .getParser())));
0572: template.clear();
0573: assertEquals(template.getContent(), getTemplateContent(
0574: "testhtml_out", TemplateFactory.HTML.getParser()));
0575: }
0576:
0577: public void testFilteredTagsRenderHtml() throws Exception {
0578: Template t = TemplateFactory.HTML.get("filtered_tags_render");
0579: assertEquals(
0580: "This is the render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:1'.\n"
0581: + "This is another render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:1'.\n"
0582: + "This is the render value with a differentiator 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPL:DIFFERENT:different:2'.\n",
0583: t.getContent());
0584: }
0585:
0586: public void testFilteredTagsRenderXhtml() throws Exception {
0587: Template t = TemplateFactory.XHTML.get("filtered_tags_render");
0588: assertEquals(
0589: "This is the render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:3'.\n"
0590: + "This is another render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:3'.\n"
0591: + "This is the render value with a differentiator 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPL:DIFFERENT:different:4'.\n",
0592: t.getContent());
0593: }
0594:
0595: public void testFilteredTagsRenderXml() throws Exception {
0596: Template t = TemplateFactory.XML.get("filtered_tags_render");
0597: assertEquals(
0598: "This is the render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:5'.\n"
0599: + "This is another render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:5'.\n"
0600: + "This is the render value with a differentiator 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPL:DIFFERENT:different:6'.\n",
0601: t.getContent());
0602: }
0603:
0604: public void testFilteredTagsRenderTxt() throws Exception {
0605: Template t = TemplateFactory.TXT.get("filtered_tags_render");
0606: assertEquals(
0607: "This is the render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:7'.\n"
0608: + "This is another render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:7'.\n"
0609: + "This is the render value with a differentiator 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPL:DIFFERENT:different:8'.\n",
0610: t.getContent());
0611: }
0612:
0613: public void testFilteredTagsRenderSql() throws Exception {
0614: Template t = TemplateFactory.SQL.get("filtered_tags_render");
0615: assertEquals(
0616: "This is the render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:9'.\n"
0617: + "This is another render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:9'.\n"
0618: + "This is the render value with a differentiator 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPL:DIFFERENT:different:10'.\n",
0619: t.getContent());
0620: }
0621:
0622: public void testFilteredTagsRenderJava() throws Exception {
0623: Template t = TemplateFactory.JAVA.get("filtered_tags_render");
0624: assertEquals(
0625: "This is the render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:11'.\n"
0626: + "This is another render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:11'.\n"
0627: + "This is the render value with a differentiator 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPL:DIFFERENT:different:12'.\n",
0628: t.getContent());
0629: }
0630:
0631: public void testFilteredTagsRenderEnginehtml() throws Exception {
0632: Template t = TemplateFactory.ENGINEHTML
0633: .get("filtered_tags_render");
0634: assertEquals(
0635: "This is the render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:13'.\n"
0636: + "This is another render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:13'.\n"
0637: + "This is the render value with a differentiator 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPL:DIFFERENT:different:14'.\n",
0638: t.getContent());
0639: }
0640:
0641: public void testFilteredTagsRenderEnginexhtml() throws Exception {
0642: Template t = TemplateFactory.ENGINEXHTML
0643: .get("filtered_tags_render");
0644: assertEquals(
0645: "This is the render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:15'.\n"
0646: + "This is another render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:15'.\n"
0647: + "This is the render value with a differentiator 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPL:DIFFERENT:different:16'.\n",
0648: t.getContent());
0649: }
0650:
0651: public void testFilteredTagsRenderEnginexml() throws Exception {
0652: Template t = TemplateFactory.ENGINEXML
0653: .get("filtered_tags_render");
0654: assertEquals(
0655: "This is the render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:17'.\n"
0656: + "This is another render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:17'.\n"
0657: + "This is the render value with a differentiator 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPL:DIFFERENT:different:18'.\n",
0658: t.getContent());
0659: }
0660:
0661: public void testFilteredTagsRenderEnginetxt() throws Exception {
0662: Template t = TemplateFactory.ENGINETXT
0663: .get("filtered_tags_render");
0664: assertEquals(
0665: "This is the render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:19'.\n"
0666: + "This is another render value 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPLnull:19'.\n"
0667: + "This is the render value with a differentiator 'RENDER:COM.UWYN.RIFE.TEMPLATE.RENDERERIMPL:DIFFERENT:different:20'.\n",
0668: t.getContent());
0669: }
0670:
0671: public void testFilteredTagsConfigHtml() throws Exception {
0672: Template template_html = TemplateFactory.HTML
0673: .get("filtered_tags_config");
0674: assertEquals(
0675: "This is the config value 'the config value'.\nThis is an unknown config value '[!V 'CONFIG:TEMPLATE_CONFIG_VALUE_UNKNOWN'/]'.\n",
0676: template_html.getContent());
0677: }
0678:
0679: public void testFilteredTagsConfigXhtml() throws Exception {
0680: Template template_xhtml = TemplateFactory.XHTML
0681: .get("filtered_tags_config");
0682: assertEquals(
0683: "This is the config value 'the config value'.\nThis is an unknown config value '[!V 'CONFIG:TEMPLATE_CONFIG_VALUE_UNKNOWN'/]'.\n",
0684: template_xhtml.getContent());
0685: }
0686:
0687: public void testFilteredTagsConfigXml() throws Exception {
0688: Template template_xml = TemplateFactory.XML
0689: .get("filtered_tags_config");
0690: assertEquals(
0691: "This is the config value 'the config value'.\nThis is an unknown config value '[!V 'CONFIG:TEMPLATE_CONFIG_VALUE_UNKNOWN'/]'.\n",
0692: template_xml.getContent());
0693: }
0694:
0695: public void testFilteredTagsConfigTxt() throws Exception {
0696: Template template_text = TemplateFactory.TXT
0697: .get("filtered_tags_config");
0698: assertEquals(
0699: "This is the config value 'the config value'.\nThis is an unknown config value '[!V 'CONFIG:TEMPLATE_CONFIG_VALUE_UNKNOWN'/]'.\n",
0700: template_text.getContent());
0701: }
0702:
0703: public void testFilteredTagsConfigSql() throws Exception {
0704: Template template_sql = TemplateFactory.SQL
0705: .get("filtered_tags_config");
0706: assertEquals(
0707: "This is the config value 'the config value'.\nThis is an unknown config value '[!V 'CONFIG:TEMPLATE_CONFIG_VALUE_UNKNOWN'/]'.\n",
0708: template_sql.getContent());
0709: }
0710:
0711: public void testFilteredTagsConfigJava() throws Exception {
0712: Template template_java = TemplateFactory.JAVA
0713: .get("filtered_tags_config");
0714: assertEquals(
0715: "// This is the config value 'the config value'.\n// This is an unknown config value '[!V 'CONFIG:TEMPLATE_CONFIG_VALUE_UNKNOWN'/]'.\n",
0716: template_java.getContent());
0717: }
0718:
0719: public void testFilteredTagsConfigEnginehtml() throws Exception {
0720: Template template_enginehtml = TemplateFactory.ENGINEHTML
0721: .get("filtered_tags_config");
0722: assertEquals(
0723: "This is the config value 'the config value'.\nThis is an unknown config value '[!V 'CONFIG:TEMPLATE_CONFIG_VALUE_UNKNOWN'/]'.\n",
0724: template_enginehtml.getContent());
0725: }
0726:
0727: public void testFilteredTagsConfigEnginexhtml() throws Exception {
0728: Template template_enginexhtml = TemplateFactory.ENGINEXHTML
0729: .get("filtered_tags_config");
0730: assertEquals(
0731: "This is the config value 'the config value'.\nThis is an unknown config value '[!V 'CONFIG:TEMPLATE_CONFIG_VALUE_UNKNOWN'/]'.\n",
0732: template_enginexhtml.getContent());
0733: }
0734:
0735: public void testFilteredTagsConfigEnginexml() throws Exception {
0736: Template template_enginexml = TemplateFactory.ENGINEXML
0737: .get("filtered_tags_config");
0738: assertEquals(
0739: "This is the config value 'the config value'.\nThis is an unknown config value '[!V 'CONFIG:TEMPLATE_CONFIG_VALUE_UNKNOWN'/]'.\n",
0740: template_enginexml.getContent());
0741: }
0742:
0743: public void testFilteredTagsConfigEnginetxt() throws Exception {
0744: Template template_enginetext = TemplateFactory.ENGINETXT
0745: .get("filtered_tags_config");
0746: assertEquals(
0747: "This is the config value 'the config value'.\nThis is an unknown config value '[!V 'CONFIG:TEMPLATE_CONFIG_VALUE_UNKNOWN'/]'.\n",
0748: template_enginetext.getContent());
0749: }
0750:
0751: public void testFilteredTagsL10nEnginehtml() throws Exception {
0752: Template template_html = TemplateFactory.ENGINEHTML
0753: .get("filtered_tags_l10n");
0754: assertEquals(
0755: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0756: template_html.getContent());
0757:
0758: template_html.addResourceBundle(Localization.getResourceBundle(
0759: "localization/filtered-tags-l10n", "en"));
0760: assertEquals(
0761: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0762: template_html.getContent());
0763:
0764: template_html.clear();
0765: template_html.addResourceBundle(Localization.getResourceBundle(
0766: "localization/filtered-tags-l10n", "nl"));
0767: assertEquals(
0768: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0769: template_html.getContent());
0770:
0771: template_html.clear();
0772: template_html.addResourceBundle(Localization.getResourceBundle(
0773: "localization/filtered-tags-l10n", "fr"));
0774: assertEquals(
0775: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0776: template_html.getContent());
0777: }
0778:
0779: public void testFilteredTagsL10nEnginehtmlDefaultResourceBundles()
0780: throws Exception {
0781: Template template_html;
0782:
0783: ArrayList<String> bundles = new ArrayList<String>();
0784: bundles.add("localization/filtered-tags-l10n");
0785: bundles.add("com.uwyn.rife.template.TestResourceBundleClass");
0786: RifeConfig.Template.setDefaultResourcebundles(
0787: TemplateFactory.ENGINEHTML, bundles);
0788:
0789: try {
0790: RifeConfig.Tools.setDefaultLanguage("en");
0791: template_html = TemplateFactory.ENGINEHTML
0792: .get("filtered_tags_l10n");
0793: assertEquals(
0794: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
0795: template_html.getContent());
0796:
0797: RifeConfig.Tools.setDefaultLanguage("nl");
0798: template_html = TemplateFactory.ENGINEHTML
0799: .get("filtered_tags_l10n");
0800: assertEquals(
0801: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
0802: template_html.getContent());
0803:
0804: RifeConfig.Tools.setDefaultLanguage("fr");
0805: template_html = TemplateFactory.ENGINEHTML
0806: .get("filtered_tags_l10n");
0807: assertEquals(
0808: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
0809: template_html.getContent());
0810: } finally {
0811: RifeConfig.Template.setDefaultResourcebundles(
0812: TemplateFactory.ENGINEHTML, null);
0813: RifeConfig.Tools.setDefaultLanguage("en");
0814: }
0815: }
0816:
0817: public void testFilteredTagsL10nEnginehtmlSeveralResourcebundles()
0818: throws Exception {
0819: Template template_html = TemplateFactory.ENGINEHTML
0820: .get("filtered_tags_l10n");
0821: assertEquals(
0822: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0823: template_html.getContent());
0824:
0825: template_html.addResourceBundle(new ListResourceBundle() {
0826: public Object[][] getContents() {
0827: return new Object[][] { { "THE_KEY", "list key" } };
0828: }
0829: });
0830: template_html.addResourceBundle(Localization.getResourceBundle(
0831: "localization/filtered-tags-l10n", "en"));
0832: assertEquals(
0833: "This is the localized key 'list key'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0834: template_html.getContent());
0835:
0836: template_html.clear();
0837: template_html.addResourceBundle(Localization.getResourceBundle(
0838: "localization/filtered-tags-l10n", "en"));
0839: template_html.addResourceBundle(new ListResourceBundle() {
0840: public Object[][] getContents() {
0841: return new Object[][] { { "THE_KEY", "list key" } };
0842: }
0843: });
0844: assertEquals(
0845: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0846: template_html.getContent());
0847:
0848: template_html.clear();
0849: template_html.addResourceBundle(new ListResourceBundle() {
0850: public Object[][] getContents() {
0851: return new Object[][] { { "THE_OTHER_KEY", "list key" } };
0852: }
0853: });
0854: template_html.addResourceBundle(Localization.getResourceBundle(
0855: "localization/filtered-tags-l10n", "en"));
0856: assertEquals(
0857: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0858: template_html.getContent());
0859: }
0860:
0861: public void testFilteredTagsL10nEnginexhtml() throws Exception {
0862: Template template_xhtml = TemplateFactory.ENGINEXHTML
0863: .get("filtered_tags_l10n");
0864: assertEquals(
0865: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0866: template_xhtml.getContent());
0867:
0868: template_xhtml.addResourceBundle(Localization
0869: .getResourceBundle("localization/filtered-tags-l10n",
0870: "en"));
0871: assertEquals(
0872: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0873: template_xhtml.getContent());
0874:
0875: template_xhtml.clear();
0876: template_xhtml.addResourceBundle(Localization
0877: .getResourceBundle("localization/filtered-tags-l10n",
0878: "nl"));
0879: assertEquals(
0880: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0881: template_xhtml.getContent());
0882:
0883: template_xhtml.clear();
0884: template_xhtml.addResourceBundle(Localization
0885: .getResourceBundle("localization/filtered-tags-l10n",
0886: "fr"));
0887: assertEquals(
0888: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0889: template_xhtml.getContent());
0890: }
0891:
0892: public void testFilteredTagsL10nEnginexhtmlDefaultResourceBundles()
0893: throws Exception {
0894: Template template_xhtml;
0895:
0896: ArrayList<String> bundles = new ArrayList<String>();
0897: bundles.add("localization/filtered-tags-l10n");
0898: bundles.add("com.uwyn.rife.template.TestResourceBundleClass");
0899: RifeConfig.Template.setDefaultResourcebundles(
0900: TemplateFactory.ENGINEXHTML, bundles);
0901:
0902: try {
0903: RifeConfig.Tools.setDefaultLanguage("en");
0904: template_xhtml = TemplateFactory.ENGINEXHTML
0905: .get("filtered_tags_l10n");
0906: assertEquals(
0907: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
0908: template_xhtml.getContent());
0909:
0910: RifeConfig.Tools.setDefaultLanguage("nl");
0911: template_xhtml = TemplateFactory.ENGINEXHTML
0912: .get("filtered_tags_l10n");
0913: assertEquals(
0914: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
0915: template_xhtml.getContent());
0916:
0917: RifeConfig.Tools.setDefaultLanguage("fr");
0918: template_xhtml = TemplateFactory.ENGINEXHTML
0919: .get("filtered_tags_l10n");
0920: assertEquals(
0921: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
0922: template_xhtml.getContent());
0923: } finally {
0924: RifeConfig.Template.setDefaultResourcebundles(
0925: TemplateFactory.ENGINEXHTML, null);
0926: RifeConfig.Tools.setDefaultLanguage("en");
0927: }
0928: }
0929:
0930: public void testFilteredTagsL10nEnginexhtmlSeveralResourcebundles()
0931: throws Exception {
0932: Template template_xhtml = TemplateFactory.ENGINEXHTML
0933: .get("filtered_tags_l10n");
0934: assertEquals(
0935: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0936: template_xhtml.getContent());
0937:
0938: template_xhtml.addResourceBundle(new ListResourceBundle() {
0939: public Object[][] getContents() {
0940: return new Object[][] { { "THE_KEY", "list key" } };
0941: }
0942: });
0943: template_xhtml.addResourceBundle(Localization
0944: .getResourceBundle("localization/filtered-tags-l10n",
0945: "en"));
0946: assertEquals(
0947: "This is the localized key 'list key'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0948: template_xhtml.getContent());
0949:
0950: template_xhtml.clear();
0951: template_xhtml.addResourceBundle(Localization
0952: .getResourceBundle("localization/filtered-tags-l10n",
0953: "en"));
0954: template_xhtml.addResourceBundle(new ListResourceBundle() {
0955: public Object[][] getContents() {
0956: return new Object[][] { { "THE_KEY", "list key" } };
0957: }
0958: });
0959: assertEquals(
0960: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0961: template_xhtml.getContent());
0962:
0963: template_xhtml.clear();
0964: template_xhtml.addResourceBundle(new ListResourceBundle() {
0965: public Object[][] getContents() {
0966: return new Object[][] { { "THE_OTHER_KEY", "list key" } };
0967: }
0968: });
0969: template_xhtml.addResourceBundle(Localization
0970: .getResourceBundle("localization/filtered-tags-l10n",
0971: "en"));
0972: assertEquals(
0973: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0974: template_xhtml.getContent());
0975: }
0976:
0977: public void testFilteredTagsL10nEnginexml() throws Exception {
0978: Template template_html = TemplateFactory.ENGINEXML
0979: .get("filtered_tags_l10n");
0980: assertEquals(
0981: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0982: template_html.getContent());
0983:
0984: template_html.addResourceBundle(Localization.getResourceBundle(
0985: "localization/filtered-tags-l10n", "en"));
0986: assertEquals(
0987: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0988: template_html.getContent());
0989:
0990: template_html.clear();
0991: template_html.addResourceBundle(Localization.getResourceBundle(
0992: "localization/filtered-tags-l10n", "nl"));
0993: assertEquals(
0994: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
0995: template_html.getContent());
0996:
0997: template_html.clear();
0998: template_html.addResourceBundle(Localization.getResourceBundle(
0999: "localization/filtered-tags-l10n", "fr"));
1000: assertEquals(
1001: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1002: template_html.getContent());
1003: }
1004:
1005: public void testFilteredTagsL10nEnginexmlDefaultResourceBundles()
1006: throws Exception {
1007: Template template_xml;
1008:
1009: ArrayList<String> bundles = new ArrayList<String>();
1010: bundles.add("localization/filtered-tags-l10n");
1011: bundles.add("com.uwyn.rife.template.TestResourceBundleClass");
1012: RifeConfig.Template.setDefaultResourcebundles(
1013: TemplateFactory.ENGINEXML, bundles);
1014:
1015: try {
1016: RifeConfig.Tools.setDefaultLanguage("en");
1017: template_xml = TemplateFactory.ENGINEXML
1018: .get("filtered_tags_l10n");
1019: assertEquals(
1020: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1021: template_xml.getContent());
1022:
1023: RifeConfig.Tools.setDefaultLanguage("nl");
1024: template_xml = TemplateFactory.ENGINEXML
1025: .get("filtered_tags_l10n");
1026: assertEquals(
1027: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1028: template_xml.getContent());
1029:
1030: RifeConfig.Tools.setDefaultLanguage("fr");
1031: template_xml = TemplateFactory.ENGINEXML
1032: .get("filtered_tags_l10n");
1033: assertEquals(
1034: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1035: template_xml.getContent());
1036: } finally {
1037: RifeConfig.Template.setDefaultResourcebundles(
1038: TemplateFactory.ENGINEXML, null);
1039: RifeConfig.Tools.setDefaultLanguage("en");
1040: }
1041: }
1042:
1043: public void testFilteredTagsL10nEnginexmlSeveralResourcebundles()
1044: throws Exception {
1045: Template template_xml = TemplateFactory.ENGINEXML
1046: .get("filtered_tags_l10n");
1047: assertEquals(
1048: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1049: template_xml.getContent());
1050:
1051: template_xml.addResourceBundle(new ListResourceBundle() {
1052: public Object[][] getContents() {
1053: return new Object[][] { { "THE_KEY", "list key" } };
1054: }
1055: });
1056: template_xml.addResourceBundle(Localization.getResourceBundle(
1057: "localization/filtered-tags-l10n", "en"));
1058: assertEquals(
1059: "This is the localized key 'list key'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1060: template_xml.getContent());
1061:
1062: template_xml.clear();
1063: template_xml.addResourceBundle(Localization.getResourceBundle(
1064: "localization/filtered-tags-l10n", "en"));
1065: template_xml.addResourceBundle(new ListResourceBundle() {
1066: public Object[][] getContents() {
1067: return new Object[][] { { "THE_KEY", "list key" } };
1068: }
1069: });
1070: assertEquals(
1071: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1072: template_xml.getContent());
1073:
1074: template_xml.clear();
1075: template_xml.addResourceBundle(new ListResourceBundle() {
1076: public Object[][] getContents() {
1077: return new Object[][] { { "THE_OTHER_KEY", "list key" } };
1078: }
1079: });
1080: template_xml.addResourceBundle(Localization.getResourceBundle(
1081: "localization/filtered-tags-l10n", "en"));
1082: assertEquals(
1083: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1084: template_xml.getContent());
1085: }
1086:
1087: public void testFilteredTagsL10Enginetxt() throws Exception {
1088: Template template_txt = TemplateFactory.ENGINETXT
1089: .get("filtered_tags_l10n");
1090: assertEquals(
1091: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1092: template_txt.getContent());
1093:
1094: template_txt.addResourceBundle(Localization.getResourceBundle(
1095: "localization/filtered-tags-l10n", "en"));
1096: assertEquals(
1097: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1098: template_txt.getContent());
1099:
1100: template_txt.clear();
1101: template_txt.addResourceBundle(Localization.getResourceBundle(
1102: "localization/filtered-tags-l10n", "nl"));
1103: assertEquals(
1104: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1105: template_txt.getContent());
1106:
1107: template_txt.clear();
1108: template_txt.addResourceBundle(Localization.getResourceBundle(
1109: "localization/filtered-tags-l10n", "fr"));
1110: assertEquals(
1111: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1112: template_txt.getContent());
1113: }
1114:
1115: public void testFilteredTagsL10nEnginetxtDefaultResourceBundles()
1116: throws Exception {
1117: Template template_txt;
1118:
1119: ArrayList<String> bundles = new ArrayList<String>();
1120: bundles.add("localization/filtered-tags-l10n");
1121: bundles.add("com.uwyn.rife.template.TestResourceBundleClass");
1122: RifeConfig.Template.setDefaultResourcebundles(
1123: TemplateFactory.ENGINETXT, bundles);
1124:
1125: try {
1126: RifeConfig.Tools.setDefaultLanguage("en");
1127: template_txt = TemplateFactory.ENGINETXT
1128: .get("filtered_tags_l10n");
1129: assertEquals(
1130: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1131: template_txt.getContent());
1132:
1133: RifeConfig.Tools.setDefaultLanguage("nl");
1134: template_txt = TemplateFactory.ENGINETXT
1135: .get("filtered_tags_l10n");
1136: assertEquals(
1137: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1138: template_txt.getContent());
1139:
1140: RifeConfig.Tools.setDefaultLanguage("fr");
1141: template_txt = TemplateFactory.ENGINETXT
1142: .get("filtered_tags_l10n");
1143: assertEquals(
1144: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1145: template_txt.getContent());
1146: } finally {
1147: RifeConfig.Template.setDefaultResourcebundles(
1148: TemplateFactory.ENGINETXT, null);
1149: RifeConfig.Tools.setDefaultLanguage("en");
1150: }
1151: }
1152:
1153: public void testFilteredTagsL10nEnginetxtSeveralResourcebundles()
1154: throws Exception {
1155: Template template_txt = TemplateFactory.ENGINETXT
1156: .get("filtered_tags_l10n");
1157: assertEquals(
1158: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1159: template_txt.getContent());
1160:
1161: template_txt.addResourceBundle(new ListResourceBundle() {
1162: public Object[][] getContents() {
1163: return new Object[][] { { "THE_KEY", "list key" } };
1164: }
1165: });
1166: template_txt.addResourceBundle(Localization.getResourceBundle(
1167: "localization/filtered-tags-l10n", "en"));
1168: assertEquals(
1169: "This is the localized key 'list key'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1170: template_txt.getContent());
1171:
1172: template_txt.clear();
1173: template_txt.addResourceBundle(Localization.getResourceBundle(
1174: "localization/filtered-tags-l10n", "en"));
1175: template_txt.addResourceBundle(new ListResourceBundle() {
1176: public Object[][] getContents() {
1177: return new Object[][] { { "THE_KEY", "list key" } };
1178: }
1179: });
1180: assertEquals(
1181: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1182: template_txt.getContent());
1183:
1184: template_txt.clear();
1185: template_txt.addResourceBundle(new ListResourceBundle() {
1186: public Object[][] getContents() {
1187: return new Object[][] { { "THE_OTHER_KEY", "list key" } };
1188: }
1189: });
1190: template_txt.addResourceBundle(Localization.getResourceBundle(
1191: "localization/filtered-tags-l10n", "en"));
1192: assertEquals(
1193: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1194: template_txt.getContent());
1195: }
1196:
1197: public void testFilteredTagsL10nHtml() throws Exception {
1198: Template template_html = TemplateFactory.HTML
1199: .get("filtered_tags_l10n");
1200: assertEquals(
1201: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1202: template_html.getContent());
1203:
1204: template_html.addResourceBundle(Localization.getResourceBundle(
1205: "localization/filtered-tags-l10n", "en"));
1206: assertEquals(
1207: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1208: template_html.getContent());
1209:
1210: template_html.clear();
1211: template_html.addResourceBundle(Localization.getResourceBundle(
1212: "localization/filtered-tags-l10n", "nl"));
1213: assertEquals(
1214: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1215: template_html.getContent());
1216:
1217: template_html.clear();
1218: template_html.addResourceBundle(Localization.getResourceBundle(
1219: "localization/filtered-tags-l10n", "fr"));
1220: assertEquals(
1221: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1222: template_html.getContent());
1223: }
1224:
1225: public void testFilteredTagsL10nHtmlDefaultResourceBundles()
1226: throws Exception {
1227: Template template_html;
1228:
1229: ArrayList<String> bundles = new ArrayList<String>();
1230: bundles.add("localization/filtered-tags-l10n");
1231: bundles.add("com.uwyn.rife.template.TestResourceBundleClass");
1232: RifeConfig.Template.setDefaultResourcebundles(
1233: TemplateFactory.HTML, bundles);
1234:
1235: try {
1236: RifeConfig.Tools.setDefaultLanguage("en");
1237: template_html = TemplateFactory.HTML
1238: .get("filtered_tags_l10n");
1239: assertEquals(
1240: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1241: template_html.getContent());
1242:
1243: RifeConfig.Tools.setDefaultLanguage("nl");
1244: template_html = TemplateFactory.HTML
1245: .get("filtered_tags_l10n");
1246: assertEquals(
1247: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1248: template_html.getContent());
1249:
1250: RifeConfig.Tools.setDefaultLanguage("fr");
1251: template_html = TemplateFactory.HTML
1252: .get("filtered_tags_l10n");
1253: assertEquals(
1254: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1255: template_html.getContent());
1256: } finally {
1257: RifeConfig.Template.setDefaultResourcebundles(
1258: TemplateFactory.HTML, null);
1259: RifeConfig.Tools.setDefaultLanguage("en");
1260: }
1261: }
1262:
1263: public void testFilteredTagsL10nHtmlSeveralResourcebundles()
1264: throws Exception {
1265: Template template_html = TemplateFactory.HTML
1266: .get("filtered_tags_l10n");
1267: assertEquals(
1268: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1269: template_html.getContent());
1270:
1271: template_html.addResourceBundle(new ListResourceBundle() {
1272: public Object[][] getContents() {
1273: return new Object[][] { { "THE_KEY", "list key" } };
1274: }
1275: });
1276: template_html.addResourceBundle(Localization.getResourceBundle(
1277: "localization/filtered-tags-l10n", "en"));
1278: assertEquals(
1279: "This is the localized key 'list key'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1280: template_html.getContent());
1281:
1282: template_html.clear();
1283: template_html.addResourceBundle(Localization.getResourceBundle(
1284: "localization/filtered-tags-l10n", "en"));
1285: template_html.addResourceBundle(new ListResourceBundle() {
1286: public Object[][] getContents() {
1287: return new Object[][] { { "THE_KEY", "list key" } };
1288: }
1289: });
1290: assertEquals(
1291: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1292: template_html.getContent());
1293:
1294: template_html.clear();
1295: template_html.addResourceBundle(new ListResourceBundle() {
1296: public Object[][] getContents() {
1297: return new Object[][] { { "THE_OTHER_KEY", "list key" } };
1298: }
1299: });
1300: template_html.addResourceBundle(Localization.getResourceBundle(
1301: "localization/filtered-tags-l10n", "en"));
1302: assertEquals(
1303: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1304: template_html.getContent());
1305: }
1306:
1307: public void testFilteredTagsL10nXhtml() throws Exception {
1308: Template template_xhtml = TemplateFactory.XHTML
1309: .get("filtered_tags_l10n");
1310: assertEquals(
1311: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1312: template_xhtml.getContent());
1313:
1314: template_xhtml.addResourceBundle(Localization
1315: .getResourceBundle("localization/filtered-tags-l10n",
1316: "en"));
1317: assertEquals(
1318: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1319: template_xhtml.getContent());
1320:
1321: template_xhtml.clear();
1322: template_xhtml.addResourceBundle(Localization
1323: .getResourceBundle("localization/filtered-tags-l10n",
1324: "nl"));
1325: assertEquals(
1326: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1327: template_xhtml.getContent());
1328:
1329: template_xhtml.clear();
1330: template_xhtml.addResourceBundle(Localization
1331: .getResourceBundle("localization/filtered-tags-l10n",
1332: "fr"));
1333: assertEquals(
1334: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1335: template_xhtml.getContent());
1336: }
1337:
1338: public void testFilteredTagsL10nXhtmlDefaultResourceBundles()
1339: throws Exception {
1340: Template template_xhtml;
1341:
1342: ArrayList<String> bundles = new ArrayList<String>();
1343: bundles.add("localization/filtered-tags-l10n");
1344: bundles.add("com.uwyn.rife.template.TestResourceBundleClass");
1345: RifeConfig.Template.setDefaultResourcebundles(
1346: TemplateFactory.XHTML, bundles);
1347:
1348: try {
1349: RifeConfig.Tools.setDefaultLanguage("en");
1350: template_xhtml = TemplateFactory.XHTML
1351: .get("filtered_tags_l10n");
1352: assertEquals(
1353: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1354: template_xhtml.getContent());
1355:
1356: RifeConfig.Tools.setDefaultLanguage("nl");
1357: template_xhtml = TemplateFactory.XHTML
1358: .get("filtered_tags_l10n");
1359: assertEquals(
1360: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1361: template_xhtml.getContent());
1362:
1363: RifeConfig.Tools.setDefaultLanguage("fr");
1364: template_xhtml = TemplateFactory.XHTML
1365: .get("filtered_tags_l10n");
1366: assertEquals(
1367: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1368: template_xhtml.getContent());
1369: } finally {
1370: RifeConfig.Template.setDefaultResourcebundles(
1371: TemplateFactory.XHTML, null);
1372: RifeConfig.Tools.setDefaultLanguage("en");
1373: }
1374: }
1375:
1376: public void testFilteredTagsL10nXhtmlSeveralResourcebundles()
1377: throws Exception {
1378: Template template_xhtml = TemplateFactory.XHTML
1379: .get("filtered_tags_l10n");
1380: assertEquals(
1381: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1382: template_xhtml.getContent());
1383:
1384: template_xhtml.addResourceBundle(new ListResourceBundle() {
1385: public Object[][] getContents() {
1386: return new Object[][] { { "THE_KEY", "list key" } };
1387: }
1388: });
1389: template_xhtml.addResourceBundle(Localization
1390: .getResourceBundle("localization/filtered-tags-l10n",
1391: "en"));
1392: assertEquals(
1393: "This is the localized key 'list key'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1394: template_xhtml.getContent());
1395:
1396: template_xhtml.clear();
1397: template_xhtml.addResourceBundle(Localization
1398: .getResourceBundle("localization/filtered-tags-l10n",
1399: "en"));
1400: template_xhtml.addResourceBundle(new ListResourceBundle() {
1401: public Object[][] getContents() {
1402: return new Object[][] { { "THE_KEY", "list key" } };
1403: }
1404: });
1405: assertEquals(
1406: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1407: template_xhtml.getContent());
1408:
1409: template_xhtml.clear();
1410: template_xhtml.addResourceBundle(new ListResourceBundle() {
1411: public Object[][] getContents() {
1412: return new Object[][] { { "THE_OTHER_KEY", "list key" } };
1413: }
1414: });
1415: template_xhtml.addResourceBundle(Localization
1416: .getResourceBundle("localization/filtered-tags-l10n",
1417: "en"));
1418: assertEquals(
1419: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1420: template_xhtml.getContent());
1421: }
1422:
1423: public void testFilteredTagsL10nXml() throws Exception {
1424: Template template_html = TemplateFactory.XML
1425: .get("filtered_tags_l10n");
1426: assertEquals(
1427: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1428: template_html.getContent());
1429:
1430: template_html.addResourceBundle(Localization.getResourceBundle(
1431: "localization/filtered-tags-l10n", "en"));
1432: assertEquals(
1433: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1434: template_html.getContent());
1435:
1436: template_html.clear();
1437: template_html.addResourceBundle(Localization.getResourceBundle(
1438: "localization/filtered-tags-l10n", "nl"));
1439: assertEquals(
1440: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1441: template_html.getContent());
1442:
1443: template_html.clear();
1444: template_html.addResourceBundle(Localization.getResourceBundle(
1445: "localization/filtered-tags-l10n", "fr"));
1446: assertEquals(
1447: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1448: template_html.getContent());
1449: }
1450:
1451: public void testFilteredTagsL10nXmlDefaultResourceBundles()
1452: throws Exception {
1453: Template template_xml;
1454:
1455: ArrayList<String> bundles = new ArrayList<String>();
1456: bundles.add("localization/filtered-tags-l10n");
1457: bundles.add("com.uwyn.rife.template.TestResourceBundleClass");
1458: RifeConfig.Template.setDefaultResourcebundles(
1459: TemplateFactory.XML, bundles);
1460:
1461: try {
1462: RifeConfig.Tools.setDefaultLanguage("en");
1463: template_xml = TemplateFactory.XML
1464: .get("filtered_tags_l10n");
1465: assertEquals(
1466: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1467: template_xml.getContent());
1468:
1469: RifeConfig.Tools.setDefaultLanguage("nl");
1470: template_xml = TemplateFactory.XML
1471: .get("filtered_tags_l10n");
1472: assertEquals(
1473: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1474: template_xml.getContent());
1475:
1476: RifeConfig.Tools.setDefaultLanguage("fr");
1477: template_xml = TemplateFactory.XML
1478: .get("filtered_tags_l10n");
1479: assertEquals(
1480: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1481: template_xml.getContent());
1482: } finally {
1483: RifeConfig.Template.setDefaultResourcebundles(
1484: TemplateFactory.XML, null);
1485: RifeConfig.Tools.setDefaultLanguage("en");
1486: }
1487: }
1488:
1489: public void testFilteredTagsL10nXmlSeveralResourcebundles()
1490: throws Exception {
1491: Template template_xml = TemplateFactory.XML
1492: .get("filtered_tags_l10n");
1493: assertEquals(
1494: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1495: template_xml.getContent());
1496:
1497: template_xml.addResourceBundle(new ListResourceBundle() {
1498: public Object[][] getContents() {
1499: return new Object[][] { { "THE_KEY", "list key" } };
1500: }
1501: });
1502: template_xml.addResourceBundle(Localization.getResourceBundle(
1503: "localization/filtered-tags-l10n", "en"));
1504: assertEquals(
1505: "This is the localized key 'list key'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1506: template_xml.getContent());
1507:
1508: template_xml.clear();
1509: template_xml.addResourceBundle(Localization.getResourceBundle(
1510: "localization/filtered-tags-l10n", "en"));
1511: template_xml.addResourceBundle(new ListResourceBundle() {
1512: public Object[][] getContents() {
1513: return new Object[][] { { "THE_KEY", "list key" } };
1514: }
1515: });
1516: assertEquals(
1517: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1518: template_xml.getContent());
1519:
1520: template_xml.clear();
1521: template_xml.addResourceBundle(new ListResourceBundle() {
1522: public Object[][] getContents() {
1523: return new Object[][] { { "THE_OTHER_KEY", "list key" } };
1524: }
1525: });
1526: template_xml.addResourceBundle(Localization.getResourceBundle(
1527: "localization/filtered-tags-l10n", "en"));
1528: assertEquals(
1529: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1530: template_xml.getContent());
1531: }
1532:
1533: public void testFilteredTagsL10nTxt() throws Exception {
1534: Template template_txt = TemplateFactory.TXT
1535: .get("filtered_tags_l10n");
1536: assertEquals(
1537: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1538: template_txt.getContent());
1539:
1540: template_txt.addResourceBundle(Localization.getResourceBundle(
1541: "localization/filtered-tags-l10n", "en"));
1542: assertEquals(
1543: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1544: template_txt.getContent());
1545:
1546: template_txt.clear();
1547: template_txt.addResourceBundle(Localization.getResourceBundle(
1548: "localization/filtered-tags-l10n", "nl"));
1549: assertEquals(
1550: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1551: template_txt.getContent());
1552:
1553: template_txt.clear();
1554: template_txt.addResourceBundle(Localization.getResourceBundle(
1555: "localization/filtered-tags-l10n", "fr"));
1556: assertEquals(
1557: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1558: template_txt.getContent());
1559: }
1560:
1561: public void testFilteredTagsL10nTxtDefaultResourceBundles()
1562: throws Exception {
1563: Template template_txt;
1564:
1565: ArrayList<String> bundles = new ArrayList<String>();
1566: bundles.add("localization/filtered-tags-l10n");
1567: bundles.add("com.uwyn.rife.template.TestResourceBundleClass");
1568: RifeConfig.Template.setDefaultResourcebundles(
1569: TemplateFactory.TXT, bundles);
1570:
1571: try {
1572: RifeConfig.Tools.setDefaultLanguage("en");
1573: template_txt = TemplateFactory.TXT
1574: .get("filtered_tags_l10n");
1575: assertEquals(
1576: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1577: template_txt.getContent());
1578:
1579: RifeConfig.Tools.setDefaultLanguage("nl");
1580: template_txt = TemplateFactory.TXT
1581: .get("filtered_tags_l10n");
1582: assertEquals(
1583: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1584: template_txt.getContent());
1585:
1586: RifeConfig.Tools.setDefaultLanguage("fr");
1587: template_txt = TemplateFactory.TXT
1588: .get("filtered_tags_l10n");
1589: assertEquals(
1590: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1591: template_txt.getContent());
1592: } finally {
1593: RifeConfig.Template.setDefaultResourcebundles(
1594: TemplateFactory.TXT, null);
1595: RifeConfig.Tools.setDefaultLanguage("en");
1596: }
1597: }
1598:
1599: public void testFilteredTagsL10nTxtSeveralResourcebundles()
1600: throws Exception {
1601: Template template_txt = TemplateFactory.TXT
1602: .get("filtered_tags_l10n");
1603: assertEquals(
1604: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1605: template_txt.getContent());
1606:
1607: template_txt.addResourceBundle(new ListResourceBundle() {
1608: public Object[][] getContents() {
1609: return new Object[][] { { "THE_KEY", "list key" } };
1610: }
1611: });
1612: template_txt.addResourceBundle(Localization.getResourceBundle(
1613: "localization/filtered-tags-l10n", "en"));
1614: assertEquals(
1615: "This is the localized key 'list key'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1616: template_txt.getContent());
1617:
1618: template_txt.clear();
1619: template_txt.addResourceBundle(Localization.getResourceBundle(
1620: "localization/filtered-tags-l10n", "en"));
1621: template_txt.addResourceBundle(new ListResourceBundle() {
1622: public Object[][] getContents() {
1623: return new Object[][] { { "THE_KEY", "list key" } };
1624: }
1625: });
1626: assertEquals(
1627: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1628: template_txt.getContent());
1629:
1630: template_txt.clear();
1631: template_txt.addResourceBundle(new ListResourceBundle() {
1632: public Object[][] getContents() {
1633: return new Object[][] { { "THE_OTHER_KEY", "list key" } };
1634: }
1635: });
1636: template_txt.addResourceBundle(Localization.getResourceBundle(
1637: "localization/filtered-tags-l10n", "en"));
1638: assertEquals(
1639: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1640: template_txt.getContent());
1641: }
1642:
1643: public void testFilteredTagsL10nSql() throws Exception {
1644: Template template_sql = TemplateFactory.SQL
1645: .get("filtered_tags_l10n");
1646: assertEquals(
1647: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1648: template_sql.getContent());
1649:
1650: template_sql.addResourceBundle(Localization.getResourceBundle(
1651: "localization/filtered-tags-l10n", "en"));
1652: assertEquals(
1653: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1654: template_sql.getContent());
1655:
1656: template_sql.clear();
1657: template_sql.addResourceBundle(Localization.getResourceBundle(
1658: "localization/filtered-tags-l10n", "nl"));
1659: assertEquals(
1660: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1661: template_sql.getContent());
1662:
1663: template_sql.clear();
1664: template_sql.addResourceBundle(Localization.getResourceBundle(
1665: "localization/filtered-tags-l10n", "fr"));
1666: assertEquals(
1667: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1668: template_sql.getContent());
1669: }
1670:
1671: public void testFilteredTagsL10nSqlDefaultResourceBundles()
1672: throws Exception {
1673: Template template_sql;
1674:
1675: ArrayList<String> bundles = new ArrayList<String>();
1676: bundles.add("localization/filtered-tags-l10n");
1677: bundles.add("com.uwyn.rife.template.TestResourceBundleClass");
1678: RifeConfig.Template.setDefaultResourcebundles(
1679: TemplateFactory.SQL, bundles);
1680:
1681: try {
1682: RifeConfig.Tools.setDefaultLanguage("en");
1683: template_sql = TemplateFactory.SQL
1684: .get("filtered_tags_l10n");
1685: assertEquals(
1686: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1687: template_sql.getContent());
1688:
1689: RifeConfig.Tools.setDefaultLanguage("nl");
1690: template_sql = TemplateFactory.SQL
1691: .get("filtered_tags_l10n");
1692: assertEquals(
1693: "This is the localized key 'De Nederlandse tekst'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1694: template_sql.getContent());
1695:
1696: RifeConfig.Tools.setDefaultLanguage("fr");
1697: template_sql = TemplateFactory.SQL
1698: .get("filtered_tags_l10n");
1699: assertEquals(
1700: "This is the localized key 'Le texte Francais'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key 'list key class'.\n",
1701: template_sql.getContent());
1702: } finally {
1703: RifeConfig.Template.setDefaultResourcebundles(
1704: TemplateFactory.SQL, null);
1705: RifeConfig.Tools.setDefaultLanguage("en");
1706: }
1707: }
1708:
1709: public void testFilteredTagsL10nSqlSeveralResourcebundles()
1710: throws Exception {
1711: Template template_sql = TemplateFactory.SQL
1712: .get("filtered_tags_l10n");
1713: assertEquals(
1714: "This is the localized key 'default value'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1715: template_sql.getContent());
1716:
1717: template_sql.addResourceBundle(new ListResourceBundle() {
1718: public Object[][] getContents() {
1719: return new Object[][] { { "THE_KEY", "list key" } };
1720: }
1721: });
1722: template_sql.addResourceBundle(Localization.getResourceBundle(
1723: "localization/filtered-tags-l10n", "en"));
1724: assertEquals(
1725: "This is the localized key 'list key'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1726: template_sql.getContent());
1727:
1728: template_sql.clear();
1729: template_sql.addResourceBundle(Localization.getResourceBundle(
1730: "localization/filtered-tags-l10n", "en"));
1731: template_sql.addResourceBundle(new ListResourceBundle() {
1732: public Object[][] getContents() {
1733: return new Object[][] { { "THE_KEY", "list key" } };
1734: }
1735: });
1736: assertEquals(
1737: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1738: template_sql.getContent());
1739:
1740: template_sql.clear();
1741: template_sql.addResourceBundle(new ListResourceBundle() {
1742: public Object[][] getContents() {
1743: return new Object[][] { { "THE_OTHER_KEY", "list key" } };
1744: }
1745: });
1746: template_sql.addResourceBundle(Localization.getResourceBundle(
1747: "localization/filtered-tags-l10n", "en"));
1748: assertEquals(
1749: "This is the localized key 'The English text'.\nThis is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\nThis is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1750: template_sql.getContent());
1751: }
1752:
1753: public void testFilteredTagsL10nJava() throws Exception {
1754: Template template_java = TemplateFactory.JAVA
1755: .get("filtered_tags_l10n");
1756: assertEquals(
1757: "// This is the localized key 'default value'.\n// This is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\n// This is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1758: template_java.getContent());
1759:
1760: template_java.addResourceBundle(Localization.getResourceBundle(
1761: "localization/filtered-tags-l10n", "en"));
1762: assertEquals(
1763: "// This is the localized key 'The English text'.\n// This is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\n// This is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1764: template_java.getContent());
1765:
1766: template_java.clear();
1767: template_java.addResourceBundle(Localization.getResourceBundle(
1768: "localization/filtered-tags-l10n", "nl"));
1769: assertEquals(
1770: "// This is the localized key 'De Nederlandse tekst'.\n// This is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\n// This is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1771: template_java.getContent());
1772:
1773: template_java.clear();
1774: template_java.addResourceBundle(Localization.getResourceBundle(
1775: "localization/filtered-tags-l10n", "fr"));
1776: assertEquals(
1777: "// This is the localized key 'Le texte Francais'.\n// This is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\n// This is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1778: template_java.getContent());
1779: }
1780:
1781: public void testFilteredTagsL10nJavaDefaultResourceBundles()
1782: throws Exception {
1783: Template template_java;
1784:
1785: ArrayList<String> bundles = new ArrayList<String>();
1786: bundles.add("localization/filtered-tags-l10n");
1787: bundles.add("com.uwyn.rife.template.TestResourceBundleClass");
1788: RifeConfig.Template.setDefaultResourcebundles(
1789: TemplateFactory.JAVA, bundles);
1790:
1791: try {
1792: RifeConfig.Tools.setDefaultLanguage("en");
1793: template_java = TemplateFactory.JAVA
1794: .get("filtered_tags_l10n");
1795: assertEquals(
1796: "// This is the localized key 'The English text'.\n// This is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\n// This is a class key 'list key class'.\n",
1797: template_java.getContent());
1798:
1799: RifeConfig.Tools.setDefaultLanguage("nl");
1800: template_java = TemplateFactory.JAVA
1801: .get("filtered_tags_l10n");
1802: assertEquals(
1803: "// This is the localized key 'De Nederlandse tekst'.\n// This is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\n// This is a class key 'list key class'.\n",
1804: template_java.getContent());
1805:
1806: RifeConfig.Tools.setDefaultLanguage("fr");
1807: template_java = TemplateFactory.JAVA
1808: .get("filtered_tags_l10n");
1809: assertEquals(
1810: "// This is the localized key 'Le texte Francais'.\n// This is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\n// This is a class key 'list key class'.\n",
1811: template_java.getContent());
1812: } finally {
1813: RifeConfig.Template.setDefaultResourcebundles(
1814: TemplateFactory.JAVA, null);
1815: RifeConfig.Tools.setDefaultLanguage("en");
1816: }
1817: }
1818:
1819: public void testFilteredTagsL10nJavaSeveralResourcebundles()
1820: throws Exception {
1821: Template template_java = TemplateFactory.JAVA
1822: .get("filtered_tags_l10n");
1823: assertEquals(
1824: "// This is the localized key 'default value'.\n// This is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\n// This is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1825: template_java.getContent());
1826:
1827: template_java.addResourceBundle(new ListResourceBundle() {
1828: public Object[][] getContents() {
1829: return new Object[][] { { "THE_KEY", "list key" } };
1830: }
1831: });
1832: template_java.addResourceBundle(Localization.getResourceBundle(
1833: "localization/filtered-tags-l10n", "en"));
1834: assertEquals(
1835: "// This is the localized key 'list key'.\n// This is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\n// This is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1836: template_java.getContent());
1837:
1838: template_java.clear();
1839: template_java.addResourceBundle(Localization.getResourceBundle(
1840: "localization/filtered-tags-l10n", "en"));
1841: template_java.addResourceBundle(new ListResourceBundle() {
1842: public Object[][] getContents() {
1843: return new Object[][] { { "THE_KEY", "list key" } };
1844: }
1845: });
1846: assertEquals(
1847: "// This is the localized key 'The English text'.\n// This is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\n// This is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1848: template_java.getContent());
1849:
1850: template_java.clear();
1851: template_java.addResourceBundle(new ListResourceBundle() {
1852: public Object[][] getContents() {
1853: return new Object[][] { { "THE_OTHER_KEY", "list key" } };
1854: }
1855: });
1856: template_java.addResourceBundle(Localization.getResourceBundle(
1857: "localization/filtered-tags-l10n", "en"));
1858: assertEquals(
1859: "// This is the localized key 'The English text'.\n// This is an unknown key '[!V 'L10N:UNKNOWN_KEY'/]'.\n// This is a class key '[!V 'L10N:THE_CLASS_KEY'/]'.\n",
1860: template_java.getContent());
1861: }
1862:
1863: public void testFilteredTagsLangEngineHtml() throws Exception {
1864: Template template_html = TemplateFactory.ENGINEHTML
1865: .get("filtered_tags_lang");
1866: assertEquals(
1867: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
1868: template_html.getContent());
1869:
1870: template_html = TemplateFactory.ENGINEHTML
1871: .get("filtered_tags_lang");
1872: RifeConfig.Tools.setDefaultLanguage("nl");
1873: assertEquals(
1874: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
1875: template_html.getContent());
1876:
1877: template_html = TemplateFactory.ENGINEHTML
1878: .get("filtered_tags_lang");
1879: RifeConfig.Tools.setDefaultLanguage("fr");
1880: assertEquals(
1881: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
1882: template_html.getContent());
1883:
1884: RifeConfig.Tools.setDefaultLanguage(null);
1885:
1886: template_html = TemplateFactory.ENGINEHTML
1887: .get("filtered_tags_lang");
1888: template_html.setLanguage("en");
1889: assertEquals(
1890: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
1891: template_html.getContent());
1892:
1893: template_html = TemplateFactory.ENGINEHTML
1894: .get("filtered_tags_lang");
1895: template_html.setLanguage("nl");
1896: assertEquals(
1897: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
1898: template_html.getContent());
1899:
1900: template_html = TemplateFactory.ENGINEHTML
1901: .get("filtered_tags_lang");
1902: template_html.setLanguage("fr");
1903: assertEquals(
1904: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
1905: template_html.getContent());
1906: }
1907:
1908: public void testFilteredTagsLangEngineXhtml() throws Exception {
1909: Template template_xhtml = TemplateFactory.ENGINEXHTML
1910: .get("filtered_tags_lang");
1911: assertEquals(
1912: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
1913: template_xhtml.getContent());
1914:
1915: template_xhtml = TemplateFactory.ENGINEXHTML
1916: .get("filtered_tags_lang");
1917: RifeConfig.Tools.setDefaultLanguage("nl");
1918: assertEquals(
1919: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
1920: template_xhtml.getContent());
1921:
1922: template_xhtml = TemplateFactory.ENGINEXHTML
1923: .get("filtered_tags_lang");
1924: RifeConfig.Tools.setDefaultLanguage("fr");
1925: assertEquals(
1926: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
1927: template_xhtml.getContent());
1928:
1929: RifeConfig.Tools.setDefaultLanguage(null);
1930:
1931: template_xhtml = TemplateFactory.ENGINEXHTML
1932: .get("filtered_tags_lang");
1933: template_xhtml.setLanguage("en");
1934: assertEquals(
1935: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
1936: template_xhtml.getContent());
1937:
1938: template_xhtml = TemplateFactory.ENGINEXHTML
1939: .get("filtered_tags_lang");
1940: template_xhtml.setLanguage("nl");
1941: assertEquals(
1942: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
1943: template_xhtml.getContent());
1944:
1945: template_xhtml = TemplateFactory.ENGINEXHTML
1946: .get("filtered_tags_lang");
1947: template_xhtml.setLanguage("fr");
1948: assertEquals(
1949: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
1950: template_xhtml.getContent());
1951: }
1952:
1953: public void testFilteredTagsLangEngineXml() throws Exception {
1954: Template template_xml = TemplateFactory.ENGINEXML
1955: .get("filtered_tags_lang");
1956: assertEquals(
1957: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
1958: template_xml.getContent());
1959:
1960: template_xml = TemplateFactory.ENGINEXML
1961: .get("filtered_tags_lang");
1962: RifeConfig.Tools.setDefaultLanguage("nl");
1963: assertEquals(
1964: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
1965: template_xml.getContent());
1966:
1967: template_xml = TemplateFactory.ENGINEXML
1968: .get("filtered_tags_lang");
1969: RifeConfig.Tools.setDefaultLanguage("fr");
1970: assertEquals(
1971: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
1972: template_xml.getContent());
1973:
1974: RifeConfig.Tools.setDefaultLanguage(null);
1975:
1976: template_xml = TemplateFactory.ENGINEXML
1977: .get("filtered_tags_lang");
1978: template_xml.setLanguage("en");
1979: assertEquals(
1980: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
1981: template_xml.getContent());
1982:
1983: template_xml = TemplateFactory.ENGINEXML
1984: .get("filtered_tags_lang");
1985: template_xml.setLanguage("nl");
1986: assertEquals(
1987: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
1988: template_xml.getContent());
1989:
1990: template_xml = TemplateFactory.ENGINEXML
1991: .get("filtered_tags_lang");
1992: template_xml.setLanguage("fr");
1993: assertEquals(
1994: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
1995: template_xml.getContent());
1996: }
1997:
1998: public void testFilteredTagsLangEngineTxt() throws Exception {
1999: Template template_txt = TemplateFactory.ENGINETXT
2000: .get("filtered_tags_lang");
2001: assertEquals(
2002: "This expression is Dutch '<!V 'LANG:value1'/>'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
2003: template_txt.getContent());
2004:
2005: template_txt = TemplateFactory.ENGINETXT
2006: .get("filtered_tags_lang");
2007: RifeConfig.Tools.setDefaultLanguage("nl");
2008: assertEquals(
2009: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
2010: template_txt.getContent());
2011:
2012: template_txt = TemplateFactory.ENGINETXT
2013: .get("filtered_tags_lang");
2014: RifeConfig.Tools.setDefaultLanguage("fr");
2015: assertEquals(
2016: "This expression is Dutch '<!V 'LANG:value1'/>'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
2017: template_txt.getContent());
2018:
2019: RifeConfig.Tools.setDefaultLanguage(null);
2020:
2021: template_txt = TemplateFactory.ENGINETXT
2022: .get("filtered_tags_lang");
2023: template_txt.setLanguage("en");
2024: assertEquals(
2025: "This expression is Dutch '<!V 'LANG:value1'/>'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
2026: template_txt.getContent());
2027:
2028: template_txt = TemplateFactory.ENGINETXT
2029: .get("filtered_tags_lang");
2030: template_txt.setLanguage("nl");
2031: assertEquals(
2032: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
2033: template_txt.getContent());
2034:
2035: template_txt = TemplateFactory.ENGINETXT
2036: .get("filtered_tags_lang");
2037: template_txt.setLanguage("fr");
2038: assertEquals(
2039: "This expression is Dutch '<!V 'LANG:value1'/>'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
2040: template_txt.getContent());
2041: }
2042:
2043: public void testFilteredTagsLangHtml() throws Exception {
2044: Template template_html = TemplateFactory.HTML
2045: .get("filtered_tags_lang");
2046: assertEquals(
2047: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
2048: template_html.getContent());
2049:
2050: template_html = TemplateFactory.HTML.get("filtered_tags_lang");
2051: RifeConfig.Tools.setDefaultLanguage("nl");
2052: assertEquals(
2053: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
2054: template_html.getContent());
2055:
2056: template_html = TemplateFactory.HTML.get("filtered_tags_lang");
2057: RifeConfig.Tools.setDefaultLanguage("fr");
2058: assertEquals(
2059: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
2060: template_html.getContent());
2061:
2062: RifeConfig.Tools.setDefaultLanguage(null);
2063:
2064: template_html = TemplateFactory.HTML.get("filtered_tags_lang");
2065: template_html.setLanguage("en");
2066: assertEquals(
2067: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
2068: template_html.getContent());
2069:
2070: template_html = TemplateFactory.HTML.get("filtered_tags_lang");
2071: template_html.setLanguage("nl");
2072: assertEquals(
2073: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
2074: template_html.getContent());
2075:
2076: template_html = TemplateFactory.HTML.get("filtered_tags_lang");
2077: template_html.setLanguage("fr");
2078: assertEquals(
2079: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
2080: template_html.getContent());
2081: }
2082:
2083: public void testFilteredTagsLangXhtml() throws Exception {
2084: Template template_xhtml = TemplateFactory.XHTML
2085: .get("filtered_tags_lang");
2086: assertEquals(
2087: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
2088: template_xhtml.getContent());
2089:
2090: template_xhtml = TemplateFactory.XHTML
2091: .get("filtered_tags_lang");
2092: RifeConfig.Tools.setDefaultLanguage("nl");
2093: assertEquals(
2094: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
2095: template_xhtml.getContent());
2096:
2097: template_xhtml = TemplateFactory.XHTML
2098: .get("filtered_tags_lang");
2099: RifeConfig.Tools.setDefaultLanguage("fr");
2100: assertEquals(
2101: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
2102: template_xhtml.getContent());
2103:
2104: RifeConfig.Tools.setDefaultLanguage(null);
2105:
2106: template_xhtml = TemplateFactory.XHTML
2107: .get("filtered_tags_lang");
2108: template_xhtml.setLanguage("en");
2109: assertEquals(
2110: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
2111: template_xhtml.getContent());
2112:
2113: template_xhtml = TemplateFactory.XHTML
2114: .get("filtered_tags_lang");
2115: template_xhtml.setLanguage("nl");
2116: assertEquals(
2117: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
2118: template_xhtml.getContent());
2119:
2120: template_xhtml = TemplateFactory.XHTML
2121: .get("filtered_tags_lang");
2122: template_xhtml.setLanguage("fr");
2123: assertEquals(
2124: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
2125: template_xhtml.getContent());
2126: }
2127:
2128: public void testFilteredTagsLangXml() throws Exception {
2129: Template template_xml = TemplateFactory.XML
2130: .get("filtered_tags_lang");
2131: assertEquals(
2132: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
2133: template_xml.getContent());
2134:
2135: template_xml = TemplateFactory.XML.get("filtered_tags_lang");
2136: RifeConfig.Tools.setDefaultLanguage("nl");
2137: assertEquals(
2138: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
2139: template_xml.getContent());
2140:
2141: template_xml = TemplateFactory.XML.get("filtered_tags_lang");
2142: RifeConfig.Tools.setDefaultLanguage("fr");
2143: assertEquals(
2144: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
2145: template_xml.getContent());
2146:
2147: RifeConfig.Tools.setDefaultLanguage(null);
2148:
2149: template_xml = TemplateFactory.XML.get("filtered_tags_lang");
2150: template_xml.setLanguage("en");
2151: assertEquals(
2152: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
2153: template_xml.getContent());
2154:
2155: template_xml = TemplateFactory.XML.get("filtered_tags_lang");
2156: template_xml.setLanguage("nl");
2157: assertEquals(
2158: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
2159: template_xml.getContent());
2160:
2161: template_xml = TemplateFactory.XML.get("filtered_tags_lang");
2162: template_xml.setLanguage("fr");
2163: assertEquals(
2164: "This expression is Dutch '<!--V 'LANG:value1'/-->'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
2165: template_xml.getContent());
2166: }
2167:
2168: public void testFilteredTagsLangSql() throws Exception {
2169: Template template_sql = TemplateFactory.SQL
2170: .get("filtered_tags_lang");
2171: assertEquals(
2172: "This expression is Dutch '/*V 'LANG:value1'-*/'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
2173: template_sql.getContent());
2174:
2175: template_sql = TemplateFactory.SQL.get("filtered_tags_lang");
2176: RifeConfig.Tools.setDefaultLanguage("nl");
2177: assertEquals(
2178: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
2179: template_sql.getContent());
2180:
2181: template_sql = TemplateFactory.SQL.get("filtered_tags_lang");
2182: RifeConfig.Tools.setDefaultLanguage("fr");
2183: assertEquals(
2184: "This expression is Dutch '/*V 'LANG:value1'-*/'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
2185: template_sql.getContent());
2186:
2187: RifeConfig.Tools.setDefaultLanguage(null);
2188:
2189: template_sql = TemplateFactory.SQL.get("filtered_tags_lang");
2190: template_sql.setLanguage("en");
2191: assertEquals(
2192: "This expression is Dutch '/*V 'LANG:value1'-*/'.\nThis expression is French or English 'yes yes'.\n\n\n\n",
2193: template_sql.getContent());
2194:
2195: template_sql = TemplateFactory.SQL.get("filtered_tags_lang");
2196: template_sql.setLanguage("nl");
2197: assertEquals(
2198: "This expression is Dutch 'ja ja'.\nThis expression is French or English '[!V 'LANG:value2'/]'.\n\n\n\n",
2199: template_sql.getContent());
2200:
2201: template_sql = TemplateFactory.SQL.get("filtered_tags_lang");
2202: template_sql.setLanguage("fr");
2203: assertEquals(
2204: "This expression is Dutch '/*V 'LANG:value1'-*/'.\nThis expression is French or English 'oui oui'.\n\n\n\n",
2205: template_sql.getContent());
2206: }
2207:
2208: public void testFilteredTagsLangJava() throws Exception {
2209: Template template_java = TemplateFactory.JAVA
2210: .get("filtered_tags_lang");
2211: assertEquals(
2212: "//This expression is Dutch '/*V 'LANG:value1'-*/'.\n//This expression is French or English 'yes yes'.\n//\n//\n//\n",
2213: template_java.getContent());
2214:
2215: template_java = TemplateFactory.JAVA.get("filtered_tags_lang");
2216: RifeConfig.Tools.setDefaultLanguage("nl");
2217: assertEquals(
2218: "//This expression is Dutch 'ja ja'.\n//This expression is French or English '[!V 'LANG:value2'/]'.\n//\n//\n//\n",
2219: template_java.getContent());
2220:
2221: template_java = TemplateFactory.JAVA.get("filtered_tags_lang");
2222: RifeConfig.Tools.setDefaultLanguage("fr");
2223: assertEquals(
2224: "//This expression is Dutch '/*V 'LANG:value1'-*/'.\n//This expression is French or English 'oui oui'.\n//\n//\n//\n",
2225: template_java.getContent());
2226:
2227: RifeConfig.Tools.setDefaultLanguage(null);
2228:
2229: template_java = TemplateFactory.JAVA.get("filtered_tags_lang");
2230: template_java.setLanguage("en");
2231: assertEquals(
2232: "//This expression is Dutch '/*V 'LANG:value1'-*/'.\n//This expression is French or English 'yes yes'.\n//\n//\n//\n",
2233: template_java.getContent());
2234:
2235: template_java = TemplateFactory.JAVA.get("filtered_tags_lang");
2236: template_java.setLanguage("nl");
2237: assertEquals(
2238: "//This expression is Dutch 'ja ja'.\n//This expression is French or English '[!V 'LANG:value2'/]'.\n//\n//\n//\n",
2239: template_java.getContent());
2240:
2241: template_java = TemplateFactory.JAVA.get("filtered_tags_lang");
2242: template_java.setLanguage("fr");
2243: assertEquals(
2244: "//This expression is Dutch '/*V 'LANG:value1'-*/'.\n//This expression is French or English 'oui oui'.\n//\n//\n//\n",
2245: template_java.getContent());
2246: }
2247:
2248: public void testFilteredTagsOgnlConfigEngineHtml() throws Exception {
2249: Template template_html = TemplateFactory.ENGINEHTML
2250: .get("filtered_tags_ognl_config");
2251: template_html.setExpressionVar("thevalue", "the wrong value");
2252: assertEquals(
2253: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2254: template_html.getContent());
2255: template_html.setExpressionVar("thevalue", "the value");
2256: assertEquals(
2257: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2258: template_html.getContent());
2259:
2260: Map<String, Object> map = new HashMap<String, Object>();
2261: template_html = TemplateFactory.ENGINEHTML
2262: .get("filtered_tags_ognl_config");
2263: template_html.setExpressionVars(map);
2264: map.put("thevalue", "the wrong value");
2265: assertEquals(
2266: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2267: template_html.getContent());
2268: map.put("thevalue", "the value");
2269: assertEquals(
2270: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2271: template_html.getContent());
2272: }
2273:
2274: public void testFilteredTagsOgnlConfigEngineXhtml()
2275: throws Exception {
2276: Template template_xhtml = TemplateFactory.ENGINEXHTML
2277: .get("filtered_tags_ognl_config");
2278: template_xhtml.setExpressionVar("thevalue", "the wrong value");
2279: assertEquals(
2280: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2281: template_xhtml.getContent());
2282: template_xhtml.setExpressionVar("thevalue", "the value");
2283: assertEquals(
2284: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2285: template_xhtml.getContent());
2286:
2287: Map<String, Object> map = new HashMap<String, Object>();
2288: template_xhtml = TemplateFactory.ENGINEXHTML
2289: .get("filtered_tags_ognl_config");
2290: template_xhtml.setExpressionVars(map);
2291: map.put("thevalue", "the wrong value");
2292: assertEquals(
2293: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2294: template_xhtml.getContent());
2295: map.put("thevalue", "the value");
2296: assertEquals(
2297: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2298: template_xhtml.getContent());
2299: }
2300:
2301: public void testFilteredTagsOgnlConfigEngineXml() throws Exception {
2302: Template template_xml = TemplateFactory.ENGINEXML
2303: .get("filtered_tags_ognl_config");
2304: template_xml.setExpressionVar("thevalue", "the wrong value");
2305: assertEquals(
2306: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2307: template_xml.getContent());
2308: template_xml.setExpressionVar("thevalue", "the value");
2309: assertEquals(
2310: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2311: template_xml.getContent());
2312:
2313: Map<String, Object> map = new HashMap<String, Object>();
2314: template_xml = TemplateFactory.ENGINEXML
2315: .get("filtered_tags_ognl_config");
2316: template_xml.setExpressionVars(map);
2317: map.put("thevalue", "the wrong value");
2318: assertEquals(
2319: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2320: template_xml.getContent());
2321: map.put("thevalue", "the value");
2322: assertEquals(
2323: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2324: template_xml.getContent());
2325: }
2326:
2327: public void testFilteredTagsOgnlConfigEngineTxt() throws Exception {
2328: Template template_txt = TemplateFactory.ENGINETXT
2329: .get("filtered_tags_ognl_config");
2330: template_txt.setExpressionVar("thevalue", "the wrong value");
2331: assertEquals(
2332: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2333: template_txt.getContent());
2334: template_txt.setExpressionVar("thevalue", "the value");
2335: assertEquals(
2336: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2337: template_txt.getContent());
2338:
2339: Map<String, Object> map = new HashMap<String, Object>();
2340: template_txt = TemplateFactory.ENGINETXT
2341: .get("filtered_tags_ognl_config");
2342: template_txt.setExpressionVars(map);
2343: map.put("thevalue", "the wrong value");
2344: assertEquals(
2345: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2346: template_txt.getContent());
2347: map.put("thevalue", "the value");
2348: assertEquals(
2349: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2350: template_txt.getContent());
2351: }
2352:
2353: public void testFilteredTagsOgnlConfigHtml() throws Exception {
2354: Template template_html = TemplateFactory.HTML
2355: .get("filtered_tags_ognl_config");
2356: template_html.setExpressionVar("thevalue", "the wrong value");
2357: assertEquals(
2358: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2359: template_html.getContent());
2360: template_html.setExpressionVar("thevalue", "the value");
2361: assertEquals(
2362: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2363: template_html.getContent());
2364:
2365: Map<String, Object> map = new HashMap<String, Object>();
2366: template_html = TemplateFactory.HTML
2367: .get("filtered_tags_ognl_config");
2368: template_html.setExpressionVars(map);
2369: map.put("thevalue", "the wrong value");
2370: assertEquals(
2371: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2372: template_html.getContent());
2373: map.put("thevalue", "the value");
2374: assertEquals(
2375: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2376: template_html.getContent());
2377: }
2378:
2379: public void testFilteredTagsOgnlConfigXhtml() throws Exception {
2380: Template template_xhtml = TemplateFactory.XHTML
2381: .get("filtered_tags_ognl_config");
2382: template_xhtml.setExpressionVar("thevalue", "the wrong value");
2383: assertEquals(
2384: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2385: template_xhtml.getContent());
2386: template_xhtml.setExpressionVar("thevalue", "the value");
2387: assertEquals(
2388: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2389: template_xhtml.getContent());
2390:
2391: Map<String, Object> map = new HashMap<String, Object>();
2392: template_xhtml = TemplateFactory.XHTML
2393: .get("filtered_tags_ognl_config");
2394: template_xhtml.setExpressionVars(map);
2395: map.put("thevalue", "the wrong value");
2396: assertEquals(
2397: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2398: template_xhtml.getContent());
2399: map.put("thevalue", "the value");
2400: assertEquals(
2401: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2402: template_xhtml.getContent());
2403: }
2404:
2405: public void testFilteredTagsOgnlConfigXml() throws Exception {
2406: Template template_xml = TemplateFactory.XML
2407: .get("filtered_tags_ognl_config");
2408: template_xml.setExpressionVar("thevalue", "the wrong value");
2409: assertEquals(
2410: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2411: template_xml.getContent());
2412: template_xml.setExpressionVar("thevalue", "the value");
2413: assertEquals(
2414: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2415: template_xml.getContent());
2416:
2417: Map<String, Object> map = new HashMap<String, Object>();
2418: template_xml = TemplateFactory.XML
2419: .get("filtered_tags_ognl_config");
2420: template_xml.setExpressionVars(map);
2421: map.put("thevalue", "the wrong value");
2422: assertEquals(
2423: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2424: template_xml.getContent());
2425: map.put("thevalue", "the value");
2426: assertEquals(
2427: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2428: template_xml.getContent());
2429: }
2430:
2431: public void testFilteredTagsOgnlConfigTxt() throws Exception {
2432: Template template_txt = TemplateFactory.TXT
2433: .get("filtered_tags_ognl_config");
2434: template_txt.setExpressionVar("thevalue", "the wrong value");
2435: assertEquals(
2436: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2437: template_txt.getContent());
2438: template_txt.setExpressionVar("thevalue", "the value");
2439: assertEquals(
2440: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2441: template_txt.getContent());
2442:
2443: Map<String, Object> map = new HashMap<String, Object>();
2444: template_txt = TemplateFactory.TXT
2445: .get("filtered_tags_ognl_config");
2446: template_txt.setExpressionVars(map);
2447: map.put("thevalue", "the wrong value");
2448: assertEquals(
2449: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2450: template_txt.getContent());
2451: map.put("thevalue", "the value");
2452: assertEquals(
2453: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2454: template_txt.getContent());
2455: }
2456:
2457: public void testFilteredTagsOgnlConfigSql() throws Exception {
2458: Template template_sql = TemplateFactory.SQL
2459: .get("filtered_tags_ognl_config");
2460: template_sql.setExpressionVar("thevalue", "the wrong value");
2461: assertEquals(
2462: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2463: template_sql.getContent());
2464: template_sql.setExpressionVar("thevalue", "the value");
2465: assertEquals(
2466: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2467: template_sql.getContent());
2468:
2469: Map<String, Object> map = new HashMap<String, Object>();
2470: template_sql = TemplateFactory.SQL
2471: .get("filtered_tags_ognl_config");
2472: template_sql.setExpressionVars(map);
2473: map.put("thevalue", "the wrong value");
2474: assertEquals(
2475: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n\n\n\n",
2476: template_sql.getContent());
2477: map.put("thevalue", "the value");
2478: assertEquals(
2479: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2480: template_sql.getContent());
2481: }
2482:
2483: public void testFilteredTagsOgnlConfigJava() throws Exception {
2484: Template template_java = TemplateFactory.JAVA
2485: .get("filtered_tags_ognl_config");
2486: template_java.setExpressionVar("thevalue", "the wrong value");
2487: assertEquals(
2488: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\n//This config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n//\n//\n//\n",
2489: template_java.getContent());
2490: template_java.setExpressionVar("thevalue", "the value");
2491: assertEquals(
2492: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\n//This config value expression is dynamic 'dynamic value'.\n//\n//\n//\n",
2493: template_java.getContent());
2494:
2495: Map<String, Object> map = new HashMap<String, Object>();
2496: template_java = TemplateFactory.JAVA
2497: .get("filtered_tags_ognl_config");
2498: template_java.setExpressionVars(map);
2499: map.put("thevalue", "the wrong value");
2500: assertEquals(
2501: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\n//This config value expression is dynamic '[!V 'OGNL:CONFIG:value3'/]'.\n//\n//\n//\n",
2502: template_java.getContent());
2503: map.put("thevalue", "the value");
2504: assertEquals(
2505: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'OGNL:CONFIG:value2'/]'.\n//This config value expression is dynamic 'dynamic value'.\n//\n//\n//\n",
2506: template_java.getContent());
2507: }
2508:
2509: public void testFilteredTagsOgnlEngineHtml() throws Exception {
2510: Template template_html = TemplateFactory.ENGINEHTML
2511: .get("filtered_tags_ognl");
2512: template_html.setExpressionVar("thevalue", false);
2513: assertEquals(
2514: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2515: template_html.getContent());
2516: template_html.setExpressionVar("thevalue", true);
2517: assertEquals(
2518: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2519: template_html.getContent());
2520:
2521: Map<String, Object> map = new HashMap<String, Object>();
2522: template_html = TemplateFactory.ENGINEHTML
2523: .get("filtered_tags_ognl");
2524: template_html.setExpressionVars(map);
2525: map.put("thevalue", false);
2526: assertEquals(
2527: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2528: template_html.getContent());
2529: map.put("thevalue", true);
2530: assertEquals(
2531: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2532: template_html.getContent());
2533: }
2534:
2535: public void testFilteredTagsOgnlEngineXhtml() throws Exception {
2536: Template template_xhtml = TemplateFactory.ENGINEXHTML
2537: .get("filtered_tags_ognl");
2538: template_xhtml.setExpressionVar("thevalue", false);
2539: assertEquals(
2540: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2541: template_xhtml.getContent());
2542: template_xhtml.setExpressionVar("thevalue", true);
2543: assertEquals(
2544: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2545: template_xhtml.getContent());
2546:
2547: Map<String, Object> map = new HashMap<String, Object>();
2548: template_xhtml = TemplateFactory.ENGINEXHTML
2549: .get("filtered_tags_ognl");
2550: template_xhtml.setExpressionVars(map);
2551: map.put("thevalue", false);
2552: assertEquals(
2553: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2554: template_xhtml.getContent());
2555: map.put("thevalue", true);
2556: assertEquals(
2557: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2558: template_xhtml.getContent());
2559: }
2560:
2561: public void testFilteredTagsOgnlEngineXml() throws Exception {
2562: Template template_xml = TemplateFactory.ENGINEXML
2563: .get("filtered_tags_ognl");
2564: template_xml.setExpressionVar("thevalue", false);
2565: assertEquals(
2566: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2567: template_xml.getContent());
2568: template_xml.setExpressionVar("thevalue", true);
2569: assertEquals(
2570: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2571: template_xml.getContent());
2572:
2573: Map<String, Object> map = new HashMap<String, Object>();
2574: template_xml = TemplateFactory.ENGINEXML
2575: .get("filtered_tags_ognl");
2576: template_xml.setExpressionVars(map);
2577: map.put("thevalue", false);
2578: assertEquals(
2579: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2580: template_xml.getContent());
2581: map.put("thevalue", true);
2582: assertEquals(
2583: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2584: template_xml.getContent());
2585: }
2586:
2587: public void testFilteredTagsOgnlEngineTxt() throws Exception {
2588: Template template_txt = TemplateFactory.ENGINETXT
2589: .get("filtered_tags_ognl");
2590: template_txt.setExpressionVar("thevalue", false);
2591: assertEquals(
2592: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2593: template_txt.getContent());
2594: template_txt.setExpressionVar("thevalue", true);
2595: assertEquals(
2596: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2597: template_txt.getContent());
2598:
2599: Map<String, Object> map = new HashMap<String, Object>();
2600: template_txt = TemplateFactory.ENGINETXT
2601: .get("filtered_tags_ognl");
2602: template_txt.setExpressionVars(map);
2603: map.put("thevalue", false);
2604: assertEquals(
2605: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2606: template_txt.getContent());
2607: map.put("thevalue", true);
2608: assertEquals(
2609: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2610: template_txt.getContent());
2611: }
2612:
2613: public void testFilteredTagsOgnlHtml() throws Exception {
2614: Template template_html = TemplateFactory.HTML
2615: .get("filtered_tags_ognl");
2616: template_html.setExpressionVar("thevalue", false);
2617: assertEquals(
2618: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2619: template_html.getContent());
2620: template_html.setExpressionVar("thevalue", true);
2621: assertEquals(
2622: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2623: template_html.getContent());
2624:
2625: Map<String, Object> map = new HashMap<String, Object>();
2626: template_html = TemplateFactory.HTML.get("filtered_tags_ognl");
2627: template_html.setExpressionVars(map);
2628: map.put("thevalue", false);
2629: assertEquals(
2630: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2631: template_html.getContent());
2632: map.put("thevalue", true);
2633: assertEquals(
2634: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2635: template_html.getContent());
2636: }
2637:
2638: public void testFilteredTagsOgnlXhtml() throws Exception {
2639: Template template_xhtml = TemplateFactory.XHTML
2640: .get("filtered_tags_ognl");
2641: template_xhtml.setExpressionVar("thevalue", false);
2642: assertEquals(
2643: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2644: template_xhtml.getContent());
2645: template_xhtml.setExpressionVar("thevalue", true);
2646: assertEquals(
2647: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2648: template_xhtml.getContent());
2649:
2650: Map<String, Object> map = new HashMap<String, Object>();
2651: template_xhtml = TemplateFactory.XHTML
2652: .get("filtered_tags_ognl");
2653: template_xhtml.setExpressionVars(map);
2654: map.put("thevalue", false);
2655: assertEquals(
2656: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2657: template_xhtml.getContent());
2658: map.put("thevalue", true);
2659: assertEquals(
2660: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2661: template_xhtml.getContent());
2662: }
2663:
2664: public void testFilteredTagsOgnlXml() throws Exception {
2665: Template template_xml = TemplateFactory.XML
2666: .get("filtered_tags_ognl");
2667: template_xml.setExpressionVar("thevalue", false);
2668: assertEquals(
2669: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2670: template_xml.getContent());
2671: template_xml.setExpressionVar("thevalue", true);
2672: assertEquals(
2673: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2674: template_xml.getContent());
2675:
2676: Map<String, Object> map = new HashMap<String, Object>();
2677: template_xml = TemplateFactory.XML.get("filtered_tags_ognl");
2678: template_xml.setExpressionVars(map);
2679: map.put("thevalue", false);
2680: assertEquals(
2681: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2682: template_xml.getContent());
2683: map.put("thevalue", true);
2684: assertEquals(
2685: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2686: template_xml.getContent());
2687: }
2688:
2689: public void testFilteredTagsOgnlTxt() throws Exception {
2690: Template template_txt = TemplateFactory.TXT
2691: .get("filtered_tags_ognl");
2692: template_txt.setExpressionVar("thevalue", false);
2693: assertEquals(
2694: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2695: template_txt.getContent());
2696: template_txt.setExpressionVar("thevalue", true);
2697: assertEquals(
2698: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2699: template_txt.getContent());
2700:
2701: Map<String, Object> map = new HashMap<String, Object>();
2702: template_txt = TemplateFactory.TXT.get("filtered_tags_ognl");
2703: template_txt.setExpressionVars(map);
2704: map.put("thevalue", false);
2705: assertEquals(
2706: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2707: template_txt.getContent());
2708: map.put("thevalue", true);
2709: assertEquals(
2710: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2711: template_txt.getContent());
2712: }
2713:
2714: public void testFilteredTagsOgnlSql() throws Exception {
2715: Template template_sql = TemplateFactory.SQL
2716: .get("filtered_tags_ognl");
2717: template_sql.setExpressionVar("thevalue", false);
2718: assertEquals(
2719: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2720: template_sql.getContent());
2721: template_sql.setExpressionVar("thevalue", true);
2722: assertEquals(
2723: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2724: template_sql.getContent());
2725:
2726: Map<String, Object> map = new HashMap<String, Object>();
2727: template_sql = TemplateFactory.SQL.get("filtered_tags_ognl");
2728: template_sql.setExpressionVars(map);
2729: map.put("thevalue", false);
2730: assertEquals(
2731: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic '[!V 'OGNL:value3'/]'.\n\n\n\n",
2732: template_sql.getContent());
2733: map.put("thevalue", true);
2734: assertEquals(
2735: "This expression is true 'true value'.\nThis expression is false '[!V 'OGNL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
2736: template_sql.getContent());
2737: }
2738:
2739: public void testFilteredTagsOgnlJava() throws Exception {
2740: Template template_java = TemplateFactory.JAVA
2741: .get("filtered_tags_ognl");
2742: template_java.setExpressionVar("thevalue", false);
2743: assertEquals(
2744: "//This expression is true 'true value'.\n//This expression is false '[!V 'OGNL:value2'/]'.\n//This expression is dynamic '[!V 'OGNL:value3'/]'.\n//\n//\n//\n",
2745: template_java.getContent());
2746: template_java.setExpressionVar("thevalue", true);
2747: assertEquals(
2748: "//This expression is true 'true value'.\n//This expression is false '[!V 'OGNL:value2'/]'.\n//This expression is dynamic 'dynamic value'.\n//\n//\n//\n",
2749: template_java.getContent());
2750:
2751: Map<String, Object> map = new HashMap<String, Object>();
2752: template_java = TemplateFactory.JAVA.get("filtered_tags_ognl");
2753: template_java.setExpressionVars(map);
2754: map.put("thevalue", false);
2755: assertEquals(
2756: "//This expression is true 'true value'.\n//This expression is false '[!V 'OGNL:value2'/]'.\n//This expression is dynamic '[!V 'OGNL:value3'/]'.\n//\n//\n//\n",
2757: template_java.getContent());
2758: map.put("thevalue", true);
2759: assertEquals(
2760: "//This expression is true 'true value'.\n//This expression is false '[!V 'OGNL:value2'/]'.\n//This expression is dynamic 'dynamic value'.\n//\n//\n//\n",
2761: template_java.getContent());
2762: }
2763:
2764: public void testFilteredTagsMvelConfigEngineHtml() throws Exception {
2765: Template template_html = TemplateFactory.ENGINEHTML
2766: .get("filtered_tags_mvel_config");
2767: template_html.setExpressionVar("thevalue", "the wrong value");
2768: assertEquals(
2769: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2770: template_html.getContent());
2771: template_html.setExpressionVar("thevalue", "the value");
2772: assertEquals(
2773: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2774: template_html.getContent());
2775:
2776: Map<String, Object> map = new HashMap<String, Object>();
2777: template_html = TemplateFactory.ENGINEHTML
2778: .get("filtered_tags_mvel_config");
2779: template_html.setExpressionVars(map);
2780: map.put("thevalue", "the wrong value");
2781: assertEquals(
2782: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2783: template_html.getContent());
2784: map.put("thevalue", "the value");
2785: assertEquals(
2786: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2787: template_html.getContent());
2788: }
2789:
2790: public void testFilteredTagsMvelConfigEngineXhtml()
2791: throws Exception {
2792: Template template_xhtml = TemplateFactory.ENGINEXHTML
2793: .get("filtered_tags_mvel_config");
2794: template_xhtml.setExpressionVar("thevalue", "the wrong value");
2795: assertEquals(
2796: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2797: template_xhtml.getContent());
2798: template_xhtml.setExpressionVar("thevalue", "the value");
2799: assertEquals(
2800: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2801: template_xhtml.getContent());
2802:
2803: Map<String, Object> map = new HashMap<String, Object>();
2804: template_xhtml = TemplateFactory.ENGINEXHTML
2805: .get("filtered_tags_mvel_config");
2806: template_xhtml.setExpressionVars(map);
2807: map.put("thevalue", "the wrong value");
2808: assertEquals(
2809: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2810: template_xhtml.getContent());
2811: map.put("thevalue", "the value");
2812: assertEquals(
2813: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2814: template_xhtml.getContent());
2815: }
2816:
2817: public void testFilteredTagsMvelConfigEngineXml() throws Exception {
2818: Template template_xml = TemplateFactory.ENGINEXML
2819: .get("filtered_tags_mvel_config");
2820: template_xml.setExpressionVar("thevalue", "the wrong value");
2821: assertEquals(
2822: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2823: template_xml.getContent());
2824: template_xml.setExpressionVar("thevalue", "the value");
2825: assertEquals(
2826: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2827: template_xml.getContent());
2828:
2829: Map<String, Object> map = new HashMap<String, Object>();
2830: template_xml = TemplateFactory.ENGINEXML
2831: .get("filtered_tags_mvel_config");
2832: template_xml.setExpressionVars(map);
2833: map.put("thevalue", "the wrong value");
2834: assertEquals(
2835: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2836: template_xml.getContent());
2837: map.put("thevalue", "the value");
2838: assertEquals(
2839: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2840: template_xml.getContent());
2841: }
2842:
2843: public void testFilteredTagsMvelConfigEngineTxt() throws Exception {
2844: Template template_txt = TemplateFactory.ENGINETXT
2845: .get("filtered_tags_mvel_config");
2846: template_txt.setExpressionVar("thevalue", "the wrong value");
2847: assertEquals(
2848: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2849: template_txt.getContent());
2850: template_txt.setExpressionVar("thevalue", "the value");
2851: assertEquals(
2852: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2853: template_txt.getContent());
2854:
2855: Map<String, Object> map = new HashMap<String, Object>();
2856: template_txt = TemplateFactory.ENGINETXT
2857: .get("filtered_tags_mvel_config");
2858: template_txt.setExpressionVars(map);
2859: map.put("thevalue", "the wrong value");
2860: assertEquals(
2861: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2862: template_txt.getContent());
2863: map.put("thevalue", "the value");
2864: assertEquals(
2865: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2866: template_txt.getContent());
2867: }
2868:
2869: public void testFilteredTagsMvelConfigHtml() throws Exception {
2870: Template template_html = TemplateFactory.HTML
2871: .get("filtered_tags_mvel_config");
2872: template_html.setExpressionVar("thevalue", "the wrong value");
2873: assertEquals(
2874: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2875: template_html.getContent());
2876: template_html.setExpressionVar("thevalue", "the value");
2877: assertEquals(
2878: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2879: template_html.getContent());
2880:
2881: Map<String, Object> map = new HashMap<String, Object>();
2882: template_html = TemplateFactory.HTML
2883: .get("filtered_tags_mvel_config");
2884: template_html.setExpressionVars(map);
2885: map.put("thevalue", "the wrong value");
2886: assertEquals(
2887: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2888: template_html.getContent());
2889: map.put("thevalue", "the value");
2890: assertEquals(
2891: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2892: template_html.getContent());
2893: }
2894:
2895: public void testFilteredTagsMvelConfigXhtml() throws Exception {
2896: Template template_xhtml = TemplateFactory.XHTML
2897: .get("filtered_tags_mvel_config");
2898: template_xhtml.setExpressionVar("thevalue", "the wrong value");
2899: assertEquals(
2900: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2901: template_xhtml.getContent());
2902: template_xhtml.setExpressionVar("thevalue", "the value");
2903: assertEquals(
2904: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2905: template_xhtml.getContent());
2906:
2907: Map<String, Object> map = new HashMap<String, Object>();
2908: template_xhtml = TemplateFactory.XHTML
2909: .get("filtered_tags_mvel_config");
2910: template_xhtml.setExpressionVars(map);
2911: map.put("thevalue", "the wrong value");
2912: assertEquals(
2913: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2914: template_xhtml.getContent());
2915: map.put("thevalue", "the value");
2916: assertEquals(
2917: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2918: template_xhtml.getContent());
2919: }
2920:
2921: public void testFilteredTagsMvelConfigXml() throws Exception {
2922: Template template_xml = TemplateFactory.XML
2923: .get("filtered_tags_mvel_config");
2924: template_xml.setExpressionVar("thevalue", "the wrong value");
2925: assertEquals(
2926: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2927: template_xml.getContent());
2928: template_xml.setExpressionVar("thevalue", "the value");
2929: assertEquals(
2930: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2931: template_xml.getContent());
2932:
2933: Map<String, Object> map = new HashMap<String, Object>();
2934: template_xml = TemplateFactory.XML
2935: .get("filtered_tags_mvel_config");
2936: template_xml.setExpressionVars(map);
2937: map.put("thevalue", "the wrong value");
2938: assertEquals(
2939: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2940: template_xml.getContent());
2941: map.put("thevalue", "the value");
2942: assertEquals(
2943: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2944: template_xml.getContent());
2945: }
2946:
2947: public void testFilteredTagsMvelConfigTxt() throws Exception {
2948: Template template_txt = TemplateFactory.TXT
2949: .get("filtered_tags_mvel_config");
2950: template_txt.setExpressionVar("thevalue", "the wrong value");
2951: assertEquals(
2952: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2953: template_txt.getContent());
2954: template_txt.setExpressionVar("thevalue", "the value");
2955: assertEquals(
2956: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2957: template_txt.getContent());
2958:
2959: Map<String, Object> map = new HashMap<String, Object>();
2960: template_txt = TemplateFactory.TXT
2961: .get("filtered_tags_mvel_config");
2962: template_txt.setExpressionVars(map);
2963: map.put("thevalue", "the wrong value");
2964: assertEquals(
2965: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2966: template_txt.getContent());
2967: map.put("thevalue", "the value");
2968: assertEquals(
2969: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2970: template_txt.getContent());
2971: }
2972:
2973: public void testFilteredTagsMvelConfigSql() throws Exception {
2974: Template template_sql = TemplateFactory.SQL
2975: .get("filtered_tags_mvel_config");
2976: template_sql.setExpressionVar("thevalue", "the wrong value");
2977: assertEquals(
2978: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2979: template_sql.getContent());
2980: template_sql.setExpressionVar("thevalue", "the value");
2981: assertEquals(
2982: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2983: template_sql.getContent());
2984:
2985: Map<String, Object> map = new HashMap<String, Object>();
2986: template_sql = TemplateFactory.SQL
2987: .get("filtered_tags_mvel_config");
2988: template_sql.setExpressionVars(map);
2989: map.put("thevalue", "the wrong value");
2990: assertEquals(
2991: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n\n\n\n",
2992: template_sql.getContent());
2993: map.put("thevalue", "the value");
2994: assertEquals(
2995: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
2996: template_sql.getContent());
2997: }
2998:
2999: public void testFilteredTagsMvelConfigJava() throws Exception {
3000: Template template_java = TemplateFactory.JAVA
3001: .get("filtered_tags_mvel_config");
3002: template_java.setExpressionVar("thevalue", "the wrong value");
3003: assertEquals(
3004: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\n//This config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n//\n//\n//\n",
3005: template_java.getContent());
3006: template_java.setExpressionVar("thevalue", "the value");
3007: assertEquals(
3008: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\n//This config value expression is dynamic 'dynamic value'.\n//\n//\n//\n",
3009: template_java.getContent());
3010:
3011: Map<String, Object> map = new HashMap<String, Object>();
3012: template_java = TemplateFactory.JAVA
3013: .get("filtered_tags_mvel_config");
3014: template_java.setExpressionVars(map);
3015: map.put("thevalue", "the wrong value");
3016: assertEquals(
3017: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\n//This config value expression is dynamic '[!V 'MVEL:CONFIG:value3'/]'.\n//\n//\n//\n",
3018: template_java.getContent());
3019: map.put("thevalue", "the value");
3020: assertEquals(
3021: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'MVEL:CONFIG:value2'/]'.\n//This config value expression is dynamic 'dynamic value'.\n//\n//\n//\n",
3022: template_java.getContent());
3023: }
3024:
3025: public void testFilteredTagsMvelEngineHtml() throws Exception {
3026: Template template_html = TemplateFactory.ENGINEHTML
3027: .get("filtered_tags_mvel");
3028: template_html.setExpressionVar("thevalue", false);
3029: assertEquals(
3030: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3031: template_html.getContent());
3032: template_html.setExpressionVar("thevalue", true);
3033: assertEquals(
3034: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3035: template_html.getContent());
3036:
3037: Map<String, Object> map = new HashMap<String, Object>();
3038: template_html = TemplateFactory.ENGINEHTML
3039: .get("filtered_tags_mvel");
3040: template_html.setExpressionVars(map);
3041: map.put("thevalue", false);
3042: assertEquals(
3043: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3044: template_html.getContent());
3045: map.put("thevalue", true);
3046: assertEquals(
3047: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3048: template_html.getContent());
3049: }
3050:
3051: public void testFilteredTagsMvelEngineXhtml() throws Exception {
3052: Template template_xhtml = TemplateFactory.ENGINEXHTML
3053: .get("filtered_tags_mvel");
3054: template_xhtml.setExpressionVar("thevalue", false);
3055: assertEquals(
3056: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3057: template_xhtml.getContent());
3058: template_xhtml.setExpressionVar("thevalue", true);
3059: assertEquals(
3060: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3061: template_xhtml.getContent());
3062:
3063: Map<String, Object> map = new HashMap<String, Object>();
3064: template_xhtml = TemplateFactory.ENGINEXHTML
3065: .get("filtered_tags_mvel");
3066: template_xhtml.setExpressionVars(map);
3067: map.put("thevalue", false);
3068: assertEquals(
3069: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3070: template_xhtml.getContent());
3071: map.put("thevalue", true);
3072: assertEquals(
3073: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3074: template_xhtml.getContent());
3075: }
3076:
3077: public void testFilteredTagsMvelEngineXml() throws Exception {
3078: Template template_xml = TemplateFactory.ENGINEXML
3079: .get("filtered_tags_mvel");
3080: template_xml.setExpressionVar("thevalue", false);
3081: assertEquals(
3082: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3083: template_xml.getContent());
3084: template_xml.setExpressionVar("thevalue", true);
3085: assertEquals(
3086: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3087: template_xml.getContent());
3088:
3089: Map<String, Object> map = new HashMap<String, Object>();
3090: template_xml = TemplateFactory.ENGINEXML
3091: .get("filtered_tags_mvel");
3092: template_xml.setExpressionVars(map);
3093: map.put("thevalue", false);
3094: assertEquals(
3095: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3096: template_xml.getContent());
3097: map.put("thevalue", true);
3098: assertEquals(
3099: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3100: template_xml.getContent());
3101: }
3102:
3103: public void testFilteredTagsMvelEngineTxt() throws Exception {
3104: Template template_txt = TemplateFactory.ENGINETXT
3105: .get("filtered_tags_mvel");
3106: template_txt.setExpressionVar("thevalue", false);
3107: assertEquals(
3108: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3109: template_txt.getContent());
3110: template_txt.setExpressionVar("thevalue", true);
3111: assertEquals(
3112: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3113: template_txt.getContent());
3114:
3115: Map<String, Object> map = new HashMap<String, Object>();
3116: template_txt = TemplateFactory.ENGINETXT
3117: .get("filtered_tags_mvel");
3118: template_txt.setExpressionVars(map);
3119: map.put("thevalue", false);
3120: assertEquals(
3121: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3122: template_txt.getContent());
3123: map.put("thevalue", true);
3124: assertEquals(
3125: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3126: template_txt.getContent());
3127: }
3128:
3129: public void testFilteredTagsMvelHtml() throws Exception {
3130: Template template_html = TemplateFactory.HTML
3131: .get("filtered_tags_mvel");
3132: template_html.setExpressionVar("thevalue", false);
3133: assertEquals(
3134: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3135: template_html.getContent());
3136: template_html.setExpressionVar("thevalue", true);
3137: assertEquals(
3138: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3139: template_html.getContent());
3140:
3141: Map<String, Object> map = new HashMap<String, Object>();
3142: template_html = TemplateFactory.HTML.get("filtered_tags_mvel");
3143: template_html.setExpressionVars(map);
3144: map.put("thevalue", false);
3145: assertEquals(
3146: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3147: template_html.getContent());
3148: map.put("thevalue", true);
3149: assertEquals(
3150: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3151: template_html.getContent());
3152: }
3153:
3154: public void testFilteredTagsMvelXhtml() throws Exception {
3155: Template template_xhtml = TemplateFactory.XHTML
3156: .get("filtered_tags_mvel");
3157: template_xhtml.setExpressionVar("thevalue", false);
3158: assertEquals(
3159: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3160: template_xhtml.getContent());
3161: template_xhtml.setExpressionVar("thevalue", true);
3162: assertEquals(
3163: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3164: template_xhtml.getContent());
3165:
3166: Map<String, Object> map = new HashMap<String, Object>();
3167: template_xhtml = TemplateFactory.XHTML
3168: .get("filtered_tags_mvel");
3169: template_xhtml.setExpressionVars(map);
3170: map.put("thevalue", false);
3171: assertEquals(
3172: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3173: template_xhtml.getContent());
3174: map.put("thevalue", true);
3175: assertEquals(
3176: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3177: template_xhtml.getContent());
3178: }
3179:
3180: public void testFilteredTagsMvelXml() throws Exception {
3181: Template template_xml = TemplateFactory.XML
3182: .get("filtered_tags_mvel");
3183: template_xml.setExpressionVar("thevalue", false);
3184: assertEquals(
3185: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3186: template_xml.getContent());
3187: template_xml.setExpressionVar("thevalue", true);
3188: assertEquals(
3189: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3190: template_xml.getContent());
3191:
3192: Map<String, Object> map = new HashMap<String, Object>();
3193: template_xml = TemplateFactory.XML.get("filtered_tags_mvel");
3194: template_xml.setExpressionVars(map);
3195: map.put("thevalue", false);
3196: assertEquals(
3197: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3198: template_xml.getContent());
3199: map.put("thevalue", true);
3200: assertEquals(
3201: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3202: template_xml.getContent());
3203: }
3204:
3205: public void testFilteredTagsMvelTxt() throws Exception {
3206: Template template_txt = TemplateFactory.TXT
3207: .get("filtered_tags_mvel");
3208: template_txt.setExpressionVar("thevalue", false);
3209: assertEquals(
3210: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3211: template_txt.getContent());
3212: template_txt.setExpressionVar("thevalue", true);
3213: assertEquals(
3214: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3215: template_txt.getContent());
3216:
3217: Map<String, Object> map = new HashMap<String, Object>();
3218: template_txt = TemplateFactory.TXT.get("filtered_tags_mvel");
3219: template_txt.setExpressionVars(map);
3220: map.put("thevalue", false);
3221: assertEquals(
3222: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3223: template_txt.getContent());
3224: map.put("thevalue", true);
3225: assertEquals(
3226: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3227: template_txt.getContent());
3228: }
3229:
3230: public void testFilteredTagsMvelSql() throws Exception {
3231: Template template_sql = TemplateFactory.SQL
3232: .get("filtered_tags_mvel");
3233: template_sql.setExpressionVar("thevalue", false);
3234: assertEquals(
3235: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3236: template_sql.getContent());
3237: template_sql.setExpressionVar("thevalue", true);
3238: assertEquals(
3239: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3240: template_sql.getContent());
3241:
3242: Map<String, Object> map = new HashMap<String, Object>();
3243: template_sql = TemplateFactory.SQL.get("filtered_tags_mvel");
3244: template_sql.setExpressionVars(map);
3245: map.put("thevalue", false);
3246: assertEquals(
3247: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic '[!V 'MVEL:value3'/]'.\n\n\n\n",
3248: template_sql.getContent());
3249: map.put("thevalue", true);
3250: assertEquals(
3251: "This expression is true 'true value'.\nThis expression is false '[!V 'MVEL:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3252: template_sql.getContent());
3253: }
3254:
3255: public void testFilteredTagsMvelJava() throws Exception {
3256: Template template_java = TemplateFactory.JAVA
3257: .get("filtered_tags_mvel");
3258: template_java.setExpressionVar("thevalue", false);
3259: assertEquals(
3260: "//This expression is true 'true value'.\n//This expression is false '[!V 'MVEL:value2'/]'.\n//This expression is dynamic '[!V 'MVEL:value3'/]'.\n//\n//\n//\n",
3261: template_java.getContent());
3262: template_java.setExpressionVar("thevalue", true);
3263: assertEquals(
3264: "//This expression is true 'true value'.\n//This expression is false '[!V 'MVEL:value2'/]'.\n//This expression is dynamic 'dynamic value'.\n//\n//\n//\n",
3265: template_java.getContent());
3266:
3267: Map<String, Object> map = new HashMap<String, Object>();
3268: template_java = TemplateFactory.JAVA.get("filtered_tags_mvel");
3269: template_java.setExpressionVars(map);
3270: map.put("thevalue", false);
3271: assertEquals(
3272: "//This expression is true 'true value'.\n//This expression is false '[!V 'MVEL:value2'/]'.\n//This expression is dynamic '[!V 'MVEL:value3'/]'.\n//\n//\n//\n",
3273: template_java.getContent());
3274: map.put("thevalue", true);
3275: assertEquals(
3276: "//This expression is true 'true value'.\n//This expression is false '[!V 'MVEL:value2'/]'.\n//This expression is dynamic 'dynamic value'.\n//\n//\n//\n",
3277: template_java.getContent());
3278: }
3279:
3280: public void testFilteredTagsGroovyConfigEngineHtml()
3281: throws Exception {
3282: Template template_html = TemplateFactory.ENGINEHTML
3283: .get("filtered_tags_groovy_config");
3284: template_html.setExpressionVar("thevalue", "the wrong value");
3285: assertEquals(
3286: "This config value expression is true 'true value'.\nThis config value expression is false '<r:v name=\"GROOVY:CONFIG:value2\"/>'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3287: template_html.getContent());
3288: template_html.setExpressionVar("thevalue", "the value");
3289: assertEquals(
3290: "This config value expression is true 'true value'.\nThis config value expression is false '<r:v name=\"GROOVY:CONFIG:value2\"/>'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3291: template_html.getContent());
3292:
3293: Map<String, Object> map = new HashMap<String, Object>();
3294: template_html = TemplateFactory.ENGINEHTML
3295: .get("filtered_tags_groovy_config");
3296: template_html.setExpressionVars(map);
3297: map.put("thevalue", "the wrong value");
3298: assertEquals(
3299: "This config value expression is true 'true value'.\nThis config value expression is false '<r:v name=\"GROOVY:CONFIG:value2\"/>'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3300: template_html.getContent());
3301: map.put("thevalue", "the value");
3302: assertEquals(
3303: "This config value expression is true 'true value'.\nThis config value expression is false '<r:v name=\"GROOVY:CONFIG:value2\"/>'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3304: template_html.getContent());
3305: }
3306:
3307: public void testFilteredTagsGroovyConfigEngineXhtml()
3308: throws Exception {
3309: Template template_xhtml = TemplateFactory.ENGINEXHTML
3310: .get("filtered_tags_groovy_config");
3311: template_xhtml.setExpressionVar("thevalue", "the wrong value");
3312: assertEquals(
3313: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3314: template_xhtml.getContent());
3315: template_xhtml.setExpressionVar("thevalue", "the value");
3316: assertEquals(
3317: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3318: template_xhtml.getContent());
3319:
3320: Map<String, Object> map = new HashMap<String, Object>();
3321: template_xhtml = TemplateFactory.ENGINEXHTML
3322: .get("filtered_tags_groovy_config");
3323: template_xhtml.setExpressionVars(map);
3324: map.put("thevalue", "the wrong value");
3325: assertEquals(
3326: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3327: template_xhtml.getContent());
3328: map.put("thevalue", "the value");
3329: assertEquals(
3330: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3331: template_xhtml.getContent());
3332: }
3333:
3334: public void testFilteredTagsGroovyConfigEngineXml()
3335: throws Exception {
3336: Template template_xml = TemplateFactory.ENGINEXML
3337: .get("filtered_tags_groovy_config");
3338: template_xml.setExpressionVar("thevalue", "the wrong value");
3339: assertEquals(
3340: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3341: template_xml.getContent());
3342: template_xml.setExpressionVar("thevalue", "the value");
3343: assertEquals(
3344: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3345: template_xml.getContent());
3346:
3347: Map<String, Object> map = new HashMap<String, Object>();
3348: template_xml = TemplateFactory.ENGINEXML
3349: .get("filtered_tags_groovy_config");
3350: template_xml.setExpressionVars(map);
3351: map.put("thevalue", "the wrong value");
3352: assertEquals(
3353: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3354: template_xml.getContent());
3355: map.put("thevalue", "the value");
3356: assertEquals(
3357: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3358: template_xml.getContent());
3359: }
3360:
3361: public void testFilteredTagsGroovyConfigEngineTxt()
3362: throws Exception {
3363: Template template_txt = TemplateFactory.ENGINETXT
3364: .get("filtered_tags_groovy_config");
3365: template_txt.setExpressionVar("thevalue", "the wrong value");
3366: assertEquals(
3367: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3368: template_txt.getContent());
3369: template_txt.setExpressionVar("thevalue", "the value");
3370: assertEquals(
3371: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3372: template_txt.getContent());
3373:
3374: Map<String, Object> map = new HashMap<String, Object>();
3375: template_txt = TemplateFactory.ENGINETXT
3376: .get("filtered_tags_groovy_config");
3377: template_txt.setExpressionVars(map);
3378: map.put("thevalue", "the wrong value");
3379: assertEquals(
3380: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3381: template_txt.getContent());
3382: map.put("thevalue", "the value");
3383: assertEquals(
3384: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3385: template_txt.getContent());
3386: }
3387:
3388: public void testFilteredTagsGroovyConfigHtml() throws Exception {
3389: Template template_html = TemplateFactory.HTML
3390: .get("filtered_tags_groovy_config");
3391: template_html.setExpressionVar("thevalue", "the wrong value");
3392: assertEquals(
3393: "This config value expression is true 'true value'.\nThis config value expression is false '<r:v name=\"GROOVY:CONFIG:value2\"/>'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3394: template_html.getContent());
3395: template_html.setExpressionVar("thevalue", "the value");
3396: assertEquals(
3397: "This config value expression is true 'true value'.\nThis config value expression is false '<r:v name=\"GROOVY:CONFIG:value2\"/>'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3398: template_html.getContent());
3399:
3400: Map<String, Object> map = new HashMap<String, Object>();
3401: template_html = TemplateFactory.HTML
3402: .get("filtered_tags_groovy_config");
3403: template_html.setExpressionVars(map);
3404: map.put("thevalue", "the wrong value");
3405: assertEquals(
3406: "This config value expression is true 'true value'.\nThis config value expression is false '<r:v name=\"GROOVY:CONFIG:value2\"/>'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3407: template_html.getContent());
3408: map.put("thevalue", "the value");
3409: assertEquals(
3410: "This config value expression is true 'true value'.\nThis config value expression is false '<r:v name=\"GROOVY:CONFIG:value2\"/>'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3411: template_html.getContent());
3412: }
3413:
3414: public void testFilteredTagsGroovyConfigXhtml() throws Exception {
3415: Template template_xhtml = TemplateFactory.XHTML
3416: .get("filtered_tags_groovy_config");
3417: template_xhtml.setExpressionVar("thevalue", "the wrong value");
3418: assertEquals(
3419: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3420: template_xhtml.getContent());
3421: template_xhtml.setExpressionVar("thevalue", "the value");
3422: assertEquals(
3423: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3424: template_xhtml.getContent());
3425:
3426: Map<String, Object> map = new HashMap<String, Object>();
3427: template_xhtml = TemplateFactory.XHTML
3428: .get("filtered_tags_groovy_config");
3429: template_xhtml.setExpressionVars(map);
3430: map.put("thevalue", "the wrong value");
3431: assertEquals(
3432: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3433: template_xhtml.getContent());
3434: map.put("thevalue", "the value");
3435: assertEquals(
3436: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3437: template_xhtml.getContent());
3438: }
3439:
3440: public void testFilteredTagsGroovyConfigXml() throws Exception {
3441: Template template_xml = TemplateFactory.XML
3442: .get("filtered_tags_groovy_config");
3443: template_xml.setExpressionVar("thevalue", "the wrong value");
3444: assertEquals(
3445: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3446: template_xml.getContent());
3447: template_xml.setExpressionVar("thevalue", "the value");
3448: assertEquals(
3449: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3450: template_xml.getContent());
3451:
3452: Map<String, Object> map = new HashMap<String, Object>();
3453: template_xml = TemplateFactory.XML
3454: .get("filtered_tags_groovy_config");
3455: template_xml.setExpressionVars(map);
3456: map.put("thevalue", "the wrong value");
3457: assertEquals(
3458: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3459: template_xml.getContent());
3460: map.put("thevalue", "the value");
3461: assertEquals(
3462: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3463: template_xml.getContent());
3464: }
3465:
3466: public void testFilteredTagsGroovyConfigTxt() throws Exception {
3467: Template template_txt = TemplateFactory.TXT
3468: .get("filtered_tags_groovy_config");
3469: template_txt.setExpressionVar("thevalue", "the wrong value");
3470: assertEquals(
3471: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3472: template_txt.getContent());
3473: template_txt.setExpressionVar("thevalue", "the value");
3474: assertEquals(
3475: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3476: template_txt.getContent());
3477:
3478: Map<String, Object> map = new HashMap<String, Object>();
3479: template_txt = TemplateFactory.TXT
3480: .get("filtered_tags_groovy_config");
3481: template_txt.setExpressionVars(map);
3482: map.put("thevalue", "the wrong value");
3483: assertEquals(
3484: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3485: template_txt.getContent());
3486: map.put("thevalue", "the value");
3487: assertEquals(
3488: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3489: template_txt.getContent());
3490: }
3491:
3492: public void testFilteredTagsGroovyConfigSql() throws Exception {
3493: Template template_sql = TemplateFactory.SQL
3494: .get("filtered_tags_groovy_config");
3495: template_sql.setExpressionVar("thevalue", "the wrong value");
3496: assertEquals(
3497: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3498: template_sql.getContent());
3499: template_sql.setExpressionVar("thevalue", "the value");
3500: assertEquals(
3501: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3502: template_sql.getContent());
3503:
3504: Map<String, Object> map = new HashMap<String, Object>();
3505: template_sql = TemplateFactory.SQL
3506: .get("filtered_tags_groovy_config");
3507: template_sql.setExpressionVars(map);
3508: map.put("thevalue", "the wrong value");
3509: assertEquals(
3510: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n\n\n\n",
3511: template_sql.getContent());
3512: map.put("thevalue", "the value");
3513: assertEquals(
3514: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3515: template_sql.getContent());
3516: }
3517:
3518: public void testFilteredTagsGroovyConfigJava() throws Exception {
3519: Template template_java = TemplateFactory.JAVA
3520: .get("filtered_tags_groovy_config");
3521: template_java.setExpressionVar("thevalue", "the wrong value");
3522: assertEquals(
3523: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\n//This config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n//\n//\n//\n",
3524: template_java.getContent());
3525: template_java.setExpressionVar("thevalue", "the value");
3526: assertEquals(
3527: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\n//This config value expression is dynamic 'dynamic value'.\n//\n//\n//\n",
3528: template_java.getContent());
3529:
3530: Map<String, Object> map = new HashMap<String, Object>();
3531: template_java = TemplateFactory.JAVA
3532: .get("filtered_tags_groovy_config");
3533: template_java.setExpressionVars(map);
3534: map.put("thevalue", "the wrong value");
3535: assertEquals(
3536: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\n//This config value expression is dynamic '[!V 'GROOVY:CONFIG:value3'/]'.\n//\n//\n//\n",
3537: template_java.getContent());
3538: map.put("thevalue", "the value");
3539: assertEquals(
3540: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'GROOVY:CONFIG:value2'/]'.\n//This config value expression is dynamic 'dynamic value'.\n//\n//\n//\n",
3541: template_java.getContent());
3542: }
3543:
3544: public void testFilteredTagsGroovyEngineHtml() throws Exception {
3545: Template template_html = TemplateFactory.ENGINEHTML
3546: .get("filtered_tags_groovy");
3547: template_html.setExpressionVar("thevalue", false);
3548: assertEquals(
3549: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '<r:v name=\"GROOVY:value3\"/>'.\n\n\n\n",
3550: template_html.getContent());
3551: template_html.setExpressionVar("thevalue", true);
3552: assertEquals(
3553: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3554: template_html.getContent());
3555:
3556: Map<String, Object> map = new HashMap<String, Object>();
3557: template_html = TemplateFactory.ENGINEHTML
3558: .get("filtered_tags_groovy");
3559: template_html.setExpressionVars(map);
3560: map.put("thevalue", false);
3561: assertEquals(
3562: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '<r:v name=\"GROOVY:value3\"/>'.\n\n\n\n",
3563: template_html.getContent());
3564: map.put("thevalue", true);
3565: assertEquals(
3566: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3567: template_html.getContent());
3568: }
3569:
3570: public void testFilteredTagsGroovyEngineXhtml() throws Exception {
3571: Template template_xhtml = TemplateFactory.ENGINEXHTML
3572: .get("filtered_tags_groovy");
3573: template_xhtml.setExpressionVar("thevalue", false);
3574: assertEquals(
3575: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3576: template_xhtml.getContent());
3577: template_xhtml.setExpressionVar("thevalue", true);
3578: assertEquals(
3579: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3580: template_xhtml.getContent());
3581:
3582: Map<String, Object> map = new HashMap<String, Object>();
3583: template_xhtml = TemplateFactory.ENGINEXHTML
3584: .get("filtered_tags_groovy");
3585: template_xhtml.setExpressionVars(map);
3586: map.put("thevalue", false);
3587: assertEquals(
3588: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3589: template_xhtml.getContent());
3590: map.put("thevalue", true);
3591: assertEquals(
3592: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3593: template_xhtml.getContent());
3594: }
3595:
3596: public void testFilteredTagsGroovyEngineXml() throws Exception {
3597: Template template_xml = TemplateFactory.ENGINEXML
3598: .get("filtered_tags_groovy");
3599: template_xml.setExpressionVar("thevalue", false);
3600: assertEquals(
3601: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3602: template_xml.getContent());
3603: template_xml.setExpressionVar("thevalue", true);
3604: assertEquals(
3605: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3606: template_xml.getContent());
3607:
3608: Map<String, Object> map = new HashMap<String, Object>();
3609: template_xml = TemplateFactory.ENGINEXML
3610: .get("filtered_tags_groovy");
3611: template_xml.setExpressionVars(map);
3612: map.put("thevalue", false);
3613: assertEquals(
3614: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3615: template_xml.getContent());
3616: map.put("thevalue", true);
3617: assertEquals(
3618: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3619: template_xml.getContent());
3620: }
3621:
3622: public void testFilteredTagsGroovyEngineTxt() throws Exception {
3623: Template template_txt = TemplateFactory.ENGINETXT
3624: .get("filtered_tags_groovy");
3625: template_txt.setExpressionVar("thevalue", false);
3626: assertEquals(
3627: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3628: template_txt.getContent());
3629: template_txt.setExpressionVar("thevalue", true);
3630: assertEquals(
3631: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3632: template_txt.getContent());
3633:
3634: Map<String, Object> map = new HashMap<String, Object>();
3635: template_txt = TemplateFactory.ENGINETXT
3636: .get("filtered_tags_groovy");
3637: template_txt.setExpressionVars(map);
3638: map.put("thevalue", false);
3639: assertEquals(
3640: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3641: template_txt.getContent());
3642: map.put("thevalue", true);
3643: assertEquals(
3644: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3645: template_txt.getContent());
3646: }
3647:
3648: public void testFilteredTagsGroovyHtml() throws Exception {
3649: Template template_html = TemplateFactory.HTML
3650: .get("filtered_tags_groovy");
3651: template_html.setExpressionVar("thevalue", false);
3652: assertEquals(
3653: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '<r:v name=\"GROOVY:value3\"/>'.\n\n\n\n",
3654: template_html.getContent());
3655: template_html.setExpressionVar("thevalue", true);
3656: assertEquals(
3657: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3658: template_html.getContent());
3659:
3660: Map<String, Object> map = new HashMap<String, Object>();
3661: template_html = TemplateFactory.HTML
3662: .get("filtered_tags_groovy");
3663: template_html.setExpressionVars(map);
3664: map.put("thevalue", false);
3665: assertEquals(
3666: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '<r:v name=\"GROOVY:value3\"/>'.\n\n\n\n",
3667: template_html.getContent());
3668: map.put("thevalue", true);
3669: assertEquals(
3670: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3671: template_html.getContent());
3672: }
3673:
3674: public void testFilteredTagsGroovyXhtml() throws Exception {
3675: Template template_xhtml = TemplateFactory.XHTML
3676: .get("filtered_tags_groovy");
3677: template_xhtml.setExpressionVar("thevalue", false);
3678: assertEquals(
3679: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3680: template_xhtml.getContent());
3681: template_xhtml.setExpressionVar("thevalue", true);
3682: assertEquals(
3683: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3684: template_xhtml.getContent());
3685:
3686: Map<String, Object> map = new HashMap<String, Object>();
3687: template_xhtml = TemplateFactory.XHTML
3688: .get("filtered_tags_groovy");
3689: template_xhtml.setExpressionVars(map);
3690: map.put("thevalue", false);
3691: assertEquals(
3692: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3693: template_xhtml.getContent());
3694: map.put("thevalue", true);
3695: assertEquals(
3696: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3697: template_xhtml.getContent());
3698: }
3699:
3700: public void testFilteredTagsGroovyXml() throws Exception {
3701: Template template_xml = TemplateFactory.XML
3702: .get("filtered_tags_groovy");
3703: template_xml.setExpressionVar("thevalue", false);
3704: assertEquals(
3705: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3706: template_xml.getContent());
3707: template_xml.setExpressionVar("thevalue", true);
3708: assertEquals(
3709: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3710: template_xml.getContent());
3711:
3712: Map<String, Object> map = new HashMap<String, Object>();
3713: template_xml = TemplateFactory.XML.get("filtered_tags_groovy");
3714: template_xml.setExpressionVars(map);
3715: map.put("thevalue", false);
3716: assertEquals(
3717: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3718: template_xml.getContent());
3719: map.put("thevalue", true);
3720: assertEquals(
3721: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3722: template_xml.getContent());
3723: }
3724:
3725: public void testFilteredTagsGroovyTxt() throws Exception {
3726: Template template_txt = TemplateFactory.TXT
3727: .get("filtered_tags_groovy");
3728: template_txt.setExpressionVar("thevalue", false);
3729: assertEquals(
3730: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3731: template_txt.getContent());
3732: template_txt.setExpressionVar("thevalue", true);
3733: assertEquals(
3734: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3735: template_txt.getContent());
3736:
3737: Map<String, Object> map = new HashMap<String, Object>();
3738: template_txt = TemplateFactory.TXT.get("filtered_tags_groovy");
3739: template_txt.setExpressionVars(map);
3740: map.put("thevalue", false);
3741: assertEquals(
3742: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3743: template_txt.getContent());
3744: map.put("thevalue", true);
3745: assertEquals(
3746: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3747: template_txt.getContent());
3748: }
3749:
3750: public void testFilteredTagsGroovySql() throws Exception {
3751: Template template_sql = TemplateFactory.SQL
3752: .get("filtered_tags_groovy");
3753: template_sql.setExpressionVar("thevalue", false);
3754: assertEquals(
3755: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3756: template_sql.getContent());
3757: template_sql.setExpressionVar("thevalue", true);
3758: assertEquals(
3759: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3760: template_sql.getContent());
3761:
3762: Map<String, Object> map = new HashMap<String, Object>();
3763: template_sql = TemplateFactory.SQL.get("filtered_tags_groovy");
3764: template_sql.setExpressionVars(map);
3765: map.put("thevalue", false);
3766: assertEquals(
3767: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic '[!V 'GROOVY:value3'/]'.\n\n\n\n",
3768: template_sql.getContent());
3769: map.put("thevalue", true);
3770: assertEquals(
3771: "This expression is true 'true value'.\nThis expression is false '[!V 'GROOVY:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
3772: template_sql.getContent());
3773: }
3774:
3775: public void testFilteredTagsGroovyJava() throws Exception {
3776: Template template_java = TemplateFactory.JAVA
3777: .get("filtered_tags_groovy");
3778: template_java.setExpressionVar("thevalue", false);
3779: assertEquals(
3780: "//This expression is true 'true value'.\n//This expression is false '[!V 'GROOVY:value2'/]'.\n//This expression is dynamic '[!V 'GROOVY:value3'/]'.\n//\n//\n//\n",
3781: template_java.getContent());
3782: template_java.setExpressionVar("thevalue", true);
3783: assertEquals(
3784: "//This expression is true 'true value'.\n//This expression is false '[!V 'GROOVY:value2'/]'.\n//This expression is dynamic 'dynamic value'.\n//\n//\n//\n",
3785: template_java.getContent());
3786:
3787: Map<String, Object> map = new HashMap<String, Object>();
3788: template_java = TemplateFactory.JAVA
3789: .get("filtered_tags_groovy");
3790: template_java.setExpressionVars(map);
3791: map.put("thevalue", false);
3792: assertEquals(
3793: "//This expression is true 'true value'.\n//This expression is false '[!V 'GROOVY:value2'/]'.\n//This expression is dynamic '[!V 'GROOVY:value3'/]'.\n//\n//\n//\n",
3794: template_java.getContent());
3795: map.put("thevalue", true);
3796: assertEquals(
3797: "//This expression is true 'true value'.\n//This expression is false '[!V 'GROOVY:value2'/]'.\n//This expression is dynamic 'dynamic value'.\n//\n//\n//\n",
3798: template_java.getContent());
3799: }
3800:
3801: public void testFilteredTagsJaninoConfigEngineHtml()
3802: throws Exception {
3803: Template template_html = TemplateFactory.ENGINEHTML
3804: .get("filtered_tags_janino_config");
3805: template_html.setExpressionVar("thevalue", "the wrong value");
3806: assertEquals(
3807: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
3808: template_html.getContent());
3809: template_html.setExpressionVar("thevalue", "the value");
3810: assertEquals(
3811: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3812: template_html.getContent());
3813:
3814: Map<String, Object> map = new HashMap<String, Object>();
3815: template_html = TemplateFactory.ENGINEHTML
3816: .get("filtered_tags_janino_config");
3817: template_html.setExpressionVars(map);
3818: map.put("thevalue", "the wrong value");
3819: assertEquals(
3820: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
3821: template_html.getContent());
3822: map.put("thevalue", "the value");
3823: assertEquals(
3824: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3825: template_html.getContent());
3826: }
3827:
3828: public void testFilteredTagsJaninoConfigEngineXhtml()
3829: throws Exception {
3830: Template template_xhtml = TemplateFactory.ENGINEXHTML
3831: .get("filtered_tags_janino_config");
3832: template_xhtml.setExpressionVar("thevalue", "the wrong value");
3833: assertEquals(
3834: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '${v JANINO:CONFIG:value3/}'.\n\n\n\n",
3835: template_xhtml.getContent());
3836: template_xhtml.setExpressionVar("thevalue", "the value");
3837: assertEquals(
3838: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3839: template_xhtml.getContent());
3840:
3841: Map<String, Object> map = new HashMap<String, Object>();
3842: template_xhtml = TemplateFactory.ENGINEXHTML
3843: .get("filtered_tags_janino_config");
3844: template_xhtml.setExpressionVars(map);
3845: map.put("thevalue", "the wrong value");
3846: assertEquals(
3847: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '${v JANINO:CONFIG:value3/}'.\n\n\n\n",
3848: template_xhtml.getContent());
3849: map.put("thevalue", "the value");
3850: assertEquals(
3851: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3852: template_xhtml.getContent());
3853: }
3854:
3855: public void testFilteredTagsJaninoConfigEngineXml()
3856: throws Exception {
3857: Template template_xml = TemplateFactory.ENGINEXML
3858: .get("filtered_tags_janino_config");
3859: template_xml.setExpressionVar("thevalue", "the wrong value");
3860: assertEquals(
3861: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
3862: template_xml.getContent());
3863: template_xml.setExpressionVar("thevalue", "the value");
3864: assertEquals(
3865: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3866: template_xml.getContent());
3867:
3868: Map<String, Object> map = new HashMap<String, Object>();
3869: template_xml = TemplateFactory.ENGINEXML
3870: .get("filtered_tags_janino_config");
3871: template_xml.setExpressionVars(map);
3872: map.put("thevalue", "the wrong value");
3873: assertEquals(
3874: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
3875: template_xml.getContent());
3876: map.put("thevalue", "the value");
3877: assertEquals(
3878: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3879: template_xml.getContent());
3880: }
3881:
3882: public void testFilteredTagsJaninoConfigEngineTxt()
3883: throws Exception {
3884: Template template_txt = TemplateFactory.ENGINETXT
3885: .get("filtered_tags_janino_config");
3886: template_txt.setExpressionVar("thevalue", "the wrong value");
3887: assertEquals(
3888: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
3889: template_txt.getContent());
3890: template_txt.setExpressionVar("thevalue", "the value");
3891: assertEquals(
3892: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3893: template_txt.getContent());
3894:
3895: Map<String, Object> map = new HashMap<String, Object>();
3896: template_txt = TemplateFactory.ENGINETXT
3897: .get("filtered_tags_janino_config");
3898: template_txt.setExpressionVars(map);
3899: map.put("thevalue", "the wrong value");
3900: assertEquals(
3901: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
3902: template_txt.getContent());
3903: map.put("thevalue", "the value");
3904: assertEquals(
3905: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3906: template_txt.getContent());
3907: }
3908:
3909: public void testFilteredTagsJaninoConfigHtml() throws Exception {
3910: Template template_html = TemplateFactory.HTML
3911: .get("filtered_tags_janino_config");
3912: template_html.setExpressionVar("thevalue", "the wrong value");
3913: assertEquals(
3914: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
3915: template_html.getContent());
3916: template_html.setExpressionVar("thevalue", "the value");
3917: assertEquals(
3918: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3919: template_html.getContent());
3920:
3921: Map<String, Object> map = new HashMap<String, Object>();
3922: template_html = TemplateFactory.HTML
3923: .get("filtered_tags_janino_config");
3924: template_html.setExpressionVars(map);
3925: map.put("thevalue", "the wrong value");
3926: assertEquals(
3927: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
3928: template_html.getContent());
3929: map.put("thevalue", "the value");
3930: assertEquals(
3931: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3932: template_html.getContent());
3933: }
3934:
3935: public void testFilteredTagsJaninoConfigXhtml() throws Exception {
3936: Template template_xhtml = TemplateFactory.XHTML
3937: .get("filtered_tags_janino_config");
3938: template_xhtml.setExpressionVar("thevalue", "the wrong value");
3939: assertEquals(
3940: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '${v JANINO:CONFIG:value3/}'.\n\n\n\n",
3941: template_xhtml.getContent());
3942: template_xhtml.setExpressionVar("thevalue", "the value");
3943: assertEquals(
3944: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3945: template_xhtml.getContent());
3946:
3947: Map<String, Object> map = new HashMap<String, Object>();
3948: template_xhtml = TemplateFactory.XHTML
3949: .get("filtered_tags_janino_config");
3950: template_xhtml.setExpressionVars(map);
3951: map.put("thevalue", "the wrong value");
3952: assertEquals(
3953: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '${v JANINO:CONFIG:value3/}'.\n\n\n\n",
3954: template_xhtml.getContent());
3955: map.put("thevalue", "the value");
3956: assertEquals(
3957: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3958: template_xhtml.getContent());
3959: }
3960:
3961: public void testFilteredTagsJaninoConfigXml() throws Exception {
3962: Template template_xml = TemplateFactory.XML
3963: .get("filtered_tags_janino_config");
3964: template_xml.setExpressionVar("thevalue", "the wrong value");
3965: assertEquals(
3966: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
3967: template_xml.getContent());
3968: template_xml.setExpressionVar("thevalue", "the value");
3969: assertEquals(
3970: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3971: template_xml.getContent());
3972:
3973: Map<String, Object> map = new HashMap<String, Object>();
3974: template_xml = TemplateFactory.XML
3975: .get("filtered_tags_janino_config");
3976: template_xml.setExpressionVars(map);
3977: map.put("thevalue", "the wrong value");
3978: assertEquals(
3979: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
3980: template_xml.getContent());
3981: map.put("thevalue", "the value");
3982: assertEquals(
3983: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3984: template_xml.getContent());
3985: }
3986:
3987: public void testFilteredTagsJaninoConfigTxt() throws Exception {
3988: Template template_txt = TemplateFactory.TXT
3989: .get("filtered_tags_janino_config");
3990: template_txt.setExpressionVar("thevalue", "the wrong value");
3991: assertEquals(
3992: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
3993: template_txt.getContent());
3994: template_txt.setExpressionVar("thevalue", "the value");
3995: assertEquals(
3996: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
3997: template_txt.getContent());
3998:
3999: Map<String, Object> map = new HashMap<String, Object>();
4000: template_txt = TemplateFactory.TXT
4001: .get("filtered_tags_janino_config");
4002: template_txt.setExpressionVars(map);
4003: map.put("thevalue", "the wrong value");
4004: assertEquals(
4005: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
4006: template_txt.getContent());
4007: map.put("thevalue", "the value");
4008: assertEquals(
4009: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
4010: template_txt.getContent());
4011: }
4012:
4013: public void testFilteredTagsJaninoConfigSql() throws Exception {
4014: Template template_sql = TemplateFactory.SQL
4015: .get("filtered_tags_janino_config");
4016: template_sql.setExpressionVar("thevalue", "the wrong value");
4017: assertEquals(
4018: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
4019: template_sql.getContent());
4020: template_sql.setExpressionVar("thevalue", "the value");
4021: assertEquals(
4022: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
4023: template_sql.getContent());
4024:
4025: Map<String, Object> map = new HashMap<String, Object>();
4026: template_sql = TemplateFactory.SQL
4027: .get("filtered_tags_janino_config");
4028: template_sql.setExpressionVars(map);
4029: map.put("thevalue", "the wrong value");
4030: assertEquals(
4031: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n\n\n\n",
4032: template_sql.getContent());
4033: map.put("thevalue", "the value");
4034: assertEquals(
4035: "This config value expression is true 'true value'.\nThis config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\nThis config value expression is dynamic 'dynamic value'.\n\n\n\n",
4036: template_sql.getContent());
4037: }
4038:
4039: public void testFilteredTagsJaninoConfigJava() throws Exception {
4040: Template template_java = TemplateFactory.JAVA
4041: .get("filtered_tags_janino_config");
4042: template_java.setExpressionVar("thevalue", "the wrong value");
4043: assertEquals(
4044: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\n//This config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n//\n//\n//\n",
4045: template_java.getContent());
4046: template_java.setExpressionVar("thevalue", "the value");
4047: assertEquals(
4048: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\n//This config value expression is dynamic 'dynamic value'.\n//\n//\n//\n",
4049: template_java.getContent());
4050:
4051: Map<String, Object> map = new HashMap<String, Object>();
4052: template_java = TemplateFactory.JAVA
4053: .get("filtered_tags_janino_config");
4054: template_java.setExpressionVars(map);
4055: map.put("thevalue", "the wrong value");
4056: assertEquals(
4057: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\n//This config value expression is dynamic '[!V 'JANINO:CONFIG:value3'/]'.\n//\n//\n//\n",
4058: template_java.getContent());
4059: map.put("thevalue", "the value");
4060: assertEquals(
4061: "//This config value expression is true 'true value'.\n//This config value expression is false '[!V 'JANINO:CONFIG:value2'/]'.\n//This config value expression is dynamic 'dynamic value'.\n//\n//\n//\n",
4062: template_java.getContent());
4063: }
4064:
4065: public void testFilteredTagsJaninoEngineHtml() throws Exception {
4066: Template template_html = TemplateFactory.ENGINEHTML
4067: .get("filtered_tags_janino");
4068: template_html.setExpressionVar("thevalue", false);
4069: assertEquals(
4070: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4071: template_html.getContent());
4072: template_html.setExpressionVar("thevalue", true);
4073: assertEquals(
4074: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4075: template_html.getContent());
4076:
4077: Map<String, Object> map = new HashMap<String, Object>();
4078: template_html = TemplateFactory.ENGINEHTML
4079: .get("filtered_tags_janino");
4080: template_html.setExpressionVars(map);
4081: map.put("thevalue", false);
4082: assertEquals(
4083: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4084: template_html.getContent());
4085: map.put("thevalue", true);
4086: assertEquals(
4087: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4088: template_html.getContent());
4089: }
4090:
4091: public void testFilteredTagsJaninoEngineXhtml() throws Exception {
4092: Template template_xhtml = TemplateFactory.ENGINEXHTML
4093: .get("filtered_tags_janino");
4094: template_xhtml.setExpressionVar("thevalue", false);
4095: assertEquals(
4096: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4097: template_xhtml.getContent());
4098: template_xhtml.setExpressionVar("thevalue", true);
4099: assertEquals(
4100: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4101: template_xhtml.getContent());
4102:
4103: Map<String, Object> map = new HashMap<String, Object>();
4104: template_xhtml = TemplateFactory.ENGINEXHTML
4105: .get("filtered_tags_janino");
4106: template_xhtml.setExpressionVars(map);
4107: map.put("thevalue", false);
4108: assertEquals(
4109: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4110: template_xhtml.getContent());
4111: map.put("thevalue", true);
4112: assertEquals(
4113: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4114: template_xhtml.getContent());
4115: }
4116:
4117: public void testFilteredTagsJaninoEngineXml() throws Exception {
4118: Template template_xml = TemplateFactory.ENGINEXML
4119: .get("filtered_tags_janino");
4120: template_xml.setExpressionVar("thevalue", false);
4121: assertEquals(
4122: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4123: template_xml.getContent());
4124: template_xml.setExpressionVar("thevalue", true);
4125: assertEquals(
4126: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4127: template_xml.getContent());
4128:
4129: Map<String, Object> map = new HashMap<String, Object>();
4130: template_xml = TemplateFactory.ENGINEXML
4131: .get("filtered_tags_janino");
4132: template_xml.setExpressionVars(map);
4133: map.put("thevalue", false);
4134: assertEquals(
4135: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4136: template_xml.getContent());
4137: map.put("thevalue", true);
4138: assertEquals(
4139: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4140: template_xml.getContent());
4141: }
4142:
4143: public void testFilteredTagsJaninoEngineTxt() throws Exception {
4144: Template template_txt = TemplateFactory.ENGINETXT
4145: .get("filtered_tags_janino");
4146: template_txt.setExpressionVar("thevalue", false);
4147: assertEquals(
4148: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4149: template_txt.getContent());
4150: template_txt.setExpressionVar("thevalue", true);
4151: assertEquals(
4152: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4153: template_txt.getContent());
4154:
4155: Map<String, Object> map = new HashMap<String, Object>();
4156: template_txt = TemplateFactory.ENGINETXT
4157: .get("filtered_tags_janino");
4158: template_txt.setExpressionVars(map);
4159: map.put("thevalue", false);
4160: assertEquals(
4161: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4162: template_txt.getContent());
4163: map.put("thevalue", true);
4164: assertEquals(
4165: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4166: template_txt.getContent());
4167: }
4168:
4169: public void testFilteredTagsJaninoHtml() throws Exception {
4170: Template template_html = TemplateFactory.HTML
4171: .get("filtered_tags_janino");
4172: template_html.setExpressionVar("thevalue", false);
4173: assertEquals(
4174: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4175: template_html.getContent());
4176: template_html.setExpressionVar("thevalue", true);
4177: assertEquals(
4178: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4179: template_html.getContent());
4180:
4181: Map<String, Object> map = new HashMap<String, Object>();
4182: template_html = TemplateFactory.HTML
4183: .get("filtered_tags_janino");
4184: template_html.setExpressionVars(map);
4185: map.put("thevalue", false);
4186: assertEquals(
4187: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4188: template_html.getContent());
4189: map.put("thevalue", true);
4190: assertEquals(
4191: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4192: template_html.getContent());
4193: }
4194:
4195: public void testFilteredTagsJaninoXhtml() throws Exception {
4196: Template template_xhtml = TemplateFactory.XHTML
4197: .get("filtered_tags_janino");
4198: template_xhtml.setExpressionVar("thevalue", false);
4199: assertEquals(
4200: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4201: template_xhtml.getContent());
4202: template_xhtml.setExpressionVar("thevalue", true);
4203: assertEquals(
4204: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4205: template_xhtml.getContent());
4206:
4207: Map<String, Object> map = new HashMap<String, Object>();
4208: template_xhtml = TemplateFactory.XHTML
4209: .get("filtered_tags_janino");
4210: template_xhtml.setExpressionVars(map);
4211: map.put("thevalue", false);
4212: assertEquals(
4213: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4214: template_xhtml.getContent());
4215: map.put("thevalue", true);
4216: assertEquals(
4217: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4218: template_xhtml.getContent());
4219: }
4220:
4221: public void testFilteredTagsJaninoXml() throws Exception {
4222: Template template_xml = TemplateFactory.XML
4223: .get("filtered_tags_janino");
4224: template_xml.setExpressionVar("thevalue", false);
4225: assertEquals(
4226: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4227: template_xml.getContent());
4228: template_xml.setExpressionVar("thevalue", true);
4229: assertEquals(
4230: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4231: template_xml.getContent());
4232:
4233: Map<String, Object> map = new HashMap<String, Object>();
4234: template_xml = TemplateFactory.XML.get("filtered_tags_janino");
4235: template_xml.setExpressionVars(map);
4236: map.put("thevalue", false);
4237: assertEquals(
4238: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4239: template_xml.getContent());
4240: map.put("thevalue", true);
4241: assertEquals(
4242: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4243: template_xml.getContent());
4244: }
4245:
4246: public void testFilteredTagsJaninoTxt() throws Exception {
4247: Template template_txt = TemplateFactory.TXT
4248: .get("filtered_tags_janino");
4249: template_txt.setExpressionVar("thevalue", false);
4250: assertEquals(
4251: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4252: template_txt.getContent());
4253: template_txt.setExpressionVar("thevalue", true);
4254: assertEquals(
4255: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4256: template_txt.getContent());
4257:
4258: Map<String, Object> map = new HashMap<String, Object>();
4259: template_txt = TemplateFactory.TXT.get("filtered_tags_janino");
4260: template_txt.setExpressionVars(map);
4261: map.put("thevalue", false);
4262: assertEquals(
4263: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4264: template_txt.getContent());
4265: map.put("thevalue", true);
4266: assertEquals(
4267: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4268: template_txt.getContent());
4269: }
4270:
4271: public void testFilteredTagsJaninoSql() throws Exception {
4272: Template template_sql = TemplateFactory.SQL
4273: .get("filtered_tags_janino");
4274: template_sql.setExpressionVar("thevalue", false);
4275: assertEquals(
4276: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4277: template_sql.getContent());
4278: template_sql.setExpressionVar("thevalue", true);
4279: assertEquals(
4280: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4281: template_sql.getContent());
4282:
4283: Map<String, Object> map = new HashMap<String, Object>();
4284: template_sql = TemplateFactory.SQL.get("filtered_tags_janino");
4285: template_sql.setExpressionVars(map);
4286: map.put("thevalue", false);
4287: assertEquals(
4288: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic '[!V 'JANINO:value3'/]'.\n\n\n\n",
4289: template_sql.getContent());
4290: map.put("thevalue", true);
4291: assertEquals(
4292: "This expression is true 'true value'.\nThis expression is false '[!V 'JANINO:value2'/]'.\nThis expression is dynamic 'dynamic value'.\n\n\n\n",
4293: template_sql.getContent());
4294: }
4295:
4296: public void testFilteredTagsJaninoJava() throws Exception {
4297: Template template_java = TemplateFactory.JAVA
4298: .get("filtered_tags_janino");
4299: template_java.setExpressionVar("thevalue", false);
4300: assertEquals(
4301: "//This expression is true 'true value'.\n//This expression is false '[!V 'JANINO:value2'/]'.\n//This expression is dynamic '[!V 'JANINO:value3'/]'.\n//\n//\n//\n",
4302: template_java.getContent());
4303: template_java.setExpressionVar("thevalue", true);
4304: assertEquals(
4305: "//This expression is true 'true value'.\n//This expression is false '[!V 'JANINO:value2'/]'.\n//This expression is dynamic 'dynamic value'.\n//\n//\n//\n",
4306: template_java.getContent());
4307:
4308: Map<String, Object> map = new HashMap<String, Object>();
4309: template_java = TemplateFactory.JAVA
4310: .get("filtered_tags_janino");
4311: template_java.setExpressionVars(map);
4312: map.put("thevalue", false);
4313: assertEquals(
4314: "//This expression is true 'true value'.\n//This expression is false '[!V 'JANINO:value2'/]'.\n//This expression is dynamic '[!V 'JANINO:value3'/]'.\n//\n//\n//\n",
4315: template_java.getContent());
4316: map.put("thevalue", true);
4317: assertEquals(
4318: "//This expression is true 'true value'.\n//This expression is false '[!V 'JANINO:value2'/]'.\n//This expression is dynamic 'dynamic value'.\n//\n//\n//\n",
4319: template_java.getContent());
4320: }
4321:
4322: public void testEncoding() {
4323: Template template_iso8859_1 = null;
4324: Template template_utf_8 = null;
4325: try {
4326: template_iso8859_1 = TemplateFactory.TXT.get(
4327: "encoding_latin1_iso88591", "ISO8859-1");
4328: assertNotNull(template_iso8859_1);
4329: template_utf_8 = TemplateFactory.TXT.get(
4330: "encoding_latin1_utf8", "UTF-8");
4331: assertNotNull(template_utf_8);
4332: assertEquals(template_iso8859_1.getContent(),
4333: template_utf_8.getContent());
4334: } catch (TemplateException e) {
4335: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4336: }
4337: }
4338:
4339: public void testCaching() {
4340: Template template1 = null;
4341: Template template2 = null;
4342: try {
4343: template1 = TemplateFactory.HTML.get("defaultvalues_in");
4344: assertNotNull(template1);
4345: template2 = TemplateFactory.HTML.get("defaultvalues_in");
4346: assertNotNull(template2);
4347: assertTrue(template1 != template2);
4348: assertSame(template1.getClass(), template2.getClass());
4349: } catch (TemplateException e) {
4350: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4351: }
4352: }
4353:
4354: public void testPackageFullName() {
4355: Template template = TemplateFactory.HTML
4356: .get("test_package.noblocks_in");
4357: assertNotNull(template);
4358: assertEquals("test_package.noblocks_in", template.getFullName());
4359: }
4360:
4361: public void testTemplatesInPackageCaching() {
4362: Template template1 = null;
4363: Template template2 = null;
4364: try {
4365: template1 = TemplateFactory.HTML
4366: .get("test_package.noblocks_in");
4367: assertNotNull(template1);
4368: template2 = TemplateFactory.HTML
4369: .get("test_package.noblocks_in");
4370: assertNotNull(template2);
4371: assertTrue(template1 != template2);
4372: assertSame(template1.getClass(), template2.getClass());
4373: } catch (TemplateException e) {
4374: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4375: }
4376: }
4377:
4378: public void testTemplatesInPackagePath() {
4379: Template template1 = null;
4380: Template template2 = null;
4381: try {
4382: template1 = TemplateFactory.HTML
4383: .get("test_package/noblocks_in.html");
4384: assertNotNull(template1);
4385: template2 = TemplateFactory.HTML
4386: .get("test_package/noblocks_in.html");
4387: assertNotNull(template2);
4388: assertTrue(template1 != template2);
4389: assertSame(template1.getClass(), template2.getClass());
4390: } catch (TemplateException e) {
4391: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4392: }
4393: }
4394:
4395: public void testFilteredBlocks() {
4396: String filter1 = "^FILTER1:(\\w+):CONST:(\\w+)$";
4397: String filter2 = "^FILTER2:(\\w+)$";
4398: String filter3 = "^CONST-FILTER3:(\\w+)$";
4399: String filter4 = "(\\w+)";
4400:
4401: TemplateFactory factory = null;
4402: Template template = null;
4403:
4404: try {
4405: factory = new TemplateFactory(
4406: ResourceFinderClasspath.getInstance(),
4407: "html",
4408: new Parser.Config[] { TemplateFactory.CONFIG_INVISIBLE_XML },
4409: "text/html", ".html", new String[] { filter1,
4410: filter2, filter3, filter4 }, null, null,
4411: null, null);
4412:
4413: template = factory.get("blocks_filtered_in");
4414:
4415: assertTrue(template.hasFilteredBlocks(filter1));
4416: assertTrue(template.hasFilteredBlocks(filter2));
4417: assertTrue(template.hasFilteredBlocks(filter3));
4418: assertFalse(template.hasFilteredBlocks(filter4));
4419:
4420: List<String[]> filtered_blocks = null;
4421:
4422: filtered_blocks = template.getFilteredBlocks(filter1);
4423: assertEquals(3, filtered_blocks.size());
4424:
4425: boolean filter1_got_block1 = false;
4426: boolean filter1_got_block2 = false;
4427: boolean filter1_got_block3 = false;
4428: for (String[] block_groups : filtered_blocks) {
4429: assertEquals(3, block_groups.length);
4430: if (block_groups[0]
4431: .equals("FILTER1:BLOCK1a:CONST:BLOCK1b")
4432: && block_groups[1].equals("BLOCK1a")
4433: && block_groups[2].equals("BLOCK1b")) {
4434: filter1_got_block1 = true;
4435: } else if (block_groups[0]
4436: .equals("FILTER1:BLOCK2a:CONST:BLOCK2b")
4437: && block_groups[1].equals("BLOCK2a")
4438: && block_groups[2].equals("BLOCK2b")) {
4439: filter1_got_block2 = true;
4440: } else if (block_groups[0]
4441: .equals("FILTER1:BLOCK3a:CONST:BLOCK3b")
4442: && block_groups[1].equals("BLOCK3a")
4443: && block_groups[2].equals("BLOCK3b")) {
4444: filter1_got_block3 = true;
4445: }
4446: }
4447: assertTrue(filter1_got_block1 && filter1_got_block2
4448: && filter1_got_block3);
4449:
4450: filtered_blocks = template.getFilteredBlocks(filter2);
4451: assertEquals(2, filtered_blocks.size());
4452:
4453: boolean filter2_got_block1 = false;
4454: boolean filter2_got_block2 = false;
4455: for (String[] block_groups : filtered_blocks) {
4456: assertEquals(2, block_groups.length);
4457: if (block_groups[0].equals("FILTER2:BLOCK1")
4458: && block_groups[1].equals("BLOCK1")) {
4459: filter2_got_block1 = true;
4460: } else if (block_groups[0].equals("FILTER2:BLOCK2")
4461: && block_groups[1].equals("BLOCK2")) {
4462: filter2_got_block2 = true;
4463: }
4464: }
4465: assertTrue(filter2_got_block1 && filter2_got_block2);
4466:
4467: filtered_blocks = template.getFilteredBlocks(filter3);
4468: assertEquals(2, filtered_blocks.size());
4469:
4470: boolean filter3_got_block1 = false;
4471: boolean filter3_got_block2 = false;
4472: for (String[] block_groups : filtered_blocks) {
4473: assertEquals(2, block_groups.length);
4474: if (block_groups[0].equals("CONST-FILTER3:BLOCK1")
4475: && block_groups[1].equals("BLOCK1")) {
4476: filter3_got_block1 = true;
4477: } else if (block_groups[0]
4478: .equals("CONST-FILTER3:BLOCK2")
4479: && block_groups[1].equals("BLOCK2")) {
4480: filter3_got_block2 = true;
4481: }
4482: }
4483: assertTrue(filter3_got_block1 && filter3_got_block2);
4484:
4485: factory = new TemplateFactory(
4486: ResourceFinderClasspath.getInstance(),
4487: "html",
4488: new Parser.Config[] { TemplateFactory.CONFIG_INVISIBLE_XML },
4489: "text/html", ".html", new String[] { filter4,
4490: filter1, filter2, filter3 }, null, null,
4491: null, null);
4492:
4493: template = factory.get("blocks_filtered_in");
4494:
4495: assertFalse(template.hasFilteredBlocks(filter1));
4496: assertFalse(template.hasFilteredBlocks(filter2));
4497: assertFalse(template.hasFilteredBlocks(filter3));
4498: assertTrue(template.hasFilteredBlocks(filter4));
4499:
4500: filtered_blocks = template.getFilteredBlocks(filter4);
4501: assertEquals(7, filtered_blocks.size());
4502:
4503: boolean filter4_got_block1 = false;
4504: boolean filter4_got_block2 = false;
4505: boolean filter4_got_block3 = false;
4506: boolean filter4_got_block4 = false;
4507: boolean filter4_got_block5 = false;
4508: boolean filter4_got_block6 = false;
4509: boolean filter4_got_block7 = false;
4510: for (String[] block_groups : filtered_blocks) {
4511: if (block_groups[0]
4512: .equals("FILTER1:BLOCK1a:CONST:BLOCK1b")
4513: && block_groups[1].equals("FILTER1")
4514: && block_groups[2].equals("BLOCK1a")
4515: && block_groups[3].equals("CONST")
4516: && block_groups[4].equals("BLOCK1b")) {
4517: assertEquals(5, block_groups.length);
4518: filter4_got_block1 = true;
4519: continue;
4520: }
4521: if (block_groups[0]
4522: .equals("FILTER1:BLOCK2a:CONST:BLOCK2b")
4523: && block_groups[1].equals("FILTER1")
4524: && block_groups[2].equals("BLOCK2a")
4525: && block_groups[3].equals("CONST")
4526: && block_groups[4].equals("BLOCK2b")) {
4527: assertEquals(5, block_groups.length);
4528: filter4_got_block2 = true;
4529: continue;
4530: }
4531: if (block_groups[0]
4532: .equals("FILTER1:BLOCK3a:CONST:BLOCK3b")
4533: && block_groups[1].equals("FILTER1")
4534: && block_groups[2].equals("BLOCK3a")
4535: && block_groups[3].equals("CONST")
4536: && block_groups[4].equals("BLOCK3b")) {
4537: assertEquals(5, block_groups.length);
4538: filter4_got_block3 = true;
4539: continue;
4540: }
4541: if (block_groups[0].equals("FILTER2:BLOCK1")
4542: && block_groups[1].equals("FILTER2")
4543: && block_groups[2].equals("BLOCK1")) {
4544: assertEquals(3, block_groups.length);
4545: filter4_got_block4 = true;
4546: continue;
4547: }
4548: if (block_groups[0].equals("FILTER2:BLOCK2")
4549: && block_groups[1].equals("FILTER2")
4550: && block_groups[2].equals("BLOCK2")) {
4551: assertEquals(3, block_groups.length);
4552: filter4_got_block5 = true;
4553: continue;
4554: }
4555: if (block_groups[0].equals("CONST-FILTER3:BLOCK1")
4556: && block_groups[1].equals("CONST")
4557: && block_groups[2].equals("FILTER3")
4558: && block_groups[3].equals("BLOCK1")) {
4559: assertEquals(4, block_groups.length);
4560: filter4_got_block6 = true;
4561: continue;
4562: }
4563: if (block_groups[0].equals("CONST-FILTER3:BLOCK2")
4564: && block_groups[1].equals("CONST")
4565: && block_groups[2].equals("FILTER3")
4566: && block_groups[3].equals("BLOCK2")) {
4567: assertEquals(4, block_groups.length);
4568: filter4_got_block7 = true;
4569: continue;
4570: }
4571: }
4572: assertTrue(filter4_got_block1 && filter4_got_block2
4573: && filter4_got_block3 && filter4_got_block4
4574: && filter4_got_block5 && filter4_got_block6
4575: && filter4_got_block7);
4576: } catch (TemplateException e) {
4577: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4578: }
4579: }
4580:
4581: public void testFilteredValues() {
4582: String filter1 = "^FILTER1:(\\w+):CONST:(\\w+)$";
4583: String filter2 = "^FILTER2:(\\w+)$";
4584: String filter3 = "^CONST-FILTER3:(\\w+)$";
4585: String filter4 = "(\\w+)";
4586:
4587: TemplateFactory factory = null;
4588: Template template = null;
4589:
4590: try {
4591: factory = new TemplateFactory(
4592: ResourceFinderClasspath.getInstance(),
4593: "html",
4594: new Parser.Config[] { TemplateFactory.CONFIG_INVISIBLE_XML },
4595: "text/html", ".html", null, new String[] { filter1,
4596: filter2, filter3, filter4 }, null, null,
4597: null);
4598:
4599: template = factory.get("values_filtered_in");
4600:
4601: assertTrue(template.hasFilteredValues(filter1));
4602: assertTrue(template.hasFilteredValues(filter2));
4603: assertTrue(template.hasFilteredValues(filter3));
4604: assertFalse(template.hasFilteredValues(filter4));
4605:
4606: List<String[]> filtered_values = null;
4607:
4608: filtered_values = template.getFilteredValues(filter1);
4609: assertEquals(3, filtered_values.size());
4610:
4611: boolean filter1_got_value1 = false;
4612: boolean filter1_got_value2 = false;
4613: boolean filter1_got_value3 = false;
4614: for (String[] value_groups : filtered_values) {
4615: assertEquals(3, value_groups.length);
4616: if (value_groups[0]
4617: .equals("FILTER1:VALUE1a:CONST:VALUE1b")
4618: && value_groups[1].equals("VALUE1a")
4619: && value_groups[2].equals("VALUE1b")) {
4620: filter1_got_value1 = true;
4621: } else if (value_groups[0]
4622: .equals("FILTER1:VALUE2a:CONST:VALUE2b")
4623: && value_groups[1].equals("VALUE2a")
4624: && value_groups[2].equals("VALUE2b")) {
4625: filter1_got_value2 = true;
4626: } else if (value_groups[0]
4627: .equals("FILTER1:VALUE3a:CONST:VALUE3b")
4628: && value_groups[1].equals("VALUE3a")
4629: && value_groups[2].equals("VALUE3b")) {
4630: filter1_got_value3 = true;
4631: }
4632: }
4633: assertTrue(filter1_got_value1 && filter1_got_value2
4634: && filter1_got_value3);
4635:
4636: filtered_values = template.getFilteredValues(filter2);
4637: assertEquals(2, filtered_values.size());
4638:
4639: boolean filter2_got_value1 = false;
4640: boolean filter2_got_value2 = false;
4641: for (String[] value_groups : filtered_values) {
4642: assertEquals(2, value_groups.length);
4643: if (value_groups[0].equals("FILTER2:VALUE1")
4644: && value_groups[1].equals("VALUE1")) {
4645: filter2_got_value1 = true;
4646: } else if (value_groups[0].equals("FILTER2:VALUE2")
4647: && value_groups[1].equals("VALUE2")) {
4648: filter2_got_value2 = true;
4649: }
4650: }
4651: assertTrue(filter2_got_value1 && filter2_got_value2);
4652:
4653: filtered_values = template.getFilteredValues(filter3);
4654: assertEquals(2, filtered_values.size());
4655:
4656: boolean filter3_got_value1 = false;
4657: boolean filter3_got_value2 = false;
4658: for (String[] value_groups : filtered_values) {
4659: assertEquals(2, value_groups.length);
4660: if (value_groups[0].equals("CONST-FILTER3:VALUE1")
4661: && value_groups[1].equals("VALUE1")) {
4662: filter3_got_value1 = true;
4663: } else if (value_groups[0]
4664: .equals("CONST-FILTER3:VALUE2")
4665: && value_groups[1].equals("VALUE2")) {
4666: filter3_got_value2 = true;
4667: }
4668: }
4669: assertTrue(filter3_got_value1 && filter3_got_value2);
4670:
4671: factory = new TemplateFactory(
4672: ResourceFinderClasspath.getInstance(),
4673: "html",
4674: new Parser.Config[] { TemplateFactory.CONFIG_INVISIBLE_XML },
4675: "text/html", ".html", null, new String[] { filter4,
4676: filter1, filter2, filter3 }, null, null,
4677: null);
4678:
4679: template = factory.get("values_filtered_in");
4680:
4681: assertFalse(template.hasFilteredValues(filter1));
4682: assertFalse(template.hasFilteredValues(filter2));
4683: assertFalse(template.hasFilteredValues(filter3));
4684: assertTrue(template.hasFilteredValues(filter4));
4685:
4686: filtered_values = template.getFilteredValues(filter4);
4687: assertEquals(7, filtered_values.size());
4688:
4689: boolean filter4_got_value1 = false;
4690: boolean filter4_got_value2 = false;
4691: boolean filter4_got_value3 = false;
4692: boolean filter4_got_value4 = false;
4693: boolean filter4_got_value5 = false;
4694: boolean filter4_got_value6 = false;
4695: boolean filter4_got_value7 = false;
4696: for (String[] value_groups : filtered_values) {
4697: if (value_groups[0]
4698: .equals("FILTER1:VALUE1a:CONST:VALUE1b")
4699: && value_groups[1].equals("FILTER1")
4700: && value_groups[2].equals("VALUE1a")
4701: && value_groups[3].equals("CONST")
4702: && value_groups[4].equals("VALUE1b")) {
4703: assertEquals(5, value_groups.length);
4704: filter4_got_value1 = true;
4705: continue;
4706: }
4707: if (value_groups[0]
4708: .equals("FILTER1:VALUE2a:CONST:VALUE2b")
4709: && value_groups[1].equals("FILTER1")
4710: && value_groups[2].equals("VALUE2a")
4711: && value_groups[3].equals("CONST")
4712: && value_groups[4].equals("VALUE2b")) {
4713: assertEquals(5, value_groups.length);
4714: filter4_got_value2 = true;
4715: continue;
4716: }
4717: if (value_groups[0]
4718: .equals("FILTER1:VALUE3a:CONST:VALUE3b")
4719: && value_groups[1].equals("FILTER1")
4720: && value_groups[2].equals("VALUE3a")
4721: && value_groups[3].equals("CONST")
4722: && value_groups[4].equals("VALUE3b")) {
4723: assertEquals(5, value_groups.length);
4724: filter4_got_value3 = true;
4725: continue;
4726: }
4727: if (value_groups[0].equals("FILTER2:VALUE1")
4728: && value_groups[1].equals("FILTER2")
4729: && value_groups[2].equals("VALUE1")) {
4730: assertEquals(3, value_groups.length);
4731: filter4_got_value4 = true;
4732: continue;
4733: }
4734: if (value_groups[0].equals("FILTER2:VALUE2")
4735: && value_groups[1].equals("FILTER2")
4736: && value_groups[2].equals("VALUE2")) {
4737: assertEquals(3, value_groups.length);
4738: filter4_got_value5 = true;
4739: continue;
4740: }
4741: if (value_groups[0].equals("CONST-FILTER3:VALUE1")
4742: && value_groups[1].equals("CONST")
4743: && value_groups[2].equals("FILTER3")
4744: && value_groups[3].equals("VALUE1")) {
4745: assertEquals(4, value_groups.length);
4746: filter4_got_value6 = true;
4747: continue;
4748: }
4749: if (value_groups[0].equals("CONST-FILTER3:VALUE2")
4750: && value_groups[1].equals("CONST")
4751: && value_groups[2].equals("FILTER3")
4752: && value_groups[3].equals("VALUE2")) {
4753: assertEquals(4, value_groups.length);
4754: filter4_got_value7 = true;
4755: continue;
4756: }
4757: }
4758: assertTrue(filter4_got_value1 && filter4_got_value2
4759: && filter4_got_value3 && filter4_got_value4
4760: && filter4_got_value5 && filter4_got_value6
4761: && filter4_got_value7);
4762: } catch (TemplateException e) {
4763: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4764: }
4765: }
4766:
4767: public void testReloadBasic() {
4768: // setup the temporary directory
4769: String template_dir = RifeConfig.Global.getTempPath();
4770: File template_dir_file = new File(template_dir);
4771: template_dir_file.mkdirs();
4772:
4773: // setup the first template file
4774: URL template1_resource = TemplateFactory.HTML.getParser()
4775: .resolve("defaultvalues_in");
4776: String template1_name = "reload_basic";
4777: File template1_file = new File(template_dir + File.separator
4778: + template1_name
4779: + TemplateFactory.HTML.getParser().getExtension());
4780: template1_file.delete();
4781: try {
4782: FileUtils.copy(template1_resource.openStream(),
4783: template1_file);
4784: } catch (FileUtilsErrorException e) {
4785: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4786: return;
4787: } catch (IOException e) {
4788: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4789: return;
4790: }
4791: // obtain the original template
4792: Template template1 = null;
4793: try {
4794: template1 = TemplateFactory.HTML.get(template1_name);
4795: assertNotNull(template1);
4796: } catch (TemplateException e) {
4797: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4798: }
4799:
4800: // wait a second
4801: try {
4802: Thread.sleep(1000);
4803: } catch (InterruptedException e) {
4804: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4805: }
4806:
4807: // overwrite the template file with new content
4808: URL template2_resource = TemplateFactory.HTML.getParser()
4809: .resolve("noblocks_in");
4810: try {
4811: FileUtils.copy(template2_resource.openStream(),
4812: template1_file);
4813: } catch (FileUtilsErrorException e) {
4814: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4815: return;
4816: } catch (IOException e) {
4817: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4818: return;
4819: }
4820: // obtain the modified template
4821: Template template2 = null;
4822: try {
4823: template2 = TemplateFactory.HTML.get(template1_name);
4824: assertNotNull(template2);
4825: } catch (TemplateException e) {
4826: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4827: }
4828:
4829: // verify if the template was correctly reloaded
4830: assertTrue(template1 != template2);
4831: assertTrue(template1.getClass() != template2.getClass());
4832: assertTrue(template1.getModificationTime() < template2
4833: .getModificationTime());
4834: assertFalse(template1.getContent().equals(
4835: template2.getContent()));
4836:
4837: // clean up the copied files
4838: template1_file.delete();
4839: }
4840:
4841: public void testReloadIncludes() {
4842: // setup the temporary directory
4843: String template_dir = RifeConfig.Global.getTempPath();
4844: File template_dir_file = new File(template_dir);
4845: template_dir_file.mkdirs();
4846:
4847: // setup the first template file with its included file
4848: URL template1_resource = TemplateFactory.HTML.getParser()
4849: .resolve("includes_reload_master_in");
4850: String template1_name = "includes_reload_master";
4851: File template1_file = new File(template_dir + File.separator
4852: + template1_name
4853: + TemplateFactory.HTML.getParser().getExtension());
4854: template1_file.delete();
4855: URL template1_included_resource = TemplateFactory.HTML
4856: .getParser().resolve("defaultvalues_in");
4857: String template1_included_name = "includes_reload_included_in";
4858: File template1_included_file = new File(template_dir
4859: + File.separator + template1_included_name
4860: + TemplateFactory.HTML.getParser().getExtension());
4861: template1_included_file.delete();
4862: try {
4863: FileUtils.copy(template1_resource.openStream(),
4864: template1_file);
4865: FileUtils.copy(template1_included_resource.openStream(),
4866: template1_included_file);
4867: } catch (FileUtilsErrorException e) {
4868: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4869: return;
4870: } catch (IOException e) {
4871: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4872: return;
4873: }
4874: // obtain the original template
4875: Template template1 = null;
4876: try {
4877: template1 = TemplateFactory.HTML.get(template1_name);
4878: assertNotNull(template1);
4879: } catch (TemplateException e) {
4880: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4881: }
4882:
4883: // wait a second
4884: try {
4885: Thread.sleep(1000);
4886: } catch (InterruptedException e) {
4887: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4888: }
4889:
4890: // modify the contents of the included file
4891: URL template1_included_resource2 = TemplateFactory.HTML
4892: .getParser().resolve("noblocks_in");
4893: try {
4894: FileUtils.copy(template1_included_resource2.openStream(),
4895: template1_included_file);
4896: } catch (FileUtilsErrorException e) {
4897: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4898: return;
4899: } catch (IOException e) {
4900: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4901: return;
4902: }
4903: // obtain the modified template
4904: Template template2 = null;
4905: try {
4906: template2 = TemplateFactory.HTML.get(template1_name);
4907: assertNotNull(template2);
4908: } catch (TemplateException e) {
4909: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4910: }
4911:
4912: // check if the template was correctly updated
4913: assertTrue(template1 != template2);
4914: assertTrue(template1.getClass() != template2.getClass());
4915: assertTrue(false == template1.getContent().equals(
4916: template2.getContent()));
4917:
4918: // clean up the copied files and the created dir
4919: template1_file.delete();
4920: template1_included_file.delete();
4921: }
4922:
4923: public void testReloadMultiLevelIncludes() {
4924: // setup the temporary directory
4925: String template_dir = RifeConfig.Global.getTempPath();
4926: File template_dir_file = new File(template_dir);
4927: template_dir_file.mkdirs();
4928:
4929: // setup the first template file with its included file
4930: URL template1_resource = TemplateFactory.HTML.getParser()
4931: .resolve("includes_reload_multi_master_in");
4932: String template1_name = "includes_reload_multi_master";
4933: File template1_file = new File(template_dir + File.separator
4934: + template1_name
4935: + TemplateFactory.HTML.getParser().getExtension());
4936: template1_file.delete();
4937:
4938: URL template1_included_resource = TemplateFactory.HTML
4939: .getParser().resolve("defaultvalues_in");
4940: String template1_included_name = "includes_reload_multi_included2_in";
4941: File template1_included_file = new File(template_dir
4942: + File.separator + template1_included_name
4943: + TemplateFactory.HTML.getParser().getExtension());
4944: template1_included_file.delete();
4945: try {
4946: FileUtils.copy(template1_resource.openStream(),
4947: template1_file);
4948: FileUtils.copy(template1_included_resource.openStream(),
4949: template1_included_file);
4950: } catch (FileUtilsErrorException e) {
4951: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4952: return;
4953: } catch (IOException e) {
4954: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4955: return;
4956: }
4957: // obtain the original template
4958: Template template1 = null;
4959: try {
4960: template1 = TemplateFactory.HTML.get(template1_name);
4961: assertNotNull(template1);
4962: } catch (TemplateException e) {
4963: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4964: }
4965:
4966: // wait a second
4967: try {
4968: Thread.sleep(1000);
4969: } catch (InterruptedException e) {
4970: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4971: }
4972:
4973: // modify the contents of the included file
4974: URL template1_included_resource2 = TemplateFactory.HTML
4975: .getParser().resolve("noblocks_in");
4976: try {
4977: FileUtils.copy(template1_included_resource2.openStream(),
4978: template1_included_file);
4979: } catch (FileUtilsErrorException e) {
4980: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4981: return;
4982: } catch (IOException e) {
4983: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4984: return;
4985: }
4986: // obtain the modified template
4987: Template template2 = null;
4988: try {
4989: template2 = TemplateFactory.HTML.get(template1_name);
4990: assertNotNull(template2);
4991: } catch (TemplateException e) {
4992: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
4993: }
4994:
4995: // check if the template was correctly updated
4996: assertTrue(template1 != template2);
4997: assertTrue(template1.getClass() != template2.getClass());
4998: assertTrue(false == template1.getContent().equals(
4999: template2.getContent()));
5000:
5001: // clean up the copied files and the created dir
5002: template1_file.delete();
5003: template1_included_file.delete();
5004: }
5005:
5006: public void testReloadTransformationDependencies() {
5007: // setup the temporary directory
5008: String template_dir = RifeConfig.Global.getTempPath();
5009: File template_dir_file = new File(template_dir);
5010: template_dir_file.mkdirs();
5011:
5012: // setup the first template file with its dependencies
5013: URL template1_resource = TemplateFactory.XML.getParser()
5014: .resolve("transformation_reload_master_in");
5015: String template1_name = "transformation_reload_master";
5016: File template1_file = new File(template_dir + File.separator
5017: + template1_name
5018: + TemplateFactory.XML.getParser().getExtension());
5019: template1_file.delete();
5020:
5021: URL template1_dependency_resource1 = ResourceFinderClasspath
5022: .getInstance().getResource("testxslt_stylesheet1.xsl");
5023: String template1_dependency_name1 = "transformation_reload_dependency1.xsl";
5024: File template1_dependency_file1 = new File(template_dir
5025: + File.separator + template1_dependency_name1);
5026: template1_dependency_file1.delete();
5027:
5028: URL template1_dependency_resource2 = ResourceFinderClasspath
5029: .getInstance().getResource("testxslt_stylesheet2.xsl");
5030: String template1_dependency_name2 = "transformation_reload_dependency2.xsl";
5031: File template1_dependency_file2 = new File(template_dir
5032: + File.separator + template1_dependency_name2);
5033: template1_dependency_file2.delete();
5034:
5035: try {
5036: FileUtils.copy(template1_resource.openStream(),
5037: template1_file);
5038: FileUtils.copy(template1_dependency_resource1.openStream(),
5039: template1_dependency_file1);
5040: FileUtils.copy(template1_dependency_resource2.openStream(),
5041: template1_dependency_file2);
5042: } catch (FileUtilsErrorException e) {
5043: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5044: return;
5045: } catch (IOException e) {
5046: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5047: return;
5048: }
5049:
5050: // setup the transformer
5051: TemplateTransformerXslt transformer = new TemplateTransformerXslt();
5052: transformer.addFilter(template1_dependency_name2);
5053:
5054: // obtain the original template
5055: Template template1 = null;
5056: try {
5057: template1 = TemplateFactory.XML.get(template1_name,
5058: transformer);
5059: assertNotNull(template1);
5060: } catch (TemplateException e) {
5061: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5062: }
5063:
5064: // wait a second
5065: try {
5066: Thread.sleep(1000);
5067: } catch (InterruptedException e) {
5068: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5069: }
5070:
5071: // modify the contents of the second dependency file
5072: URL template1_dependency_resource3 = ResourceFinderClasspath
5073: .getInstance().getResource("testxslt_stylesheet3.xsl");
5074: try {
5075: FileUtils.copy(template1_dependency_resource3.openStream(),
5076: template1_dependency_file2);
5077: } catch (FileUtilsErrorException e) {
5078: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5079: return;
5080: } catch (IOException e) {
5081: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5082: return;
5083: }
5084:
5085: // obtain the modified template
5086: Template template2 = null;
5087: try {
5088: template2 = TemplateFactory.XML.get(template1_name,
5089: transformer);
5090: assertNotNull(template2);
5091: } catch (TemplateException e) {
5092: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5093: }
5094:
5095: // check if the template was correctly updated
5096: assertTrue(template1 != template2);
5097: assertTrue(template1.getClass() != template2.getClass());
5098: assertTrue(false == template1.getContent().equals(
5099: template2.getContent()));
5100:
5101: // wait a second
5102: try {
5103: Thread.sleep(1000);
5104: } catch (InterruptedException e) {
5105: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5106: }
5107:
5108: // modify the contents of the second dependency file
5109: URL template1_dependency_resource4 = ResourceFinderClasspath
5110: .getInstance().getResource("testxslt_stylesheet2.xsl");
5111: try {
5112: FileUtils.copy(template1_dependency_resource4.openStream(),
5113: template1_dependency_file1);
5114: } catch (FileUtilsErrorException e) {
5115: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5116: return;
5117: } catch (IOException e) {
5118: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5119: return;
5120: }
5121:
5122: // obtain the modified template
5123: Template template3 = null;
5124: try {
5125: template3 = TemplateFactory.XML.get(template1_name,
5126: transformer);
5127: assertNotNull(template3);
5128: } catch (TemplateException e) {
5129: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5130: }
5131:
5132: // check if the template was correctly updated
5133: assertTrue(template1 != template3);
5134: assertTrue(template2 != template3);
5135: assertTrue(template1.getClass() != template3.getClass());
5136: assertTrue(template2.getClass() != template3.getClass());
5137: assertTrue(false == template1.getContent().equals(
5138: template3.getContent()));
5139: assertTrue(false == template2.getContent().equals(
5140: template3.getContent()));
5141:
5142: // clean up the copied files and the created dir
5143: template1_file.delete();
5144: template1_dependency_file1.delete();
5145: template1_dependency_file2.delete();
5146: }
5147:
5148: public void testReloadTransformerState() {
5149: TemplateTransformerXslt transformer1 = new TemplateTransformerXslt();
5150: transformer1.addFilter("testxslt_stylesheet2.xsl");
5151: transformer1.addFilter("testxslt_stylesheet3.xsl");
5152:
5153: Template template1 = TemplateFactory.XML.get("testxslt_in",
5154: transformer1);
5155:
5156: TemplateTransformerXslt transformer2 = new TemplateTransformerXslt();
5157: transformer2.addFilter("testxslt_stylesheet2.xsl");
5158: transformer2.addFilter("testxslt_stylesheet3.xsl");
5159:
5160: Template template2 = TemplateFactory.XML.get("testxslt_in",
5161: transformer2);
5162:
5163: TemplateTransformerXslt transformer3 = new TemplateTransformerXslt();
5164: transformer3.addFilter("testxslt_stylesheet2.xsl");
5165:
5166: Template template3 = TemplateFactory.XML.get("testxslt_in",
5167: transformer3);
5168:
5169: TemplateTransformerXslt transformer4 = new TemplateTransformerXslt();
5170: transformer4.addFilter("testxslt_stylesheet2.xsl");
5171: transformer4.setOutputProperty(
5172: TemplateTransformerXslt.OUTPUT_USE_URL_ESCAPING,
5173: "false");
5174:
5175: Template template4 = TemplateFactory.XML.get("testxslt_in",
5176: transformer4);
5177:
5178: assertSame(template1.getClass(), template2.getClass());
5179: assertNotSame(template1.getClass(), template3.getClass());
5180: assertNotSame(template1.getClass(), template4.getClass());
5181: assertNotSame(template2.getClass(), template3.getClass());
5182: assertNotSame(template2.getClass(), template4.getClass());
5183: assertNotSame(template3.getClass(), template4.getClass());
5184: }
5185:
5186: public void testOtherResourceFinder() {
5187: DatabaseResources resources = DatabaseResourcesFactory
5188: .getInstance(Datasources.getRepInstance()
5189: .getDatasource("unittestsderby"));
5190: try {
5191: resources.install();
5192: resources
5193: .addResource("db_template_name.txt",
5194: "[!B 'block1']a block with value [!V 'value1'/][!/B][!V 'value2'/]");
5195:
5196: TemplateFactory factory = new TemplateFactory(resources,
5197: "databasetext", TemplateFactory.CONFIGS_TXT,
5198: "text/txt", ".txt", new String[] {
5199: TemplateFactory.TAG_CONFIG,
5200: TemplateFactory.TAG_L10N }, null,
5201: BeanHandlerPlainSingleton.INSTANCE, null, null);
5202: Template template = null;
5203:
5204: template = factory.get("db_template_name");
5205: assertEquals("[!V 'value2'/]", template.getContent());
5206: template.setValue("value1", 1);
5207: template.appendBlock("value2", "block1");
5208: template.setValue("value1", 2);
5209: template.appendBlock("value2", "block1");
5210: template.setValue("value1", 3);
5211: template.appendBlock("value2", "block1");
5212: template.setValue("value1", 4);
5213: template.appendBlock("value2", "block1");
5214: assertEquals("a block with value 1"
5215: + "a block with value 2" + "a block with value 3"
5216: + "a block with value 4", template.getContent());
5217:
5218: resources
5219: .updateResource("db_template_name.txt",
5220: "[!B 'block1']another block with value [!V 'value1'/][!/B][!V 'value3'/]");
5221:
5222: template = factory.get("db_template_name");
5223: assertEquals("[!V 'value3'/]", template.getContent());
5224: template.setValue("value1", 1);
5225: template.appendBlock("value3", "block1");
5226: template.setValue("value1", 2);
5227: template.appendBlock("value3", "block1");
5228: template.setValue("value1", 3);
5229: template.appendBlock("value3", "block1");
5230: template.setValue("value1", 4);
5231: template.appendBlock("value3", "block1");
5232: assertEquals("another block with value 1"
5233: + "another block with value 2"
5234: + "another block with value 3"
5235: + "another block with value 4", template
5236: .getContent());
5237: } catch (ResourceWriterErrorException e) {
5238: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5239: } catch (TemplateException e) {
5240: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5241: } finally {
5242: try {
5243: resources.remove();
5244: } catch (ResourceWriterErrorException e) {
5245: assertTrue(ExceptionUtils.getExceptionStackTrace(e),
5246: false);
5247: }
5248: }
5249: }
5250:
5251: public void testOtherResourceFinderCommonFactory() {
5252: DatabaseResources resources = DatabaseResourcesFactory
5253: .getInstance(Datasources.getRepInstance()
5254: .getDatasource("unittestsderby"));
5255: ResourceFinder previous = TemplateFactory.ENGINEHTML
5256: .getResourceFinder();
5257: TemplateFactory.ENGINEHTML.setResourceFinder(resources);
5258: try {
5259: resources.install();
5260: resources
5261: .addResource(
5262: "db_template_name.html",
5263: "<!--B 'block1'-->a block with value <!--V 'value1'/--><!--/B--><!--V 'value2'/-->");
5264:
5265: Template template = null;
5266:
5267: template = TemplateFactory.ENGINEHTML
5268: .get("db_template_name");
5269: assertEquals("<!--V 'value2'/-->", template.getContent());
5270: template.setValue("value1", 1);
5271: template.appendBlock("value2", "block1");
5272: template.setValue("value1", 2);
5273: template.appendBlock("value2", "block1");
5274: template.setValue("value1", 3);
5275: template.appendBlock("value2", "block1");
5276: template.setValue("value1", 4);
5277: template.appendBlock("value2", "block1");
5278: assertEquals("a block with value 1"
5279: + "a block with value 2" + "a block with value 3"
5280: + "a block with value 4", template.getContent());
5281:
5282: resources
5283: .updateResource(
5284: "db_template_name.html",
5285: "<!--B 'block1'-->another block with value <!--V 'value1'/--><!--/B--><!--V 'value3'/-->");
5286:
5287: template = TemplateFactory.ENGINEHTML
5288: .get("db_template_name");
5289: assertEquals("<!--V 'value3'/-->", template.getContent());
5290: template.setValue("value1", 1);
5291: template.appendBlock("value3", "block1");
5292: template.setValue("value1", 2);
5293: template.appendBlock("value3", "block1");
5294: template.setValue("value1", 3);
5295: template.appendBlock("value3", "block1");
5296: template.setValue("value1", 4);
5297: template.appendBlock("value3", "block1");
5298: assertEquals("another block with value 1"
5299: + "another block with value 2"
5300: + "another block with value 3"
5301: + "another block with value 4", template
5302: .getContent());
5303: } catch (ResourceWriterErrorException e) {
5304: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5305: } catch (TemplateException e) {
5306: assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
5307: } finally {
5308: TemplateFactory.ENGINEHTML.setResourceFinder(previous);
5309: try {
5310: resources.remove();
5311: } catch (ResourceWriterErrorException e) {
5312: assertTrue(ExceptionUtils.getExceptionStackTrace(e),
5313: false);
5314: }
5315: }
5316: }
5317: }
|