Selenium: cover Apache Camel language server functionality by selenium test (#10376)

6.19.x
Sergey Skorik 2018-07-12 14:42:07 +00:00 committed by GitHub
parent cb562b9795
commit fd2ae02ef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 284 additions and 0 deletions

View File

@ -25,6 +25,7 @@ public class WorkspaceTemplate {
public static final String DEFAULT = "default.json";
public static final String DEFAULT_WITH_GITHUB_PROJECTS = "default_with_github_projects.json";
public static final String PYTHON = "ubuntu_python.json";
public static final String UBUNTU_CAMEL = "ubuntu_jdk8_with_camel_ls.json";
private WorkspaceTemplate() {}
}

View File

@ -31,6 +31,7 @@ import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.DEBUGGE
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.DEBUGGER_PREFIX_XPATH;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.EDITOR_TABS_PANEL;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.HIGHLIGHT_ITEM_PATTERN;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.HOVER_POPUP_XPATH;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.IMPLEMENTATIONS_ITEM;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.IMPLEMENTATION_CONTAINER;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.ITEM_TAB_LIST;
@ -202,6 +203,9 @@ public class CodenvyEditor {
"//div//iframe[contains(@src, 'api/java/code-assist/compute/info?')]";
String HIGHLIGHT_ITEM_PATTERN = "//li[@selected='true']//span[text()='%s']";
String TOOLTIP_TITLE_CSS = "span.tooltipTitle";
String TEXT_TO_MOVE_CURSOR_XPATH =
ORION_ACTIVE_EDITOR_CONTAINER_XPATH + "//span[contains(text(),'%s')]";
String HOVER_POPUP_XPATH = "//div[@class='textviewTooltip']";
}
public enum TabActionLocator {
@ -327,6 +331,9 @@ public class CodenvyEditor {
@FindBy(css = TOOLTIP_TITLE_CSS)
private WebElement tooltipTitle;
@FindBy(xpath = HOVER_POPUP_XPATH)
private WebElement hoverPopup;
/**
* Waits during {@code timeout} until current editor's tab is ready to work.
*
@ -422,6 +429,15 @@ public class CodenvyEditor {
seleniumWebDriverHelper.waitTextContains(tooltipTitle, expectedText);
}
/**
* wait text in hover pop-up (after hovering on text)
*
* @param expectedText the expected text into hover pop-up
*/
public void waitTextInHoverPopup(String expectedText) {
seleniumWebDriverHelper.waitTextContains(hoverPopup, expectedText);
}
/**
* Waits during {@code timeout} until specified {@code text} is not present in the editor's tab
* with defined {@code indexOfEditor}.
@ -2146,4 +2162,9 @@ public class CodenvyEditor {
By.xpath(
format("//div[@id='gwt-debug-multiSplitPanel-tabsPanel']//div[text()='%s']", tabName)));
}
public void moveCursorToText(String text) {
seleniumWebDriverHelper.moveCursorTo(
By.xpath(format(Locators.TEXT_TO_MOVE_CURSOR_XPATH, text)));
}
}

View File

@ -0,0 +1,103 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.selenium.languageserver;
import static java.lang.String.format;
import static org.eclipse.che.selenium.core.project.ProjectTemplates.CONSOLE_JAVA_SIMPLE;
import static org.eclipse.che.selenium.core.workspace.WorkspaceTemplate.UBUNTU_CAMEL;
import com.google.inject.Inject;
import java.net.URL;
import java.nio.file.Paths;
import org.eclipse.che.selenium.core.client.TestProjectServiceClient;
import org.eclipse.che.selenium.core.workspace.InjectTestWorkspace;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.pageobject.CodenvyEditor;
import org.eclipse.che.selenium.pageobject.Consoles;
import org.eclipse.che.selenium.pageobject.Ide;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/** @author Skoryk Serhii */
public class ApacheCamelFileEditingTest {
private static final String PROJECT_NAME = "project-for-camel-ls";
private static final String CAMEL_FILE_NAME = "camel.xml";
private static final String PATH_TO_CAMEL_FILE = PROJECT_NAME + "/" + CAMEL_FILE_NAME;
private static final String LS_INIT_MESSAGE =
format("Finished language servers initialization, file path '/%s'", PATH_TO_CAMEL_FILE);
@InjectTestWorkspace(template = UBUNTU_CAMEL)
private TestWorkspace workspace;
@Inject private Ide ide;
@Inject private Consoles consoles;
@Inject private CodenvyEditor editor;
@Inject private ProjectExplorer projectExplorer;
@Inject private TestProjectServiceClient testProjectServiceClient;
@BeforeClass
public void setUp() throws Exception {
URL resource = ApacheCamelFileEditingTest.class.getResource("/projects/project-for-camel-ls");
testProjectServiceClient.importProject(
workspace.getId(), Paths.get(resource.toURI()), PROJECT_NAME, CONSOLE_JAVA_SIMPLE);
ide.open(workspace);
}
@Test
public void checkLanguageServerInitialized() {
projectExplorer.waitAndSelectItem(PROJECT_NAME);
projectExplorer.openItemByPath(PROJECT_NAME);
projectExplorer.openItemByPath(PATH_TO_CAMEL_FILE);
editor.waitTabIsPresent(CAMEL_FILE_NAME);
// check Apache Camel language server initialized
consoles.selectProcessByTabName("dev-machine");
consoles.waitExpectedTextIntoConsole(LS_INIT_MESSAGE);
}
@Test(priority = 1)
public void checkAutocompleteFeature() {
editor.selectTabByName(CAMEL_FILE_NAME);
editor.goToPosition(49, 21);
editor.launchAutocomplete();
editor.waitTextIntoEditor("timer:timerName");
// launch autocomplete feature, select proposal and check expected text in the Editor
editor.typeTextIntoEditor("?");
editor.launchAutocompleteAndWaitContainer();
editor.waitTextIntoAutocompleteContainer("fixedRate ");
editor.enterAutocompleteProposal("fixedRate ");
editor.waitTextIntoEditor("timer:timerName?fixedRate=false");
editor.typeTextIntoEditor("&");
editor.launchAutocompleteAndWaitContainer();
editor.waitTextIntoAutocompleteContainer("exchangePattern ");
editor.enterAutocompleteProposal("exchangePattern ");
editor.waitTextIntoEditor("timer:timerName?fixedRate=false&exchangePattern=");
editor.launchAutocompleteAndWaitContainer();
editor.waitTextIntoAutocompleteContainer("InOnly");
editor.enterAutocompleteProposal("InOnly");
editor.waitTextIntoEditor("timer:timerName?fixedRate=false&exchangePattern=InOnly");
}
@Test(priority = 2)
public void checkHoverFeature() {
// move cursor on text and check expected text in hover popup
editor.moveCursorToText("timer");
editor.waitTextInHoverPopup(
"The timer component is used for generating message exchanges when a timer fires.");
}
}

View File

@ -0,0 +1,72 @@
<!--
Copyright (c) 2012-2018 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<!-- here we have Spring XML file with all the namespaces here in the top of the XML file -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<!-- this is Spring XML example of the Camel route in the ReportIncidentRoutes class -->
<!-- this is for demonstration purpose, to show how you can use Camel with XML DSL -->
<!-- here we define the CXF endpoint, where {{port}} refers to a placeholder so we can define the port number
in an external .properties file -->
<cxf:cxfEndpoint id="reportIncident"
address="http://localhost:{{port}}/camel-example-reportincident/webservices/incident"
wsdlURL="etc/report_incident.wsdl"
serviceClass="org.apache.camel.example.reportincident.ReportIncidentEndpoint"/>
<!-- We use a bean to make the response bean that CXF expects -->
<bean id="responseBean" class="org.apache.camel.example.reportincident.MyBean"/>
<!-- this is the bean we use to generate the dynamic file name -->
<bean id="filenameGenerator" class="org.apache.camel.example.reportincident.FilenameGenerator"/>
<!-- this CamelContext contains the equivalent route from the Java DSL, but in XML
so end users can see how to implement the route in both Java and XML -->
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<!-- property which contains port number -->
<!-- we have file:target/custom.properties which can be optional and override existing values, we use this for testing purpose -->
<camel:propertyPlaceholder id="properties" location="classpath:incident.properties,file:target/custom.properties"/>
<!-- this is the first route that uses CXF as web service -->
<route>
<from uri="tim"/>
<convertBodyTo type="org.apache.camel.example.reportincident.InputReportIncident"/>
<setHeader headerName="CamelFileName">
<method bean="filenameGenerator" method="generateFilename"/>
</setHeader>
<to uri="velocity:etc/MailBody.vm"/>
<to uri="file://target/subfolder"/>
<transform>
<method bean="responseBean" method="getOK"/>
</transform>
</route>
<!-- this is the 2nd route that pickup files and send them as emails -->
<route>
<from uri="file://target/subfolder"/>
<setHeader headerName="subject">
<constant>new incident reported</constant>
</setHeader>
<to uri="smtp://someone@localhost?password=secret&amp;to=incident@mycompany.com"/>
</route>
</camelContext>
</beans>

View File

@ -52,6 +52,7 @@
<class name="org.eclipse.che.selenium.languageserver.PythonFileEditingTest"/>
<class name="org.eclipse.che.selenium.languageserver.TypeScriptEditingTest"/>
<class name="org.eclipse.che.selenium.languageserver.ClangFileEditingTest"/>
<class name="org.eclipse.che.selenium.languageserver.ApacheCamelFileEditingTest"/>
<class name="org.eclipse.che.selenium.dashboard.CreateAndDeleteProjectsTest"/>
<class name="org.eclipse.che.selenium.dashboard.DeleteRunningWorkspaceTest"/>
<class name="org.eclipse.che.selenium.dashboard.DeleteStoppingWorkspaceTest"/>

View File

@ -0,0 +1,43 @@
{
"environments": {
"replaced_name": {
"machines": {
"dev-machine": {
"installers": [
"org.eclipse.che.terminal",
"org.eclipse.che.ws-agent",
"org.eclipse.che.exec",
"org.eclipse.che.ls.camel"
],
"attributes": {
"memoryLimitBytes": "desired_memory_value"
},
"servers" : {
"tomcat8" : {
"port" : "8080",
"protocol" : "http"
},
"tomcat8-debug" : {
"port" : "8000",
"protocol" : "http"
},
"codeserver" : {
"port" : "9876",
"protocol" : "http"
}
}
}
},
"recipe": {
"content": "eclipse/ubuntu_jdk8",
"type": "dockerimage"
}
}
},
"defaultEnv": "replaced_name",
"projects": [],
"name": "replaced_name",
"attributes": {},
"temporary": false
}

View File

@ -0,0 +1,43 @@
{
"environments": {
"replaced_name": {
"machines": {
"dev-machine": {
"installers": [
"org.eclipse.che.terminal",
"org.eclipse.che.ws-agent",
"org.eclipse.che.exec",
"org.eclipse.che.ls.camel"
],
"attributes": {
"memoryLimitBytes": "desired_memory_value"
},
"servers" : {
"tomcat8" : {
"port" : "8080",
"protocol" : "http"
},
"tomcat8-debug" : {
"port" : "8000",
"protocol" : "http"
},
"codeserver" : {
"port" : "9876",
"protocol" : "http"
}
}
}
},
"recipe": {
"content": "eclipse/ubuntu_jdk8",
"type": "dockerimage"
}
}
},
"defaultEnv": "replaced_name",
"projects": [],
"name": "replaced_name",
"attributes": {},
"temporary": false
}