use of org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource in project tapestry-5 by apache.
the class ApplicationStateManagerImplTest method get_from_configured_aso.
@SuppressWarnings("unchecked")
@Test
public void get_from_configured_aso() {
String strategyName = "ethereal";
ApplicationStatePersistenceStrategy strategy = mockApplicationStatePersistenceStrategy();
ApplicationStatePersistenceStrategySource source = mockApplicationStatePersistenceStrategySource();
Class asoClass = ReadOnlyBean.class;
ApplicationStateCreator<ReadOnlyBean> creator = mockApplicationStateCreator();
ReadOnlyBean aso = new ReadOnlyBean();
Map<Class, ApplicationStateContribution> configuration = Collections.singletonMap(asoClass, new ApplicationStateContribution(strategyName, creator));
train_get(source, strategyName, strategy);
train_get(strategy, asoClass, creator, aso);
replay();
ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source, null);
assertSame(manager.get(asoClass), aso);
verify();
}
use of org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource in project tapestry-5 by apache.
the class ApplicationStateManagerImplTest method get_if_exists_and_it_doesnt.
@Test
public void get_if_exists_and_it_doesnt() {
String strategyName = "ethereal";
ApplicationStatePersistenceStrategy strategy = mockApplicationStatePersistenceStrategy();
ApplicationStatePersistenceStrategySource source = mockApplicationStatePersistenceStrategySource();
Class asoClass = ReadOnlyBean.class;
ApplicationStateCreator<ReadOnlyBean> creator = mockApplicationStateCreator();
Map<Class, ApplicationStateContribution> configuration = Collections.singletonMap(asoClass, new ApplicationStateContribution(strategyName, creator));
train_get(source, strategyName, strategy);
train_getIfExists(strategy, asoClass, null);
replay();
ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source, null);
assertNull(manager.getIfExists(asoClass));
verify();
}
use of org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource in project tapestry-5 by apache.
the class ApplicationStateManagerImplTest method get_if_exists_when_it_does_exist.
@Test
public void get_if_exists_when_it_does_exist() {
String strategyName = "ethereal";
ApplicationStatePersistenceStrategy strategy = mockApplicationStatePersistenceStrategy();
ApplicationStatePersistenceStrategySource source = mockApplicationStatePersistenceStrategySource();
Class asoClass = ReadOnlyBean.class;
ApplicationStateCreator<ReadOnlyBean> creator = mockApplicationStateCreator();
ReadOnlyBean aso = new ReadOnlyBean();
Map<Class, ApplicationStateContribution> configuration = Collections.singletonMap(asoClass, new ApplicationStateContribution(strategyName, creator));
train_get(source, strategyName, strategy);
train_getIfExists(strategy, asoClass, aso);
replay();
ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source, null);
assertSame(manager.getIfExists(asoClass), aso);
verify();
}
use of org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource in project tapestry-5 by apache.
the class ApplicationStatePersistenceStrategySourceImplTest method strategy_found.
@Test
public void strategy_found() {
ApplicationStatePersistenceStrategy strategy = mockApplicationStatePersistenceStrategy();
Map<String, ApplicationStatePersistenceStrategy> configuration = Collections.singletonMap("session", strategy);
replay();
ApplicationStatePersistenceStrategySource source = new ApplicationStatePersistenceStrategySourceImpl(configuration);
assertSame(strategy, source.get("session"));
verify();
}
use of org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource in project tapestry-5 by apache.
the class ApplicationStateManagerImplTest method set_configured_aso.
@SuppressWarnings("unchecked")
@Test
public void set_configured_aso() {
String strategyName = "ethereal";
ApplicationStatePersistenceStrategy strategy = mockApplicationStatePersistenceStrategy();
ApplicationStatePersistenceStrategySource source = mockApplicationStatePersistenceStrategySource();
Class asoClass = ReadOnlyBean.class;
Object aso = new ReadOnlyBean();
Map<Class, ApplicationStateContribution> configuration = Collections.singletonMap(asoClass, new ApplicationStateContribution(strategyName));
train_get(source, strategyName, strategy);
strategy.set(asoClass, aso);
replay();
ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source, null);
manager.set(asoClass, aso);
verify();
}
Aggregations