Repository: zeppelin Updated Branches: refs/heads/master dd1be03de -> 7bff131a5
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7bff131a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java deleted file mode 100644 index 6c7dfa6..0000000 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java +++ /dev/null @@ -1,888 +0,0 @@ -/* - * 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. - */ - -package org.apache.zeppelin.integration; - - -import org.apache.commons.lang.StringUtils; -import org.apache.zeppelin.AbstractZeppelinIT; -import org.apache.zeppelin.WebDriverManager; -import org.apache.zeppelin.ZeppelinITUtils; -import org.hamcrest.CoreMatchers; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ErrorCollector; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.Select; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ParagraphActionsIT extends AbstractZeppelinIT { - private static final Logger LOG = LoggerFactory.getLogger(ParagraphActionsIT.class); - - - @Rule - public ErrorCollector collector = new ErrorCollector(); - - @Before - public void startUp() { - if (!endToEndTestEnabled()) { - return; - } - driver = WebDriverManager.getWebDriver(); - } - - @After - public void tearDown() { - if (!endToEndTestEnabled()) { - return; - } - - driver.quit(); - } - - @Test - public void testCreateNewButton() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - Actions action = new Actions(driver); - waitForParagraph(1, "READY"); - Integer oldNosOfParas = driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); - collector.checkThat("Before Insert New : the number of paragraph ", - oldNosOfParas, - CoreMatchers.equalTo(1)); - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click=\"insertNew('below')\"]")).click(); - waitForParagraph(2, "READY"); - Integer newNosOfParas = driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); - collector.checkThat("After Insert New (using Insert New button) : number of paragraph", - oldNosOfParas + 1, - CoreMatchers.equalTo(newNosOfParas)); - - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='removeParagraph(paragraph)']")).click(); - ZeppelinITUtils.sleep(1000, false); - driver.findElement(By.xpath("//div[@class='modal-dialog'][contains(.,'delete this paragraph')]" + - "//div[@class='modal-footer']//button[contains(.,'OK')]")).click(); - ZeppelinITUtils.sleep(1000, false); - - setTextOfParagraph(1, " original paragraph "); - - WebElement newPara = driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class,'new-paragraph')][1]")); - action.moveToElement(newPara).click().build().perform(); - ZeppelinITUtils.sleep(1000, false); - waitForParagraph(1, "READY"); - - collector.checkThat("Paragraph is created above", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), - CoreMatchers.equalTo(StringUtils.EMPTY)); - setTextOfParagraph(1, " this is above "); - - newPara = driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class,'new-paragraph')][2]")); - action.moveToElement(newPara).click().build().perform(); - - waitForParagraph(3, "READY"); - - collector.checkThat("Paragraph is created below", - driver.findElement(By.xpath(getParagraphXPath(3) + "//div[contains(@class, 'editor')]")).getText(), - CoreMatchers.equalTo(StringUtils.EMPTY)); - setTextOfParagraph(3, " this is below "); - - collector.checkThat("The output field of paragraph1 contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), - CoreMatchers.equalTo(" this is above ")); - collector.checkThat("The output field paragraph2 contains", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")).getText(), - CoreMatchers.equalTo(" original paragraph ")); - collector.checkThat("The output field paragraph3 contains", - driver.findElement(By.xpath(getParagraphXPath(3) + "//div[contains(@class, 'editor')]")).getText(), - CoreMatchers.equalTo(" this is below ")); - collector.checkThat("The current number of paragraphs after creating paragraph above and below", - driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(), - CoreMatchers.equalTo(3)); - - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testCreateNewButton ", e); - } - - } - - @Test - public void testRemoveButton() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - waitForParagraph(1, "READY"); - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click=\"insertNew('below')\"]")) - .click(); - waitForParagraph(2, "READY"); - Integer oldNosOfParas = driver.findElements(By.xpath - ("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); - collector.checkThat("Before Remove : Number of paragraphs are ", - oldNosOfParas, - CoreMatchers.equalTo(2)); - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - - clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='removeParagraph(paragraph)']")); - - clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'delete this paragraph')" + - "]//div[@class='modal-footer']//button[contains(.,'OK')]")); - - Integer newNosOfParas = driver.findElements(By.xpath - ("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); - collector.checkThat("After Remove : Number of paragraphs are", - newNosOfParas, - CoreMatchers.equalTo(oldNosOfParas - 1)); - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testRemoveButton ", e); - } - } - - @Test - public void testMoveUpAndDown() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - waitForParagraph(1, "READY"); - setTextOfParagraph(1, "1"); - - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click=\"insertNew('below')\"]")).click(); - - - waitForParagraph(2, "READY"); - setTextOfParagraph(2, "2"); - - - collector.checkThat("The paragraph1 value contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), - CoreMatchers.equalTo("1")); - collector.checkThat("The paragraph1 value contains", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")).getText(), - CoreMatchers.equalTo("2")); - - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='moveDown(paragraph)']")); - - collector.checkThat("The paragraph1 value contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), - CoreMatchers.equalTo("2")); - collector.checkThat("The paragraph1 value contains", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")).getText(), - CoreMatchers.equalTo("1")); - - driver.findElement(By.xpath(getParagraphXPath(2) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(2) + "//ul/li/a[@ng-click='moveUp(paragraph)']")); - - collector.checkThat("The paragraph1 value contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), - CoreMatchers.equalTo("1")); - collector.checkThat("The paragraph1 value contains", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")).getText(), - CoreMatchers.equalTo("2")); - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testMoveUpAndDown ", e); - } - - } - - @Test - public void testDisableParagraphRunButton() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - waitForParagraph(1, "READY"); - setTextOfParagraph(1, "println (\"abcd\")"); - - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='toggleEnableDisable(paragraph)']")); - collector.checkThat("The play button class was ", - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-control-play shortcut-icon']")).isDisplayed(), CoreMatchers.equalTo(false) - ); - - driver.findElement(By.xpath(".//*[@id='main']//button[contains(@ng-click, 'runAllParagraphs')]")).sendKeys(Keys.ENTER); - ZeppelinITUtils.sleep(1000, true); - driver.findElement(By.xpath("//div[@class='modal-dialog'][contains(.,'Run all paragraphs?')]" + - "//div[@class='modal-footer']//button[contains(.,'OK')]")).click(); - ZeppelinITUtils.sleep(2000, false); - - collector.checkThat("Paragraph status is ", - getParagraphStatus(1), CoreMatchers.equalTo("READY") - ); - - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testDisableParagraphRunButton ", e); - } - } - - @Test - public void testRunOnSelectionChange() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - String xpathToRunOnSelectionChangeCheckbox = getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]"; - String xpathToDropdownMenu = getParagraphXPath(1) + "//select"; - String xpathToResultText = getParagraphXPath(1) + "//div[contains(@id,\"_html\")]"; - - createNewNote(); - - waitForParagraph(1, "READY"); - setTextOfParagraph(1, "%md My selection is ${my selection=1,1|2|3}"); - runParagraph(1); - waitForParagraph(1, "FINISHED"); - - // 1. 'RunOnSelectionChange' is true by default - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - collector.checkThat("'Run on selection change' checkbox will be shown under dropdown menu ", - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-click, 'turnOnAutoRun(paragraph)')]")).isDisplayed(), - CoreMatchers.equalTo(true)); - - Select dropDownMenu = new Select(driver.findElement(By.xpath((xpathToDropdownMenu)))); - dropDownMenu.selectByVisibleText("2"); - waitForParagraph(1, "FINISHED"); - collector.checkThat("If 'RunOnSelectionChange' is true, the paragraph result will be updated right after click any options in the dropdown menu ", - driver.findElement(By.xpath(xpathToResultText)).getText(), - CoreMatchers.equalTo("My selection is 2")); - - // 2. set 'RunOnSelectionChange' to false - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(xpathToRunOnSelectionChangeCheckbox)).click(); - collector.checkThat("If 'Run on selection change' checkbox is unchecked, 'paragraph.config.runOnSelectionChange' will be false ", - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/span[contains(@ng-if, 'paragraph.config.runOnSelectionChange == false')]")).isDisplayed(), - CoreMatchers.equalTo(true)); - - Select sameDropDownMenu = new Select(driver.findElement(By.xpath((xpathToDropdownMenu)))); - sameDropDownMenu.selectByVisibleText("1"); - waitForParagraph(1, "FINISHED"); - collector.checkThat("If 'RunOnSelectionChange' is false, the paragraph result won't be updated even if we select any options in the dropdown menu ", - driver.findElement(By.xpath(xpathToResultText)).getText(), - CoreMatchers.equalTo("My selection is 2")); - - // run paragraph manually by pressing ENTER - driver.findElement(By.xpath(xpathToDropdownMenu)).sendKeys(Keys.ENTER); - waitForParagraph(1, "FINISHED"); - collector.checkThat("Even if 'RunOnSelectionChange' is set as false, still can run the paragraph by pressing ENTER ", - driver.findElement(By.xpath(xpathToResultText)).getText(), - CoreMatchers.equalTo("My selection is 1")); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testRunOnSelectionChange ", e); - } - } - - @Test - public void testClearOutputButton() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - waitForParagraph(1, "READY"); - String xpathToOutputField = getParagraphXPath(1) + "//div[contains(@id,\"_text\")]"; - setTextOfParagraph(1, "println (\"abcd\")"); - collector.checkThat("Before Run Output field contains ", - driver.findElements(By.xpath(xpathToOutputField)).size(), - CoreMatchers.equalTo(0)); - runParagraph(1); - waitForParagraph(1, "FINISHED"); - collector.checkThat("After Run Output field contains ", - driver.findElement(By.xpath(xpathToOutputField)).getText(), - CoreMatchers.equalTo("abcd")); - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(1) + - "//ul/li/a[@ng-click='clearParagraphOutput(paragraph)']")); - collector.checkThat("After Clear Output field contains ", - driver.findElements(By.xpath(xpathToOutputField)).size(), - CoreMatchers.equalTo(0)); - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testClearOutputButton ", e); - } - } - - @Test - public void testWidth() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - waitForParagraph(1, "READY"); - - collector.checkThat("Default Width is 12 ", - driver.findElement(By.xpath("//div[contains(@class,'col-md-12')]")).isDisplayed(), - CoreMatchers.equalTo(true)); - for (Integer newWidth = 1; newWidth <= 11; newWidth++) { - clickAndWait(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")); - String visibleText = newWidth.toString(); - new Select(driver.findElement(By.xpath(getParagraphXPath(1) - + "//ul/li/a/select[(@ng-model='paragraph.config.colWidth')]"))).selectByVisibleText(visibleText); - collector.checkThat("New Width is : " + newWidth, - driver.findElement(By.xpath("//div[contains(@class,'col-md-" + newWidth + "')]")).isDisplayed(), - CoreMatchers.equalTo(true)); - } - deleteTestNotebook(driver); - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testWidth ", e); - } - } - - @Test - public void testFontSize() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - waitForParagraph(1, "READY"); - Float height = Float.valueOf(driver.findElement(By.xpath("//div[contains(@class,'ace_content')]")) - .getCssValue("height").replace("px", "")); - for (Integer newFontSize = 10; newFontSize <= 20; newFontSize++) { - clickAndWait(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")); - String visibleText = newFontSize.toString(); - new Select(driver.findElement(By.xpath(getParagraphXPath(1) - + "//ul/li/a/select[(@ng-model='paragraph.config.fontSize')]"))).selectByVisibleText(visibleText); - Float newHeight = Float.valueOf(driver.findElement(By.xpath("//div[contains(@class,'ace_content')]")) - .getCssValue("height").replace("px", "")); - collector.checkThat("New Font size is : " + newFontSize, - newHeight > height, - CoreMatchers.equalTo(true)); - height = newHeight; - } - deleteTestNotebook(driver); - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testFontSize ", e); - } - } - - @Test - public void testTitleButton() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - waitForParagraph(1, "READY"); - - String xpathToTitle = getParagraphXPath(1) + "//div[contains(@class, 'title')]/div"; - String xpathToSettingIcon = getParagraphXPath(1) + "//span[@class='icon-settings']"; - String xpathToShowTitle = getParagraphXPath(1) + "//ul/li/a[@ng-show='!paragraph.config.title']"; - String xpathToHideTitle = getParagraphXPath(1) + "//ul/li/a[@ng-show='paragraph.config.title']"; - - ZeppelinITUtils.turnOffImplicitWaits(driver); - Integer titleElems = driver.findElements(By.xpath(xpathToTitle)).size(); - collector.checkThat("Before Show Title : The title doesn't exist", - titleElems, - CoreMatchers.equalTo(0)); - ZeppelinITUtils.turnOnImplicitWaits(driver); - - clickAndWait(By.xpath(xpathToSettingIcon)); - collector.checkThat("Before Show Title : The title option in option panel of paragraph is labeled as", - driver.findElement(By.xpath(xpathToShowTitle)).getText(), - CoreMatchers.allOf(CoreMatchers.endsWith("Show title"), CoreMatchers.containsString("Ctrl+"), - CoreMatchers.anyOf(CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), - CoreMatchers.containsString("+T"))); - - clickAndWait(By.xpath(xpathToShowTitle)); - collector.checkThat("After Show Title : The title field contains", - driver.findElement(By.xpath(xpathToTitle)).getText(), - CoreMatchers.equalTo("Untitled")); - - clickAndWait(By.xpath(xpathToSettingIcon)); - collector.checkThat("After Show Title : The title option in option panel of paragraph is labeled as", - driver.findElement(By.xpath(xpathToHideTitle)).getText(), - CoreMatchers.allOf(CoreMatchers.endsWith("Hide title"), CoreMatchers.containsString("Ctrl+"), - CoreMatchers.anyOf(CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), - CoreMatchers.containsString("+T"))); - - clickAndWait(By.xpath(xpathToHideTitle)); - ZeppelinITUtils.turnOffImplicitWaits(driver); - titleElems = driver.findElements(By.xpath(xpathToTitle)).size(); - collector.checkThat("After Hide Title : The title field is hidden", - titleElems, - CoreMatchers.equalTo(0)); - ZeppelinITUtils.turnOnImplicitWaits(driver); - - driver.findElement(By.xpath(xpathToSettingIcon)).click(); - driver.findElement(By.xpath(xpathToShowTitle)).click(); - - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'title')]")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//input")).sendKeys("NEW TITLE" + Keys.ENTER); - ZeppelinITUtils.sleep(500, false); - collector.checkThat("After Editing the Title : The title field contains ", - driver.findElement(By.xpath(xpathToTitle)).getText(), - CoreMatchers.equalTo("NEW TITLE")); - driver.navigate().refresh(); - ZeppelinITUtils.sleep(1000, false); - collector.checkThat("After Page Refresh : The title field contains ", - driver.findElement(By.xpath(xpathToTitle)).getText(), - CoreMatchers.equalTo("NEW TITLE")); - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testTitleButton ", e); - } - - } - - @Test - public void testShowAndHideLineNumbers() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - waitForParagraph(1, "READY"); - String xpathToLineNumberField = getParagraphXPath(1) + "//div[contains(@class, 'ace_gutter-layer')]"; - String xpathToShowLineNumberButton = getParagraphXPath(1) + "//ul/li/a[@ng-click='showLineNumbers(paragraph)']"; - String xpathToHideLineNumberButton = getParagraphXPath(1) + "//ul/li/a[@ng-click='hideLineNumbers(paragraph)']"; - - collector.checkThat("Before \"Show line number\" the Line Number is Enabled ", - driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(), - CoreMatchers.equalTo(false)); - - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - collector.checkThat("Before \"Show line number\" The option panel in paragraph has button labeled ", - driver.findElement(By.xpath(xpathToShowLineNumberButton)).getText(), - CoreMatchers.allOf(CoreMatchers.endsWith("Show line numbers"), CoreMatchers.containsString("Ctrl+"), - CoreMatchers.anyOf(CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), - CoreMatchers.containsString("+M"))); - - - clickAndWait(By.xpath(xpathToShowLineNumberButton)); - collector.checkThat("After \"Show line number\" the Line Number is Enabled ", - driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(), - CoreMatchers.equalTo(true)); - - clickAndWait(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")); - collector.checkThat("After \"Show line number\" The option panel in paragraph has button labeled ", - driver.findElement(By.xpath(xpathToHideLineNumberButton)).getText(), - CoreMatchers.allOf(CoreMatchers.endsWith("Hide line numbers"), CoreMatchers.containsString("Ctrl+"), - CoreMatchers.anyOf(CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), - CoreMatchers.containsString("+M"))); - - clickAndWait(By.xpath(xpathToHideLineNumberButton)); - collector.checkThat("After \"Hide line number\" the Line Number is Enabled", - driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(), - CoreMatchers.equalTo(false)); - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testShowAndHideLineNumbers ", e); - } - } - - @Test - public void testEditOnDoubleClick() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - Actions action = new Actions(driver); - - waitForParagraph(1, "READY"); - - setTextOfParagraph(1, "%md"); - driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")).sendKeys(Keys.ARROW_RIGHT); - driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")).sendKeys(Keys.ENTER); - driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")).sendKeys(Keys.SHIFT + "3"); - driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")).sendKeys(" abc"); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - - collector.checkThat("Markdown editor is hidden after run ", - driver.findElements(By.xpath(getParagraphXPath(1) + "//div[contains(@ng-if, 'paragraph.config.editorHide')]")).size(), - CoreMatchers.equalTo(0)); - - collector.checkThat("Markdown editor is shown after run ", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@ng-show, 'paragraph.config.tableHide')]")).isDisplayed(), - CoreMatchers.equalTo(true)); - - // to check if editOnDblClick field is fetched correctly after refresh - driver.navigate().refresh(); - waitForParagraph(1, "FINISHED"); - - action.doubleClick(driver.findElement(By.xpath(getParagraphXPath(1)))).perform(); - ZeppelinITUtils.sleep(1000, false); - collector.checkThat("Markdown editor is shown after double click ", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@ng-if, 'paragraph.config.editorHide')]")).isDisplayed(), - CoreMatchers.equalTo(true)); - - collector.checkThat("Markdown editor is hidden after double click ", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@ng-show, 'paragraph.config.tableHide')]")).isDisplayed(), - CoreMatchers.equalTo(false)); - - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testEditOnDoubleClick ", e); - } - } - - @Test - public void testSingleDynamicFormTextInput() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - setTextOfParagraph(1, "%spark println(\"Hello \"+z.textbox(\"name\", \"world\")) "); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text is equal to value specified initially", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Hello world")); - - driver.findElement(By.xpath(getParagraphXPath(1) + "//input")).clear(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//input")).sendKeys("Zeppelin"); - - collector.checkThat("After new data in text input form, output should not be changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Hello world")); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - collector.checkThat("Only after running the paragraph, we can see the newly updated output", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Hello Zeppelin")); - - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testSingleDynamicFormTextInput ", e); - } - } - - @Test - public void testSingleDynamicFormSelectForm() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - setTextOfParagraph(1, "%spark println(\"Howdy \"+z.select(\"names\", Seq((\"1\",\"Alice\"), " + - "(\"2\",\"Bob\"),(\"3\",\"stranger\"))))"); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text should not display any of the options in select form", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy ")); - - Select dropDownMenu = new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[1]")))); - - dropDownMenu.selectByVisibleText("Alice"); - collector.checkThat("After selection in drop down menu, output should display the newly selected option", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy 1")); - - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]")); - - Select sameDropDownMenu = new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[1]")))); - sameDropDownMenu.selectByVisibleText("Bob"); - collector.checkThat("After 'Run on selection change' checkbox is unchecked, the paragraph should not run if selecting a different option", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy 1")); - - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testSingleDynamicFormSelectForm ", e); - } - } - - @Test - public void testSingleDynamicFormCheckboxForm() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - setTextOfParagraph(1, "%spark val options = Seq((\"han\",\"Han\"), (\"leia\",\"Leia\"), " + - "(\"luke\",\"Luke\")); println(\"Greetings \"+z.checkbox(\"skywalkers\",options).mkString(\" and \"))"); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text should display all of the options included in check boxes", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.containsString("Greetings han and leia and luke")); - - WebElement firstCheckbox = driver.findElement(By.xpath("(" + getParagraphXPath(1) + "//input[@type='checkbox'])[1]")); - firstCheckbox.click(); - collector.checkThat("After unchecking one of the boxes, we can see the newly updated output without the option we unchecked", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.containsString("Greetings leia and luke")); - - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]")); - - WebElement secondCheckbox = driver.findElement(By.xpath("(" + getParagraphXPath(1) + "//input[@type='checkbox'])[2]")); - secondCheckbox.click(); - collector.checkThat("After 'Run on selection change' checkbox is unchecked, the paragraph should not run if check box state is modified", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.containsString("Greetings leia and luke")); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - - - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testSingleDynamicFormCheckboxForm ", e); - } - } - - @Test - public void testMultipleDynamicFormsSameType() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - setTextOfParagraph(1, "%spark println(\"Howdy \"+z.select(\"fruits\", Seq((\"1\",\"Apple\")," + - "(\"2\",\"Orange\"),(\"3\",\"Peach\")))); println(\"Howdy \"+z.select(\"planets\", " + - "Seq((\"1\",\"Venus\"),(\"2\",\"Earth\"),(\"3\",\"Mars\"))))"); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text should not display any of the options in select form", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy \nHowdy ")); - - Select dropDownMenu = new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[1]")))); - dropDownMenu.selectByVisibleText("Apple"); - collector.checkThat("After selection in drop down menu, output should display the new option we selected", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy 1\nHowdy ")); - - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]")); - - Select sameDropDownMenu = new Select(driver.findElement(By.xpath("(" + (getParagraphXPath(1) + "//select)[2]")))); - sameDropDownMenu.selectByVisibleText("Earth"); - waitForParagraph(1, "FINISHED"); - collector.checkThat("After 'Run on selection change' checkbox is unchecked, the paragraph should not run if selecting a different option", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy 1\nHowdy ")); - - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testMultipleDynamicFormsSameType ", e); - } - } - - @Test - public void testNoteDynamicFormTextInput() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - setTextOfParagraph(1, "%spark println(\"Hello \"+z.noteTextbox(\"name\", \"world\")) "); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text is equal to value specified initially", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), CoreMatchers.equalTo("Hello world")); - driver.findElement(By.xpath(getNoteFormsXPath() + "//input")).clear(); - driver.findElement(By.xpath(getNoteFormsXPath() + "//input")).sendKeys("Zeppelin"); - driver.findElement(By.xpath(getNoteFormsXPath() + "//input")).sendKeys(Keys.RETURN); - - collector.checkThat("After new data in text input form, output should not be changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Hello world")); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - collector.checkThat("Only after running the paragraph, we can see the newly updated output", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Hello Zeppelin")); - - setTextOfParagraph(2, "%spark println(\"Hello \"+z.noteTextbox(\"name\", \"world\")) "); - runParagraph(2); - waitForParagraph(2, "FINISHED"); - collector.checkThat("Running the another paragraph with same form, we can see value from note form", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Hello Zeppelin")); - - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testNoteDynamicFormTextInput ", e); - } - } - - @Test - public void testNoteDynamicFormSelect() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - setTextOfParagraph(1, "%spark println(\"Howdy \"+z.noteSelect(\"names\", Seq((\"1\",\"Alice\"), " + - "(\"2\",\"Bob\"),(\"3\",\"stranger\"))))"); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text should not display any of the options in select form", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy ")); - - Select dropDownMenu = new Select(driver.findElement(By.xpath("(" + (getNoteFormsXPath() + "//select)[1]")))); - - dropDownMenu.selectByVisibleText("Bob"); - collector.checkThat("After selection in drop down menu, output should not be changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy ")); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - - collector.checkThat("After run paragraph again, we can see the newly updated output", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy 2")); - - setTextOfParagraph(2, "%spark println(\"Howdy \"+z.noteSelect(\"names\", Seq((\"1\",\"Alice\"), " + - "(\"2\",\"Bob\"),(\"3\",\"stranger\"))))"); - - runParagraph(2); - waitForParagraph(2, "FINISHED"); - - collector.checkThat("Running the another paragraph with same form, we can see value from note form", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Howdy 2")); - - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testNoteDynamicFormSelect ", e); - } - } - - @Test - public void testDynamicNoteFormCheckbox() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - setTextOfParagraph(1, "%spark val options = Seq((\"han\",\"Han\"), (\"leia\",\"Leia\"), " + - "(\"luke\",\"Luke\")); println(\"Greetings \"+z.noteCheckbox(\"skywalkers\",options).mkString(\" and \"))"); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - collector.checkThat("Output text should display all of the options included in check boxes", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.containsString("Greetings han and leia and luke")); - - WebElement firstCheckbox = driver.findElement(By.xpath("(" + getNoteFormsXPath() + "//input[@type='checkbox'])[1]")); - firstCheckbox.click(); - collector.checkThat("After unchecking one of the boxes, output should not be changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.containsString("Greetings han and leia and luke")); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - - collector.checkThat("After run paragraph again, we can see the newly updated output", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.containsString("Greetings leia and luke")); - - setTextOfParagraph(2, "%spark val options = Seq((\"han\",\"Han\"), (\"leia\",\"Leia\"), " + - "(\"luke\",\"Luke\")); println(\"Greetings \"+z.noteCheckbox(\"skywalkers\",options).mkString(\" and \"))"); - - runParagraph(2); - waitForParagraph(2, "FINISHED"); - - collector.checkThat("Running the another paragraph with same form, we can see value from note form", - driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.containsString("Greetings leia and luke")); - - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testDynamicNoteFormCheckbox ", e); - } - } - - @Test - public void testWithNoteAndParagraphDynamicFormTextInput() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - setTextOfParagraph(1, "%spark println(z.noteTextbox(\"name\", \"note\") + \" \" + z.textbox(\"name\", \"paragraph\")) "); - - runParagraph(1); - waitForParagraph(1, "FINISHED"); - - collector.checkThat("After run paragraph, we can see computed output from two forms", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("note paragraph")); - - deleteTestNotebook(driver); - - } catch (Exception e) { - handleException("Exception in ParagraphActionsIT while testWithNoteAndParagraphDynamicFormTextInput ", e); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7bff131a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/PersonalizeActionsIT.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/PersonalizeActionsIT.java b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/PersonalizeActionsIT.java deleted file mode 100644 index dc07435..0000000 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/PersonalizeActionsIT.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * 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. - */ -package org.apache.zeppelin.integration; - -import org.apache.commons.lang.StringUtils; -import org.apache.zeppelin.AbstractZeppelinIT; -import org.apache.zeppelin.integration.AuthenticationIT; -import org.apache.zeppelin.WebDriverManager; -import org.apache.zeppelin.ZeppelinITUtils; -import org.apache.zeppelin.conf.ZeppelinConfiguration; -import org.hamcrest.CoreMatchers; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ErrorCollector; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.TimeoutException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.commons.io.FileUtils; -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - -import static org.junit.Assert.assertTrue; - -public class PersonalizeActionsIT extends AbstractZeppelinIT { - private static final Logger LOG = LoggerFactory.getLogger(PersonalizeActionsIT.class); - - @Rule - public ErrorCollector collector = new ErrorCollector(); - static String shiroPath; - static String authShiro = "[users]\n" + - "admin = password1, admin\n" + - "user1 = password2, user\n" + - "[main]\n" + - "sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager\n" + - "securityManager.sessionManager = $sessionManager\n" + - "securityManager.sessionManager.globalSessionTimeout = 86400000\n" + - "shiro.loginUrl = /api/login\n" + - "[roles]\n" + - "admin = *\n" + - "user = *\n" + - "[urls]\n" + - "/api/version = anon\n" + - "/** = authc"; - - static String originalShiro = ""; - - @BeforeClass - public static void startUp() { - if (!endToEndTestEnabled()) { - return; - } - try { - System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), new File("../").getAbsolutePath()); - ZeppelinConfiguration conf = ZeppelinConfiguration.create(); - shiroPath = conf.getRelativeDir(String.format("%s/shiro.ini", conf.getConfDir())); - File file = new File(shiroPath); - if (file.exists()) { - originalShiro = StringUtils.join(FileUtils.readLines(file, "UTF-8"), "\n"); - } - FileUtils.write(file, authShiro, "UTF-8"); - } catch (IOException e) { - LOG.error("Error in PersonalizeActionsIT startUp::", e); - } - ZeppelinITUtils.restartZeppelin(); - driver = WebDriverManager.getWebDriver(); - } - - @AfterClass - public static void tearDown() { - if (!endToEndTestEnabled()) { - return; - } - try { - if (!StringUtils.isBlank(shiroPath)) { - File file = new File(shiroPath); - if (StringUtils.isBlank(originalShiro)) { - FileUtils.deleteQuietly(file); - } else { - FileUtils.write(file, originalShiro, "UTF-8"); - } - } - } catch (IOException e) { - LOG.error("Error in PersonalizeActionsIT tearDown::", e); - } - ZeppelinITUtils.restartZeppelin(); - driver.quit(); - } - - private void setParagraphText(String text) { - setTextOfParagraph(1, "%md\\n # " + text); - runParagraph(1); - waitForParagraph(1, "FINISHED"); - } - - @Test - public void testSimpleAction() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - // step 1 : (admin) create a new note, run a paragraph and turn on personalized mode - AuthenticationIT authenticationIT = new AuthenticationIT(); - PersonalizeActionsIT personalizeActionsIT = new PersonalizeActionsIT(); - authenticationIT.authenticationUser("admin", "password1"); - By locator = By.xpath("//div[contains(@class, \"col-md-4\")]/div/h5/a[contains(.,'Create new" + - " note')]"); - WebDriverWait wait = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC); - WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); - if (element.isDisplayed()) { - createNewNote(); - } - String noteId = driver.getCurrentUrl().substring(driver.getCurrentUrl().lastIndexOf("/") + 1); - waitForParagraph(1, "READY"); - personalizeActionsIT.setParagraphText("Before"); - collector.checkThat("The output field paragraph contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'markdown-body')]")).getText(), - CoreMatchers.equalTo("Before")); - pollingWait(By.xpath("//*[@id='actionbar']" + - "//button[contains(@uib-tooltip, 'Switch to personal mode')]"), MAX_BROWSER_TIMEOUT_SEC).click(); - clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to personalize your analysis?')" + - "]//div[@class='modal-footer']//button[contains(.,'OK')]")); - authenticationIT.logoutUser("admin"); - - // step 2 : (user1) make sure it is on personalized mode and 'Before' in result of paragraph - authenticationIT.authenticationUser("user1", "password2"); - locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"); - wait = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC); - element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); - if (element.isDisplayed()) { - pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), - MAX_BROWSER_TIMEOUT_SEC).click(); - } - collector.checkThat("The personalized mode enables", - driver.findElement(By.xpath("//*[@id='actionbar']" + - "//button[contains(@class, 'btn btn-default btn-xs ng-scope ng-hide')]")).getAttribute("uib-tooltip"), - CoreMatchers.equalTo("Switch to personal mode (owner can change)")); - waitForParagraph(1, "READY"); - runParagraph(1); - collector.checkThat("The output field paragraph contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'markdown-body')]")).getText(), - CoreMatchers.equalTo("Before")); - authenticationIT.logoutUser("user1"); - - // step 3 : (admin) change paragraph contents to 'After' and check result of paragraph - authenticationIT.authenticationUser("admin", "password1"); - locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"); - element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); - if (element.isDisplayed()) { - pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC).click(); - } - waitForParagraph(1, "FINISHED"); - personalizeActionsIT.setParagraphText("After"); - collector.checkThat("The output field paragraph contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'markdown-body')]")).getText(), - CoreMatchers.equalTo("After")); - authenticationIT.logoutUser("admin"); - - // step 4 : (user1) check whether result is 'Before' or not - authenticationIT.authenticationUser("user1", "password2"); - locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"); - element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); - if (element.isDisplayed()) { - pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC).click(); - } - collector.checkThat("The output field paragraph contains", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'markdown-body')]")).getText(), - CoreMatchers.equalTo("Before")); - authenticationIT.logoutUser("user1"); - } catch (Exception e) { - handleException("Exception in PersonalizeActionsIT while testSimpleAction ", e); - } - } - - @Test - public void testGraphAction() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - // step 1 : (admin) create a new note, run a paragraph, change active graph to 'Bar chart', turn on personalized mode - AuthenticationIT authenticationIT = new AuthenticationIT(); - authenticationIT.authenticationUser("admin", "password1"); - By locator = By.xpath("//div[contains(@class, \"col-md-4\")]/div/h5/a[contains(.,'Create new" + - " note')]"); - WebDriverWait wait = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC); - WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); - if (element.isDisplayed()) { - createNewNote(); - } - String noteId = driver.getCurrentUrl().substring(driver.getCurrentUrl().lastIndexOf("/") + 1); - setTextOfParagraph(1, "print(s\"\"\"%table\\n" + - "name\\tsize\\n" + - "sun\\t100\\n" + - "moon\\t10\"\"\")"); - - runParagraph(1); - try { - waitForParagraph(1, "FINISHED"); - } catch (TimeoutException e) { - waitForParagraph(1, "ERROR"); - collector.checkThat("Exception in PersonalizeActionsIT while testGraphAction, status of 1st Spark Paragraph ", - "ERROR", CoreMatchers.equalTo("FINISHED")); - } - - pollingWait(By.xpath(getParagraphXPath(1) + - "//button[contains(@uib-tooltip, 'Bar Chart')]"), MAX_BROWSER_TIMEOUT_SEC).click(); - collector.checkThat("The output of graph mode is changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//button[contains(@class," + - "'btn btn-default btn-sm ng-binding ng-scope active')]//i")).getAttribute("class"), - CoreMatchers.equalTo("fa fa-bar-chart")); - - pollingWait(By.xpath("//*[@id='actionbar']" + - "//button[contains(@uib-tooltip, 'Switch to personal mode')]"), MAX_BROWSER_TIMEOUT_SEC).click(); - clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to personalize your analysis?')" + - "]//div[@class='modal-footer']//button[contains(.,'OK')]")); - authenticationIT.logoutUser("admin"); - - // step 2 : (user1) make sure it is on personalized mode and active graph is 'Bar chart', - // try to change active graph to 'Table' and then check result - authenticationIT.authenticationUser("user1", "password2"); - locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"); - element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); - if (element.isDisplayed()) { - pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), - MAX_BROWSER_TIMEOUT_SEC).click(); - } - collector.checkThat("The personalized mode enables", - driver.findElement(By.xpath("//*[@id='actionbar']" + - "//button[contains(@class, 'btn btn-default btn-xs ng-scope ng-hide')]")).getAttribute("uib-tooltip"), - CoreMatchers.equalTo("Switch to personal mode (owner can change)")); - - collector.checkThat("Make sure the output of graph mode is", - driver.findElement(By.xpath(getParagraphXPath(1) + "//button[contains(@class," + - "'btn btn-default btn-sm ng-binding ng-scope active')]//i")).getAttribute("class"), - CoreMatchers.equalTo("fa fa-bar-chart")); - - pollingWait(By.xpath(getParagraphXPath(1) + - "//button[contains(@uib-tooltip, 'Table')]"), MAX_BROWSER_TIMEOUT_SEC).click(); - collector.checkThat("The output of graph mode is not changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//button[contains(@class," + - "'btn btn-default btn-sm ng-binding ng-scope active')]//i")).getAttribute("class"), - CoreMatchers.equalTo("fa fa-bar-chart")); - authenticationIT.logoutUser("user1"); - - } catch (Exception e) { - handleException("Exception in PersonalizeActionsIT while testGraphAction ", e); - } - } - - @Test - public void testDynamicFormAction() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - // step 1 : (admin) login, create a new note, run a paragraph with data of spark tutorial, logout. - AuthenticationIT authenticationIT = new AuthenticationIT(); - authenticationIT.authenticationUser("admin", "password1"); - By locator = By.xpath("//div[contains(@class, \"col-md-4\")]/div/h5/a[contains(.,'Create new" + - " note')]"); - WebDriverWait wait = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC); - WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); - if (element.isDisplayed()) { - createNewNote(); - } - String noteId = driver.getCurrentUrl().substring(driver.getCurrentUrl().lastIndexOf("/") + 1); - setTextOfParagraph(1, "%spark println(\"Status: \"+z.textbox(\"name\", \"Before\")) "); - runParagraph(1); - try { - waitForParagraph(1, "FINISHED"); - } catch (TimeoutException e) { - waitForParagraph(1, "ERROR"); - collector.checkThat("Exception in PersonalizeActionsIT while testDynamicFormAction, status of 1st Spark Paragraph ", - "ERROR", CoreMatchers.equalTo("FINISHED")); - } - - collector.checkThat("The output of graph mode is changed", - driver.findElement(By.xpath(getParagraphXPath(1) + - "//input[contains(@name, 'name')]")).getAttribute("value"), - CoreMatchers.equalTo("Before")); - - pollingWait(By.xpath("//*[@id='actionbar']" + - "//button[contains(@uib-tooltip, 'Switch to personal mode')]"), MAX_BROWSER_TIMEOUT_SEC).click(); - clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to personalize your analysis?')" + - "]//div[@class='modal-footer']//button[contains(.,'OK')]")); - authenticationIT.logoutUser("admin"); - - // step 2 : (user1) make sure it is on personalized mode and dynamic form value is 'Before', - // try to change dynamic form value to 'After' and then check result - authenticationIT.authenticationUser("user1", "password2"); - locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"); - element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); - if (element.isDisplayed()) { - pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), - MAX_BROWSER_TIMEOUT_SEC).click(); - } - collector.checkThat("The personalized mode enables", - driver.findElement(By.xpath("//*[@id='actionbar']" + - "//button[contains(@class, 'btn btn-default btn-xs ng-scope ng-hide')]")).getAttribute("uib-tooltip"), - CoreMatchers.equalTo("Switch to personal mode (owner can change)")); - - collector.checkThat("The output of graph mode is changed", - driver.findElement(By.xpath(getParagraphXPath(1) + - "//input[contains(@name, 'name')]")).getAttribute("value"), - CoreMatchers.equalTo("Before")); - - pollingWait(By.xpath(getParagraphXPath(1) + - "//input[contains(@name, 'name')]"), MAX_BROWSER_TIMEOUT_SEC).clear(); - pollingWait(By.xpath(getParagraphXPath(1) + - "//input[contains(@name, 'name')]"), MAX_BROWSER_TIMEOUT_SEC).sendKeys("After"); - - runParagraph(1); - try { - waitForParagraph(1, "FINISHED"); - } catch (TimeoutException e) { - waitForParagraph(1, "ERROR"); - collector.checkThat("Exception in PersonalizeActionsIT while testDynamicFormAction, status of 1st Spark Paragraph ", - "ERROR", CoreMatchers.equalTo("FINISHED")); - } - - collector.checkThat("The output of graph mode is changed", - driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), - CoreMatchers.equalTo("Status: Before")); - authenticationIT.logoutUser("user1"); - - } catch (Exception e) { - handleException("Exception in PersonalizeActionsIT while testGraphAction ", e); - } - } -} http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7bff131a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/SparkParagraphIT.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/SparkParagraphIT.java b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/SparkParagraphIT.java deleted file mode 100644 index 8afdb9b..0000000 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/SparkParagraphIT.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * 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. - */ - -package org.apache.zeppelin.integration; - - -import org.apache.zeppelin.AbstractZeppelinIT; -import org.apache.zeppelin.WebDriverManager; -import org.hamcrest.CoreMatchers; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ErrorCollector; -import org.openqa.selenium.By; -import org.openqa.selenium.TimeoutException; -import org.openqa.selenium.WebElement; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; - -public class SparkParagraphIT extends AbstractZeppelinIT { - private static final Logger LOG = LoggerFactory.getLogger(SparkParagraphIT.class); - - @Rule - public ErrorCollector collector = new ErrorCollector(); - - @Before - public void startUp() { - if (!endToEndTestEnabled()) { - return; - } - driver = WebDriverManager.getWebDriver(); - createNewNote(); - waitForParagraph(1, "READY"); - } - - @After - public void tearDown() { - if (!endToEndTestEnabled()) { - return; - } - deleteTestNotebook(driver); - driver.quit(); - } - - @Test - public void testSpark() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - setTextOfParagraph(1, "sc.version"); - runParagraph(1); - - waitForParagraph(1, "FINISHED"); - - /* - equivalent of - import org.apache.commons.io.IOUtils - import java.net.URL - import java.nio.charset.Charset - val bankText = sc.parallelize(IOUtils.toString(new URL("https://s3.amazonaws.com/apache-zeppelin/tutorial/bank/bank.csv"),Charset.forName("utf8")).split("\n")) - case class Bank(age: Integer, job: String, marital: String, education: String, balance: Integer) - - val bank = bankText.map(s => s.split(";")).filter(s => s(0) != "\"age\"").map(s => Bank(s(0).toInt,s(1).replaceAll("\"", ""),s(2).replaceAll("\"", ""),s(3).replaceAll("\"", ""),s(5).replaceAll("\"", "").toInt)).toDF() - bank.registerTempTable("bank") - */ - setTextOfParagraph(2, "import org.apache.commons.io.IOUtils\\n" + - "import java.net.URL\\n" + - "import java.nio.charset.Charset\\n" + - "val bankText = sc.parallelize(IOUtils.toString(new URL(\"https://s3.amazonaws.com/apache-zeppelin/tutorial/bank/bank.csv\"),Charset.forName(\"utf8\")).split(\"\\\\n\"))\\n" + - "case class Bank(age: Integer, job: String, marital: String, education: String, balance: Integer)\\n" + - "\\n" + - "val bank = bankText.map(s => s.split(\";\")).filter(s => s(0) != \"\\\\\"age\\\\\"\").map(s => Bank(s(0).toInt,s(1).replaceAll(\"\\\\\"\", \"\"),s(2).replaceAll(\"\\\\\"\", \"\"),s(3).replaceAll(\"\\\\\"\", \"\"),s(5).replaceAll(\"\\\\\"\", \"\").toInt)).toDF()\\n" + - "bank.registerTempTable(\"bank\")"); - runParagraph(2); - - try { - waitForParagraph(2, "FINISHED"); - } catch (TimeoutException e) { - waitForParagraph(2, "ERROR"); - collector.checkThat("2nd Paragraph from SparkParagraphIT of testSpark status:", - "ERROR", CoreMatchers.equalTo("FINISHED") - ); - } - - WebElement paragraph2Result = driver.findElement(By.xpath( - getParagraphXPath(2) + "//div[contains(@id,\"_text\")]")); - - collector.checkThat("2nd Paragraph from SparkParagraphIT of testSpark result: ", - paragraph2Result.getText().toString(), CoreMatchers.containsString( - "import org.apache.commons.io.IOUtils" - ) - ); - - } catch (Exception e) { - handleException("Exception in SparkParagraphIT while testSpark", e); - } - } - - @Test - public void testPySpark() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - setTextOfParagraph(1, "%pyspark\\n" + - "for x in range(0, 3):\\n" + - " print \"test loop %d\" % (x)"); - - runParagraph(1); - - try { - waitForParagraph(1, "FINISHED"); - } catch (TimeoutException e) { - waitForParagraph(1, "ERROR"); - collector.checkThat("Paragraph from SparkParagraphIT of testPySpark status: ", - "ERROR", CoreMatchers.equalTo("FINISHED") - ); - } - - WebElement paragraph1Result = driver.findElement(By.xpath( - getParagraphXPath(1) + "//div[contains(@id,\"_text\")]")); - collector.checkThat("Paragraph from SparkParagraphIT of testPySpark result: ", - paragraph1Result.getText().toString(), CoreMatchers.containsString("test loop 0\ntest loop 1\ntest loop 2") - ); - - // the last statement's evaluation result is printed - setTextOfParagraph(2, "%pyspark\\n" + - "sc.version\\n" + - "1+1"); - runParagraph(2); - try { - waitForParagraph(2, "FINISHED"); - } catch (TimeoutException e) { - waitForParagraph(2, "ERROR"); - collector.checkThat("Paragraph from SparkParagraphIT of testPySpark status: ", - "ERROR", CoreMatchers.equalTo("FINISHED") - ); - } - WebElement paragraph2Result = driver.findElement(By.xpath( - getParagraphXPath(2) + "//div[contains(@id,\"_text\")]")); - collector.checkThat("Paragraph from SparkParagraphIT of testPySpark result: ", - paragraph2Result.getText().toString(), CoreMatchers.equalTo("2") - ); - - } catch (Exception e) { - handleException("Exception in SparkParagraphIT while testPySpark", e); - } - } - - @Test - public void testSqlSpark() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - setTextOfParagraph(1,"%sql\\n" + - "select * from bank limit 1"); - runParagraph(1); - - try { - waitForParagraph(1, "FINISHED"); - } catch (TimeoutException e) { - waitForParagraph(1, "ERROR"); - collector.checkThat("Paragraph from SparkParagraphIT of testSqlSpark status: ", - "ERROR", CoreMatchers.equalTo("FINISHED") - ); - } - - // Age, Job, Marital, Education, Balance - List<WebElement> tableHeaders = driver.findElements(By.cssSelector("span.ui-grid-header-cell-label")); - String headerNames = ""; - - for(WebElement header : tableHeaders) { - headerNames += header.getText().toString() + "|"; - } - - collector.checkThat("Paragraph from SparkParagraphIT of testSqlSpark result: ", - headerNames, CoreMatchers.equalTo("age|job|marital|education|balance|")); - } catch (Exception e) { - handleException("Exception in SparkParagraphIT while testSqlSpark", e); - } - } - - @Test - public void testDep() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - // restart spark interpreter before running %dep - clickAndWait(By.xpath("//span[@uib-tooltip='Interpreter binding']")); - clickAndWait(By.xpath("//div[font[contains(text(), 'spark')]]/preceding-sibling::a[@uib-tooltip='Restart']")); - clickAndWait(By.xpath("//button[contains(.,'OK')]")); - - setTextOfParagraph(1,"%dep z.load(\"org.apache.commons:commons-csv:1.1\")"); - runParagraph(1); - - try { - waitForParagraph(1, "FINISHED"); - WebElement paragraph1Result = driver.findElement(By.xpath(getParagraphXPath(1) + - "//div[contains(@id,'_text')]")); - collector.checkThat("Paragraph from SparkParagraphIT of testSqlSpark result: ", - paragraph1Result.getText(), CoreMatchers.containsString("res0: org.apache.zeppelin.dep.Dependency = org.apache.zeppelin.dep.Dependency")); - - setTextOfParagraph(2, "import org.apache.commons.csv.CSVFormat"); - runParagraph(2); - - try { - waitForParagraph(2, "FINISHED"); - WebElement paragraph2Result = driver.findElement(By.xpath(getParagraphXPath(2) + - "//div[contains(@id,'_text')]")); - collector.checkThat("Paragraph from SparkParagraphIT of testSqlSpark result: ", - paragraph2Result.getText(), CoreMatchers.equalTo("import org.apache.commons.csv.CSVFormat")); - - } catch (TimeoutException e) { - waitForParagraph(2, "ERROR"); - collector.checkThat("Second paragraph from SparkParagraphIT of testDep status: ", - "ERROR", CoreMatchers.equalTo("FINISHED") - ); - } - - } catch (TimeoutException e) { - waitForParagraph(1, "ERROR"); - collector.checkThat("First paragraph from SparkParagraphIT of testDep status: ", - "ERROR", CoreMatchers.equalTo("FINISHED") - ); - } - } catch (Exception e) { - handleException("Exception in SparkParagraphIT while testDep", e); - } - } -} http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7bff131a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ZeppelinIT.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ZeppelinIT.java b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ZeppelinIT.java deleted file mode 100644 index afdae10..0000000 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ZeppelinIT.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * 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. - */ - -package org.apache.zeppelin.integration; - -import org.apache.zeppelin.AbstractZeppelinIT; -import org.apache.zeppelin.WebDriverManager; -import org.apache.zeppelin.ZeppelinITUtils; -import org.hamcrest.CoreMatchers; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ErrorCollector; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; -import org.openqa.selenium.StaleElementReferenceException; -import org.openqa.selenium.TimeoutException; -import org.openqa.selenium.WebElement; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.apache.commons.lang3.StringUtils.isNotBlank; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * Test Zeppelin with web browser. - * - * To test, ZeppelinServer should be running on port 8080 - * On OSX, you'll need firefox 42.0 installed, then you can run with - * - * PATH=~/Applications/Firefox.app/Contents/MacOS/:$PATH TEST_SELENIUM="" \ - * mvn -Dtest=org.apache.zeppelin.integration.ZeppelinIT -Denforcer.skip=true \ - * test -pl zeppelin-server - * - */ -public class ZeppelinIT extends AbstractZeppelinIT { - private static final Logger LOG = LoggerFactory.getLogger(ZeppelinIT.class); - - @Rule - public ErrorCollector collector = new ErrorCollector(); - - @Before - public void startUp() { - if (!endToEndTestEnabled()) { - return; - } - driver = WebDriverManager.getWebDriver(); - } - - @After - public void tearDown() { - if (!endToEndTestEnabled()) { - return; - } - - driver.quit(); - } - - @Test - public void testAngularDisplay() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - createNewNote(); - - // wait for first paragraph's " READY " status text - waitForParagraph(1, "READY"); - - /* - * print angular template - * %angular <div id='angularTestButton' ng-click='myVar=myVar+1'>BindingTest_{{myVar}}_</div> - */ - setTextOfParagraph(1, "println(\"%angular <div id=\\'angularTestButton\\' ng-click=\\'myVar=myVar+1\\'>BindingTest_{{myVar}}_</div>\")"); - runParagraph(1); - waitForParagraph(1, "FINISHED"); - - // check expected text - waitForText("BindingTest__", By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); - - /* - * Bind variable - * z.angularBind("myVar", 1) - */ - assertEquals(1, driver.findElements(By.xpath(getParagraphXPath(2) + "//textarea")).size()); - setTextOfParagraph(2, "z.angularBind(\"myVar\", 1)"); - runParagraph(2); - waitForParagraph(2, "FINISHED"); - - // check expected text - waitForText("BindingTest_1_", By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); - - - /* - * print variable - * print("myVar="+z.angular("myVar")) - */ - setTextOfParagraph(3, "print(\"myVar=\"+z.angular(\"myVar\"))"); - runParagraph(3); - waitForParagraph(3, "FINISHED"); - - // check expected text - waitForText("myVar=1", By.xpath( - getParagraphXPath(3) + "//div[contains(@id,\"_text\") and @class=\"text\"]")); - - /* - * Click element - */ - driver.findElement(By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click(); - - // check expected text - waitForText("BindingTest_2_", By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); - - /* - * Register watcher - * z.angularWatch("myVar", (before:Object, after:Object, context:org.apache.zeppelin.interpreter.InterpreterContext) => { - * z.run(2, context) - * } - */ - setTextOfParagraph(4, "z.angularWatch(\"myVar\", (before:Object, after:Object, context:org.apache.zeppelin.interpreter.InterpreterContext)=>{ z.run(2, false)})"); - runParagraph(4); - waitForParagraph(4, "FINISHED"); - - - /* - * Click element, again and see watcher works - */ - driver.findElement(By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click(); - - // check expected text - waitForText("BindingTest_3_", By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); - waitForParagraph(3, "FINISHED"); - - // check expected text by watcher - waitForText("myVar=3", By.xpath( - getParagraphXPath(3) + "//div[contains(@id,\"_text\") and @class=\"text\"]")); - - - /* - * Click element, again and see watcher still works - */ - driver.findElement(By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click(); - // check expected text - waitForText("BindingTest_4_", By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); - waitForParagraph(3, "FINISHED"); - - // check expected text by watcher - waitForText("myVar=4", By.xpath( - getParagraphXPath(3) + "//div[contains(@id,\"_text\") and @class=\"text\"]")); - - /* - * Unbind - * z.angularUnbind("myVar") - */ - setTextOfParagraph(5, "z.angularUnbind(\"myVar\")"); - runParagraph(5); - waitForParagraph(5, "FINISHED"); - - // check expected text - waitForText("BindingTest__", - By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); - - /* - * Bind again and see rebind works. - */ - runParagraph(2); - waitForParagraph(2, "FINISHED"); - - // check expected text - waitForText("BindingTest_1_", - By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")); - - driver.findElement(By.xpath(".//*[@id='main']//button[@ng-click='moveNoteToTrash(note.id)']")) - .sendKeys(Keys.ENTER); - ZeppelinITUtils.sleep(1000, true); - driver.findElement(By.xpath("//div[@class='modal-dialog'][contains(.,'This note will be moved to trash')]" + - "//div[@class='modal-footer']//button[contains(.,'OK')]")).click(); - ZeppelinITUtils.sleep(100, true); - - LOG.info("testCreateNotebook Test executed"); - } catch (Exception e) { - handleException("Exception in ZeppelinIT while testAngularDisplay ", e); - } - } - - @Test - public void testSparkInterpreterDependencyLoading() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - try { - // navigate to interpreter page - WebElement settingButton = driver.findElement(By.xpath("//button[@class='nav-btn dropdown-toggle ng-scope']")); - settingButton.click(); - WebElement interpreterLink = driver.findElement(By.xpath("//a[@href='#/interpreter']")); - interpreterLink.click(); - - // add new dependency to spark interpreter - driver.findElement(By.xpath("//div[@id='spark']//button[contains(.,'edit')]")).sendKeys(Keys.ENTER); - - WebElement depArtifact = pollingWait(By.xpath("//input[@ng-model='setting.depArtifact']"), - MAX_BROWSER_TIMEOUT_SEC); - String artifact = "org.apache.commons:commons-csv:1.1"; - depArtifact.sendKeys(artifact); - driver.findElement(By.xpath("//div[@id='spark']//form//button[1]")).click(); - clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to update this interpreter and restart with new settings?')]" + - "//div[@class='modal-footer']//button[contains(.,'OK')]")); - - try { - clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to " + - "update this interpreter and restart with new settings?')]//" + - "div[@class='bootstrap-dialog-close-button']/button")); - } catch (TimeoutException | StaleElementReferenceException e) { - //Modal dialog got closed earlier than expected nothing to worry. - } - - driver.navigate().back(); - createNewNote(); - - // wait for first paragraph's " READY " status text - waitForParagraph(1, "READY"); - - setTextOfParagraph(1, "import org.apache.commons.csv.CSVFormat"); - runParagraph(1); - waitForParagraph(1, "FINISHED"); - - // check expected text - WebElement paragraph1Result = driver.findElement(By.xpath( - getParagraphXPath(1) + "//div[contains(@id,\"_text\")]")); - - collector.checkThat("Paragraph from ZeppelinIT of testSparkInterpreterDependencyLoading result: ", - paragraph1Result.getText().toString(), CoreMatchers.containsString( - "import org.apache.commons.csv.CSVFormat" - ) - ); - - //delete created notebook for cleanup. - deleteTestNotebook(driver); - ZeppelinITUtils.sleep(1000, false); - - // reset dependency - settingButton.click(); - interpreterLink.click(); - driver.findElement(By.xpath("//div[@id='spark']//button[contains(.,'edit')]")).sendKeys(Keys.ENTER); - WebElement testDepRemoveBtn = pollingWait(By.xpath("//tr[descendant::text()[contains(.,'" + - artifact + "')]]/td[3]/button"), MAX_IMPLICIT_WAIT); - testDepRemoveBtn.sendKeys(Keys.ENTER); - driver.findElement(By.xpath("//div[@id='spark']//form//button[1]")).click(); - driver.findElement(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to update this interpreter and restart with new settings?')]" + - "//div[@class='modal-footer']//button[contains(.,'OK')]")).click(); - } catch (Exception e) { - handleException("Exception in ZeppelinIT while testSparkInterpreterDependencyLoading ", e); - } - } - - @Test - public void testAngularRunParagraph() throws Exception { - if (!endToEndTestEnabled()) { - return; - } - - try { - createNewNote(); - - // wait for first paragraph's " READY " status text - waitForParagraph(1, "READY"); - - // Create 1st paragraph - setTextOfParagraph(1, - "%angular <div id=\\'angularRunParagraph\\'>Run second paragraph</div>"); - runParagraph(1); - waitForParagraph(1, "FINISHED"); - waitForText("Run second paragraph", By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularRunParagraph\"]")); - - // Create 2nd paragraph - setTextOfParagraph(2, "%sh echo TEST"); - runParagraph(2); - waitForParagraph(2, "FINISHED"); - - // Get 2nd paragraph id - final String secondParagraphId = driver.findElement(By.xpath(getParagraphXPath(2) - + "//div[@class=\"control ng-scope\"]//ul[@class=\"dropdown-menu dropdown-menu-right\"]/li[1]")) - .getAttribute("textContent"); - - assertTrue("Cannot find paragraph id for the 2nd paragraph", isNotBlank(secondParagraphId)); - - // Update first paragraph to call z.runParagraph() with 2nd paragraph id - setTextOfParagraph(1, - "%angular <div id=\\'angularRunParagraph\\' ng-click=\\'z.runParagraph(\"" - + secondParagraphId.trim() - + "\")\\'>Run second paragraph</div>"); - runParagraph(1); - waitForParagraph(1, "FINISHED"); - - // Set new text value for 2nd paragraph - setTextOfParagraph(2, "%sh echo NEW_VALUE"); - - // Click on 1 paragraph to trigger z.runParagraph() function - driver.findElement(By.xpath( - getParagraphXPath(1) + "//div[@id=\"angularRunParagraph\"]")).click(); - - waitForParagraph(2, "FINISHED"); - - // Check that 2nd paragraph has been executed - waitForText("NEW_VALUE", By.xpath( - getParagraphXPath(2) + "//div[contains(@id,\"_text\") and @class=\"text\"]")); - - //delete created notebook for cleanup. - deleteTestNotebook(driver); - ZeppelinITUtils.sleep(1000, true); - - LOG.info("testAngularRunParagraph Test executed"); - } catch (Exception e) { - handleException("Exception in ZeppelinIT while testAngularRunParagraph", e); - } - - } -} http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7bff131a/zeppelin-server/src/test/scala/org/apache/zeppelin/AbstractFunctionalSuite.scala ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/scala/org/apache/zeppelin/AbstractFunctionalSuite.scala b/zeppelin-server/src/test/scala/org/apache/zeppelin/AbstractFunctionalSuite.scala deleted file mode 100644 index 2f773c6..0000000 --- a/zeppelin-server/src/test/scala/org/apache/zeppelin/AbstractFunctionalSuite.scala +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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. - */ - -package org.apache.zeppelin - -import org.apache.zeppelin.AbstractFunctionalSuite.SERVER_ADDRESS -import org.openqa.selenium.WebDriver -import org.openqa.selenium.chrome.ChromeDriver -import org.openqa.selenium.firefox.{FirefoxBinary, FirefoxDriver, FirefoxProfile} -import org.openqa.selenium.safari.SafariDriver -import org.scalatest.concurrent.Eventually._ -import org.scalatest.time._ -import org.scalatest.selenium.WebBrowser -import org.scalatest.{BeforeAndAfterAll, FunSuite, Suite} - -import scala.sys.process._ -import scala.util.Try - -object AbstractFunctionalSuite { - val SERVER_ADDRESS = "http://localhost:8080" -} - -class AbstractFunctionalSuite extends FunSuite with WebBrowser with BeforeAndAfterAll { - - implicit val webDriver = getDriver() - - override def beforeAll() = { - "../bin/zeppelin-daemon.sh start" ! - - eventually (timeout(Span(180, Seconds))) { - go to SERVER_ADDRESS - assert(find("welcome").isDefined) - } - } - - override def nestedSuites = - List[Suite](new WelcomePageSuite).toIndexedSeq - - override def afterAll() = { - "../bin/zeppelin-daemon.sh stop" ! - - webDriver.close() - } - - def getDriver(): WebDriver = { - val possibleDrivers = List[() => WebDriver](safari, chrome, firefox) - val createdDriver = possibleDrivers.map(driverFactory => Try(driverFactory.apply())).find(_.isSuccess) - createdDriver match { - case Some(driver) => driver.get - case None => throw new RuntimeException("Could not initialize any driver") - } - } - - def safari(): WebDriver = { - new SafariDriver() - } - - def chrome(): WebDriver = { - new ChromeDriver() - } - - def firefox(): WebDriver = { - val ffox: FirefoxBinary = new FirefoxBinary - if ("true" == System.getenv("TRAVIS")) { - ffox.setEnvironmentProperty("DISPLAY", ":99") - } - val profile: FirefoxProfile = new FirefoxProfile - new FirefoxDriver(ffox, profile) - } -} http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7bff131a/zeppelin-server/src/test/scala/org/apache/zeppelin/WelcomePageSuite.scala ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/scala/org/apache/zeppelin/WelcomePageSuite.scala b/zeppelin-server/src/test/scala/org/apache/zeppelin/WelcomePageSuite.scala deleted file mode 100644 index 1798214..0000000 --- a/zeppelin-server/src/test/scala/org/apache/zeppelin/WelcomePageSuite.scala +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ - -package org.apache.zeppelin - -import org.openqa.selenium.WebDriver -import org.scalatest.concurrent.Eventually._ -import org.scalatest.time._ -import org.scalatest.selenium.WebBrowser -import org.scalatest.{DoNotDiscover, FunSuite} -import AbstractFunctionalSuite.SERVER_ADDRESS - -@DoNotDiscover -class WelcomePageSuite(implicit driver: WebDriver) extends FunSuite with WebBrowser { - - test("Welcome sign is correct") { - eventually (timeout(Span(180, Seconds))) { - go to SERVER_ADDRESS - assert(find("welcome").isDefined) - } - } - -}