Search in sources :

Example 1 with EngineContext

use of org.thymeleaf.context.EngineContext in project thymeleaf-tests by thymeleaf.

the class EngineContextTest method test02.

@Test
public void test02() {
    final IEngineConfiguration configuration = TestTemplateEngineConfigurationBuilder.build();
    final TemplateData templateData1 = TestTemplateDataConfigurationBuilder.build("test01", TemplateMode.HTML);
    final Map<String, Object> starting = new LinkedHashMap<String, Object>();
    starting.put("one", "ha");
    starting.put("ten", "tieen");
    final EngineContext vm = new EngineContext(configuration, templateData1, null, LOCALE, starting);
    Assert.assertTrue(vm.containsVariable("one"));
    Assert.assertTrue(vm.containsVariable("ten"));
    Assert.assertEquals("ha", vm.getVariable("one"));
    Assert.assertEquals("tieen", vm.getVariable("ten"));
    vm.setVariable("one", "a value");
    Assert.assertTrue(vm.containsVariable("one"));
    Assert.assertTrue(vm.containsVariable("ten"));
    Assert.assertEquals("a value", vm.getVariable("one"));
    Assert.assertEquals("tieen", vm.getVariable("ten"));
    vm.increaseLevel();
    vm.setVariable("one", "hello");
    Assert.assertTrue(vm.containsVariable("one"));
    Assert.assertTrue(vm.containsVariable("ten"));
    Assert.assertEquals("hello", vm.getVariable("one"));
    Assert.assertEquals("tieen", vm.getVariable("ten"));
    vm.decreaseLevel();
    Assert.assertTrue(vm.containsVariable("one"));
    Assert.assertTrue(vm.containsVariable("ten"));
    Assert.assertEquals("a value", vm.getVariable("one"));
    Assert.assertEquals("tieen", vm.getVariable("ten"));
}
Also used : IEngineConfiguration(org.thymeleaf.IEngineConfiguration) EngineContext(org.thymeleaf.context.EngineContext) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 2 with EngineContext

use of org.thymeleaf.context.EngineContext in project thymeleaf-tests by thymeleaf.

the class EngineContextTest method test04.

@Test
public void test04() {
    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());
    vm.setVariable("one", "two values");
    Assert.assertEquals("{0:{one=two values}(test01)}[0]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=two values}(test01)", vm.toString());
    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());
    vm.setVariable("two", "twello");
    Assert.assertEquals("{1:{one=hello, two=twello},0:{one=two values}(test01)}[1]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=hello, two=twello}(test01)", vm.toString());
    vm.decreaseLevel();
    Assert.assertEquals("{0:{one=two values}(test01)}[0]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=two values}(test01)", vm.toString());
    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());
    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());
    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());
    vm.increaseLevel();
    vm.increaseLevel();
    vm.increaseLevel();
    Assert.assertEquals("{2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[5]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, two=twellor, three=twelloree}(test01)", vm.toString());
    vm.setVariable("four", "lotwss");
    Assert.assertEquals("{5:{four=lotwss},2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[5]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, two=twellor, three=twelloree, four=lotwss}(test01)", vm.toString());
    vm.setVariable("two", "itwiii");
    Assert.assertEquals("{5:{four=lotwss, two=itwiii},2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[5]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, two=itwiii, three=twelloree, four=lotwss}(test01)", vm.toString());
    vm.decreaseLevel();
    Assert.assertEquals("{2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[4]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, two=twellor, three=twelloree}(test01)", vm.toString());
    vm.decreaseLevel();
    Assert.assertEquals("{2:{one=atwe, three=twelloree},1:{two=twellor},0:{one=two values}(test01)}[3]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, two=twellor, three=twelloree}(test01)", vm.toString());
    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());
    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());
    vm.decreaseLevel();
    Assert.assertEquals("{0:{one=two values}(test01)}[0]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=two values}(test01)", vm.toString());
}
Also used : IEngineConfiguration(org.thymeleaf.IEngineConfiguration) EngineContext(org.thymeleaf.context.EngineContext) Test(org.junit.Test)

Example 3 with EngineContext

use of org.thymeleaf.context.EngineContext in project thymeleaf-tests by thymeleaf.

the class EngineContextTest method test08.

