use of cn.taketoday.beans.DirectFieldAccessor in project today-infrastructure by TAKETODAY.
the class ScriptTemplateViewTests method engineSupplierWithNonSharedEngine.
// gh-23258
@Test
public void engineSupplierWithNonSharedEngine() {
this.configurer.setEngineSupplier(() -> mock(InvocableScriptEngine.class));
this.configurer.setRenderObject("Template");
this.configurer.setRenderFunction("render");
this.configurer.setSharedEngine(false);
DirectFieldAccessor accessor = new DirectFieldAccessor(view);
this.view.setApplicationContext(this.wac);
ScriptEngine engine1 = this.view.getEngine();
ScriptEngine engine2 = this.view.getEngine();
assertThat(engine1).isNotNull();
assertThat(engine2).isNotNull();
assertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template");
assertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
assertThat(accessor.getPropertyValue("sharedEngine")).asInstanceOf(BOOLEAN).isFalse();
}
use of cn.taketoday.beans.DirectFieldAccessor in project today-infrastructure by TAKETODAY.
the class GroovyMarkupViewTests method customTemplateEngine.
@Test
public void customTemplateEngine() throws Exception {
GroovyMarkupView view = new GroovyMarkupView();
view.setTemplateEngine(new TestTemplateEngine());
view.setApplicationContext(this.webAppContext);
DirectFieldAccessor accessor = new DirectFieldAccessor(view);
TemplateEngine engine = (TemplateEngine) accessor.getPropertyValue("engine");
assertThat(engine).isNotNull();
assertThat(engine.getClass()).isEqualTo(TestTemplateEngine.class);
}
use of cn.taketoday.beans.DirectFieldAccessor in project today-infrastructure by TAKETODAY.
the class GroovyMarkupViewTests method detectTemplateEngine.
@Test
public void detectTemplateEngine() throws Exception {
GroovyMarkupView view = new GroovyMarkupView();
view.setTemplateEngine(new TestTemplateEngine());
view.setApplicationContext(this.webAppContext);
DirectFieldAccessor accessor = new DirectFieldAccessor(view);
TemplateEngine engine = (TemplateEngine) accessor.getPropertyValue("engine");
assertThat(engine).isNotNull();
assertThat(engine.getClass()).isEqualTo(TestTemplateEngine.class);
}
use of cn.taketoday.beans.DirectFieldAccessor in project today-infrastructure by TAKETODAY.
the class ScriptTemplateViewResolverTests method viewClass.
@Test
public void viewClass() throws Exception {
ScriptTemplateViewResolver resolver = new ScriptTemplateViewResolver();
assertThat(resolver.requiredViewClass()).isEqualTo(ScriptTemplateView.class);
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
Class<?> viewClass = (Class<?>) viewAccessor.getPropertyValue("viewClass");
assertThat(viewClass).isEqualTo(ScriptTemplateView.class);
}
use of cn.taketoday.beans.DirectFieldAccessor in project today-infrastructure by TAKETODAY.
the class BinaryExceptionClassifierTests method testClassifySubclassMatchInCauseFalse.
@Test
public void testClassifySubclassMatchInCauseFalse() {
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
map.put(IllegalStateException.class, true);
map.put(BarException.class, false);
BinaryExceptionClassifier binaryExceptionClassifier = new BinaryExceptionClassifier(map, true);
binaryExceptionClassifier.setTraverseCauses(true);
assertTrue(binaryExceptionClassifier.classify(new RuntimeException(new FooException("Foo", new BarException()))));
assertTrue(((Map<?, ?>) new DirectFieldAccessor(binaryExceptionClassifier).getPropertyValue("classified")).containsKey(FooException.class));
}
Aggregations