From 966066457fd555d62d69e2bad43346e443ab5687 Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Wed, 18 Jul 2018 13:37:30 +0000 Subject: [PATCH] Fix selenium tests in projectexplorer package (#10452) * Fix selenium tests in projectexplorer package Signed-off-by: Anatoliy Bazko * Fixup Signed-off-by: Anatoliy Bazko --- .../che/ide/editor/EditorAgentImpl.java | 5 ++ .../CheckShowHideHiddenFilesTest.java | 16 ++-- .../projectexplorer/DeleteProjectsTest.java | 14 ---- .../projectexplorer/DownloadProjectTest.java | 77 +++++++++++-------- .../NavigationByKeyboardTest.java | 3 +- .../UploadIntoProjectTest.java | 7 +- ...enExternalLibraryFileAfterRefreshTest.java | 20 ++--- .../.codenvy/misc.xml | 18 ----- .../.codenvy/project.json | 1 - .../ProjectWithDifferentTypeOfFiles2/pom.xml | 2 +- .../example/spring/GreetingController.java | 73 ------------------ .../com/codenvy/example/spring/SomeLess.less | 13 ---- .../com/codenvy/example/spring/SqlFile.sql | 23 ------ .../main/java/com/codenvy/example/spring/some | 11 --- .../java/com/codenvy/example/test/Test1.java | 15 ---- .../java/com/codenvy/example/test/Test2.java | 15 ---- .../java/com/codenvy/example/test/Test3.java | 15 ---- .../java/com/codenvy/example/test/Test4.java | 15 ---- .../eclipse/qa/examples/AppController.java | 41 ++++++++++ .../src/main/webapp/WEB-INF/DefaultCss.css | 23 ------ .../src/main/webapp/WEB-INF/SomeHtml.html | 22 ------ .../src/main/webapp/WEB-INF/someJS.js | 18 ----- 22 files changed, 116 insertions(+), 331 deletions(-) delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/.codenvy/misc.xml delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/.codenvy/project.json delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/GreetingController.java delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/SomeLess.less delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/SqlFile.sql delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/some delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test1.java delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test2.java delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test3.java delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test4.java create mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/org/eclipse/qa/examples/AppController.java delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/webapp/WEB-INF/DefaultCss.css delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/webapp/WEB-INF/SomeHtml.html delete mode 100644 selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/webapp/WEB-INF/someJS.js diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java index f1ad38cffa0..2d0910d0fda 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java @@ -651,6 +651,11 @@ public void apply(java.util.Optional optionalFile) callback.onSuccess(null); } } + }) + .catchError( + error -> { + removeFromOpeningFilesList(path, editorPartStack); + callback.onSuccess(null); }); } }); diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/CheckShowHideHiddenFilesTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/CheckShowHideHiddenFilesTest.java index ac8159872d9..c2d75813ed5 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/CheckShowHideHiddenFilesTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/CheckShowHideHiddenFilesTest.java @@ -15,6 +15,7 @@ import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants; 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.Loader; import org.eclipse.che.selenium.pageobject.Menu; @@ -26,8 +27,8 @@ /** @author Andrey Chizhikov */ public class CheckShowHideHiddenFilesTest { private static final String PROJECT_NAME = "RefreshProject"; - private static final String PATH_TO_CODENVY_FOLDER = PROJECT_NAME + "/.che"; - private static final String PATH_TO_CLASSPATH_FILE = PROJECT_NAME + "/.che/classpath"; + private static final String PATH_TO_CLASSPATH_FILE = PROJECT_NAME + "/.classpath"; + private static final String PATH_TO_PROJECT_FILE = PROJECT_NAME + "/.project"; public static final String CLASSPATH_CONTENT = ""; @Inject private TestWorkspace testWorkspace; @@ -37,6 +38,7 @@ public class CheckShowHideHiddenFilesTest { @Inject private CodenvyEditor editor; @Inject private Menu menu; @Inject private Wizard projectWizard; + @Inject private Consoles consoles; @BeforeClass public void setUp() throws Exception { @@ -46,6 +48,7 @@ public void setUp() throws Exception { @Test public void checkShowHideHiddenFilesTest() { createProject(PROJECT_NAME); + consoles.waitJDTLSProjectResolveFinishedMessage(PROJECT_NAME); projectExplorer.waitProjectExplorer(); projectExplorer.waitItem(PROJECT_NAME); projectExplorer.openItemByPath(PROJECT_NAME); @@ -54,10 +57,8 @@ public void checkShowHideHiddenFilesTest() { TestMenuCommandsConstants.Project.PROJECT, TestMenuCommandsConstants.Project.SHOW_HIDE_HIDDEN_FILES); loader.waitOnClosed(); - projectExplorer.waitItem(PATH_TO_CODENVY_FOLDER); - projectExplorer.openItemByPath(PATH_TO_CODENVY_FOLDER); - loader.waitOnClosed(); projectExplorer.waitItem(PATH_TO_CLASSPATH_FILE); + projectExplorer.waitItem(PATH_TO_PROJECT_FILE); projectExplorer.openItemByPath(PATH_TO_CLASSPATH_FILE); loader.waitOnClosed(); editor.waitActive(); @@ -67,8 +68,9 @@ public void checkShowHideHiddenFilesTest() { TestMenuCommandsConstants.Project.PROJECT, TestMenuCommandsConstants.Project.SHOW_HIDE_HIDDEN_FILES); loader.waitOnClosed(); - editor.waitTabIsPresent("classpath"); - projectExplorer.waitItemInvisibility(PATH_TO_CODENVY_FOLDER); + editor.waitTabIsPresent(".classpath"); + projectExplorer.waitItemInvisibility(PATH_TO_CLASSPATH_FILE); + projectExplorer.waitItemInvisibility(PATH_TO_PROJECT_FILE); } private void createProject(String projectName) { diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/DeleteProjectsTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/DeleteProjectsTest.java index a74dd4f34c2..7485704a38f 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/DeleteProjectsTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/DeleteProjectsTest.java @@ -12,7 +12,6 @@ package org.eclipse.che.selenium.projectexplorer; import static org.eclipse.che.selenium.core.constant.TestProjectExplorerContextMenuConstants.ContextMenuFirstLevelItems.DELETE; -import static org.testng.Assert.fail; import com.google.inject.Inject; import java.net.URL; @@ -30,7 +29,6 @@ import org.eclipse.che.selenium.pageobject.Loader; import org.eclipse.che.selenium.pageobject.Menu; import org.eclipse.che.selenium.pageobject.ProjectExplorer; -import org.openqa.selenium.TimeoutException; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -92,7 +90,6 @@ public void shouldDeleteProjectByContextMenu() { projectExplorer.openContextMenuByPathSelectedItem(PROJECT_NAMES.get(0)); projectExplorer.clickOnItemInContextMenu(DELETE); acceptDeletion(PROJECT_NAMES.get(0)); - checkErrorMessageNotPresentInConsole(); } @Test @@ -101,7 +98,6 @@ public void shouldDeleteProjectByMenuFile() { projectExplorer.waitAndSelectItem(PROJECT_NAMES.get(1)); menu.runCommand(TestMenuCommandsConstants.Edit.EDIT, TestMenuCommandsConstants.Edit.DELETE); acceptDeletion(PROJECT_NAMES.get(1)); - checkErrorMessageNotPresentInConsole(); } @Test @@ -114,7 +110,6 @@ public void shouldDeleteOpenedProjectByMenuFile() { menu.runCommand(TestMenuCommandsConstants.Edit.EDIT, TestMenuCommandsConstants.Edit.DELETE); acceptDeletion(PROJECT_NAMES.get(3)); projectExplorer.waitDisappearItemByPath(PROJECT_NAMES.get(3)); - checkErrorMessageNotPresentInConsole(); } @Test @@ -128,7 +123,6 @@ public void shouldDeleteOpenedProjectFromContextMenu() { projectExplorer.clickOnItemInContextMenu(DELETE); acceptDeletion(PROJECT_NAMES.get(4)); projectExplorer.waitDisappearItemByPath(PROJECT_NAMES.get(4)); - checkErrorMessageNotPresentInConsole(); } private void deleteFromDeleteIcon(String pathToProject) { @@ -146,14 +140,6 @@ private void acceptDeletion(String projectName) { projectExplorer.waitDisappearItemByPath(projectName); } - private void checkErrorMessageNotPresentInConsole() { - try { - consoles.waitExpectedTextIntoConsole("[ERROR]", 7); - fail("Error message is present in console"); - } catch (TimeoutException ex) { - } - } - private void waitAllProjectsInProjectExplorer() { PROJECT_NAMES.forEach((String projectName) -> projectExplorer.waitItem(projectName)); } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/DownloadProjectTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/DownloadProjectTest.java index 54b3b9095b5..07465f66337 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/DownloadProjectTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/DownloadProjectTest.java @@ -17,12 +17,12 @@ import static org.eclipse.che.selenium.core.utils.WaitUtils.sleepQuietly; import static org.testng.Assert.assertEquals; -import com.google.common.collect.ImmutableList; import com.google.inject.Inject; import java.io.IOException; import java.net.URL; import java.nio.file.Paths; import java.util.List; +import java.util.stream.Collectors; import org.eclipse.che.selenium.core.SeleniumWebDriver; import org.eclipse.che.selenium.core.client.TestProjectServiceClient; import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants; @@ -32,6 +32,7 @@ import org.eclipse.che.selenium.core.user.DefaultTestUser; import org.eclipse.che.selenium.core.webdriver.DownloadedFileUtil; import org.eclipse.che.selenium.core.workspace.TestWorkspace; +import org.eclipse.che.selenium.pageobject.Consoles; import org.eclipse.che.selenium.pageobject.Ide; import org.eclipse.che.selenium.pageobject.Loader; import org.eclipse.che.selenium.pageobject.Menu; @@ -44,16 +45,15 @@ public class DownloadProjectTest { private static final String TEST_PROJECT_1 = "TestProject1"; private static final String TEST_PROJECT_2 = "TestProject2"; - private static final ImmutableList PROJECT_NAMES = - ImmutableList.of(TEST_PROJECT_1, TEST_PROJECT_2); - private static final String TEST_FILE_NAME = "README.md"; private static final String TEST_DIRECTORY_NAME = "src"; private static final int MAX_ATTEMPTS = 5; - private static final URL PROJECT_SOURCES = + private static final URL PROJECT_1_SOURCES = DownloadProjectTest.class.getResource("/projects/ProjectWithDifferentTypeOfFiles"); + private static final URL PROJECT_2_SOURCES = + DownloadProjectTest.class.getResource("/projects/ProjectWithDifferentTypeOfFiles2"); private static final String DOWNLOADED_PROJECTS_PACKAGE_NAME = "download.zip"; private static final String DOWNLOADED_TEST_PROJECT_1_PACKAGE_NAME = TEST_PROJECT_1 + ".zip"; @@ -68,23 +68,24 @@ public class DownloadProjectTest { @Inject private DownloadedFileUtil downloadedFileUtil; @Inject private SeleniumWebDriver seleniumWebDriver; @Inject private DefaultTestUser user; + @Inject private Consoles consoles; @BeforeClass public void setUp() throws Exception { - PROJECT_NAMES.forEach( - testProject -> { - try { - testProjectServiceClient.importProject( - workspace.getId(), - Paths.get(PROJECT_SOURCES.toURI()), - testProject, - ProjectTemplates.MAVEN_SPRING); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); + testProjectServiceClient.importProject( + workspace.getId(), + Paths.get(PROJECT_1_SOURCES.toURI()), + TEST_PROJECT_1, + ProjectTemplates.MAVEN_SPRING); + testProjectServiceClient.importProject( + workspace.getId(), + Paths.get(PROJECT_2_SOURCES.toURI()), + TEST_PROJECT_2, + ProjectTemplates.MAVEN_SPRING); ide.open(workspace); + consoles.waitJDTLSProjectResolveFinishedMessage(TEST_PROJECT_1); + consoles.waitJDTLSProjectResolveFinishedMessage(TEST_PROJECT_2); projectExplorer.waitProjectExplorer(); loader.waitOnClosed(); } @@ -104,7 +105,11 @@ public void downloadAllProjectsTest() throws IOException { // given List expectedPackageFileList = asList( - "TestProject1/.che/classpath", + "TestProject1/.classpath", + "TestProject1/.project", + "TestProject1/.settings/org.eclipse.jdt.apt.core.prefs", + "TestProject1/.settings/org.eclipse.jdt.core.prefs", + "TestProject1/.settings/org.eclipse.m2e.core.prefs", "TestProject1/README.md", "TestProject1/pom.xml", "TestProject1/src/main/java/org/eclipse/qa/examples/AppController.java", @@ -112,11 +117,14 @@ public void downloadAllProjectsTest() throws IOException { "TestProject1/src/main/webapp/WEB-INF/spring-servlet.xml", "TestProject1/src/main/webapp/WEB-INF/web.xml", "TestProject1/src/main/webapp/index.jsp", - "TestProject2/.che/classpath", - "TestProject2/README.md", + "TestProject2/.classpath", + "TestProject2/.project", + "TestProject2/.settings/org.eclipse.jdt.apt.core.prefs", + "TestProject2/.settings/org.eclipse.jdt.core.prefs", + "TestProject2/.settings/org.eclipse.m2e.core.prefs", "TestProject2/pom.xml", "TestProject2/src/main/java/org/eclipse/qa/examples/AppController.java", - "TestProject2/src/main/webapp/WEB-INF/jsp/guess_num.jsp", + "TestProject2/src/main/webapp/WEB-INF/jsp/hello_view.jsp", "TestProject2/src/main/webapp/WEB-INF/spring-servlet.xml", "TestProject2/src/main/webapp/WEB-INF/web.xml", "TestProject2/src/main/webapp/index.jsp"); @@ -125,8 +133,7 @@ public void downloadAllProjectsTest() throws IOException { menu.runCommand(WORKSPACE, DOWNLOAD_AS_ZIP); // then - assertEquals( - getPackageFileList(DOWNLOADED_PROJECTS_PACKAGE_NAME), expectedPackageFileList.toString()); + assertEquals(getPackageFileList(DOWNLOADED_PROJECTS_PACKAGE_NAME), expectedPackageFileList); } @Test @@ -134,7 +141,11 @@ public void downloadSingleProjectTest() throws IOException { // given List expectedPackageFileList = asList( - ".che/classpath", + ".classpath", + ".project", + ".settings/org.eclipse.jdt.apt.core.prefs", + ".settings/org.eclipse.jdt.core.prefs", + ".settings/org.eclipse.m2e.core.prefs", "README.md", "pom.xml", "src/main/java/org/eclipse/qa/examples/AppController.java", @@ -151,8 +162,7 @@ public void downloadSingleProjectTest() throws IOException { // then assertEquals( - getPackageFileList(DOWNLOADED_TEST_PROJECT_1_PACKAGE_NAME), - expectedPackageFileList.toString()); + getPackageFileList(DOWNLOADED_TEST_PROJECT_1_PACKAGE_NAME), expectedPackageFileList); // when downloadedFileUtil.removeDownloadedFiles( @@ -164,8 +174,7 @@ public void downloadSingleProjectTest() throws IOException { // then assertEquals( - getPackageFileList(DOWNLOADED_TEST_PROJECT_1_PACKAGE_NAME), - expectedPackageFileList.toString()); + getPackageFileList(DOWNLOADED_TEST_PROJECT_1_PACKAGE_NAME), expectedPackageFileList); } @Test @@ -188,8 +197,8 @@ public void downloadDirectoryTest() throws IOException { projectExplorer.clickOnItemInContextMenu(ContextMenuFirstLevelItems.DOWNLOAD); // then - String packageFileList = getPackageFileList(DOWNLOADED_TEST_DIRECTORY_PACKAGE_NAME); - assertEquals(packageFileList, expectedPackageFileList.toString()); + assertEquals( + getPackageFileList(DOWNLOADED_TEST_DIRECTORY_PACKAGE_NAME), expectedPackageFileList); } @Test @@ -224,13 +233,17 @@ private String getDownloadedFileContent(String testFileName) throws IOException throw lastException; } - private String getPackageFileList(String downloadedTestProject1PackageName) throws IOException { + private List getPackageFileList(String downloadedTestProject1PackageName) + throws IOException { IOException lastException = null; for (int i = 0; i < MAX_ATTEMPTS; i++) { try { return downloadedFileUtil .getPackageFileList(seleniumWebDriver, downloadedTestProject1PackageName) - .toString(); + .stream() + // target && .che directories appears asynchronously and leads to failed tests + .filter(s -> !s.contains("target/") && !s.startsWith(".che")) + .collect(Collectors.toList()); } catch (IOException e) { lastException = e; sleepQuietly(TestTimeoutsConstants.MINIMUM_SEC); diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/NavigationByKeyboardTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/NavigationByKeyboardTest.java index 1fba9466457..d9e681b2c42 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/NavigationByKeyboardTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/NavigationByKeyboardTest.java @@ -90,6 +90,7 @@ public void setUp() throws Exception { projectExplorer.waitProjectExplorer(); projectExplorer.waitItem(PROJECT_NAME); notificationsPopupPanel.waitProgressPopupPanelClose(); + consoles.waitJDTLSProjectResolveFinishedMessage(PROJECT_NAME); consoles.closeProcessesArea(); } @@ -148,8 +149,8 @@ public void navigationByKeyboard() throws Exception { projectExplorer.sendToItemRightArrowKey(); checkLibrariesIsVisible(); + projectExplorer.waitAndSelectItemByName("servlet-api-2.5.jar"); - projectExplorer.sendToItemDownArrowKey(); projectExplorer.sendToItemEnterKey(); projectExplorer.waitVisibilityByName("META-INF"); projectExplorer.waitVisibilityByName("javax.servlet"); diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/UploadIntoProjectTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/UploadIntoProjectTest.java index cacd3a5515e..747717aa459 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/UploadIntoProjectTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/UploadIntoProjectTest.java @@ -27,6 +27,7 @@ import org.eclipse.che.selenium.core.project.ProjectTemplates; 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.Events; import org.eclipse.che.selenium.pageobject.Ide; import org.eclipse.che.selenium.pageobject.Menu; @@ -59,6 +60,7 @@ public class UploadIntoProjectTest { @Inject private UploadDirectoryDialogPage uploadDirectoryDialogPage; @Inject private NotificationsPopupPanel notificationPopup; @Inject private CodenvyEditor editor; + @Inject private Consoles consoles; @BeforeClass public void setup() throws Exception { @@ -66,10 +68,11 @@ public void setup() throws Exception { testWorkspace.getId(), get(PROJECT_SOURCES.toURI()), PROJECT_NAME, - ProjectTemplates.MAVEN_SPRING); + ProjectTemplates.PLAIN_JAVA); ide.open(testWorkspace); - projectExplorer.waitProjectInitialization(PROJECT_NAME); + consoles.waitJDTLSProjectResolveFinishedMessage(PROJECT_NAME); + projectExplorer.waitVisibleItem(PROJECT_NAME); } @BeforeMethod diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/dependencies/OpenExternalLibraryFileAfterRefreshTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/dependencies/OpenExternalLibraryFileAfterRefreshTest.java index 9ca65a8f49c..a879a86bb02 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/dependencies/OpenExternalLibraryFileAfterRefreshTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/dependencies/OpenExternalLibraryFileAfterRefreshTest.java @@ -11,6 +11,8 @@ */ package org.eclipse.che.selenium.projectexplorer.dependencies; +import static org.testng.AssertJUnit.assertTrue; + import com.google.inject.Inject; import java.net.URL; import java.nio.file.Paths; @@ -20,6 +22,7 @@ import org.eclipse.che.selenium.core.project.ProjectTemplates; 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; @@ -27,16 +30,7 @@ public class OpenExternalLibraryFileAfterRefreshTest { private static final String PROJECT_NAME = NameGenerator.generate("ExternalFileTest", 4); - private static final String CHECKING_FILE_NAME = "DNSNameService"; - private static final String EXPECTED_EDITOR_TEXT = - "\n" - + " // Failed to get sources. Instead, stub sources have been generated.\n" - + " // Implementation of methods is unavailable.\n" - + "package sun.net.spi.nameservice.dns;\n" - + "public final class DNSNameService implements sun.net.spi.nameservice.NameService {\n" - + " private java.util.LinkedList domainList;\n" - + " private java.lang.String nameProviderUrl;\n" - + " private static java.lang.ThreadLocal> contextRef;\n"; + private static final String CHECKING_FILE_NAME = "Filter"; @Inject private TestProjectServiceClient testProjectServiceClient; @Inject private TestWorkspace testWorkspace; @@ -44,6 +38,7 @@ public class OpenExternalLibraryFileAfterRefreshTest { @Inject private ProjectExplorer projectExplorer; @Inject private CodenvyEditor editor; @Inject private SeleniumWebDriver seleniumWebDriver; + @Inject private Consoles consoles; @BeforeClass public void setUp() throws Exception { @@ -54,6 +49,7 @@ public void setUp() throws Exception { PROJECT_NAME, ProjectTemplates.MAVEN_SPRING); ide.open(testWorkspace); + consoles.waitJDTLSProjectResolveFinishedMessage(PROJECT_NAME); } @Test @@ -78,10 +74,10 @@ private void openFileFromExternalLibraryAndCheckDisplayedText() { projectExplorer.waitVisibilitySeveralItemsByName("README.md", "pom.xml", "External Libraries"); projectExplorer.openSeveralItemsByVisibleNameInExplorer( - "External Libraries", "dnsns.jar", "sun.net.spi.nameservice.dns", CHECKING_FILE_NAME); + "External Libraries", "servlet-api-2.5.jar", "javax.servlet", CHECKING_FILE_NAME); editor.waitActive(); editor.waitTabIsPresent(CHECKING_FILE_NAME); - editor.waitTextIntoEditor(EXPECTED_EDITOR_TEXT); + assertTrue(editor.getVisibleTextFromEditor().contains("package javax.servlet")); } } diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/.codenvy/misc.xml b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/.codenvy/misc.xml deleted file mode 100644 index 36d0da8a3b6..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/.codenvy/misc.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - -1415202946126 - diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/.codenvy/project.json b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/.codenvy/project.json deleted file mode 100644 index d594b084933..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/.codenvy/project.json +++ /dev/null @@ -1 +0,0 @@ -{"type":"maven","attributes":{},"runners":{"default":"system:/java/web/tomcat7","configs":{}},"builders":{"default":"maven"}} \ No newline at end of file diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/pom.xml b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/pom.xml index 3547177a5f8..003179914a2 100644 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/pom.xml +++ b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/pom.xml @@ -15,7 +15,7 @@ 4.0.0 - com.codenvy.examples + org.eclipse.qa.examples web-spring-java-simple war 1.0-SNAPSHOT diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/GreetingController.java b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/GreetingController.java deleted file mode 100644 index e3910b2bb9a..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/GreetingController.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package com.codenvy.example.spring; - -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.mvc.Controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -public class GreetingController implements Controller -{ - - @Override - public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception - { - String userName = request.getParameter("user"); - String result = ""; - if (userName != null) - { - result = "Hello, " + userName + "!"; - } - - ModelAndView view = new ModelAndView("hello_view"); - view.addObject("greeting", result); - return view; - } - - public void testMethod1() { - - } - - public void testMethod2() { - - } - - public void testMethod3() { - - } - - public void testMethod4() { - - } - - public void testMethod5() { - - } - - public void testMethod6() { - - } - - public void testMethod7() { - - } - - public void testMethod8() { - - } - - public void testMethod9() { - - } -} diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/SomeLess.less b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/SomeLess.less deleted file mode 100644 index 953f4b07942..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/SomeLess.less +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -@CHARSET "UTF-8" -; diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/SqlFile.sql b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/SqlFile.sql deleted file mode 100644 index ff308d21e75..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/SqlFile.sql +++ /dev/null @@ -1,23 +0,0 @@ --- --- Copyright (c) 2012-2018 Red Hat, Inc. --- This program and the accompanying materials are made --- available under the terms of the Eclipse Public License 2.0 --- which is available at https://www.eclipse.org/legal/epl-2.0/ --- --- SPDX-License-Identifier: EPL-2.0 --- --- Contributors: --- Red Hat, Inc. - initial API and implementation --- - -Select * From Employee Where Employee.id > 100 and Employee.salary < 2000 -Select * From Employee Where Employee.id > 100 and Employee.salary < 400 -Select * From Employee Where Employee.id > 100 and Employee.salary < 8000 - - - -Select * From Employee Where Employee.id > 200 and Employee.salary < 3000 - - - - diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/some b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/some deleted file mode 100644 index 8cc22d32f1d..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/spring/some +++ /dev/null @@ -1,11 +0,0 @@ -test1 -test2 -test3 -test4 -test5 -test6 -test7 -test8 -test9 -test10 - diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test1.java b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test1.java deleted file mode 100644 index bb97423e7c3..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test1.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package com.codenvy.example.test; - -public class Test1 { -} diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test2.java b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test2.java deleted file mode 100644 index a50bc343e73..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test2.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package com.codenvy.example.test; - -public class Test2 { -} diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test3.java b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test3.java deleted file mode 100644 index f15464a6cdf..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test3.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package com.codenvy.example.test; - -public class Test3 { -} diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test4.java b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test4.java deleted file mode 100644 index df0fb8555cb..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/com/codenvy/example/test/Test4.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package com.codenvy.example.test; - -public class Test4 { -} diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/org/eclipse/qa/examples/AppController.java b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/org/eclipse/qa/examples/AppController.java new file mode 100644 index 00000000000..09750ab6f7f --- /dev/null +++ b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/java/org/eclipse/qa/examples/AppController.java @@ -0,0 +1,41 @@ +/* + * 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.qa.examples; + +import java.util.Random; + +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.Controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class AppController implements Controller { + private static final String secretNum = Integer.toString(new Random().nextInt(10)); + + @Override + public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { + String numGuessByUser = request.getParameter("numGuess"); + String result = ""; + + if (numGuessByUser != null && numGuessByUser.equals(secretNum)) { + result = "Congrats! The number is " + secretNum; + } + + else if (numGuessByUser != null) { + result = "Sorry, you failed. Try again later!"; + } + + ModelAndView view = new ModelAndView("guess_num"); + view.addObject("num", result); + return view; + } +} diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/webapp/WEB-INF/DefaultCss.css b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/webapp/WEB-INF/DefaultCss.css deleted file mode 100644 index afef988a4b5..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/webapp/WEB-INF/DefaultCss.css +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -@CHARSET "UTF-8"; -h1 { - font-size:250%; -} - -h2 { - font-size:200%; -} - -p { - font-size:100%; -} \ No newline at end of file diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/webapp/WEB-INF/SomeHtml.html b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/webapp/WEB-INF/SomeHtml.html deleted file mode 100644 index 1a9e8da0305..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/webapp/WEB-INF/SomeHtml.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/webapp/WEB-INF/someJS.js b/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/webapp/WEB-INF/someJS.js deleted file mode 100644 index f78833a2b59..00000000000 --- a/selenium/che-selenium-test/src/test/resources/projects/ProjectWithDifferentTypeOfFiles2/src/main/webapp/WEB-INF/someJS.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -var person = { - firstName: "John", - lastName : "Doe", - id : 5566 -}; -document.getElementById("demo").innerHTML = -person["firstName"] + " " + person["lastName"]; \ No newline at end of file