Examples of ApplicationStateManager


Examples of org.apache.tapestry.services.ApplicationStateManager

    @SuppressWarnings("unchecked")
    @Test
    public void field_read_and_write() throws Exception
    {
        ApplicationStateManager manager = newApplicationStateManager();
        Logger logger = mockLogger();
        MutableComponentModel model = mockMutableComponentModel();
        InternalComponentResources resources = mockInternalComponentResources();

        String componentClassName = StateHolder.class.getName();
        Class asoClass = ReadOnlyBean.class;

        ClassPool pool = new ClassPool();
        ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
        pool.appendClassPath(new LoaderClassPath(contextLoader));

        Loader loader = new Loader(contextLoader, pool);

        loader.delegateLoadingOf("org.apache.tapestry.");

        CtClass ctClass = pool.get(componentClassName);
        InternalClassTransformation transformation = new InternalClassTransformationImpl(ctClass,
                _contextClassLoader, logger, null);

        replay();

        new ApplicationStateWorker(manager).transform(transformation, model);

        verify();

        transformation.finish();

        Class transformedClass = pool.toClass(ctClass, loader);

        Instantiator instantiator = transformation.createInstantiator(transformedClass);

        Object component = instantiator.newInstance(resources);

        // Test the companion flag field

        expect(manager.exists(asoClass)).andReturn(true);

        replay();

        assertEquals(_access.get(component, "beanExists"), true);

        verify();

        // Test read property (get from ASM)

        Object aso = new ReadOnlyBean();

        train_get(manager, asoClass, aso);

        replay();

        assertSame(_access.get(component, "bean"), aso);

        verify();

        // Test write property (set ASM)

        Object aso2 = new ReadOnlyBean();

        manager.set(asoClass, aso2);

        replay();

        _access.set(component, "bean", aso2);
View Full Code Here

Examples of org.apache.tapestry.services.ApplicationStateManager

    }

    @Test
    public void no_fields_with_annotation()
    {
        ApplicationStateManager manager = mockApplicationStateManager();
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();

        train_findFieldsWithAnnotation(ct, ApplicationState.class);
View Full Code Here

Examples of org.apache.tapestry.services.ApplicationStateManager

    @SuppressWarnings("unchecked")
    @Test
    public void field_read_and_write() throws Exception
    {
        ApplicationStateManager manager = mockApplicationStateManager();
        Logger logger = mockLogger();
        MutableComponentModel model = mockMutableComponentModel();
        InternalComponentResources resources = mockInternalComponentResources();
        ComponentClassCache cache = mockComponentClassCache();

        Class asoClass = SimpleASO.class;

        CtClass ctClass = findCtClass(StateHolder.class);

        InternalClassTransformation transformation = new InternalClassTransformationImpl(ctClass, _classFactory, logger,
                                                                                         null);
        train_forName(cache, asoClass);

        replay();

        new ApplicationStateWorker(manager, cache).transform(transformation, model);

        verify();

        transformation.finish();

        Instantiator instantiator = transformation.createInstantiator();

        Object component = instantiator.newInstance(resources);

        // Test the companion flag field

        expect(manager.exists(asoClass)).andReturn(true);

        replay();

        assertEquals(_access.get(component, "beanExists"), true);

        verify();

        // Test read property (get from ASM)

        Object aso = new SimpleASO();

        train_get(manager, asoClass, aso);

        replay();

        assertSame(_access.get(component, "bean"), aso);

        verify();

        // Test write property (set ASM)

        Object aso2 = new SimpleASO();

        manager.set(asoClass, aso2);

        replay();

        _access.set(component, "bean", aso2);
View Full Code Here

Examples of org.apache.tapestry.services.ApplicationStateManager


    @Test
    public void read_field_with_create_disabled() throws Exception
    {
        ApplicationStateManager manager = mockApplicationStateManager();
        Logger logger = mockLogger();
        MutableComponentModel model = mockMutableComponentModel();
        InternalComponentResources resources = mockInternalComponentResources();
        ComponentClassCache cache = mockComponentClassCache();
View Full Code Here

Examples of org.apache.tapestry.services.ApplicationStateManager

    }

    @Test
    public void no_fields_with_annotation()
    {
        ApplicationStateManager manager = mockApplicationStateManager();
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();

        train_findFieldsWithAnnotation(ct, ApplicationState.class);
View Full Code Here

Examples of org.apache.tapestry.services.ApplicationStateManager

    @SuppressWarnings("unchecked")
    @Test
    public void field_read_and_write() throws Exception
    {
        ApplicationStateManager manager = mockApplicationStateManager();
        Logger logger = mockLogger();
        MutableComponentModel model = mockMutableComponentModel();
        InternalComponentResources resources = mockInternalComponentResources();
        ComponentClassCache cache = mockComponentClassCache();

        Class asoClass = SimpleASO.class;

        CtClass ctClass = findCtClass(StateHolder.class);

        InternalClassTransformation transformation = new InternalClassTransformationImpl(ctClass, _classFactory, logger,
                                                                                         null);
        train_forName(cache, asoClass);

        replay();

        new ApplicationStateWorker(manager, cache).transform(transformation, model);

        verify();

        transformation.finish();

        Instantiator instantiator = transformation.createInstantiator();

        Object component = instantiator.newInstance(resources);

        // Test the companion flag field

        expect(manager.exists(asoClass)).andReturn(true);

        replay();

        assertEquals(_access.get(component, "beanExists"), true);

        verify();

        // Test read property (get from ASM)

        Object aso = new SimpleASO();

        train_get(manager, asoClass, aso);

        replay();

        assertSame(_access.get(component, "bean"), aso);

        verify();

        // Test write property (set ASM)

        Object aso2 = new SimpleASO();

        manager.set(asoClass, aso2);

        replay();

        _access.set(component, "bean", aso2);
View Full Code Here

Examples of org.apache.tapestry.services.ApplicationStateManager


    @Test
    public void read_field_with_create_disabled() throws Exception
    {
        ApplicationStateManager manager = mockApplicationStateManager();
        Logger logger = mockLogger();
        MutableComponentModel model = mockMutableComponentModel();
        InternalComponentResources resources = mockInternalComponentResources();
        ComponentClassCache cache = mockComponentClassCache();
View Full Code Here

Examples of org.apache.tapestry.services.ApplicationStateManager

    }

    @Test
    public void no_fields_with_annotation()
    {
        ApplicationStateManager manager = newApplicationStateManager();
        ClassTransformation ct = newClassTransformation();
        MutableComponentModel model = newMutableComponentModel();

        train_findFieldsWithAnnotation(ct, ApplicationState.class);
View Full Code Here

Examples of org.apache.tapestry.services.ApplicationStateManager

    @SuppressWarnings("unchecked")
    @Test
    public void field_read_and_write() throws Exception
    {
        ApplicationStateManager manager = newApplicationStateManager();
        Log log = newLog();
        MutableComponentModel model = newMutableComponentModel();
        InternalComponentResources resources = newInternalComponentResources();

        String componentClassName = StateHolder.class.getName();
        Class asoClass = ReadOnlyBean.class;

        ClassPool pool = new ClassPool();
        ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
        pool.appendClassPath(new LoaderClassPath(contextLoader));

        Loader loader = new Loader(contextLoader, pool);

        loader.delegateLoadingOf("org.apache.tapestry.");

        CtClass ctClass = pool.get(componentClassName);
        InternalClassTransformation transformation = new InternalClassTransformationImpl(ctClass,
                _contextClassLoader, log, null);

        replay();

        new ApplicationStateWorker(manager).transform(transformation, model);

        verify();

        transformation.finish();

        Class transformedClass = pool.toClass(ctClass, loader);

        Instantiator instantiator = transformation.createInstantiator(transformedClass);

        Object component = instantiator.newInstance(resources);

        // Test read property (get from ASM)

        Object aso = new ReadOnlyBean();

        train_get(manager, asoClass, aso);

        replay();

        assertSame(_access.get(component, "bean"), aso);

        verify();

        // Test write property (set ASM)

        Object aso2 = new ReadOnlyBean();

        manager.set(asoClass, aso2);

        replay();

        _access.set(component, "bean", aso2);
View Full Code Here

Examples of org.apache.tapestry.services.ApplicationStateManager

        train_get(strategy, asoClass, creator, aso);

        replay();

        ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source);

        assertSame(manager.get(asoClass), aso);

        verify();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.