Search in sources :

Example 1 with LiteDeviceDelegatingViewResolver

use of org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver in project spring-boot by spring-projects.

the class DeviceDelegatingViewResolverAutoConfigurationTests method getLiteDeviceDelegatingViewResolverAccessor.

private PropertyAccessor getLiteDeviceDelegatingViewResolverAccessor(String... configuration) {
    load(configuration);
    LiteDeviceDelegatingViewResolver liteDeviceDelegatingViewResolver = this.context.getBean("deviceDelegatingJspViewResolver", LiteDeviceDelegatingViewResolver.class);
    return new DirectFieldAccessor(liteDeviceDelegatingViewResolver);
}
Also used : LiteDeviceDelegatingViewResolver(org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor)

Example 2 with LiteDeviceDelegatingViewResolver

use of org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver in project spring-boot by spring-projects.

the class DeviceDelegatingViewResolverAutoConfigurationTests method assertLiteDeviceDelegatingViewResolver.

public void assertLiteDeviceDelegatingViewResolver(ViewResolver delegate, String delegatingBeanName) {
    LiteDeviceDelegatingViewResolver deviceDelegatingViewResolver = this.context.getBean(delegatingBeanName, LiteDeviceDelegatingViewResolver.class);
    assertThat(deviceDelegatingViewResolver.getViewResolver()).isSameAs(delegate);
    assertThat(deviceDelegatingViewResolver.getOrder()).isEqualTo(((Ordered) delegate).getOrder() - 1);
}
Also used : LiteDeviceDelegatingViewResolver(org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver) Ordered(org.springframework.core.Ordered)

Example 3 with LiteDeviceDelegatingViewResolver

use of org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver in project spring-boot by spring-projects.

the class DeviceDelegatingViewResolverAutoConfigurationTests method defaultPropertyValues.

@Test
public void defaultPropertyValues() throws Exception {
    load("spring.mobile.devicedelegatingviewresolver.enabled:true");
    LiteDeviceDelegatingViewResolver liteDeviceDelegatingViewResolver = this.context.getBean("deviceDelegatingJspViewResolver", LiteDeviceDelegatingViewResolver.class);
    DirectFieldAccessor accessor = new DirectFieldAccessor(liteDeviceDelegatingViewResolver);
    assertThat(accessor.getPropertyValue("enableFallback")).isEqualTo(Boolean.FALSE);
    assertThat(accessor.getPropertyValue("normalPrefix")).isEqualTo("");
    assertThat(accessor.getPropertyValue("mobilePrefix")).isEqualTo("mobile/");
    assertThat(accessor.getPropertyValue("tabletPrefix")).isEqualTo("tablet/");
    assertThat(accessor.getPropertyValue("normalSuffix")).isEqualTo("");
    assertThat(accessor.getPropertyValue("mobileSuffix")).isEqualTo("");
    assertThat(accessor.getPropertyValue("tabletSuffix")).isEqualTo("");
}
Also used : LiteDeviceDelegatingViewResolver(org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 4 with LiteDeviceDelegatingViewResolver

use of org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver in project spring-boot by spring-projects.

the class DeviceDelegatingViewResolverFactory method createViewResolver.

/**
	 * Create a {@link LiteDeviceDelegatingViewResolver} delegating to the specified
	 * {@link ViewResolver}.
	 * @param delegate the view resolver to delegate to
	 * @param delegatingOrder the order of the {@link LiteDeviceDelegatingViewResolver}
	 * @return a {@link LiteDeviceDelegatingViewResolver} handling the specified resolver
	 */
public LiteDeviceDelegatingViewResolver createViewResolver(ViewResolver delegate, int delegatingOrder) {
    LiteDeviceDelegatingViewResolver resolver = new LiteDeviceDelegatingViewResolver(delegate);
    resolver.setEnableFallback(this.properties.isEnableFallback());
    resolver.setNormalPrefix(this.properties.getNormalPrefix());
    resolver.setNormalSuffix(this.properties.getNormalSuffix());
    resolver.setMobilePrefix(this.properties.getMobilePrefix());
    resolver.setMobileSuffix(this.properties.getMobileSuffix());
    resolver.setTabletPrefix(this.properties.getTabletPrefix());
    resolver.setTabletSuffix(this.properties.getTabletSuffix());
    resolver.setOrder(delegatingOrder);
    return resolver;
}
Also used : LiteDeviceDelegatingViewResolver(org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver)

Aggregations

LiteDeviceDelegatingViewResolver (org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver)4 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)2 Test (org.junit.Test)1 Ordered (org.springframework.core.Ordered)1