Search in sources :

Example 1 with ApplicationStateContribution

use of org.apache.tapestry5.services.ApplicationStateContribution 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();
}
Also used : ApplicationStatePersistenceStrategySource(org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource) ApplicationStatePersistenceStrategy(org.apache.tapestry5.services.ApplicationStatePersistenceStrategy) ApplicationStateManager(org.apache.tapestry5.services.ApplicationStateManager) ApplicationStateContribution(org.apache.tapestry5.services.ApplicationStateContribution) ReadOnlyBean(org.apache.tapestry5.internal.transform.pages.ReadOnlyBean) Test(org.testng.annotations.Test)

Example 2 with ApplicationStateContribution

use of org.apache.tapestry5.services.ApplicationStateContribution 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();
}
Also used : ApplicationStatePersistenceStrategySource(org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource) ApplicationStatePersistenceStrategy(org.apache.tapestry5.services.ApplicationStatePersistenceStrategy) ApplicationStateManager(org.apache.tapestry5.services.ApplicationStateManager) ApplicationStateContribution(org.apache.tapestry5.services.ApplicationStateContribution) ReadOnlyBean(org.apache.tapestry5.internal.transform.pages.ReadOnlyBean) Test(org.testng.annotations.Test)

Example 3 with ApplicationStateContribution

use of org.apache.tapestry5.services.ApplicationStateContribution 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();
}
Also used : ApplicationStatePersistenceStrategySource(org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource) ApplicationStatePersistenceStrategy(org.apache.tapestry5.services.ApplicationStatePersistenceStrategy) ApplicationStateManager(org.apache.tapestry5.services.ApplicationStateManager) ApplicationStateContribution(org.apache.tapestry5.services.ApplicationStateContribution) ReadOnlyBean(org.apache.tapestry5.internal.transform.pages.ReadOnlyBean) Test(org.testng.annotations.Test)

Example 4 with ApplicationStateContribution

use of org.apache.tapestry5.services.ApplicationStateContribution 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();
}
Also used : ApplicationStatePersistenceStrategySource(org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource) ApplicationStatePersistenceStrategy(org.apache.tapestry5.services.ApplicationStatePersistenceStrategy) ApplicationStateManager(org.apache.tapestry5.services.ApplicationStateManager) ApplicationStateContribution(org.apache.tapestry5.services.ApplicationStateContribution) ReadOnlyBean(org.apache.tapestry5.internal.transform.pages.ReadOnlyBean) Test(org.testng.annotations.Test)

Example 5 with ApplicationStateContribution

use of org.apache.tapestry5.services.ApplicationStateContribution in project tapestry-5 by apache.

the class ApplicationStateManagerImplTest method check_exists_when_null.

@SuppressWarnings("unchecked")
@Test
public void check_exists_when_null() {
    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_exists(strategy, asoClass, false);
    replay();
    ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source, null);
    assertFalse(manager.exists(asoClass));
    verify();
}
Also used : ApplicationStatePersistenceStrategySource(org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource) ApplicationStatePersistenceStrategy(org.apache.tapestry5.services.ApplicationStatePersistenceStrategy) ApplicationStateManager(org.apache.tapestry5.services.ApplicationStateManager) ApplicationStateContribution(org.apache.tapestry5.services.ApplicationStateContribution) ReadOnlyBean(org.apache.tapestry5.internal.transform.pages.ReadOnlyBean) Test(org.testng.annotations.Test)

Aggregations

ApplicationStateContribution (org.apache.tapestry5.services.ApplicationStateContribution)8 ReadOnlyBean (org.apache.tapestry5.internal.transform.pages.ReadOnlyBean)7 ApplicationStateManager (org.apache.tapestry5.services.ApplicationStateManager)7 ApplicationStatePersistenceStrategy (org.apache.tapestry5.services.ApplicationStatePersistenceStrategy)7 ApplicationStatePersistenceStrategySource (org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource)7 Test (org.testng.annotations.Test)7 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 Metamodel (javax.persistence.metamodel.Metamodel)1 PersistenceUnitInfo (javax.persistence.spi.PersistenceUnitInfo)1 ObjectLocator (org.apache.tapestry5.commons.ObjectLocator)1 Holder (org.apache.tapestry5.internal.util.Holder)1 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)1 ApplicationStateCreator (org.apache.tapestry5.services.ApplicationStateCreator)1 IAnswer (org.easymock.IAnswer)1