tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject [4/4] git commit: Rename method to avoid confusion Create a DocumentLinkerImpl test for module-based initialization
Date Thu, 28 Jun 2012 18:08:06 GMT
Rename method to avoid confusion
Create a DocumentLinkerImpl test for module-based initialization


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/4c725462
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/4c725462
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/4c725462

Branch: refs/heads/5.4-js-rewrite
Commit: 4c725462fd19062f2757ce226bea8e5ab27801a5
Parents: 33773d0
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Wed Jun 27 15:46:27 2012 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Wed Jun 27 15:46:27 2012 -0700

----------------------------------------------------------------------
 .../internal/services/DocumentLinker.java          |    8 ++--
 .../internal/services/DocumentLinkerImpl.java      |    2 +-
 .../services/PartialMarkupDocumentLinker.java      |    2 +-
 .../services/ajax/JavaScriptSupportImpl.java       |    2 +-
 .../internal/services/DocumentLinkerImplTest.java  |   24 ++++++++++++++-
 .../services/module_based_initialization.txt       |   11 +++++++
 6 files changed, 41 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4c725462/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinker.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinker.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinker.java
index 9578167..76472a3 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinker.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinker.java
@@ -74,8 +74,8 @@ public interface DocumentLinker
      * @param arguments
      *         arguments to pass to the function
      */
-    void setInitialization(InitializationPriority priority,
-                           String moduleName,
-                           String functionName,
-                           JSONArray arguments);
+    void setModuleInitialization(InitializationPriority priority,
+                                 String moduleName,
+                                 String functionName,
+                                 JSONArray arguments);
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4c725462/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
index 38cf54a..2cab076 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
@@ -110,7 +110,7 @@ public class DocumentLinkerImpl implements DocumentLinker
     }
 
     @Override
-    public void setInitialization(InitializationPriority priority, String moduleName, String
functionName, JSONArray arguments)
+    public void setModuleInitialization(InitializationPriority priority, String moduleName,
String functionName, JSONArray arguments)
     {
         JSONArray init = new JSONArray();
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4c725462/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinker.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinker.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinker.java
index 4e4879b..c9002d1 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinker.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinker.java
@@ -58,7 +58,7 @@ public class PartialMarkupDocumentLinker implements DocumentLinker
     }
 
     @Override
-    public void setInitialization(InitializationPriority priority, String moduleName, String
functionName, JSONArray arguments)
+    public void setModuleInitialization(InitializationPriority priority, String moduleName,
String functionName, JSONArray arguments)
     {
         throw new IllegalStateException("not yet implemented");
     }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4c725462/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
index 5aa59c7..45eb7b4 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
@@ -199,7 +199,7 @@ public class JavaScriptSupportImpl implements JavaScriptSupport
             @Override
             public void work(InitializationImpl element)
             {
-                linker.setInitialization(element.priority, element.moduleName, element.functionName,
element.arguments);
+                linker.setModuleInitialization(element.priority, element.moduleName, element.functionName,
element.arguments);
             }
         });
     }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4c725462/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java
b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java
index 4d67ab3..ef64dab 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java
@@ -411,7 +411,7 @@ public class DocumentLinkerImplTest extends InternalBaseTestCase
 
         document.newRootElement("html");
 
-        DocumentLinkerImpl linker = new DocumentLinkerImpl(null, mockRequireJS(), true, "1.2.3",
true);
+        DocumentLinkerImpl linker = new DocumentLinkerImpl(null, null, true, "1.2.3", true);
 
         linker.addStylesheetLink(new StylesheetLink("everybody.css"));
         linker.addStylesheetLink(new StylesheetLink("just_ie.css", new StylesheetOptions().withCondition("IE")));
@@ -436,6 +436,28 @@ public class DocumentLinkerImplTest extends InternalBaseTestCase
         linker.updateDocument(document);
 
         assertEquals(document.toString(), readFile("stylesheet_insertion_point.txt"));
+    }
+
+    @Test
+    public void module_based_initialization()   throws Exception
+    {
+        Document document = new Document();
+
+        Element head = document.newRootElement("html").element("head");
+
+        head.element("meta");
+
+        DocumentLinkerImpl linker = new DocumentLinkerImpl(mockModuleManager(), mockRequireJS(),
true, "1.2.3", true);
+
+        replay();
+
+        linker.setModuleInitialization(InitializationPriority.NORMAL, "my/module", null,
null);
+        linker.setModuleInitialization(InitializationPriority.NORMAL, "my/other/module",
"normal", new JSONArray(111, 222));
+        linker.setModuleInitialization(InitializationPriority.LATE, "my/other/module", "late",
new JSONArray(333, 444));
+
+        linker.updateDocument(document);
+
+        assertEquals(document.toString(), readFile("module_based_initialization.txt"));
 
     }
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4c725462/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/module_based_initialization.txt
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/module_based_initialization.txt
b/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/module_based_initialization.txt
new file mode 100644
index 0000000..56fcdfc
--- /dev/null
+++ b/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/module_based_initialization.txt
@@ -0,0 +1,11 @@
+<html><head><meta/></head><body><script src="/js/require.js"></script><script
type="text/javascript">require.config();
+Tapestry.onDOMLoaded(function() {
+require(["core/pageinit"], function (pageinit) {
+  pageinit([["my/module"],
+  ["my/other/module:normal",111,222]]);
+});
+require(["core/pageinit"], function (pageinit) {
+  pageinit([["my/other/module:late",333,444]]);
+});
+});
+</script></body></html>
\ No newline at end of file


Mime
View raw message