cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lgaw...@apache.org
Subject svn commit: r367819 - in /cocoon/trunk/cocoon-template/cocoon-template-impl/src: main/java/org/apache/cocoon/template/expression/ test/java/org/apache/cocoon/template/jxtg/ test/resources/org/apache/cocoon/template/jxtg/
Date Tue, 10 Jan 2006 22:38:53 GMT
Author: lgawron
Date: Tue Jan 10 14:37:34 2006
New Revision: 367819

URL: http://svn.apache.org/viewcvs?rev=367819&view=rev
Log:
some hidden bugs that affected macro invocations

Modified:
    cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/DefaultStringTemplateParser.java
    cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java
    cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/JXTGStringTemplateParser.java
    cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/java/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.java
    cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxMacro-output.xml
    cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxMacro.xml

Modified: cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/DefaultStringTemplateParser.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/DefaultStringTemplateParser.java?rev=367819&r1=367818&r2=367819&view=diff
==============================================================================
--- cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/DefaultStringTemplateParser.java
(original)
+++ cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/DefaultStringTemplateParser.java
Tue Jan 10 14:37:34 2006
@@ -20,7 +20,8 @@
 import java.util.List;
 
 /**
- * @version SVN $Id$ 
+ * @version SVN $Id: DefaultStringTemplateParser.java 325973 2005-10-17
+ *          19:59:39Z lgawron $
  */
 public class DefaultStringTemplateParser extends StringTemplateParser {
     public List parseSubstitutions(Reader in) throws Exception {
@@ -45,7 +46,7 @@
                     } else {
                         buf.append(c);
                     }
-                } else if (c == '{' ) {
+                } else if (c == '{') {
                     ch = in.read();
                     if (ch != '{') {
                         inExpr = true;
@@ -69,7 +70,9 @@
         }
         if (inExpr)
             throw new Exception("Unterminated {");
-        substitutions.add(new Literal(buf.toString()));
+
+        if (buf.length() > 0)
+            substitutions.add(new Literal(buf.toString()));
         return substitutions;
     }
 

Modified: cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java?rev=367819&r1=367818&r2=367819&view=diff
==============================================================================
--- cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java
(original)
+++ cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java
Tue Jan 10 14:37:34 2006
@@ -134,7 +134,7 @@
             else
                 return compiled;
         } else
-            return null;
+            return this.getRaw();
     }
 
     public void setLenient(Boolean lenient) {

Modified: cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/JXTGStringTemplateParser.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/JXTGStringTemplateParser.java?rev=367819&r1=367818&r2=367819&view=diff
==============================================================================
--- cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/JXTGStringTemplateParser.java
(original)
+++ cocoon/trunk/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/expression/JXTGStringTemplateParser.java
Tue Jan 10 14:37:34 2006
@@ -20,7 +20,8 @@
 import java.util.List;
 
 /**
- * @version SVN $Id$
+ * @version SVN $Id: JXTGStringTemplateParser.java 325986 2005-10-17 21:35:18Z
+ *          lgawron $
  */
 public class JXTGStringTemplateParser extends StringTemplateParser {
     public final static String JXPATH = "jxpath";
@@ -75,7 +76,9 @@
         }
         if (inExpr)
             throw new Exception("Unterminated {");
-        substitutions.add(new Literal(buf.toString()));
+
+        if (buf.length() > 0)
+            substitutions.add(new Literal(buf.toString()));
         return substitutions;
     }
 

Modified: cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/java/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/java/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.java?rev=367819&r1=367818&r2=367819&view=diff
==============================================================================
--- cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/java/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.java
(original)
+++ cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/java/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.java
Tue Jan 10 14:37:34 2006
@@ -27,7 +27,8 @@
 import org.apache.cocoon.components.flow.FlowHelper;
 
 /**
- * @version SVN $Id$
+ * @version SVN $Id: JXTemplateGeneratorTestCase.java 358974 2005-12-25
+ *          14:00:24Z lgawron $
  */
 public class JXTemplateGeneratorTestCase extends SitemapComponentTestCase {
     private Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
@@ -35,6 +36,22 @@
     String JX = "jx";
     Map flowContext = new HashMap();
 
+    public class StringContainer {
+        private String value;
+
+        public String getValue() {
+            return value;
+        }
+
+        public void setValue(String value) {
+            this.value = value;
+        }
+
+        public StringContainer(String value) {
+            this.value = value;
+        }
+    }
+
     public void setUp() throws Exception {
         super.setUp();
 
@@ -102,7 +119,7 @@
         String inputURI = docBase + "jxForEach.xml";
         String outputURI = docBase + "jxForEach-output.xml";
 
-        String[] array = {"one", "two", "three"};
+        String[] array = { "one", "two", "three" };
         getFlowContext().put("test", array);
         assertEqual(load(outputURI), generate(JX, inputURI, EMPTY_PARAMS));
     }
@@ -111,7 +128,8 @@
         String inputURI = docBase + "jxMacro.xml";
         String outputURI = docBase + "jxMacro-output.xml";
 
-        assertEqual( load(outputURI), generate(JX, inputURI, EMPTY_PARAMS) );
+        getFlowContext().put("container", new StringContainer("foobar"));
+        assertEqual(load(outputURI), generate(JX, inputURI, EMPTY_PARAMS));
     }
 
     public void testJXDynamicMacro() throws Exception {
@@ -136,7 +154,7 @@
         getFlowContext().put("date", cal.getTime());
         assertEqual(load(outputURI), generate(JX, inputURI, EMPTY_PARAMS));
     }
-    
+
     public void testFormatDate() throws Exception {
         String inputURI = docBase + "formatDate.xml";
         String outputURI = docBase + "formatDate-output.xml";
@@ -158,7 +176,7 @@
         String inputURI = docBase + "jxOut.xml";
         String outputURI = docBase + "jxOut-output.xml";
         String includeURI = docBase + "jxOutInclude.xml";
-        
+
         getFlowContext().put("value", "simple");
         getFlowContext().put("xml", "<root><node>value</node></root>");
         getFlowContext().put("document", load(includeURI));

Modified: cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxMacro-output.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxMacro-output.xml?rev=367819&r1=367818&r2=367819&view=diff
==============================================================================
--- cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxMacro-output.xml
(original)
+++ cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxMacro-output.xml
Tue Jan 10 14:37:34 2006
@@ -9,5 +9,12 @@
 		<macroTest a="bar">
 			<content b="5"/>
 		</macroTest>
+		<macroTest a="bar1">
+			<content b="6"/>
+		</macroTest>
 	</n>
+	<o>
+		<containerValue>foobar</containerValue>
+		<containerValue>foobar</containerValue>
+	</o>
 </root>

Modified: cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxMacro.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxMacro.xml?rev=367819&r1=367818&r2=367819&view=diff
==============================================================================
--- cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxMacro.xml
(original)
+++ cocoon/trunk/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxMacro.xml
Tue Jan 10 14:37:34 2006
@@ -17,5 +17,20 @@
 			<jx:withParam name="p" value="bar"/>
 			<content b="${2+3}"/>
 		</jx:call>
+		<jx:call macro="d">
+			<jx:withParam name="p" value="bar1"/>
+			<content b="${2+3+1}"/>
+		</jx:call>
 	</n>
+	<o>
+		<jx:macro name="stringContainer">
+			<jx:parameter name="c"/>
+			<containerValue>${c.value}</containerValue>
+		</jx:macro>
+
+		<stringContainer c="${container}"/>
+		<jx:call macro="stringContainer">
+			<jx:withParam name="c" value="${container}"/>
+		</jx:call>
+	</o>
 </root>



Mime
View raw message