@Test
public void test08() {
    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 val1");
    vm.increaseLevel();
    vm.setVariable("one", "a val2");
    vm.setSelectionTarget("FORM");
    Assert.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("FORM", vm.getSelectionTarget());
    vm.decreaseLevel();
    vm.setVariable("one", "a val3");
    Assert.assertFalse(vm.hasSelectionTarget());
    Assert.assertNull(vm.getSelectionTarget());
    vm.increaseLevel();
    vm.setVariable("one", "a val4");
    Assert.assertFalse(vm.hasSelectionTarget());
    Assert.assertNull(vm.getSelectionTarget());
    vm.increaseLevel();
    vm.setVariable("one", "a val5");
    Assert.assertFalse(vm.hasSelectionTarget());
    Assert.assertNull(vm.getSelectionTarget());
}
Also used : IEngineConfiguration(org.thymeleaf.IEngineConfiguration) EngineContext(org.thymeleaf.context.EngineContext) Test(org.junit.Test)

Example 4 with EngineContext

use of org.thymeleaf.context.EngineContext in project thymeleaf-tests by thymeleaf.

the class EngineContextTest method test07.

@Test
public void test07() {
    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.assertFalse(vm.hasSelectionTarget());
    Assert.assertNull(vm.getSelectionTarget());
    Assert.assertEquals("{0:{one=a value}(test01)}[0]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=a value}(test01)", vm.toString());
    vm.increaseLevel();
    vm.setVariable("one", "hello");
    vm.removeVariable("one");
    vm.setVariable("one", "hello");
    vm.removeVariable("two");
    vm.setVariable("two", "twello");
    vm.setVariable("two", "twellor");
    Assert.assertFalse(vm.hasSelectionTarget());
    Assert.assertNull(vm.getSelectionTarget());
    Assert.assertEquals("{1:{one=hello, two=twellor},0:{one=a value}(test01)}[1]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=hello, two=twellor}(test01)", vm.toString());
    vm.increaseLevel();
    vm.setVariable("three", "twelloree");
    vm.setVariable("one", "atwe");
    Assert.assertFalse(vm.hasSelectionTarget());
    Assert.assertNull(vm.getSelectionTarget());
    Assert.assertEquals("{2:{one=atwe, three=twelloree},1:{one=hello, two=twellor},0:{one=a value}(test01)}[2]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, two=twellor, three=twelloree}(test01)", vm.toString());
    vm.setSelectionTarget("BIGFORM");
    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.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("BIGFORM", vm.getSelectionTarget());
    Assert.assertEquals("{2:{one=atwe, three=twelloree}<BIGFORM>,1:{one=hello, two=twellor},0:{one=a value}(test01)}[2]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, two=twellor, three=twelloree}<BIGFORM>(test01)", vm.toString());
    vm.increaseLevel();
    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"));
    Assert.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("BIGFORM", vm.getSelectionTarget());
    Assert.assertEquals("{3:{two=(*removed*)},2:{one=atwe, three=twelloree}<BIGFORM>,1:{one=hello, two=twellor},0:{one=a value}(test01)}[3]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, three=twelloree}<BIGFORM>(test01)", vm.toString());
    vm.increaseLevel();
    vm.removeVariable("two");
    vm.setSelectionTarget("SMALLFORM");
    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"));
    Assert.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("SMALLFORM", vm.getSelectionTarget());
    Assert.assertEquals("{4:<SMALLFORM>,3:{two=(*removed*)},2:{one=atwe, three=twelloree}<BIGFORM>,1:{one=hello, two=twellor},0:{one=a value}(test01)}[4]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, three=twelloree}<SMALLFORM>(test01)", vm.toString());
    vm.increaseLevel();
    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"));
    Assert.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("SMALLFORM", vm.getSelectionTarget());
    Assert.assertEquals("{4:<SMALLFORM>,3:{two=(*removed*)},2:{one=atwe, three=twelloree}<BIGFORM>,1:{one=hello, two=twellor},0:{one=a value}(test01)}[5]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, three=twelloree}<SMALLFORM>(test01)", vm.toString());
    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"));
    Assert.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("SMALLFORM", vm.getSelectionTarget());
    Assert.assertEquals("{5:{four=lotwss},4:<SMALLFORM>,3:{two=(*removed*)},2:{one=atwe, three=twelloree}<BIGFORM>,1:{one=hello, two=twellor},0:{one=a value}(test01)}[5]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, three=twelloree, four=lotwss}<SMALLFORM>(test01)", vm.toString());
    vm.decreaseLevel();
    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"));
    Assert.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("SMALLFORM", vm.getSelectionTarget());
    Assert.assertEquals("{4:<SMALLFORM>,3:{two=(*removed*)},2:{one=atwe, three=twelloree}<BIGFORM>,1:{one=hello, two=twellor},0:{one=a value}(test01)}[4]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, three=twelloree}<SMALLFORM>(test01)", vm.toString());
    vm.decreaseLevel();
    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"));
    Assert.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("BIGFORM", vm.getSelectionTarget());
    Assert.assertEquals("{3:{two=(*removed*)},2:{one=atwe, three=twelloree}<BIGFORM>,1:{one=hello, two=twellor},0:{one=a value}(test01)}[3]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, three=twelloree}<BIGFORM>(test01)", vm.toString());
    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"));
    Assert.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("BIGFORM", vm.getSelectionTarget());
    Assert.assertEquals("{2:{one=atwe, three=twelloree}<BIGFORM>,1:{one=hello, two=twellor},0:{one=a value}(test01)}[2]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, two=twellor, three=twelloree}<BIGFORM>(test01)", vm.toString());
    vm.setSelectionTarget("MEDIUMFORM");
    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"));
    Assert.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("MEDIUMFORM", vm.getSelectionTarget());
    Assert.assertEquals("{2:{one=atwe, three=twelloree}<MEDIUMFORM>,1:{one=hello, two=twellor},0:{one=a value}(test01)}[2]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=atwe, two=twellor, three=twelloree}<MEDIUMFORM>(test01)", vm.toString());
    vm.decreaseLevel();
    Assert.assertFalse(vm.hasSelectionTarget());
    Assert.assertNull(vm.getSelectionTarget());
    Assert.assertEquals("{1:{one=hello, two=twellor},0:{one=a value}(test01)}[1]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=hello, two=twellor}(test01)", vm.toString());
    vm.decreaseLevel();
    Assert.assertFalse(vm.hasSelectionTarget());
    Assert.assertNull(vm.getSelectionTarget());
    Assert.assertEquals("{0:{one=a value}(test01)}[0]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=a value}(test01)", vm.toString());
    vm.setSelectionTarget("TOTALFORM");
    Assert.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("TOTALFORM", vm.getSelectionTarget());
    Assert.assertEquals("{0:{one=a value}<TOTALFORM>(test01)}[0]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=a value}<TOTALFORM>(test01)", vm.toString());
    vm.increaseLevel();
    Assert.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("TOTALFORM", vm.getSelectionTarget());
    Assert.assertEquals("{0:{one=a value}<TOTALFORM>(test01)}[1]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=a value}<TOTALFORM>(test01)", vm.toString());
    vm.decreaseLevel();
    Assert.assertTrue(vm.containsVariable("one"));
    Assert.assertFalse(vm.containsVariable("two"));
    Assert.assertFalse(vm.containsVariable("three"));
    Assert.assertFalse(vm.containsVariable("four"));
    Assert.assertEquals("a value", vm.getVariable("one"));
    Assert.assertNull(vm.getVariable("two"));
    Assert.assertNull(vm.getVariable("three"));
    Assert.assertNull(vm.getVariable("four"));
    Assert.assertTrue(vm.hasSelectionTarget());
    Assert.assertEquals("TOTALFORM", vm.getSelectionTarget());
    Assert.assertEquals("{0:{one=a value}<TOTALFORM>(test01)}[0]", vm.getStringRepresentationByLevel());
    Assert.assertEquals("{one=a value}<TOTALFORM>(test01)", vm.toString());
}
Also used : IEngineConfiguration(org.thymeleaf.IEngineConfiguration) EngineContext(org.thymeleaf.context.EngineContext) Test(org.junit.Test)

Example 5 with EngineContext

use of org.thymeleaf.context.EngineContext in project thymeleaf-tests by thymeleaf.

the class EngineContextTest method test03.

@Test
public void test03() {
    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.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();
    vm.setVariable("one", "hello");
    Assert.assertTrue(vm.containsVariable("one"));
    Assert.assertEquals("hello", vm.getVariable("one"));
    vm.removeVariable("one");
    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();
    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.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();
    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.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.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.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.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"));
}
Also used : IEngineConfiguration(org.thymeleaf.IEngineConfiguration) EngineContext(org.thymeleaf.context.EngineContext) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 IEngineConfiguration (org.thymeleaf.IEngineConfiguration)10 EngineContext (org.thymeleaf.context.EngineContext)10 LinkedHashMap (java.util.LinkedHashMap)1 StandardTextInliner (org.thymeleaf.standard.inline.StandardTextInliner)1