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

/portal-web/test/com/liferay/portalweb/portlet/webcontentdisplay/webcontent/localizewcwebcontenttemplatewcd/AddStructureLocalizedTest.java

https://github.com/l15k4/liferay-portal
Java | 118 lines | 87 code | 15 blank | 16 comment | 9 complexity | 1f1468a375082a67afa2c043958175fd MD5 | raw file
  1. /**
  2. * Copyright (c) 2000-2011 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.portlet.webcontentdisplay.webcontent.localizewcwebcontenttemplatewcd;
  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 AddStructureLocalizedTest extends BaseTestCase {
  21. public void testAddStructureLocalized() throws Exception {
  22. selenium.open("/web/guest/home/");
  23. for (int second = 0;; second++) {
  24. if (second >= 90) {
  25. fail("timeout");
  26. }
  27. try {
  28. if (selenium.isElementPresent("link=Control Panel")) {
  29. break;
  30. }
  31. }
  32. catch (Exception e) {
  33. }
  34. Thread.sleep(1000);
  35. }
  36. selenium.clickAt("link=Control Panel",
  37. RuntimeVariables.replace("Control Panel"));
  38. selenium.waitForPageToLoad("30000");
  39. selenium.clickAt("link=Web Content",
  40. RuntimeVariables.replace("Web Content"));
  41. selenium.waitForPageToLoad("30000");
  42. selenium.clickAt("link=Structures",
  43. RuntimeVariables.replace("Structures"));
  44. selenium.waitForPageToLoad("30000");
  45. selenium.clickAt("//input[@value='Add Structure']",
  46. RuntimeVariables.replace("Add Structure"));
  47. selenium.waitForPageToLoad("30000");
  48. selenium.type("//input[@id='_15_name_en_US']",
  49. RuntimeVariables.replace("Web Content Localized Structure Name"));
  50. selenium.type("//textarea[@id='_15_description_en_US']",
  51. RuntimeVariables.replace(
  52. "Web Content Localized Structure Description"));
  53. selenium.clickAt("//input[@id='_15_editorButton']",
  54. RuntimeVariables.replace("Launch Editor"));
  55. for (int second = 0;; second++) {
  56. if (second >= 90) {
  57. fail("timeout");
  58. }
  59. try {
  60. if (selenium.isVisible("//textarea[@id='_15_xsdContent']")) {
  61. break;
  62. }
  63. }
  64. catch (Exception e) {
  65. }
  66. Thread.sleep(1000);
  67. }
  68. Thread.sleep(5000);
  69. selenium.type("//textarea[@id='_15_xsdContent']",
  70. RuntimeVariables.replace(
  71. "<root>\n\n<dynamic-element name='page-name' type='text'></dynamic-element> \n\n<dynamic-element name='page-description' type='text'></dynamic-element>\n\n</root>"));
  72. selenium.click("//input[@value='Update']");
  73. for (int second = 0;; second++) {
  74. if (second >= 90) {
  75. fail("timeout");
  76. }
  77. try {
  78. if (selenium.isVisible("//input[@id='_15_structure_el0_name']")) {
  79. break;
  80. }
  81. }
  82. catch (Exception e) {
  83. }
  84. Thread.sleep(1000);
  85. }
  86. assertEquals("page-name",
  87. selenium.getValue("//input[@id='_15_structure_el0_name']"));
  88. assertEquals("page-description",
  89. selenium.getValue("//input[@id='_15_structure_el1_name']"));
  90. selenium.clickAt("//input[@value='Save']",
  91. RuntimeVariables.replace("Save"));
  92. selenium.waitForPageToLoad("30000");
  93. assertEquals(RuntimeVariables.replace(
  94. "Your request completed successfully."),
  95. selenium.getText("//div[@class='portlet-msg-success']"));
  96. assertEquals(RuntimeVariables.replace(
  97. "Web Content Localized Structure Name"),
  98. selenium.getText("//td[3]/a"));
  99. assertEquals(RuntimeVariables.replace(
  100. "Web Content Localized Structure Description"),
  101. selenium.getText("//td[4]/a"));
  102. }
  103. }