Repository: wicket Updated Branches: refs/heads/master 042a55dc6 -> ddc7d415e
WICKET-5895 validateHeaders fails to detect missing head/body (regression) (cherry picked from commit 635ce53e84e42063cd699478b39abaff41ebd745) Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/ddc7d415 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/ddc7d415 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/ddc7d415 Branch: refs/heads/master Commit: ddc7d415eb1711f41e8c7458efd77bfaae962208 Parents: 042a55d Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Wed Apr 29 17:09:35 2015 +0300 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Wed Apr 29 17:09:57 2015 +0300 ---------------------------------------------------------------------- .../wicket/noheadnobody/NoHeadNoBodyPage.html | 1 + .../wicket/noheadnobody/NoHeadNoBodyPage.java | 27 ++++++++++ .../wicket/noheadnobody/NoHeadNoBodyPanel.html | 13 +++++ .../wicket/noheadnobody/NoHeadNoBodyPanel.java | 27 ++++++++++ .../wicket/noheadnobody/NoHeadNoBodyTest.java | 52 ++++++++++++++++++++ 5 files changed, 120 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/ddc7d415/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPage.html ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPage.html b/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPage.html new file mode 100644 index 0000000..8b0c64b --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPage.html @@ -0,0 +1 @@ +Hello <span wicket:id="panel"></span> http://git-wip-us.apache.org/repos/asf/wicket/blob/ddc7d415/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPage.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPage.java b/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPage.java new file mode 100644 index 0000000..8e5c3f7 --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPage.java @@ -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.noheadnobody; + +import org.apache.wicket.markup.html.WebPage; + +public class NoHeadNoBodyPage extends WebPage { + private static final long serialVersionUID = 1L; + + public NoHeadNoBodyPage() { + add(new NoHeadNoBodyPanel("panel")); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/ddc7d415/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPanel.html ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPanel.html b/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPanel.html new file mode 100644 index 0000000..6fc7b17 --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPanel.html @@ -0,0 +1,13 @@ +<html xmlns:wicket> + +<wicket:head> +<script type="text/javascript"> +alert("ring-ding-ding") +</script> +</wicket:head> + +<wicket:panel> +panel here +</wicket:panel> + +</html> http://git-wip-us.apache.org/repos/asf/wicket/blob/ddc7d415/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPanel.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPanel.java b/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPanel.java new file mode 100644 index 0000000..a869330 --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyPanel.java @@ -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.noheadnobody; + +import org.apache.wicket.markup.html.panel.Panel; + +public class NoHeadNoBodyPanel extends Panel { + private static final long serialVersionUID = 1L; + + public NoHeadNoBodyPanel(String id) { + super(id); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/ddc7d415/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyTest.java b/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyTest.java new file mode 100644 index 0000000..214d932 --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/noheadnobody/NoHeadNoBodyTest.java @@ -0,0 +1,52 @@ +/* + * 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.noheadnobody; + +import static org.hamcrest.Matchers.is; + +import java.util.concurrent.atomic.AtomicBoolean; + +import org.apache.wicket.WicketTestCase; +import org.junit.Test; + +/** + * Tests that if a page has neither <head> nor <body> + * and there are header contributors then {@link org.apache.wicket.markup.html.WebPage#reportMissingHead(CharSequence)} + * is called + * + * https://issues.apache.org/jira/browse/WICKET-5895 + */ +public class NoHeadNoBodyTest extends WicketTestCase +{ + @Test + public void noHeadNoBody() + { + final AtomicBoolean reported = new AtomicBoolean(false); + + NoHeadNoBodyPage page = new NoHeadNoBodyPage() + { + @Override + protected void reportMissingHead(CharSequence collectedHeaderOutput) + { + reported.set(true); + } + }; + + tester.startPage(page); + assertThat(reported.get(), is(true)); + } +}
