use of cn.taketoday.beans.DirectFieldAccessor in project today-infrastructure by TAKETODAY.
the class GroovyMarkupViewResolverTests method viewClass.
@Test
public void viewClass() throws Exception {
GroovyMarkupViewResolver resolver = new GroovyMarkupViewResolver();
assertThat(resolver.requiredViewClass()).isEqualTo(GroovyMarkupView.class);
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
Class<?> viewClass = (Class<?>) viewAccessor.getPropertyValue("viewClass");
assertThat(viewClass).isEqualTo(GroovyMarkupView.class);
}
use of cn.taketoday.beans.DirectFieldAccessor in project today-infrastructure by TAKETODAY.
the class MappingJackson2JsonViewTests method validateResult.
private void validateResult() throws Exception {
String json = response.getContentAsString();
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(view);
String jsonPrefix = (String) viewAccessor.getPropertyValue("jsonPrefix");
if (jsonPrefix != null) {
json = json.substring(5);
}
Object jsResult = jsContext.evaluateString(jsScope, "(" + json + ")", "JSON Stream", 1, null);
assertThat(jsResult).as("Json Result did not eval as valid JavaScript").isNotNull();
MediaType mediaType = MediaType.parseMediaType(response.getContentType());
assertThat(mediaType.isCompatibleWith(MediaType.APPLICATION_JSON)).isTrue();
}
use of cn.taketoday.beans.DirectFieldAccessor in project today-infrastructure by TAKETODAY.
the class ScriptTemplateViewTests method engineSupplierWithSharedEngine.
// gh-23258
@Test
public void engineSupplierWithSharedEngine() {
this.configurer.setEngineSupplier(() -> mock(InvocableScriptEngine.class));
this.configurer.setRenderObject("Template");
this.configurer.setRenderFunction("render");
this.configurer.setSharedEngine(true);
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).isTrue();
}
use of cn.taketoday.beans.DirectFieldAccessor in project today-infrastructure by TAKETODAY.
the class ScriptTemplateViewTests method detectScriptTemplateConfigWithEngineName.
@Test
public void detectScriptTemplateConfigWithEngineName() {
this.configurer.setEngineName("nashorn");
this.configurer.setRenderObject("Template");
this.configurer.setRenderFunction("render");
DirectFieldAccessor accessor = new DirectFieldAccessor(view);
this.view.setApplicationContext(this.wac);
assertThat(accessor.getPropertyValue("engineName")).isEqualTo("nashorn");
assertThat(accessor.getPropertyValue("engine")).isNotNull();
assertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template");
assertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render");
assertThat(accessor.getPropertyValue("contentType")).isEqualTo(MediaType.TEXT_HTML_VALUE);
assertThat(accessor.getPropertyValue("charset")).isEqualTo(StandardCharsets.UTF_8);
}
use of cn.taketoday.beans.DirectFieldAccessor in project today-infrastructure by TAKETODAY.
the class ScheduledTasksBeanDefinitionParserTests method checkScheduler.
@Test
public void checkScheduler() {
Object schedulerBean = this.context.getBean("testScheduler");
Object schedulerRef = new DirectFieldAccessor(this.registrar).getPropertyValue("taskScheduler");
assertThat(schedulerRef).isEqualTo(schedulerBean);
}
Aggregations