tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Howard Lewis Ship <hls...@gmail.com>
Subject Re: svn commit: r811842 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry5/ main/java/org/apache/tapestry5/internal/services/ main/java/org/apache/tapestry5/services/ test/java/org/apache/tapestry5/integration/app1/servi
Date Sun, 06 Sep 2009 18:04:51 GMT
I'm concerned about this change, because tapestry.js includes some calls to
Tapestry.Console.debug() and .error() and those will no longer work. This
would cause runtime exceptions (including XHR problems) to turn into
JavaScript errors, making it harder to diagnose what's gone wrong.
Perhaps tapestry.js should be changed to define placeholder versions of
Tapestry.Console.debug() and the rest that do nothing, or call
window.alert() (or use something similar to what T5.0 did, with a floaty div
that fades out).

Ideally, there would be a tapestry-console.js to provide those, and you
would either get tapestry-console.js or the blackbird.js.

On Sun, Sep 6, 2009 at 10:35 AM, <drobiazko@apache.org> wrote:

> Author: drobiazko
> Date: Sun Sep  6 17:35:12 2009
> New Revision: 811842
>
> URL: http://svn.apache.org/viewvc?rev=811842&view=rev
> Log:
> TAP5-678: Allow blackbird to be disabled in production mode
>
> Added:
>
>  tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClientInfrastructureImplTest.java
>   (with props)
> Modified:
>
>  tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
>
>  tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientInfrastructureImpl.java
>
>  tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
>
>  tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java
>
> Modified:
> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
> URL:
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java?rev=811842&r1=811841&r2=811842&view=diff
>
> ==============================================================================
> ---
> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
> (original)
> +++
> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
> Sun Sep  6 17:35:12 2009
> @@ -180,4 +180,11 @@
>      */
>     public static final String COMBINE_SCRIPTS =
> "tapestry.combine-scripts";
>
> +    /**
> +     * If "true" then Blackbird JavaScript console is enabled.
> +     *
> +     * @since 5.2.0.0
> +     */
> +    public static final String BLACKBIRD_ENABLED =
> "tapestry.blackbird-enabled";
> +
>  }
>
> Modified:
> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientInfrastructureImpl.java
> URL:
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientInfrastructureImpl.java?rev=811842&r1=811841&r2=811842&view=diff
>
> ==============================================================================
> ---
> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientInfrastructureImpl.java
> (original)
> +++
> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientInfrastructureImpl.java
> Sun Sep  6 17:35:12 2009
> @@ -15,6 +15,8 @@
>  package org.apache.tapestry5.internal.services;
>
>  import org.apache.tapestry5.Asset;
> +import org.apache.tapestry5.SymbolConstants;
> +import org.apache.tapestry5.ioc.annotations.Symbol;
>  import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
>  import org.apache.tapestry5.ioc.services.SymbolSource;
>  import org.apache.tapestry5.ioc.services.ThreadLocale;
> @@ -38,7 +40,9 @@
>
>     private final ThreadLocale threadLocale;
>
> -    private final List<Asset> javascriptStack, stylesheetStack;
> +    private final List<Asset> javascriptStack, stylesheetStack,
> javascriptStackTestMode, stylesheetStackTestMode;
> +
> +    private final boolean isBlackbirdEnabled;
>
>     private static final String[] CORE_JAVASCRIPT = new String[]
>             {
> @@ -50,24 +54,46 @@
>
>                     // Uses functions defined by the prior three
>
> -                    "org/apache/tapestry5/tapestry.js",
> +                    "org/apache/tapestry5/tapestry.js"
> +            };
> +
> +    private static final String[] CORE_JAVASCRIPT_TEST_MODE = new String[]
> +            {
> +                    // Only available in test mode
> +
>                     "${tapestry.blackbird}/blackbird.js"
>             };
> +
>
>     private static final String[] CORE_STYLESHEET = new String[]
>             {
> -                    "${tapestry.default-stylesheet}",
> +                    "${tapestry.default-stylesheet}"
> +            };
> +
> +
> +    private static final String[] CORE_STYLESHEET_TEST_MODE = new String[]
> +            {
> +                    // Only available in test mode
> +
>                     "${tapestry.blackbird}/blackbird.css"
>             };
>
> -    public ClientInfrastructureImpl(SymbolSource symbolSource, AssetSource
> assetSource, ThreadLocale threadLocale)
> +    public ClientInfrastructureImpl(SymbolSource symbolSource,
> +                                    AssetSource assetSource,
> +                                    ThreadLocale threadLocale,
> +
>  @Symbol(SymbolConstants.BLACKBIRD_ENABLED)
> +                                    boolean isBlackbirdEnabled)
>     {
>         this.symbolSource = symbolSource;
>         this.assetSource = assetSource;
>         this.threadLocale = threadLocale;
> +        this.isBlackbirdEnabled = isBlackbirdEnabled;
>
>         javascriptStack = convertToAssets(CORE_JAVASCRIPT);
>         stylesheetStack = convertToAssets(CORE_STYLESHEET);
> +
> +        javascriptStackTestMode =
> convertToAssets(CORE_JAVASCRIPT_TEST_MODE);
> +        stylesheetStackTestMode =
> convertToAssets(CORE_STYLESHEET_TEST_MODE);
>     }
>
>     private List<Asset> convertToAssets(String[] paths)
> @@ -91,7 +117,7 @@
>
>     public List<Asset> getJavascriptStack()
>     {
> -        List<Asset> result = CollectionFactory.newList(javascriptStack);
> +        List<Asset> result = createStack(javascriptStack,
> javascriptStackTestMode);
>
>         Asset messages = assetSource.getAsset(null,
> "org/apache/tapestry5/tapestry-messages.js",
>                                               threadLocale.getLocale());
> @@ -102,7 +128,19 @@
>     }
>
>     public List<Asset> getStylesheetStack()
> +    {
> +        return createStack(stylesheetStack, stylesheetStackTestMode);
> +    }
> +
> +    private List<Asset> createStack(List<Asset> stack, List<Asset>
> optionalStack)
>     {
> -        return stylesheetStack;
> +        List<Asset> result = CollectionFactory.newList(stack);
> +
> +        if(isBlackbirdEnabled)
> +        {
> +            result.addAll(optionalStack);
> +        }
> +
> +        return result;
>     }
>  }
>
> Modified:
> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
> URL:
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=811842&r1=811841&r2=811842&view=diff
>
> ==============================================================================
> ---
> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
> (original)
> +++
> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
> Sun Sep  6 17:35:12 2009
> @@ -2100,6 +2100,8 @@
>         configuration.add(SymbolConstants.COMBINE_SCRIPTS,
> matchProductionMode);
>
>         configuration.add(SymbolConstants.ENCODE_LOCALE_INTO_PATH, "true");
> +
> +        configuration.add(SymbolConstants.BLACKBIRD_ENABLED, "false");
>     }
>
>
>
> Modified:
> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java
> URL:
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java?rev=811842&r1=811841&r2=811842&view=diff
>
> ==============================================================================
> ---
> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java
> (original)
> +++
> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java
> Sun Sep  6 17:35:12 2009
> @@ -127,6 +127,8 @@
>         configuration.add(SymbolConstants.SECURE_ENABLED, "true");
>
>         configuration.add("app.injected-symbol", "Symbol contributed to
> ApplicationDefaults");
> +
> +        configuration.add(SymbolConstants.BLACKBIRD_ENABLED, "true");
>     }
>
>     public static void contributeIgnoredPathsFilter(Configuration<String>
> configuration)
>
> Added:
> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClientInfrastructureImplTest.java
> URL:
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClientInfrastructureImplTest.java?rev=811842&view=auto
>
> ==============================================================================
> ---
> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClientInfrastructureImplTest.java
> (added)
> +++
> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClientInfrastructureImplTest.java
> Sun Sep  6 17:35:12 2009
> @@ -0,0 +1,89 @@
> +// Copyright 2009 The Apache Software Foundation
> +//
> +// Licensed under the Apache License, Version 2.0 (the "License");
> +// you may not use this file except in compliance with the License.
> +// You may obtain a copy of the License at
> +//
> +//     http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +package org.apache.tapestry5.internal.services;
> +
> +import static org.easymock.EasyMock.isA;
> +
> +import java.util.List;
> +import java.util.Locale;
> +
> +import org.apache.tapestry5.Asset;
> +import org.apache.tapestry5.internal.test.InternalBaseTestCase;
> +import org.apache.tapestry5.ioc.services.SymbolSource;
> +import org.apache.tapestry5.ioc.services.ThreadLocale;
> +import org.apache.tapestry5.services.AssetSource;
> +import org.testng.annotations.Test;
> +
> +public class ClientInfrastructureImplTest  extends InternalBaseTestCase
> +{
> +    @Test
> +    public void production_mode() throws Exception
> +    {
> +        SymbolSource symbolSource = mockSymbolSource();
> +        AssetSource assetSource = mockAssetSource();
> +        ThreadLocale threadLocale = mockThreadLocale();
> +
> +        train_constructor(symbolSource, assetSource, threadLocale);
> +
> +        replay();
> +
> +        ClientInfrastructureImpl infrastructure = new
> ClientInfrastructureImpl(symbolSource, assetSource, threadLocale, false);
> +
> +        List<Asset> stack = infrastructure.getJavascriptStack();
> +
> +        List<Asset> stylesheetStack = infrastructure.getStylesheetStack();
> +
> +        verify();
> +
> +        //blackbird is the only one asset to be excluded in production
> mode
> +        //for now it is ok to check only sizes of stacks
> +        assertEquals(stack.size(), 5);
> +
> +        assertEquals(stylesheetStack.size(), 1);
> +    }
> +
> +    @Test
> +    public void test_mode() throws Exception
> +    {
> +        SymbolSource symbolSource = mockSymbolSource();
> +        AssetSource assetSource = mockAssetSource();
> +        ThreadLocale threadLocale = mockThreadLocale();
> +
> +        train_constructor(symbolSource, assetSource, threadLocale);
> +
> +        replay();
> +
> +        ClientInfrastructureImpl infrastructure = new
> ClientInfrastructureImpl(symbolSource, assetSource, threadLocale, true);
> +
> +        List<Asset> javascriptStack = infrastructure.getJavascriptStack();
> +
> +        List<Asset> stylesheetStack = infrastructure.getStylesheetStack();
> +
> +        verify();
> +
> +        //blackbird is the only one asset to be excluded in production
> mode
> +        //for now it is ok to check only sizes of stacks
> +        assertEquals(javascriptStack.size(), 6);
> +
> +        assertEquals(stylesheetStack.size(), 2);
> +    }
> +
> +    private void train_constructor(SymbolSource symbolSource, AssetSource
> assetSource, ThreadLocale threadLocale)
> +    {
> +
>  expect(symbolSource.expandSymbols(isA(String.class))).andReturn("expanded").anyTimes();
> +        expect(assetSource.getAsset(null,
> "expanded",null)).andReturn(mockAsset()).anyTimes();
> +        train_getLocale(threadLocale, Locale.ENGLISH);
> +        expect(assetSource.getAsset(null,
> "org/apache/tapestry5/tapestry-messages.js",Locale.ENGLISH)).andReturn(mockAsset());
> +    }
> +}
>
> Propchange:
> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClientInfrastructureImplTest.java
>
> ------------------------------------------------------------------------------
>    svn:eol-style = native
>
> Propchange:
> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClientInfrastructureImplTest.java
>
> ------------------------------------------------------------------------------
>    svn:mime-type = text/plain
>
>
>


-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to learn
how I can get you up and productive in Tapestry fast!

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message