Author: drobiazko
Date: Sat Sep 12 20:00:12 2009
New Revision: 814225
URL: http://svn.apache.org/viewvc?rev=814225&view=rev
Log:
TAP5-678: Allow blackbird to be disabled in production mode
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.css
(with props)
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js
(with props)
tapestry/tapestry5/trunk/tapestry-core/src/test/app3/ConsoleDemo.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/pages/ConsoleDemo.java
(with props)
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientInfrastructureImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/test/app3/Login.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/AdditionalIntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClientInfrastructureImplTest.java
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/AbstractIntegrationTestSuite.java
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=814225&r1=814224&r2=814225&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
Sat Sep 12 20:00:12 2009
@@ -40,7 +40,9 @@
private final ThreadLocale threadLocale;
- private final List<Asset> javascriptStack, stylesheetStack,
javascriptStackTestMode, stylesheetStackTestMode;
+ private final List<Asset> javascriptStack, stylesheetStack;
+
+ private final Asset consoleJavascript, consoleStylesheet;
private final boolean isBlackbirdEnabled;
@@ -54,31 +56,15 @@
// Uses functions defined by the prior three
- "org/apache/tapestry5/tapestry.js"
- };
-
- private static final String[] CORE_JAVASCRIPT_TEST_MODE = new String[]
- {
- // Only available in test mode
-
- "${tapestry.blackbird}/blackbird.js"
+ "org/apache/tapestry5/tapestry.js",
};
-
private static final String[] CORE_STYLESHEET = new String[]
{
- "${tapestry.default-stylesheet}"
- };
-
-
- private static final String[] CORE_STYLESHEET_TEST_MODE = new String[]
- {
- // Only available in test mode
-
- "${tapestry.blackbird}/blackbird.css"
+ "${tapestry.default-stylesheet}",
};
- public ClientInfrastructureImpl(SymbolSource symbolSource,
+ public ClientInfrastructureImpl(SymbolSource symbolSource,
AssetSource assetSource,
ThreadLocale threadLocale,
@Symbol(SymbolConstants.BLACKBIRD_ENABLED)
@@ -92,8 +78,8 @@
javascriptStack = convertToAssets(CORE_JAVASCRIPT);
stylesheetStack = convertToAssets(CORE_STYLESHEET);
- javascriptStackTestMode = convertToAssets(CORE_JAVASCRIPT_TEST_MODE);
- stylesheetStackTestMode = convertToAssets(CORE_STYLESHEET_TEST_MODE);
+ consoleJavascript = expand("${tapestry.blackbird}/blackbird.js",
"org/apache/tapestry5/tapestry-console.js", null);
+ consoleStylesheet = expand("${tapestry.blackbird}/blackbird.css",
"org/apache/tapestry5/tapestry-console.css", null);
}
private List<Asset> convertToAssets(String[] paths)
@@ -114,33 +100,36 @@
return assetSource.getAsset(null, expanded, locale);
}
+
+ private Asset expand(String blackbirdPath, String consolePath, Locale
locale)
+ {
+ String path = isBlackbirdEnabled? blackbirdPath: consolePath;
+
+ return expand(path, locale);
+ }
public List<Asset> getJavascriptStack()
{
- List<Asset> result = createStack(javascriptStack,
javascriptStackTestMode);
-
Asset messages = assetSource.getAsset(null,
"org/apache/tapestry5/tapestry-messages.js",
threadLocale.getLocale());
- result.add(messages);
-
- return result;
+ return createStack(javascriptStack, messages, consoleJavascript);
}
public List<Asset> getStylesheetStack()
- {
- return createStack(stylesheetStack, stylesheetStackTestMode);
+ {
+ return createStack(stylesheetStack, consoleStylesheet);
}
- private List<Asset> createStack(List<Asset> stack, List<Asset>
optionalStack)
+ public List<Asset> createStack(List<Asset> stack, Asset... assets)
{
List<Asset> result = CollectionFactory.newList(stack);
- if(isBlackbirdEnabled)
+ for (Asset next : assets)
{
- result.addAll(optionalStack);
+ result.add(next);
}
-
+
return result;
}
}
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.css
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.css?rev=814225&view=auto
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.css
(added)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.css
Sat Sep 12 20:00:12 2009
@@ -0,0 +1,27 @@
+/* The console is used to show debugging messages. */
+DIV.t-console {
+ position: fixed;
+ z-index: 1;
+ top: 2px;
+ left: 2px;
+}
+
+DIV.t-console DIV {
+ font-weight: bold;
+ padding: 0px 2px;
+}
+
+DIV.t-console DIV.t-err {
+ background-color: red;
+ color: white;
+}
+
+DIV.t-console DIV.t-warn {
+ background-color: yellow;
+ color: black;
+}
+
+DIV.t-console DIV.t-debug {
+ background-color: silver;
+ color: black;
+}
\ No newline at end of file
Propchange:
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.css
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.css
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js?rev=814225&view=auto
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js
(added)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js
Sat Sep 12 20:00:12 2009
@@ -0,0 +1,85 @@
+// 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.
+Tapestry.Logging = {
+
+ debug: function(msg)
+ {
+ Tapestry.Logging.updateConsole("t-err", msg);
+ },
+
+ warn: function(msg)
+ {
+ Tapestry.Logging.updateConsole("t-warn", msg);
+ },
+
+ error: function(msg)
+ {
+ if (Tapestry.DEBUG_ENABLED)
+ Tapestry.Logging.updateConsole("t-debug", msg);
+ },
+
+ /** Formats a message and updates the console. The console is virtual
+ * when FireBug is not present, the messages float in the upper-left
corner
+ * of the page and fade out after a short period. The background
color identifies
+ * the severity of the message (red for error, yellow for warnings,
grey for debug).
+ * Messages can be clicked, which removes the immediately.
+ *
+ * When FireBug is present, the error(), warn() and debug() methods do
not invoke
+ * this; instead those functions are rewritten to write entries into
the FireBug console.
+ *
+ * @param className to use for the div element in the console
+ * @param message message template
+ */
+ updateConsole : function (className, message)
+ {
+
+ if (Tapestry.Logging.console == undefined)
+ Tapestry.Logging.console =
Tapestry.Logging.createConsole("t-console");
+
+ Tapestry.Logging.writeToConsole(Tapestry.Logging.console,
className, message);
+ },
+
+ createConsole : function(className)
+ {
+ var body = $$("BODY").first();
+
+ var console = new Element("div", { 'class': className });
+
+ body.insert({ top: console });
+
+ return console;
+ },
+
+ writeToConsole : function(console, className, message, slideDown)
+ {
+ var div = new Element("div", { 'class': className
}).update(message).hide();
+
+ console.insert({ top: div });
+
+ new Effect.Appear(div, { duration: .25 });
+
+ var effect = new Effect.Fade(div, { delay:
Tapestry.CONSOLE_DURATION,
+ afterFinish: function()
+ {
+ div.remove();
+ }});
+
+ div.observe("click", function()
+ {
+ effect.cancel();
+ div.remove();
+ });
+ }
+
+}
\ No newline at end of file
Propchange:
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-console.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app3/ConsoleDemo.tml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app3/ConsoleDemo.tml?rev=814225&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app3/ConsoleDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app3/ConsoleDemo.tml Sat
Sep 12 20:00:12 2009
@@ -0,0 +1,13 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
+ <head>
+ <title>Console Demo</title>
+ </head>
+ <body>
+ <h1>Demonstrates Tapestry console</h1>
+
+ <p><t:zone t:id="output"/></p>
+ <p>
+ <t:actionlink t:id="fail" zone="output">Failure on the
server side</t:actionlink>
+ </p>
+ </body>
+</html>
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app3/Login.tml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app3/Login.tml?rev=814225&r1=814224&r2=814225&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app3/Login.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app3/Login.tml Sat Sep 12
20:00:12 2009
@@ -16,6 +16,9 @@
<li>
<t:pagelink page="renderpagedemo">PageDocumentGenerator
demo</t:pagelink>
</li>
+ <li>
+ <t:pagelink page="consoledemo">Console demo</t:pagelink>
+ </li>
</ul>
</body>
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/AdditionalIntegrationTests.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/AdditionalIntegrationTests.java?rev=814225&r1=814224&r2=814225&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/AdditionalIntegrationTests.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/AdditionalIntegrationTests.java
Sat Sep 12 20:00:12 2009
@@ -80,4 +80,19 @@
// Fuckin Selenium
// assertAttribute("//a[2]/@href", "login");
}
+
+ public void ajax_server_side_exception()
+ {
+ start("Console demo");
+
+ assertTextPresent("Demonstrates Tapestry console");
+
+ click("link=Failure on the server side");
+
+ // Wait for the console to appear
+
+ waitForCSSSelectedElementToAppear(".t-console div.t-err");
+
+ assertTextPresent("Communication with the server failed: Server-side
exception.");
+ }
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=814225&r1=814224&r2=814225&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
Sat Sep 12 20:00:12 2009
@@ -2309,14 +2309,6 @@
waitForCondition(condition, PAGE_LOAD_TIMEOUT);
}
- private void waitForCSSSelectedElementToAppear(String cssRule)
- {
- String condition =
String.format("selenium.browserbot.getCurrentWindow().$$(\"%s\").size() > 0",
- cssRule);
-
- waitForCondition(condition, PAGE_LOAD_TIMEOUT);
-
- }
/**
* TAPESTRY-2610
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/pages/ConsoleDemo.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/pages/ConsoleDemo.java?rev=814225&view=auto
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/pages/ConsoleDemo.java
(added)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/pages/ConsoleDemo.java
Sat Sep 12 20:00:12 2009
@@ -0,0 +1,22 @@
+// 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.integration.app3.pages;
+
+public class ConsoleDemo
+{
+ void onActionFromFail()
+ {
+ throw new RuntimeException("Server-side exception.");
+ }
+}
Propchange:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/pages/ConsoleDemo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/pages/ConsoleDemo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java?rev=814225&r1=814224&r2=814225&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/services/AppModule.java
Sat Sep 12 20:00:12 2009
@@ -29,6 +29,8 @@
public static void
contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
{
configuration.add(SymbolConstants.GZIP_COMPRESSION_ENABLED, "false");
+
+ configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
}
}
Modified:
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=814225&r1=814224&r2=814225&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClientInfrastructureImplTest.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClientInfrastructureImplTest.java
Sat Sep 12 20:00:12 2009
@@ -28,13 +28,14 @@
public class ClientInfrastructureImplTest extends InternalBaseTestCase
{
@Test
- public void production_mode() throws Exception
+ public void tapestry_console() throws Exception
{
SymbolSource symbolSource = mockSymbolSource();
AssetSource assetSource = mockAssetSource();
ThreadLocale threadLocale = mockThreadLocale();
- train_constructor(symbolSource, assetSource, threadLocale);
+ train_constructor(symbolSource, assetSource, threadLocale,
+ "org/apache/tapestry5/tapestry-console.js",
"org/apache/tapestry5/tapestry-console.css");
replay();
@@ -46,21 +47,20 @@
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(stack.size(), 6);
- assertEquals(stylesheetStack.size(), 1);
+ assertEquals(stylesheetStack.size(), 2);
}
@Test
- public void test_mode() throws Exception
+ public void blackbird() throws Exception
{
SymbolSource symbolSource = mockSymbolSource();
AssetSource assetSource = mockAssetSource();
ThreadLocale threadLocale = mockThreadLocale();
- train_constructor(symbolSource, assetSource, threadLocale);
+ train_constructor(symbolSource, assetSource, threadLocale,
+ "${tapestry.blackbird}/blackbird.js",
"${tapestry.blackbird}/blackbird.css");
replay();
@@ -72,18 +72,25 @@
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)
+ private void train_constructor(SymbolSource symbolSource, AssetSource
assetSource, ThreadLocale threadLocale,
+ String javascriptPath, String stylesheetPath)
{
-
expect(symbolSource.expandSymbols(isA(String.class))).andReturn("expanded").anyTimes();
- expect(assetSource.getAsset(null,
"expanded",null)).andReturn(mockAsset()).anyTimes();
+ train_expand(symbolSource, assetSource, isA(String.class), 5);
+ train_expand(symbolSource, assetSource, javascriptPath, 1);
+ train_expand(symbolSource, assetSource, stylesheetPath, 1);
train_getLocale(threadLocale, Locale.ENGLISH);
expect(assetSource.getAsset(null,
"org/apache/tapestry5/tapestry-messages.js",Locale.ENGLISH)).andReturn(mockAsset());
}
+
+ private void train_expand(SymbolSource symbolSource, AssetSource
assetSource, String path, int times)
+ {
+
expect(symbolSource.expandSymbols(path)).andReturn("expanded").times(times);
+ expect(assetSource.getAsset(null,
"expanded",null)).andReturn(mockAsset()).times(times);
+ }
+
}
Modified:
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/AbstractIntegrationTestSuite.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/AbstractIntegrationTestSuite.java?rev=814225&r1=814224&r2=814225&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/AbstractIntegrationTestSuite.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/AbstractIntegrationTestSuite.java
Sat Sep 12 20:00:12 2009
@@ -246,6 +246,15 @@
assertFieldValue(id, values[i]);
}
}
+
+ protected void waitForCSSSelectedElementToAppear(String cssRule)
+ {
+ String condition =
String.format("selenium.browserbot.getCurrentWindow().$$(\"%s\").size() > 0",
+ cssRule);
+
+ waitForCondition(condition, PAGE_LOAD_TIMEOUT);
+
+ }
@AfterClass(alwaysRun = true)
public void cleanup() throws Exception