Author: mstruk
Date: 2011-03-22 05:34:28 -0400 (Tue, 22 Mar 2011)
New Revision: 6108
Added:
portal/trunk/testsuite/htmlunit-tests/src/test/java/org/jboss/gatein/htmlunit/jira/Test_GTNPORTAL_1823_FailToCreatePageNavNode.java
Modified:
portal/trunk/testsuite/htmlunit-tests/src/test/java/org/jboss/gatein/htmlunit/jira/Test_GTNPORTAL_1823_FailToCreatePage.java
Log:
GTNPORTAL-1823 Fail to create one page when creating two new pages at the same time.
- Added navigation nodes test
Modified:
portal/trunk/testsuite/htmlunit-tests/src/test/java/org/jboss/gatein/htmlunit/jira/Test_GTNPORTAL_1823_FailToCreatePage.java
===================================================================
---
portal/trunk/testsuite/htmlunit-tests/src/test/java/org/jboss/gatein/htmlunit/jira/Test_GTNPORTAL_1823_FailToCreatePage.java 2011-03-22
06:53:26 UTC (rev 6107)
+++
portal/trunk/testsuite/htmlunit-tests/src/test/java/org/jboss/gatein/htmlunit/jira/Test_GTNPORTAL_1823_FailToCreatePage.java 2011-03-22
09:34:28 UTC (rev 6108)
@@ -40,13 +40,13 @@
private static final Logger log =
Logger.getLogger(Test_GTNPORTAL_1823_FailToCreatePage.class);
/** Number of concurrent threads for the test */
- private static final int TCOUNT = 2;
+ protected static final int TCOUNT = 2;
/** Counter for id generation */
- private static AtomicInteger idCounter = new AtomicInteger(1);
+ protected static AtomicInteger idCounter = new AtomicInteger(1);
/** Down counter used to synchronize threads before clicking Finish */
- private static CountDownLatch sync = new CountDownLatch(TCOUNT);
+ protected static CountDownLatch sync = new CountDownLatch(TCOUNT);
/**
* Id for inclusion in page title so that every thread uses unique name for the newly
added page
@@ -65,11 +65,11 @@
* @throws Throwable if test fails
*/
@Test(invocationCount = TCOUNT, threadPoolSize = TCOUNT, groups = {"GateIn",
"jira", "htmlunit"})
- public void testGTNPORTAL_1823_FailToCreatePage() throws Throwable
+ public void testMain() throws Throwable
{
try
{
- test();
+ test(false);
}
finally
{
@@ -84,7 +84,7 @@
*
* @throws Throwable
*/
- private void test() throws Throwable
+ protected void test(boolean navNodeTest) throws Throwable
{
String id = nextId();
String categoryTitle = "Gadgets";
@@ -107,10 +107,11 @@
sync.await();
- // Uncomment this to make the test pass
- // TODO: even though everything looks ok, it's not - navigation only contains
TestPage2 node when it should also contain TestPage1 node.
- //if (id.equals("2"))
- // Thread.sleep(5000);
+ if (navNodeTest && id.equals("2"))
+ {
+ // Finish click concurrency is inappropriate for navNodeTest where we need
predictable order
+ Thread.sleep(5000);
+ }
// Now click Finish (both threads at the same time)
finishPageEdit();
@@ -121,6 +122,12 @@
Assert.assertNotSame(textPresent, failedText, "Concurrent Add Page issue
reproduced!");
Assert.assertEquals(textPresent, portletName, "");
+ if (navNodeTest && id.equals("2"))
+ {
+ // Check that both test pages' navigation nodes are present
+ Assert.assertTrue(isElementPresent("link=TestPage1"), "TestPage1
link presence");
+ Assert.assertTrue(isElementPresent("link=TestPage2"), "TestPage2
link presence");
+ }
finished();
}
Added:
portal/trunk/testsuite/htmlunit-tests/src/test/java/org/jboss/gatein/htmlunit/jira/Test_GTNPORTAL_1823_FailToCreatePageNavNode.java
===================================================================
---
portal/trunk/testsuite/htmlunit-tests/src/test/java/org/jboss/gatein/htmlunit/jira/Test_GTNPORTAL_1823_FailToCreatePageNavNode.java
(rev 0)
+++
portal/trunk/testsuite/htmlunit-tests/src/test/java/org/jboss/gatein/htmlunit/jira/Test_GTNPORTAL_1823_FailToCreatePageNavNode.java 2011-03-22
09:34:28 UTC (rev 6108)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.gatein.htmlunit.jira;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class Test_GTNPORTAL_1823_FailToCreatePageNavNode extends
Test_GTNPORTAL_1823_FailToCreatePage
+{
+
+ /**
+ * This test method relies on TestNG parallel test execution facility
+ * to perform two concurrent executions of this method on a single instance of the
test class
+ *
+ * @throws Throwable if test fails
+ */
+ @Test(invocationCount = TCOUNT, threadPoolSize = TCOUNT, groups = {"GateIn",
"jira", "htmlunit"})
+ public void testMain() throws Throwable
+ {
+ try
+ {
+ test(true);
+ }
+ finally
+ {
+ // If exception occurs we don't want the other thread to lock up
+ // - so we perform another countDown()
+ sync.countDown();
+ }
+ }
+}
\ No newline at end of file