use of org.thymeleaf.context.EngineContext in project thymeleaf-tests by thymeleaf.
the class EngineContextTest method test06.
@Test
public void test06() {
final IEngineConfiguration configuration = TestTemplateEngineConfigurationBuilder.build();
final TemplateData templateData1 = TestTemplateDataConfigurationBuilder.build("test01", TemplateMode.HTML);
final EngineContext vm = new EngineContext(configuration, templateData1, null, LOCALE, null);
vm.setVariable("one", "a value");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("a value", vm.getVariable("one"));
vm.increaseLevel();
vm.setVariable("one", "hello");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("hello", vm.getVariable("one"));
vm.setVariable("two", "twello");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertEquals("hello", vm.getVariable("one"));
Assert.assertEquals("twello", vm.getVariable("two"));
vm.setVariable("three", "trwello");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertEquals("hello", vm.getVariable("one"));
Assert.assertEquals("twello", vm.getVariable("two"));
Assert.assertEquals("trwello", vm.getVariable("three"));
vm.setVariable("four", "fwello");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertTrue(vm.containsVariable("four"));
Assert.assertEquals("hello", vm.getVariable("one"));
Assert.assertEquals("twello", vm.getVariable("two"));
Assert.assertEquals("trwello", vm.getVariable("three"));
Assert.assertEquals("fwello", vm.getVariable("four"));
vm.setVariable("five", "vwello");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertTrue(vm.containsVariable("four"));
Assert.assertTrue(vm.containsVariable("five"));
Assert.assertEquals("hello", vm.getVariable("one"));
Assert.assertEquals("twello", vm.getVariable("two"));
Assert.assertEquals("trwello", vm.getVariable("three"));
Assert.assertEquals("fwello", vm.getVariable("four"));
Assert.assertEquals("vwello", vm.getVariable("five"));
vm.setVariable("six", "swello");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertTrue(vm.containsVariable("four"));
Assert.assertTrue(vm.containsVariable("five"));
Assert.assertTrue(vm.containsVariable("six"));
Assert.assertEquals("hello", vm.getVariable("one"));
Assert.assertEquals("twello", vm.getVariable("two"));
Assert.assertEquals("trwello", vm.getVariable("three"));
Assert.assertEquals("fwello", vm.getVariable("four"));
Assert.assertEquals("vwello", vm.getVariable("five"));
Assert.assertEquals("swello", vm.getVariable("six"));
vm.setVariable("seven", "svwello");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertTrue(vm.containsVariable("four"));
Assert.assertTrue(vm.containsVariable("five"));
Assert.assertTrue(vm.containsVariable("six"));
Assert.assertTrue(vm.containsVariable("seven"));
Assert.assertEquals("hello", vm.getVariable("one"));
Assert.assertEquals("twello", vm.getVariable("two"));
Assert.assertEquals("trwello", vm.getVariable("three"));
Assert.assertEquals("fwello", vm.getVariable("four"));
Assert.assertEquals("vwello", vm.getVariable("five"));
Assert.assertEquals("swello", vm.getVariable("six"));
Assert.assertEquals("svwello", vm.getVariable("seven"));
}
use of org.thymeleaf.context.EngineContext in project thymeleaf-tests by thymeleaf.
the class EngineContextTest method test09.
@Test
public void test09() {
final IEngineConfiguration configuration = TestTemplateEngineConfigurationBuilder.build();
final TemplateData templateData1 = TestTemplateDataConfigurationBuilder.build("test01", TemplateMode.HTML);
final TemplateData templateData2 = TestTemplateDataConfigurationBuilder.build("test02", TemplateMode.HTML);
final TemplateData templateData3 = TestTemplateDataConfigurationBuilder.build("test03", TemplateMode.XML);
final TemplateData templateData4 = TestTemplateDataConfigurationBuilder.build("test04", TemplateMode.TEXT);
final EngineContext vm = new EngineContext(configuration, templateData1, null, LOCALE, null);
Assert.assertEquals(TemplateMode.HTML, vm.getTemplateMode());
Assert.assertSame(templateData1, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1), vm.getTemplateStack());
vm.setVariable("one", "a value");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("a value", vm.getVariable("one"));
Assert.assertEquals(TemplateMode.HTML, vm.getTemplateMode());
Assert.assertSame(templateData1, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1), vm.getTemplateStack());
vm.setVariable("one", "two values");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("two values", vm.getVariable("one"));
vm.removeVariable("one");
Assert.assertFalse(vm.containsVariable("one"));
Assert.assertNull(vm.getVariable("one"));
vm.setVariable("one", "two values");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("two values", vm.getVariable("one"));
vm.increaseLevel();
Assert.assertEquals(TemplateMode.HTML, vm.getTemplateMode());
Assert.assertSame(templateData1, vm.getTemplateData());
vm.setTemplateData(templateData2);
Assert.assertEquals(TemplateMode.HTML, vm.getTemplateMode());
Assert.assertSame(templateData2, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData2), vm.getTemplateStack());
vm.setVariable("one", "hello");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("hello", vm.getVariable("one"));
vm.removeVariable("one");
Assert.assertEquals(TemplateMode.HTML, vm.getTemplateMode());
Assert.assertSame(templateData2, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData2), vm.getTemplateStack());
Assert.assertFalse(vm.containsVariable("one"));
Assert.assertNull(vm.getVariable("one"));
vm.setVariable("one", "hello");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("hello", vm.getVariable("one"));
vm.removeVariable("two");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertEquals("hello", vm.getVariable("one"));
Assert.assertNull(vm.getVariable("twello"));
vm.setVariable("two", "twello");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertEquals("hello", vm.getVariable("one"));
Assert.assertEquals("twello", vm.getVariable("two"));
vm.removeVariable("two");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertEquals("hello", vm.getVariable("one"));
Assert.assertNull(vm.getVariable("twello"));
vm.removeVariable("one");
Assert.assertFalse(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertNull(vm.getVariable("one"));
Assert.assertNull(vm.getVariable("twello"));
vm.decreaseLevel();
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertEquals("two values", vm.getVariable("one"));
Assert.assertNull(vm.getVariable("two"));
vm.increaseLevel();
Assert.assertEquals(TemplateMode.HTML, vm.getTemplateMode());
Assert.assertSame(templateData1, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1), vm.getTemplateStack());
vm.setVariable("two", "twellor");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertEquals("two values", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
vm.setTemplateData(templateData2);
vm.increaseLevel();
Assert.assertEquals(TemplateMode.HTML, vm.getTemplateMode());
Assert.assertSame(templateData2, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData2), vm.getTemplateStack());
vm.setTemplateData(templateData3);
Assert.assertEquals(TemplateMode.XML, vm.getTemplateMode());
Assert.assertSame(templateData3, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData2, templateData3), vm.getTemplateStack());
vm.setVariable("three", "twelloree");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertEquals("two values", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
vm.setVariable("one", "atwe");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
Assert.assertEquals(TemplateMode.XML, vm.getTemplateMode());
Assert.assertSame(templateData3, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData2, templateData3), vm.getTemplateStack());
vm.increaseLevel();
Assert.assertEquals(TemplateMode.XML, vm.getTemplateMode());
Assert.assertSame(templateData3, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData2, templateData3), vm.getTemplateStack());
vm.removeVariable("two");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertNull(vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
vm.increaseLevel();
Assert.assertEquals(TemplateMode.XML, vm.getTemplateMode());
Assert.assertSame(templateData3, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData2, templateData3), vm.getTemplateStack());
vm.removeVariable("two");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertNull(vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
vm.increaseLevel();
Assert.assertEquals(TemplateMode.XML, vm.getTemplateMode());
Assert.assertSame(templateData3, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData2, templateData3), vm.getTemplateStack());
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertNull(vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
vm.setVariable("four", "lotwss");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertTrue(vm.containsVariable("four"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertNull(vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
Assert.assertEquals("lotwss", vm.getVariable("four"));
vm.setVariable("two", "itwiii");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertTrue(vm.containsVariable("four"));
Assert.assertFalse(vm.containsVariable("five"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertEquals("itwiii", vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
Assert.assertEquals("lotwss", vm.getVariable("four"));
vm.decreaseLevel();
Assert.assertEquals(TemplateMode.XML, vm.getTemplateMode());
Assert.assertSame(templateData3, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData2, templateData3), vm.getTemplateStack());
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertFalse(vm.containsVariable("four"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertNull(vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
Assert.assertNull(vm.getVariable("four"));
vm.decreaseLevel();
Assert.assertEquals(TemplateMode.XML, vm.getTemplateMode());
Assert.assertSame(templateData3, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData2, templateData3), vm.getTemplateStack());
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertFalse(vm.containsVariable("four"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertNull(vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
Assert.assertNull(vm.getVariable("four"));
vm.decreaseLevel();
Assert.assertEquals(TemplateMode.XML, vm.getTemplateMode());
Assert.assertSame(templateData3, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData2, templateData3), vm.getTemplateStack());
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertFalse(vm.containsVariable("four"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
Assert.assertNull(vm.getVariable("four"));
vm.decreaseLevel();
Assert.assertEquals(TemplateMode.HTML, vm.getTemplateMode());
Assert.assertSame(templateData2, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData2), vm.getTemplateStack());
vm.setTemplateData(templateData4);
Assert.assertEquals(TemplateMode.TEXT, vm.getTemplateMode());
Assert.assertSame(templateData4, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1, templateData4), vm.getTemplateStack());
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertFalse(vm.containsVariable("three"));
Assert.assertFalse(vm.containsVariable("four"));
Assert.assertEquals("two values", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
Assert.assertNull(vm.getVariable("three"));
Assert.assertNull(vm.getVariable("four"));
vm.decreaseLevel();
Assert.assertEquals(TemplateMode.HTML, vm.getTemplateMode());
Assert.assertSame(templateData1, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData1), vm.getTemplateStack());
vm.setTemplateData(templateData4);
Assert.assertEquals(TemplateMode.TEXT, vm.getTemplateMode());
Assert.assertSame(templateData4, vm.getTemplateData());
Assert.assertEquals(Arrays.asList(templateData4), vm.getTemplateStack());
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertFalse(vm.containsVariable("three"));
Assert.assertFalse(vm.containsVariable("four"));
Assert.assertEquals("two values", vm.getVariable("one"));
Assert.assertNull(vm.getVariable("two"));
Assert.assertNull(vm.getVariable("three"));
Assert.assertNull(vm.getVariable("four"));
}
use of org.thymeleaf.context.EngineContext in project thymeleaf-tests by thymeleaf.
the class EngineContextTest method test10.
@Test
public void test10() {
final IEngineConfiguration configuration = TestTemplateEngineConfigurationBuilder.build();
final TemplateData templateData1 = TestTemplateDataConfigurationBuilder.build("test01", TemplateMode.HTML);
final EngineContext vm = new EngineContext(configuration, templateData1, null, LOCALE, null);
Assert.assertFalse(vm.containsVariable("one"));
Assert.assertNull(vm.getVariable("one"));
vm.setVariable("one", null);
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertNull(vm.getVariable("one"));
vm.setVariable("one", "a value");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("a value", vm.getVariable("one"));
vm.increaseLevel();
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("a value", vm.getVariable("one"));
vm.setVariable("one", null);
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertNull(vm.getVariable("one"));
vm.decreaseLevel();
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("a value", vm.getVariable("one"));
}
use of org.thymeleaf.context.EngineContext in project thymeleaf-tests by thymeleaf.
the class EngineContextTest method test01.
@Test
public void test01() {
final IEngineConfiguration configuration = TestTemplateEngineConfigurationBuilder.build();
final TemplateData templateData1 = TestTemplateDataConfigurationBuilder.build("test01", TemplateMode.HTML);
final EngineContext vm = new EngineContext(configuration, templateData1, null, LOCALE, null);
vm.setVariable("one", "a value");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("a value", vm.getVariable("one"));
vm.setVariable("one", "two values");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("two values", vm.getVariable("one"));
vm.increaseLevel();
vm.setVariable("one", "hello");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertEquals("hello", vm.getVariable("one"));
vm.setVariable("two", "twello");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertEquals("hello", vm.getVariable("one"));
Assert.assertEquals("twello", vm.getVariable("two"));
vm.decreaseLevel();
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertEquals("two values", vm.getVariable("one"));
Assert.assertNull(vm.getVariable("two"));
vm.increaseLevel();
vm.setVariable("two", "twellor");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertEquals("two values", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
vm.increaseLevel();
vm.setVariable("three", "twelloree");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertEquals("two values", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
vm.setVariable("one", "atwe");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
vm.increaseLevel();
vm.increaseLevel();
vm.increaseLevel();
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
vm.setVariable("four", "lotwss");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertTrue(vm.containsVariable("four"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
Assert.assertEquals("lotwss", vm.getVariable("four"));
vm.setVariable("two", "itwiii");
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertTrue(vm.containsVariable("four"));
Assert.assertFalse(vm.containsVariable("five"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertEquals("itwiii", vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
Assert.assertEquals("lotwss", vm.getVariable("four"));
vm.decreaseLevel();
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertFalse(vm.containsVariable("four"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
Assert.assertNull(vm.getVariable("four"));
vm.decreaseLevel();
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertFalse(vm.containsVariable("four"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
Assert.assertNull(vm.getVariable("four"));
vm.decreaseLevel();
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertTrue(vm.containsVariable("three"));
Assert.assertFalse(vm.containsVariable("four"));
Assert.assertEquals("atwe", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
Assert.assertEquals("twelloree", vm.getVariable("three"));
Assert.assertNull(vm.getVariable("four"));
vm.decreaseLevel();
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertTrue(vm.containsVariable("two"));
Assert.assertFalse(vm.containsVariable("three"));
Assert.assertFalse(vm.containsVariable("four"));
Assert.assertEquals("two values", vm.getVariable("one"));
Assert.assertEquals("twellor", vm.getVariable("two"));
Assert.assertNull(vm.getVariable("three"));
Assert.assertNull(vm.getVariable("four"));
vm.decreaseLevel();
Assert.assertTrue(vm.containsVariable("one"));
Assert.assertFalse(vm.containsVariable("two"));
Assert.assertFalse(vm.containsVariable("three"));
Assert.assertFalse(vm.containsVariable("four"));
Assert.assertEquals("two values", vm.getVariable("one"));
Assert.assertNull(vm.getVariable("two"));
Assert.assertNull(vm.getVariable("three"));
Assert.assertNull(vm.getVariable("four"));
}
use of org.thymeleaf.context.EngineContext in project thymeleaf-tests by thymeleaf.
the class EngineContextTest method test05.
@Test
public void test05() {
final IEngineConfiguration configuration = TestTemplateEngineConfigurationBuilder.build();
final TemplateData templateData1 = TestTemplateDataConfigurationBuilder.build("test01", TemplateMode.HTML);
final EngineContext vm = new EngineContext(configuration, templateData1, null, LOCALE, null);
vm.setVariable("one", "a value");
Assert.assertEquals("{0:{one=a value}(test01)}[0]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=a value}(test01)", vm.toString());
Assert.assertEquals(createSet("one"), vm.getVariableNames());
vm.setVariable("one", "two values");
Assert.assertEquals("{0:{one=two values}(test01)}[0]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=two values}(test01)", vm.toString());
Assert.assertEquals(createSet("one"), vm.getVariableNames());
vm.removeVariable("one");
Assert.assertEquals("{0:{}(test01)}[0]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{}(test01)", vm.toString());
Assert.assertEquals(Collections.emptySet(), vm.getVariableNames());
vm.setVariable("one", "two values");
Assert.assertEquals("{0:{one=two values}(test01)}[0]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=two values}(test01)", vm.toString());
Assert.assertEquals(createSet("one"), vm.getVariableNames());
vm.increaseLevel();
vm.setVariable("one", "hello");
Assert.assertEquals("{1:{one=hello},0:{one=two values}(test01)}[1]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=hello}(test01)", vm.toString());
Assert.assertEquals(createSet("one"), vm.getVariableNames());
vm.removeVariable("one");
Assert.assertEquals("{1:{one=(*removed*)},0:{one=two values}(test01)}[1]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{}(test01)", vm.toString());
Assert.assertEquals(Collections.emptySet(), vm.getVariableNames());
vm.setVariable("one", "hello");
Assert.assertEquals("{1:{one=hello},0:{one=two values}(test01)}[1]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=hello}(test01)", vm.toString());
Assert.assertEquals(createSet("one"), vm.getVariableNames());
vm.removeVariable("two");
Assert.assertEquals("{1:{one=hello},0:{one=two values}(test01)}[1]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=hello}(test01)", vm.toString());
Assert.assertEquals(createSet("one"), vm.getVariableNames());
vm.setVariable("two", "twello");
vm.setInliner(new StandardTextInliner(configuration));
Assert.assertEquals("{1:{one=hello, two=twello}[StandardTextInliner],0:{one=two values}(test01)}[1]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=hello, two=twello}[StandardTextInliner](test01)", vm.toString());
Assert.assertEquals(createSet("one", "two"), vm.getVariableNames());
vm.removeVariable("two");
Assert.assertEquals("{1:{one=hello}[StandardTextInliner],0:{one=two values}(test01)}[1]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=hello}[StandardTextInliner](test01)", vm.toString());
Assert.assertEquals(createSet("one"), vm.getVariableNames());
vm.removeVariable("one");
Assert.assertEquals("{1:{one=(*removed*)}[StandardTextInliner],0:{one=two values}(test01)}[1]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{}[StandardTextInliner](test01)", vm.toString());
Assert.assertEquals(Collections.emptySet(), vm.getVariableNames());
vm.decreaseLevel();
Assert.assertEquals("{0:{one=two values}(test01)}[0]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=two values}(test01)", vm.toString());
Assert.assertEquals(createSet("one"), vm.getVariableNames());
vm.increaseLevel();
vm.setVariable("two", "twellor");
Assert.assertEquals("{1:{two=twellor},0:{one=two values}(test01)}[1]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=two values, two=twellor}(test01)", vm.toString());
Assert.assertEquals(createSet("one", "two"), vm.getVariableNames());
vm.increaseLevel();
vm.setVariable("three", "twelloree");
Assert.assertEquals("{2:{three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[2]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=two values, two=twellor, three=twelloree}(test01)", vm.toString());
Assert.assertEquals(createSet("one", "three", "two"), vm.getVariableNames());
vm.setVariable("one", "atwe");
Assert.assertEquals("{2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[2]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=atwe, two=twellor, three=twelloree}(test01)", vm.toString());
Assert.assertEquals(createSet("one", "three", "two"), vm.getVariableNames());
vm.increaseLevel();
vm.removeVariable("two");
Assert.assertEquals("{3:{two=(*removed*)},2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[3]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=atwe, three=twelloree}(test01)", vm.toString());
Assert.assertEquals(createSet("one", "three"), vm.getVariableNames());
vm.increaseLevel();
vm.removeVariable("two");
Assert.assertEquals("{3:{two=(*removed*)},2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[4]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=atwe, three=twelloree}(test01)", vm.toString());
Assert.assertEquals(createSet("one", "three"), vm.getVariableNames());
vm.increaseLevel();
Assert.assertEquals("{3:{two=(*removed*)},2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[5]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=atwe, three=twelloree}(test01)", vm.toString());
Assert.assertEquals(createSet("one", "three"), vm.getVariableNames());
vm.setVariable("four", "lotwss");
Assert.assertEquals("{5:{four=lotwss},3:{two=(*removed*)},2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[5]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=atwe, three=twelloree, four=lotwss}(test01)", vm.toString());
Assert.assertEquals(createSet("one", "three", "four"), vm.getVariableNames());
vm.setVariable("two", "itwiii");
Assert.assertEquals("{5:{four=lotwss, two=itwiii},3:{two=(*removed*)},2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[5]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=atwe, three=twelloree, four=lotwss, two=itwiii}(test01)", vm.toString());
Assert.assertEquals(createSet("one", "three", "four", "two"), vm.getVariableNames());
vm.decreaseLevel();
Assert.assertEquals("{3:{two=(*removed*)},2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[4]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=atwe, three=twelloree}(test01)", vm.toString());
Assert.assertEquals(createSet("one", "three"), vm.getVariableNames());
vm.decreaseLevel();
Assert.assertEquals("{3:{two=(*removed*)},2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[3]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=atwe, three=twelloree}(test01)", vm.toString());
Assert.assertEquals(createSet("one", "three"), vm.getVariableNames());
vm.decreaseLevel();
Assert.assertEquals("{2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[2]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=atwe, two=twellor, three=twelloree}(test01)", vm.toString());
Assert.assertEquals(createSet("one", "three", "two"), vm.getVariableNames());
vm.decreaseLevel();
Assert.assertEquals("{1:{two=twellor},0:{one=two values}(test01)}[1]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=two values, two=twellor}(test01)", vm.toString());
Assert.assertEquals(createSet("one", "two"), vm.getVariableNames());
vm.decreaseLevel();
Assert.assertEquals("{0:{one=two values}(test01)}[0]", vm.getStringRepresentationByLevel());
Assert.assertEquals("{one=two values}(test01)", vm.toString());
Assert.assertEquals(createSet("one"), vm.getVariableNames());
}
Aggregations