/portal-web/test/com/liferay/portalweb/plugins/wsrp/helloworld/addproducerhw/TearDownProducerTest.java
Java | 280 lines | 215 code | 49 blank | 16 comment | 25 complexity | 8729391eadc1ee5a22a78b83d20b140e MD5 | raw file
- /**
- * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
- *
- * This library 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 library 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.
- */
- package com.liferay.portalweb.plugins.wsrp.helloworld.addproducerhw;
- import com.liferay.portalweb.portal.BaseTestCase;
- import com.liferay.portalweb.portal.util.RuntimeVariables;
- /**
- * @author Brian Wing Shun Chan
- */
- public class TearDownProducerTest extends BaseTestCase {
- public void testTearDownProducer() throws Exception {
- int label = 1;
- while (label >= 1) {
- switch (label) {
- case 1:
- selenium.open("/web/guest/home/");
- assertEquals(RuntimeVariables.replace("Go to"),
- selenium.getText("//li[@id='_145_mySites']/a/span"));
- selenium.mouseOver("//li[@id='_145_mySites']/a/span");
- for (int second = 0;; second++) {
- if (second >= 90) {
- fail("timeout");
- }
- try {
- if (selenium.isVisible("link=Control Panel")) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- selenium.clickAt("link=Control Panel",
- RuntimeVariables.replace("Control Panel"));
- selenium.waitForPageToLoad("30000");
- selenium.clickAt("link=WSRP", RuntimeVariables.replace("WSRP"));
- selenium.waitForPageToLoad("30000");
- selenium.clickAt("link=Producers",
- RuntimeVariables.replace("Producers"));
- selenium.waitForPageToLoad("30000");
- boolean producer1Present = selenium.isElementPresent(
- "//span[@title='Actions']/ul/li/strong/a/span");
- if (!producer1Present) {
- label = 6;
- continue;
- }
- Thread.sleep(5000);
- assertEquals(RuntimeVariables.replace("Actions"),
- selenium.getText(
- "//span[@title='Actions']/ul/li/strong/a/span"));
- selenium.clickAt("//span[@title='Actions']/ul/li/strong/a/span",
- RuntimeVariables.replace("Actions"));
- for (int second = 0;; second++) {
- if (second >= 90) {
- fail("timeout");
- }
- try {
- if (selenium.isVisible(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]")) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- assertEquals(RuntimeVariables.replace("Delete"),
- selenium.getText(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
- selenium.click(RuntimeVariables.replace(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.getConfirmation()
- .matches("^Are you sure you want to delete this[\\s\\S] It will be deleted immediately.$"));
- boolean producer2Present = selenium.isElementPresent(
- "//span[@title='Actions']/ul/li/strong/a/span");
- if (!producer2Present) {
- label = 5;
- continue;
- }
- Thread.sleep(5000);
- assertEquals(RuntimeVariables.replace("Actions"),
- selenium.getText(
- "//span[@title='Actions']/ul/li/strong/a/span"));
- selenium.clickAt("//span[@title='Actions']/ul/li/strong/a/span",
- RuntimeVariables.replace("Actions"));
- for (int second = 0;; second++) {
- if (second >= 90) {
- fail("timeout");
- }
- try {
- if (selenium.isVisible(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]")) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- assertEquals(RuntimeVariables.replace("Delete"),
- selenium.getText(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
- selenium.click(RuntimeVariables.replace(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.getConfirmation()
- .matches("^Are you sure you want to delete this[\\s\\S] It will be deleted immediately.$"));
- boolean producer3Present = selenium.isElementPresent(
- "//span[@title='Actions']/ul/li/strong/a/span");
- if (!producer3Present) {
- label = 4;
- continue;
- }
- Thread.sleep(5000);
- assertEquals(RuntimeVariables.replace("Actions"),
- selenium.getText(
- "//span[@title='Actions']/ul/li/strong/a/span"));
- selenium.clickAt("//span[@title='Actions']/ul/li/strong/a/span",
- RuntimeVariables.replace("Actions"));
- for (int second = 0;; second++) {
- if (second >= 90) {
- fail("timeout");
- }
- try {
- if (selenium.isVisible(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]")) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- assertEquals(RuntimeVariables.replace("Delete"),
- selenium.getText(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
- selenium.click(RuntimeVariables.replace(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.getConfirmation()
- .matches("^Are you sure you want to delete this[\\s\\S] It will be deleted immediately.$"));
- boolean producer4Present = selenium.isElementPresent(
- "//span[@title='Actions']/ul/li/strong/a/span");
- if (!producer4Present) {
- label = 3;
- continue;
- }
- Thread.sleep(5000);
- assertEquals(RuntimeVariables.replace("Actions"),
- selenium.getText(
- "//span[@title='Actions']/ul/li/strong/a/span"));
- selenium.clickAt("//span[@title='Actions']/ul/li/strong/a/span",
- RuntimeVariables.replace("Actions"));
- for (int second = 0;; second++) {
- if (second >= 90) {
- fail("timeout");
- }
- try {
- if (selenium.isVisible(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]")) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- assertEquals(RuntimeVariables.replace("Delete"),
- selenium.getText(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
- selenium.click(RuntimeVariables.replace(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.getConfirmation()
- .matches("^Are you sure you want to delete this[\\s\\S] It will be deleted immediately.$"));
- boolean producer5Present = selenium.isElementPresent(
- "//span[@title='Actions']/ul/li/strong/a/span");
- if (!producer5Present) {
- label = 2;
- continue;
- }
- Thread.sleep(5000);
- assertEquals(RuntimeVariables.replace("Actions"),
- selenium.getText(
- "//span[@title='Actions']/ul/li/strong/a/span"));
- selenium.clickAt("//span[@title='Actions']/ul/li/strong/a/span",
- RuntimeVariables.replace("Actions"));
- for (int second = 0;; second++) {
- if (second >= 90) {
- fail("timeout");
- }
- try {
- if (selenium.isVisible(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]")) {
- break;
- }
- }
- catch (Exception e) {
- }
- Thread.sleep(1000);
- }
- assertEquals(RuntimeVariables.replace("Delete"),
- selenium.getText(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
- selenium.click(RuntimeVariables.replace(
- "//div[@class='lfr-component lfr-menu-list']/ul/li/a[contains(.,'Delete')]"));
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.getConfirmation()
- .matches("^Are you sure you want to delete this[\\s\\S] It will be deleted immediately.$"));
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 100:
- label = -1;
- }
- }
- }
- }