cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gkossakow...@apache.org
Subject svn commit: r567309 - in /cocoon/trunk/core: cocoon-core/src/test/java/org/apache/cocoon/components/treeprocessor/variables/ cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/
Date Sat, 18 Aug 2007 18:11:42 GMT
Author: gkossakowski
Date: Sat Aug 18 11:11:41 2007
New Revision: 567309

URL: http://svn.apache.org/viewvc?view=rev&rev=567309
Log:
COCOON-2117: Put sitemap variables on Object Model and fix test case.

Modified:
    cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java

Modified: cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.java?view=diff&rev=567309&r1=567308&r2=567309
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.java
Sat Aug 18 11:11:41 2007
@@ -33,12 +33,16 @@
 public class PreparedVariableResolverTestCase extends SitemapComponentTestCase {
     
     private PreparedVariableResolver resolver;
+    private InvokeContext context;
     //private Map objectModel;
     
     public void setUp() throws Exception {
         super.setUp();
         resolver = new PreparedVariableResolver();
         resolver.setManager(getManager());
+        context = new InvokeContext(true);
+        context.service(getManager());
+        context.enableLogging(getLogger());
         //objectModel = getObjectModel();
     }
 
@@ -48,8 +52,6 @@
         request.reset();
         request.addParameter("foo", "bar");
         request.addParameter("bar", "123");
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
         
         Map sitemapElements = new HashMap();
         context.pushMap("sitemap", sitemapElements);
@@ -62,8 +64,6 @@
         MockRequest request = getRequest();
         request.reset();
         request.addParameter("foo", "123");
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
         
         Map sitemapElements = new HashMap();
         sitemapElements.put("1", "oo");
@@ -74,10 +74,7 @@
     
     public void testAnchors() throws PatternException {
         String expr = "{#label:name}";
-        
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
-        
+
         Map sitemapElements = new HashMap();
         sitemapElements.put("name", "123");
         context.pushMap("label", sitemapElements);
@@ -88,9 +85,6 @@
     public void testSitemapVariables() throws PatternException {
         String expr = "123{1}";
         
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
-
         Map sitemapElements = new HashMap();
         sitemapElements.put("1", "abc");
         context.pushMap("label", sitemapElements);
@@ -100,9 +94,6 @@
 
     public void testSitemapVariablesWithText() throws PatternException {
         String expr = "123{1}/def";
-    
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
 
         Map sitemapElements = new HashMap();
         sitemapElements.put("1", "abc");
@@ -113,9 +104,6 @@
     
     public void testPrefixedSitemapVariable() throws PatternException {
         String expr = "123{sitemap:1}/def";
-    
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
 
         Map sitemapElements = new HashMap();
         sitemapElements.put("1", "abc");
@@ -126,9 +114,6 @@
 
     public void testMultilevelSitemapVariables() throws PatternException {
         String expr = "from {../1} to {1}";
-        
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
 
         Map sitemapElements;
         sitemapElements = new HashMap();
@@ -145,9 +130,6 @@
 
     public void testRootSitemapVariables() throws PatternException {
         String expr = "from {/1} to {1}";
-        
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
 
         Map sitemapElements;
         sitemapElements = new HashMap();
@@ -164,9 +146,6 @@
     
     public void testColonInTextContent() throws PatternException {
         String expr = "http://cocoon.apache.org";
-        
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
 
         Map sitemapElements;
         sitemapElements = new HashMap();
@@ -178,9 +157,6 @@
     
     public void testColonBeginningTextContent() throws PatternException {
         String expr = ":colon-starts-this";
-        
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
 
         Map sitemapElements;
         sitemapElements = new HashMap();
@@ -192,9 +168,6 @@
     
     public void testEmbeddedColon() throws PatternException {
         String expr = "{1}:{1}";
-        
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
 
         Map sitemapElements;
         sitemapElements = new HashMap();
@@ -207,9 +180,6 @@
 
     public void testEscapedBraces() throws PatternException {
         String expr = "This is a \\{brace\\}";
-        
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
 
         Map sitemapElements;
         sitemapElements = new HashMap();
@@ -221,8 +191,6 @@
 
     public void testModuleWithoutOption() throws PatternException {
         String expr = "{baselink:}";
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
         
         Map sitemapElements = new HashMap();
         context.pushMap("sitemap", sitemapElements);
@@ -232,8 +200,7 @@
     
     public void testNewExpression() throws PatternException {
         String expr = "${$cocoon/request/parameters/foo}";
-        InvokeContext context = new InvokeContext(true);
-        context.enableLogging(getLogger());
+
         MockRequest request = getRequest();
         request.addParameter("foo", "bar");
         

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java?view=diff&rev=567309&r1=567308&r2=567309
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java
(original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java
Sat Aug 18 11:11:41 2007
@@ -33,6 +33,7 @@
 import org.apache.cocoon.components.pipeline.ProcessingPipeline;
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.Redirector;
+import org.apache.cocoon.objectmodel.ObjectModel;
 import org.apache.cocoon.sitemap.SitemapErrorHandler;
 
 /**
@@ -91,6 +92,9 @@
 
     /** The last processor */
     protected Processor lastProcessor;
+    
+    /** Unified Object Model */
+    private ObjectModel newObjectModel;
 
     /**
      * Create an <code>InvokeContext</code> without existing pipelines. This
also means
@@ -122,6 +126,7 @@
         if (this.processingPipeline != null) {
             this.processingPipeline.setProcessorManager(manager);
         }
+        this.newObjectModel = (ObjectModel)manager.lookup(ObjectModel.ROLE);
     }
 
     /**
@@ -223,6 +228,9 @@
      * Push a Map on top of the current Map stack.
      */
     public final void pushMap(String anchorName, Map map) {
+        final String sitemapObjectModelPathPrefix = "sitemap";
+        final String sitemapObjectModelNamedPathPrefix = sitemapObjectModelPathPrefix + "/$named$";
+        
         this.mapStack.add(map);
 
         if (getLogger().isDebugEnabled()) {
@@ -238,6 +246,9 @@
                     getLogger().error("name [" + anchorName + "] clashes");
                 }
             }
+            newObjectModel.putAt(sitemapObjectModelNamedPathPrefix + "/" + anchorName, map);
+        } else {
+            newObjectModel.putAt(sitemapObjectModelPathPrefix, map);
         }
     }
 
@@ -318,6 +329,7 @@
             this.processingPipelineParameters = null;
             this.processingPipelineObjectModel = null;
         }
+        this.currentManager.release(this.newObjectModel);
     }
 
     /**



Mime
View raw message