You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2010/12/09 12:18:20 UTC

svn commit: r1043894 - in /wicket/trunk/wicket/src: main/java/org/apache/wicket/markup/html/ test/java/org/apache/wicket/markup/

Author: mgrigorov
Date: Thu Dec  9 11:18:19 2010
New Revision: 1043894

URL: http://svn.apache.org/viewvc?rev=1043894&view=rev
Log:
Add a failing unit test that shows that MarkupUtil#isMarkupHtml5Compliant() doesn't work for page inheritance.
Add a check for null associatedMarkup before trying to use it in MarkupUtil#isMarkupHtml5Compliant()

Added:
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1_Inherited.html
      - copied, changed from r1043646, wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1.html
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1_InheritedPage.html   (with props)
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1_InheritedPage.java   (with props)
Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/MarkupUtil.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1.html
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1.html
    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/WicketNamespaceTest.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/MarkupUtil.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/MarkupUtil.java?rev=1043894&r1=1043893&r2=1043894&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/MarkupUtil.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/MarkupUtil.java Thu Dec  9 11:18:19 2010
@@ -19,6 +19,7 @@ package org.apache.wicket.markup.html;
 import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.Page;
 import org.apache.wicket.WicketRuntimeException;
+import org.apache.wicket.markup.IMarkupFragment;
 import org.apache.wicket.markup.MarkupResourceStream;
 import org.apache.wicket.util.lang.Args;
 import org.apache.wicket.util.visit.IVisit;
@@ -48,16 +49,21 @@ public class MarkupUtil
 				container.toString());
 		}
 
+
 		final boolean rtn[] = new boolean[] { true };
 		page.visitChildren(MarkupContainer.class, new IVisitor<MarkupContainer, Void>()
 		{
 			public void component(final MarkupContainer comp, final IVisit<Void> visit)
 			{
-				MarkupResourceStream rs = comp.getAssociatedMarkup().getMarkupResourceStream();
-				if (rs.isHtml5() == false)
+				IMarkupFragment associatedMarkup = comp.getAssociatedMarkup();
+				if (associatedMarkup != null)
 				{
-					rtn[0] = false;
-					visit.stop();
+					MarkupResourceStream rs = associatedMarkup.getMarkupResourceStream();
+					if (rs.isHtml5() == false)
+					{
+						rtn[0] = false;
+						visit.stop();
+					}
 				}
 			}
 		});

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1.html?rev=1043894&r1=1043893&r2=1043894&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1.html (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1.html Thu Dec  9 11:18:19 2010
@@ -16,5 +16,6 @@
 <html>
 <body>
   <span wicket:id="label">my label test</span>
+  <wicket:child/>
 </body>
 </html>

Copied: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1_Inherited.html (from r1043646, wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1.html)
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1_Inherited.html?p2=wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1_Inherited.html&p1=wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1.html&r1=1043646&r2=1043894&rev=1043894&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1.html (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/DoctypeExpectedResult_1_Inherited.html Thu Dec  9 11:18:19 2010
@@ -1,20 +1,21 @@
-<!DOCTYPE html>
-<!--
-    ====================================================================
-    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.
--->
-<html>
-<body>
-  <span wicket:id="label">my label test</span>
-</body>
-</html>
+<!DOCTYPE html>
+<!--
+    ====================================================================
+    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.
+-->
+<html>
+<body>
+  <span wicket:id="label">my label test</span>
+  <wicket:child><wicket:extend></wicket:extend></wicket:child>
+</body>
+</html>

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1.html?rev=1043894&r1=1043893&r2=1043894&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1.html (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1.html Thu Dec  9 11:18:19 2010
@@ -16,5 +16,6 @@
 <html>
 <body>
   <span wicket:id="label">xxx</span>
+  <wicket:child/>
 </body>
 </html>

Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1_InheritedPage.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1_InheritedPage.html?rev=1043894&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1_InheritedPage.html (added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1_InheritedPage.html Thu Dec  9 11:18:19 2010
@@ -0,0 +1 @@
+<wicket:extend></wicket:extend>
\ No newline at end of file

Propchange: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1_InheritedPage.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1_InheritedPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1_InheritedPage.java?rev=1043894&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1_InheritedPage.java (added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1_InheritedPage.java Thu Dec  9 11:18:19 2010
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.wicket.markup;
+
+
+/**
+ * A page that inherits another page which have <!DOCTYPE html>. Expectation is that
+ * MarkupUtil#isMarkupHtml5Compliant(this) will return <code>true</code> for the child page too
+ */
+public class Doctype_1_InheritedPage extends Doctype_1
+{
+
+}

Propchange: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/Doctype_1_InheritedPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/WicketNamespaceTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/WicketNamespaceTest.java?rev=1043894&r1=1043893&r2=1043894&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/WicketNamespaceTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/WicketNamespaceTest.java Thu Dec  9 11:18:19 2010
@@ -97,6 +97,19 @@ public class WicketNamespaceTest extends
 	/**
 	 * @throws Exception
 	 */
+	public void XXtestDoctype_InheritedPage() throws Exception
+	{
+		executeTest(Doctype_1_InheritedPage.class, "DoctypeExpectedResult_1_Inherited.html");
+		MarkupResourceStream rs = MarkupFactory.get()
+			.getMarkup(tester.getLastRenderedPage(), true)
+			.getMarkupResourceStream();
+		assertEquals("html", rs.getDoctype());
+		assertEquals(true, rs.isHtml5());
+	}
+
+	/**
+	 * @throws Exception
+	 */
 	public void testDoctype_2() throws Exception
 	{
 		executeTest(Doctype_2.class, "DoctypeExpectedResult_2.html");