Repository: tapestry-5 Updated Branches: refs/heads/master 37a801d97 -> d150c3c73
TAP5-1515 : Support for external assets (more tests) Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/d150c3c7 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/d150c3c7 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/d150c3c7 Branch: refs/heads/master Commit: d150c3c73366c0ccd7447813fad2dba9e032d35b Parents: 37a801d Author: Thiago H. de Paula Figueiredo <thiag...@apache.org> Authored: Mon Jun 30 15:32:02 2014 -0300 Committer: Thiago H. de Paula Figueiredo <thiag...@apache.org> Committed: Mon Jun 30 15:32:02 2014 -0300 ---------------------------------------------------------------------- .../tapestry5/integration/app1/AssetTests.java | 11 +++++++---- .../app1/pages/nested/AssetDemo.java | 1 + .../integration/app1/services/AppModule.java | 2 +- .../integration/app1/pages/nested/AssetDemo.js | 13 +++++++++++++ .../integration/app1/pages/nested/AssetDemo.tml | 20 +++++++++++++++++++- 5 files changed, 41 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d150c3c7/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AssetTests.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AssetTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AssetTests.java index 6848223..6e69fad 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AssetTests.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AssetTests.java @@ -60,10 +60,13 @@ public class AssetTests extends App1TestCase { openLinks("AssetDemo"); - assertEquals("http://cdnjs.cloudflare.com/ajax/libs/d3/3.4.8/d3.js", getText("httpAsset")); - assertEquals("https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.8/d3.js", getText("httpsAsset")); - assertEquals("http://cdnjs.cloudflare.com/ajax/libs/d3/3.4.8/d3.js", getText("protocolRelativeAsset")); - assertEquals("ftp://cdnjs.cloudflare.com/ajax/libs/d3/3.4.8/d3.js", getText("ftpAsset")); + assertEquals("http://cdnjs.cloudflare.com/ajax/libs/d3/3.0.0/d3.js", getText("httpAsset")); + assertEquals("https://cdnjs.cloudflare.com/ajax/libs/d3/3.0.0/d3.js", getText("httpsAsset")); + assertEquals("http://cdnjs.cloudflare.com/ajax/libs/d3/3.0.0/d3.js", getText("protocolRelativeAsset")); + assertEquals("ftp://cdnjs.cloudflare.com/ajax/libs/d3/3.0.0/d3.js", getText("ftpAsset")); + + // check whether externaly @Import'ed d3 works + assertTrue(isElementPresent("css=svg")); } private void compareDownloadedAsset(String assetURL, String localPath) throws Exception http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d150c3c7/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.java index e2b3705..57a049f 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.java @@ -28,6 +28,7 @@ import org.apache.tapestry5.services.javascript.StylesheetOptions; * Primarily used to demonstrate that assets can be localized and exposed to the client, this has grown to also * demonstrate the use of the {@link Import} annotation. */ +@Import(library = {"http://${d3.url}", "AssetDemo.js"}) public class AssetDemo { @Property http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d150c3c7/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java index 85e0fcc..7b3d1fa 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java @@ -154,7 +154,7 @@ public class AppModule // This is the emphasis of testing at this point. configuration.add(SymbolConstants.JAVASCRIPT_INFRASTRUCTURE_PROVIDER, "jquery"); - configuration.add(D3_URL_SYMBOL, "cdnjs.cloudflare.com/ajax/libs/d3/3.4.8/d3.js"); + configuration.add(D3_URL_SYMBOL, "cdnjs.cloudflare.com/ajax/libs/d3/3.0.0/d3.js"); } public static void contributeIgnoredPathsFilter(Configuration<String> configuration) http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d150c3c7/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.js ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.js b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.js new file mode 100644 index 0000000..5b6a4cb --- /dev/null +++ b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.js @@ -0,0 +1,13 @@ +var sampleSVG = d3.select("#viz") + .append("svg") + .attr("width", 100) + .attr("height", 100); + + sampleSVG.append("circle") + .style("stroke", "gray") + .style("fill", "white") + .attr("r", 40) + .attr("cx", 50) + .attr("cy", 50) + .on("mouseover", function(){d3.select(this).style("fill", "aliceblue");}) + .on("mouseout", function(){d3.select(this).style("fill", "white");}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d150c3c7/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.tml b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.tml index 969031e..6a4f8e7 100644 --- a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.tml +++ b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.tml @@ -80,9 +80,27 @@ </p> <p> - Using d3, loaded directly from a CDN using external asset support: + Using d3, loaded directly from a CDN using external asset support (example from http://christopheviau.com/d3_tutorial/): </p> +<script type="text/javascript"> + + var sampleSVG = d3.select("#viz") + .append("svg") + .attr("width", 100) + .attr("height", 100); + + sampleSVG.append("circle") + .style("stroke", "gray") + .style("fill", "white") + .attr("r", 40) + .attr("cx", 50) + .attr("cy", 50) + .on("mouseover", function(){d3.select(this).style("fill", "aliceblue");}) + .on("mouseout", function(){d3.select(this).style("fill", "white");}); + +</script> + <div id="viz"/> </html> \ No newline at end of file