Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.CookieSource


    }

    public void testSuppliedByRequest()
    {
        MockControl sourceControl = newControl(CookieSource.class);
        CookieSource source = (CookieSource) sourceControl.getMock();

        MockControl requestControl = newControl(WebRequest.class);
        WebRequest request = (WebRequest) requestControl.getMock();

        ThreadLocale tl = newThreadLocale();

        // Training

        source.readCookieValue(TapestryConstants.LOCALE_COOKIE_NAME);
        sourceControl.setReturnValue(null);

        request.getLocale();
        requestControl.setReturnValue(Locale.JAPANESE);
View Full Code Here


    }

    private void attempt(String localeName, Locale expectedLocale)
    {
        MockControl sourceControl = newControl(CookieSource.class);
        CookieSource source = (CookieSource) sourceControl.getMock();

        ThreadLocale tl = newThreadLocale();

        // Training

        source.readCookieValue(TapestryConstants.LOCALE_COOKIE_NAME);
        sourceControl.setReturnValue(localeName);

        tl.setLocale(expectedLocale);

        replayControls();
View Full Code Here

    public void testPersist()
    {
        Locale locale = Locale.SIMPLIFIED_CHINESE;

        CookieSource source = (CookieSource) newMock(CookieSource.class);
        ThreadLocale threadLocale = newThreadLocale(locale);

        // Training

        source.writeCookieValue(TapestryConstants.LOCALE_COOKIE_NAME, locale.toString());

        replayControls();

        RequestLocaleManagerImpl m = new RequestLocaleManagerImpl();
        m.setCookieSource(source);
View Full Code Here

    }

    public void testPersistNoChange()
    {
        MockControl sourceControl = newControl(CookieSource.class);
        CookieSource source = (CookieSource) sourceControl.getMock();

        MockControl requestControl = newControl(WebRequest.class);
        WebRequest request = (WebRequest) requestControl.getMock();

        MockControl tlc = newControl(ThreadLocale.class);
        ThreadLocale tl = (ThreadLocale) tlc.getMock();

        // Training

        source.readCookieValue(TapestryConstants.LOCALE_COOKIE_NAME);
        sourceControl.setReturnValue(null);

        request.getLocale();
        requestControl.setReturnValue(Locale.JAPANESE);
View Full Code Here

public class TestRequestLocaleManager extends HiveMindTestCase
{
    public void testSuppliedByRequest()
    {
        MockControl sourceControl = newControl(CookieSource.class);
        CookieSource source = (CookieSource) sourceControl.getMock();

        MockControl requestControl = newControl(HttpServletRequest.class);
        HttpServletRequest request = (HttpServletRequest) requestControl.getMock();

        // Training

        source.readCookieValue(TapestryConstants.LOCALE_COOKIE_NAME);
        sourceControl.setReturnValue(null);

        request.getLocale();
        requestControl.setReturnValue(Locale.JAPANESE);
View Full Code Here

    }

    private void attempt(String localeName, Locale expectedLocale)
    {
        MockControl sourceControl = newControl(CookieSource.class);
        CookieSource source = (CookieSource) sourceControl.getMock();

        // Training

        source.readCookieValue(TapestryConstants.LOCALE_COOKIE_NAME);
        sourceControl.setReturnValue(localeName);

        replayControls();

        RequestLocaleManagerImpl manager = new RequestLocaleManagerImpl();
View Full Code Here

        attempt("en_US_Bahstohn", new Locale("en", "US", "Bahstohn"));
    }

    public void testPersist()
    {
        CookieSource source = (CookieSource) newMock(CookieSource.class);

        Locale locale = Locale.SIMPLIFIED_CHINESE;

        // Training

        source.writeCookieValue(TapestryConstants.LOCALE_COOKIE_NAME, locale.toString());

        replayControls();

        RequestLocaleManagerImpl m = new RequestLocaleManagerImpl();
        m.setCookieSource(source);
View Full Code Here

    }

    public void testPersistNoChange()
    {
        MockControl sourceControl = newControl(CookieSource.class);
        CookieSource source = (CookieSource) sourceControl.getMock();

        MockControl requestControl = newControl(HttpServletRequest.class);
        HttpServletRequest request = (HttpServletRequest) requestControl.getMock();

        // Training

        source.readCookieValue(TapestryConstants.LOCALE_COOKIE_NAME);
        sourceControl.setReturnValue(null);

        request.getLocale();
        requestControl.setReturnValue(Locale.JAPANESE);
View Full Code Here

        return threadLocale;
    }

    public void testSuppliedByRequest()
    {
        CookieSource source = newMock(CookieSource.class);
       
        WebRequest request = newRequest();

        ThreadLocale tl = newThreadLocale();

        // Training

        expect(source.readCookieValue(TapestryConstants.LOCALE_COOKIE_NAME)).andReturn(null);

        expect(request.getLocale()).andReturn(Locale.JAPANESE);

        tl.setLocale(Locale.JAPANESE);
View Full Code Here

        verify();
    }

    private void attempt(String localeName, Locale expectedLocale)
    {
        CookieSource source = newMock(CookieSource.class);

        ThreadLocale tl = newThreadLocale();

        // Training

        expect(source.readCookieValue(TapestryConstants.LOCALE_COOKIE_NAME)).andReturn(localeName);

        tl.setLocale(expectedLocale);

        replay();
View Full Code Here

TOP

Related Classes of org.apache.tapestry.services.CookieSource

Copyright © 2018 www.massapicom. 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.