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 2014/02/18 11:01:49 UTC

[05/17] git commit: Add Gym test for the new CDI example - auto conversation

Add Gym test for the new CDI example - auto conversation


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

Branch: refs/heads/sandbox/component-queueing-2
Commit: abeb2af4a8523ba4c60ef9b3dc8b425f47025d93
Parents: 0843d28
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Feb 17 14:25:47 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Feb 17 14:25:47 2014 +0200

----------------------------------------------------------------------
 .../wicket/examples/cdi/CdiApplication.java     |  4 ++
 .../src/main/webapp/js-test/all.html            |  1 +
 .../js-test/tests/cdi/auto-conversation.js      | 76 ++++++++++++++++++++
 3 files changed, 81 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/abeb2af4/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiApplication.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiApplication.java b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiApplication.java
index c56d2e7..f6548f4 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiApplication.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiApplication.java
@@ -39,6 +39,10 @@ public class CdiApplication extends WebApplication
 
 		// configure wicket/cdi
 		new CdiConfiguration().configure(this);
+
+		mountPage("injection", InjectionPage.class);
+		mountPage("conversation", ConversationPage1.class);
+		mountPage("autoConversation", AutoConversationPage1.class);
 	}
 
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/abeb2af4/wicket-examples/src/main/webapp/js-test/all.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/webapp/js-test/all.html b/wicket-examples/src/main/webapp/js-test/all.html
index 694723f..9226a00 100644
--- a/wicket-examples/src/main/webapp/js-test/all.html
+++ b/wicket-examples/src/main/webapp/js-test/all.html
@@ -24,6 +24,7 @@
 	<script type="text/javascript" src="tests/ajax/form.js"></script>
 	<script type="text/javascript" src="tests/cdi/injection.js"></script>
 	<script type="text/javascript" src="tests/cdi/conversation.js"></script>
+	<script type="text/javascript" src="tests/cdi/auto-conversation.js"></script>
 
     <script type="text/javascript" src="tests/bean-validation/name.js"></script>
     <script type="text/javascript" src="tests/bean-validation/email.js"></script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/abeb2af4/wicket-examples/src/main/webapp/js-test/tests/cdi/auto-conversation.js
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/webapp/js-test/tests/cdi/auto-conversation.js b/wicket-examples/src/main/webapp/js-test/tests/cdi/auto-conversation.js
new file mode 100644
index 0000000..e391d92
--- /dev/null
+++ b/wicket-examples/src/main/webapp/js-test/tests/cdi/auto-conversation.js
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+$q(document).ready(function() {
+	"use strict";
+
+	var countSelector = 'p > span';
+
+	var increment = function($) {
+		return gym.click($('a:contains("increment")'));
+	};
+
+	var nextPage = function($) {
+		return gym.click($('a:contains("Continue to next page")'));
+	};
+
+	var refresh = function($) {
+		return gym.click($('a:contains("refresh")'));
+	};
+
+	module('CDI');
+
+	asyncTest('auto-conversation', function () {
+		expect(4);
+		var initialValue;
+
+		gym.load('/cdi/autoConversation').then(function($) {
+
+			initialValue = $(countSelector).text();
+			initialValue = parseInt(initialValue, 10);
+
+			return increment($);
+		}).then(function($) {
+
+			var counterLabelValue = $(countSelector).text();
+			var expectedValue = initialValue + 1;
+			equal(counterLabelValue, "" + expectedValue, 'The new value of the counter is +1');
+
+			return increment($);
+		}).then(function($) {
+
+			var counterLabelValue = $(countSelector).text();
+			var expectedValue = initialValue + 2;
+			equal(counterLabelValue, "" + expectedValue, 'The new value of the counter is +1');
+
+			return nextPage($);
+		}).then(function($) {
+
+			var counterLabelValue = $(countSelector).text();
+			var expectedValue = initialValue + 2;
+			equal(counterLabelValue, "" + expectedValue, 'The value of the counter is the same as in the previous page');
+
+			return refresh($);
+		}).then(function($) {
+
+			var counterLabelValue = $(countSelector).text();
+			var expectedValue = 0;
+			equal(counterLabelValue, "" + expectedValue, 'The new value of the counter should be 0');
+		}).always(start);
+	});
+
+});