PageRenderTime 191ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/portal-web/test/com/liferay/portalweb/plugins/wsrp/helloworld/addproducerhw/TearDownProducerTest.java

https://github.com/lululiferay/liferay-portal
Java | 280 lines | 215 code | 49 blank | 16 comment | 25 complexity | 8729391eadc1ee5a22a78b83d20b140e MD5 | raw file
  1. /**
  2. * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU Lesser General Public License as published by the Free
  6. * Software Foundation; either version 2.1 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  12. * details.
  13. */
  14. package com.liferay.portalweb.plugins.wsrp.helloworld.addproducerhw;
  15. import com.liferay.portalweb.portal.BaseTestCase;
  16. import com.liferay.portalweb.portal.util.RuntimeVariables;
  17. /**
  18. * @author Brian Wing Shun Chan
  19. */
  20. public class TearDownProducerTest extends BaseTestCase {
  21. public void testTearDownProducer() throws Exception {
  22. int label = 1;
  23. while (label >= 1) {
  24. switch (label) {
  25. case 1:
  26. selenium.open("/web/guest/home/");
  27. assertEquals(RuntimeVariables.replace("Go to"),
  28. selenium.getText("//li[@id='_145_mySites']/a/span"));
  29. selenium.mouseOver("//li[@id='_145_mySites']/a/span");
  30. for (int second = 0;; second++) {
  31. if (second >= 90) {
  32. fail("timeout");
  33. }
  34. try {
  35. if (selenium.isVisible("link=Control Panel")) {
  36. break;
  37. }
  38. }
  39. catch (Exception e) {
  40. }
  41. Thread.sleep(1000);
  42. }
  43. selenium.clickAt("link=Control Panel",
  44. RuntimeVariables.replace("Control Panel"));
  45. selenium.waitForPageToLoad("30000");
  46. selenium.clickAt("link=WSRP", RuntimeVariables.replace("WSRP"));
  47. selenium.waitForPageToLoad("30000");
  48. selenium.clickAt("link=Producers",
  49. RuntimeVariables.replace("Producers"));
  50. selenium.waitForPageToLoad("30000");
  51. boolean producer1Present = selenium.isElementPresent(
  52. "//span[@title='Actions']/ul/li/strong/a/span");
  53. if (!producer1Present) {
  54. label = 6;
  55. continue;
  56. }
  57. Thread.sleep(5000);
  58. assertEquals(RuntimeVariables.replace("Actions"),
  59. selenium.getText(
  60. "//span[@title='Actions']/ul/li/strong/a/span"));
  61. selenium.clickAt("//span[@title='Actions']/ul/li/strong/a/span",
  62. RuntimeVariables.replace("Actions"));
  63. for (int second = 0;; second++) {
  64. if (second >= 90) {
  65. fail("timeout");
  66. }
  67. try {
  68. if (selenium.isVisible(
  69. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]")) {
  70. break;
  71. }
  72. }
  73. catch (Exception e) {
  74. }
  75. Thread.sleep(1000);
  76. }
  77. assertEquals(RuntimeVariables.replace("Delete"),
  78. selenium.getText(
  79. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
  80. selenium.click(RuntimeVariables.replace(
  81. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
  82. selenium.waitForPageToLoad("30000");
  83. assertTrue(selenium.getConfirmation()
  84. .matches("^Are you sure you want to delete this[\\s\\S] It will be deleted immediately.$"));
  85. boolean producer2Present = selenium.isElementPresent(
  86. "//span[@title='Actions']/ul/li/strong/a/span");
  87. if (!producer2Present) {
  88. label = 5;
  89. continue;
  90. }
  91. Thread.sleep(5000);
  92. assertEquals(RuntimeVariables.replace("Actions"),
  93. selenium.getText(
  94. "//span[@title='Actions']/ul/li/strong/a/span"));
  95. selenium.clickAt("//span[@title='Actions']/ul/li/strong/a/span",
  96. RuntimeVariables.replace("Actions"));
  97. for (int second = 0;; second++) {
  98. if (second >= 90) {
  99. fail("timeout");
  100. }
  101. try {
  102. if (selenium.isVisible(
  103. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]")) {
  104. break;
  105. }
  106. }
  107. catch (Exception e) {
  108. }
  109. Thread.sleep(1000);
  110. }
  111. assertEquals(RuntimeVariables.replace("Delete"),
  112. selenium.getText(
  113. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
  114. selenium.click(RuntimeVariables.replace(
  115. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
  116. selenium.waitForPageToLoad("30000");
  117. assertTrue(selenium.getConfirmation()
  118. .matches("^Are you sure you want to delete this[\\s\\S] It will be deleted immediately.$"));
  119. boolean producer3Present = selenium.isElementPresent(
  120. "//span[@title='Actions']/ul/li/strong/a/span");
  121. if (!producer3Present) {
  122. label = 4;
  123. continue;
  124. }
  125. Thread.sleep(5000);
  126. assertEquals(RuntimeVariables.replace("Actions"),
  127. selenium.getText(
  128. "//span[@title='Actions']/ul/li/strong/a/span"));
  129. selenium.clickAt("//span[@title='Actions']/ul/li/strong/a/span",
  130. RuntimeVariables.replace("Actions"));
  131. for (int second = 0;; second++) {
  132. if (second >= 90) {
  133. fail("timeout");
  134. }
  135. try {
  136. if (selenium.isVisible(
  137. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]")) {
  138. break;
  139. }
  140. }
  141. catch (Exception e) {
  142. }
  143. Thread.sleep(1000);
  144. }
  145. assertEquals(RuntimeVariables.replace("Delete"),
  146. selenium.getText(
  147. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
  148. selenium.click(RuntimeVariables.replace(
  149. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
  150. selenium.waitForPageToLoad("30000");
  151. assertTrue(selenium.getConfirmation()
  152. .matches("^Are you sure you want to delete this[\\s\\S] It will be deleted immediately.$"));
  153. boolean producer4Present = selenium.isElementPresent(
  154. "//span[@title='Actions']/ul/li/strong/a/span");
  155. if (!producer4Present) {
  156. label = 3;
  157. continue;
  158. }
  159. Thread.sleep(5000);
  160. assertEquals(RuntimeVariables.replace("Actions"),
  161. selenium.getText(
  162. "//span[@title='Actions']/ul/li/strong/a/span"));
  163. selenium.clickAt("//span[@title='Actions']/ul/li/strong/a/span",
  164. RuntimeVariables.replace("Actions"));
  165. for (int second = 0;; second++) {
  166. if (second >= 90) {
  167. fail("timeout");
  168. }
  169. try {
  170. if (selenium.isVisible(
  171. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]")) {
  172. break;
  173. }
  174. }
  175. catch (Exception e) {
  176. }
  177. Thread.sleep(1000);
  178. }
  179. assertEquals(RuntimeVariables.replace("Delete"),
  180. selenium.getText(
  181. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
  182. selenium.click(RuntimeVariables.replace(
  183. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
  184. selenium.waitForPageToLoad("30000");
  185. assertTrue(selenium.getConfirmation()
  186. .matches("^Are you sure you want to delete this[\\s\\S] It will be deleted immediately.$"));
  187. boolean producer5Present = selenium.isElementPresent(
  188. "//span[@title='Actions']/ul/li/strong/a/span");
  189. if (!producer5Present) {
  190. label = 2;
  191. continue;
  192. }
  193. Thread.sleep(5000);
  194. assertEquals(RuntimeVariables.replace("Actions"),
  195. selenium.getText(
  196. "//span[@title='Actions']/ul/li/strong/a/span"));
  197. selenium.clickAt("//span[@title='Actions']/ul/li/strong/a/span",
  198. RuntimeVariables.replace("Actions"));
  199. for (int second = 0;; second++) {
  200. if (second >= 90) {
  201. fail("timeout");
  202. }
  203. try {
  204. if (selenium.isVisible(
  205. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]")) {
  206. break;
  207. }
  208. }
  209. catch (Exception e) {
  210. }
  211. Thread.sleep(1000);
  212. }
  213. assertEquals(RuntimeVariables.replace("Delete"),
  214. selenium.getText(
  215. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
  216. selenium.click(RuntimeVariables.replace(
  217. "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
  218. selenium.waitForPageToLoad("30000");
  219. assertTrue(selenium.getConfirmation()
  220. .matches("^Are you sure you want to delete this[\\s\\S] It will be deleted immediately.$"));
  221. case 2:
  222. case 3:
  223. case 4:
  224. case 5:
  225. case 6:
  226. case 100:
  227. label = -1;
  228. }
  229. }
  230. }
  231. }