Search in sources :

Example 1 with InfinispanSessionManagementConfiguration

use of org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagementConfiguration in project wildfly by wildfly.

the class DistributableWebDeploymentXMLReaderTestCase method testInfinispan.

@Test
public void testInfinispan() throws IOException, XMLStreamException {
    URL url = this.getClass().getResource(String.format("distributable-web-infinispan-%d.%d.xml", this.schema.major(), this.schema.minor()));
    XMLMapper mapper = XMLMapper.Factory.create();
    mapper.registerRootElement(this.schema.getRoot(), new DistributableWebDeploymentXMLReader(this.schema));
    try (InputStream input = url.openStream()) {
        XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(input);
        MutableDistributableDeploymentConfiguration config = new MutableDistributableDeploymentConfiguration();
        mapper.parseDocument(config, reader);
        Assert.assertNull(config.getSessionManagementName());
        DistributableSessionManagementProvider result = config.getSessionManagement();
        Assert.assertNotNull(result);
        Assert.assertTrue(result instanceof InfinispanSessionManagementProvider);
        InfinispanSessionManagementProvider provider = (InfinispanSessionManagementProvider) result;
        InfinispanSessionManagementConfiguration configuration = provider.getSessionManagementConfiguration();
        Assert.assertEquals("foo", configuration.getContainerName());
        Assert.assertEquals("bar", configuration.getCacheName());
        Assert.assertSame(SessionAttributePersistenceStrategy.FINE, configuration.getAttributePersistenceStrategy());
        if (this.schema.since(DistributableWebDeploymentSchema.VERSION_2_0)) {
            Assert.assertTrue(provider.getRouteLocatorServiceConfiguratorFactory() instanceof RankedRouteLocatorServiceConfiguratorFactory);
            RankedRoutingConfiguration routing = ((RankedRouteLocatorServiceConfiguratorFactory) provider.getRouteLocatorServiceConfiguratorFactory()).getConfiguration();
            Assert.assertEquals(":", routing.getDelimiter());
            Assert.assertEquals(4, routing.getMaxRoutes());
        } else {
            Assert.assertTrue(provider.getRouteLocatorServiceConfiguratorFactory() instanceof NullRouteLocatorServiceConfiguratorFactory);
        }
        Assert.assertNotNull(config.getImmutableClasses());
        Assert.assertEquals(Arrays.asList(Locale.class.getName(), UUID.class.getName()), config.getImmutableClasses());
    } finally {
        mapper.unregisterRootAttribute(this.schema.getRoot());
    }
}
Also used : XMLMapper(org.jboss.staxmapper.XMLMapper) RankedRouteLocatorServiceConfiguratorFactory(org.wildfly.clustering.web.infinispan.routing.RankedRouteLocatorServiceConfiguratorFactory) RankedRoutingConfiguration(org.wildfly.clustering.web.infinispan.routing.RankedRoutingConfiguration) XMLStreamReader(javax.xml.stream.XMLStreamReader) InputStream(java.io.InputStream) DistributableSessionManagementProvider(org.wildfly.clustering.web.session.DistributableSessionManagementProvider) InfinispanSessionManagementProvider(org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagementProvider) InfinispanSessionManagementConfiguration(org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagementConfiguration) URL(java.net.URL) NullRouteLocatorServiceConfiguratorFactory(org.wildfly.clustering.web.cache.routing.NullRouteLocatorServiceConfiguratorFactory) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)1 URL (java.net.URL)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 XMLMapper (org.jboss.staxmapper.XMLMapper)1 Test (org.junit.Test)1 NullRouteLocatorServiceConfiguratorFactory (org.wildfly.clustering.web.cache.routing.NullRouteLocatorServiceConfiguratorFactory)1 RankedRouteLocatorServiceConfiguratorFactory (org.wildfly.clustering.web.infinispan.routing.RankedRouteLocatorServiceConfiguratorFactory)1 RankedRoutingConfiguration (org.wildfly.clustering.web.infinispan.routing.RankedRoutingConfiguration)1 InfinispanSessionManagementConfiguration (org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagementConfiguration)1 InfinispanSessionManagementProvider (org.wildfly.clustering.web.infinispan.session.InfinispanSessionManagementProvider)1 DistributableSessionManagementProvider (org.wildfly.clustering.web.session.DistributableSessionManagementProvider)1