Tests for new functionality

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/4158b8c5
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/4158b8c5
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/4158b8c5

Branch: refs/heads/master
Commit: 4158b8c5f479bede43a413aca928d2e5d08255d8
Parents: 73d094b
Author: Domas Poliakas <dpoliakas@Domas-MBP.local>
Authored: Thu Jul 27 14:16:21 2017 +0100
Committer: Martin Tzvetanov Grigorov <mgrigo...@apache.org>
Committed: Sun Aug 6 15:27:21 2017 +0300

----------------------------------------------------------------------
 .../tester/MockPageWithLabelInEnclosure.html    | 13 ++++++++++
 .../tester/MockPageWithLabelInEnclosure.java    | 26 ++++++++++++++++++++
 .../wicket/util/tester/WicketTesterTest.java    | 12 +++++++++
 3 files changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/4158b8c5/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.html
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.html
 
b/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.html
new file mode 100644
index 0000000..35dfab8
--- /dev/null
+++ 
b/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.html
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml"; xmlns:wicket>
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+    <title>Insert title here</title>
+</head>
+<body>
+<div wicket:enclosure="testLink">
+    <a href="#" wicket:id="testLink">[Something]</a>
+</div>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/4158b8c5/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.java
 
b/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.java
new file mode 100644
index 0000000..b2f09f1
--- /dev/null
+++ 
b/wicket-core/src/test/java/org/apache/wicket/util/tester/MockPageWithLabelInEnclosure.java
@@ -0,0 +1,26 @@
+package org.apache.wicket.util.tester;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * Created by dpoliakas on 27/07/2017.
+ */
+public class MockPageWithLabelInEnclosure extends WebPage {
+
+    public MockPageWithLabelInEnclosure() {
+        // Clicking this link re-renders the link itself
+        this.add(new AjaxLink<Void>("testLink") {
+            @Override
+            public void onClick(AjaxRequestTarget target) {
+                target.add(this);
+            }
+        });
+    }
+
+    public AjaxLink<Void> getSelfRefreshingAjaxLink(){
+        return (AjaxLink<Void>) get("testLink");
+    }
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/4158b8c5/wicket-core/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java 
b/wicket-core/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
index ee32429..33ea646 100644
--- 
a/wicket-core/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
+++ 
b/wicket-core/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
@@ -1327,4 +1327,16 @@ public class WicketTesterTest extends WicketTestCase
                String secondId = tester.getSession().getId();
                assertNotEquals(firstId, secondId);
        }
+
+       @Test
+       public void assertComponentInEnclosureInAjaxResponse()
+       {
+               MockPageWithLabelInEnclosure page = new 
MockPageWithLabelInEnclosure();
+               AjaxLink<Void> testLink = page.getSelfRefreshingAjaxLink();
+
+               tester.startPage(page);
+               tester.clickLink(testLink);
+               tester.assertComponentOnAjaxResponse(testLink);
+
+       }
 }

Reply via email to