You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2021/12/03 17:55:27 UTC

[activemq-artemis] branch main updated: ARTEMIS-3600 Add console index page test

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 8f41cf6  ARTEMIS-3600 Add console index page test
8f41cf6 is described below

commit 8f41cf647ffff77d549b6c361835170bb1f59e38
Author: Domenico Francesco Bruscino <br...@apache.org>
AuthorDate: Thu Dec 2 21:00:14 2021 +0100

    ARTEMIS-3600 Add console index page test
---
 .../artemis/tests/smoke/console/ConsoleTest.java   | 21 +++++++++----
 .../console/{LoginTest.java => IndexTest.java}     | 29 +++++++-----------
 .../artemis/tests/smoke/console/LoginTest.java     | 12 ++++----
 .../artemis/tests/smoke/console/QueuesTest.java    |  4 ++-
 .../tests/smoke/console/pages/IndexPage.java       | 35 ++++++++++++++++++++++
 5 files changed, 70 insertions(+), 31 deletions(-)

diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/ConsoleTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/ConsoleTest.java
index cec3f49..4cbb7d7 100644
--- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/ConsoleTest.java
+++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/ConsoleTest.java
@@ -48,7 +48,6 @@ public abstract class ConsoleTest extends SmokeTestBase {
    protected static final int DEFAULT_TIMEOUT = 10000;
    protected static final String DEFAULT_SERVER_URL = "http://localhost:8161";
    protected static final String DEFAULT_CONTAINER_SERVER_URL = "http://host.testcontainers.internal:8161";
-   protected static final String DEFAULT_CONSOLE_BRAND_IMAGE = "/activemq-branding/plugin/img/activemq.png";
 
    protected WebDriver driver;
    protected MutableCapabilities browserOptions;
@@ -88,12 +87,22 @@ public abstract class ConsoleTest extends SmokeTestBase {
       // [4] https://github.com/mozilla/geckodriver/
 
       try {
-         if (ChromeOptions.class.equals(browserOptions.getClass()) &&
+         if (browserOptions instanceof ChromeOptions &&
             System.getProperty("webdriver.chrome.driver") != null) {
-            driver = new ChromeDriver((ChromeOptions)browserOptions);
-         } else if (FirefoxOptions.class.equals(browserOptions.getClass()) &&
+            ChromeOptions chromeOptions = (ChromeOptions)browserOptions;
+            String arguments = System.getProperty("webdriver.chrome.driver.args");
+            if (arguments != null) {
+               chromeOptions.addArguments(arguments.split(","));
+            }
+            driver = new ChromeDriver(chromeOptions);
+         } else if (browserOptions instanceof FirefoxOptions &&
             System.getProperty("webdriver.gecko.driver") != null) {
-            driver = new FirefoxDriver((FirefoxOptions)browserOptions);
+            FirefoxOptions firefoxOptions = (FirefoxOptions)browserOptions;
+            String arguments = System.getProperty("webdriver.gecko.driver.args");
+            if (arguments != null) {
+               firefoxOptions.addArguments(arguments.split(","));
+            }
+            driver = new FirefoxDriver(firefoxOptions);
          } else {
             serverUrl = DEFAULT_CONTAINER_SERVER_URL;
             Testcontainers.exposeHostPorts(8161);
@@ -111,7 +120,7 @@ public abstract class ConsoleTest extends SmokeTestBase {
 
       loadWebDriverWait.until((Function<WebDriver, Object>) webDriver -> {
          try {
-            webDriver.get(serverUrl + "/console");
+            webDriver.get(serverUrl);
             return true;
          } catch (Exception ignore) {
             return false;
diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/LoginTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/IndexTest.java
similarity index 54%
copy from tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/LoginTest.java
copy to tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/IndexTest.java
index 147b5b5..a17de91 100644
--- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/LoginTest.java
+++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/IndexTest.java
@@ -17,32 +17,25 @@
 
 package org.apache.activemq.artemis.tests.smoke.console;
 
-import org.apache.activemq.artemis.tests.smoke.console.pages.LoginPage;
-import org.apache.activemq.artemis.tests.smoke.console.pages.StatusPage;
+import org.apache.activemq.artemis.tests.smoke.console.pages.IndexPage;
 import org.junit.Test;
 import org.openqa.selenium.MutableCapabilities;
 
-public class LoginTest extends ConsoleTest {
+public class IndexTest extends ConsoleTest {
 
-   public LoginTest(MutableCapabilities browserOptions) {
-      super(browserOptions);
-   }
+   protected static final String DEFAULT_CONSOLE_INDEX_LOGO_IMAGE = "/images/activemq-logo.png";
 
-   @Test
-   public void testLogin() {
-      LoginPage loginPage = new LoginPage(driver);
-      StatusPage statusPage = loginPage.loginValidUser(
-         SERVER_ADMIN_USERNAME, SERVER_ADMIN_PASSWORD, DEFAULT_TIMEOUT);
-
-      assertEquals(SERVER_ADMIN_USERNAME, statusPage.getUser());
+   public IndexTest(MutableCapabilities browserOptions) {
+      super(browserOptions);
    }
 
    @Test
-   public void testLoginBrand() {
-      String expectedBrandImage = serverUrl + System.getProperty(
-         "artemis.console.brand.image", DEFAULT_CONSOLE_BRAND_IMAGE);
+   public void testIndexLogo() {
+      String expectedLogoImage = serverUrl + System.getProperty(
+         "artemis.console.index.logo.image", DEFAULT_CONSOLE_INDEX_LOGO_IMAGE);
 
-      LoginPage loginPage = new LoginPage(driver);
-      assertEquals(expectedBrandImage, loginPage.getBrandImage(DEFAULT_TIMEOUT));
+      driver.get(serverUrl);
+      IndexPage indexPage = new IndexPage(driver);
+      assertEquals(expectedLogoImage, indexPage.getLogoImage(DEFAULT_TIMEOUT));
    }
 }
diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/LoginTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/LoginTest.java
index 147b5b5..3c21049 100644
--- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/LoginTest.java
+++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/LoginTest.java
@@ -18,30 +18,30 @@
 package org.apache.activemq.artemis.tests.smoke.console;
 
 import org.apache.activemq.artemis.tests.smoke.console.pages.LoginPage;
-import org.apache.activemq.artemis.tests.smoke.console.pages.StatusPage;
 import org.junit.Test;
 import org.openqa.selenium.MutableCapabilities;
 
 public class LoginTest extends ConsoleTest {
 
+   private static final String DEFAULT_CONSOLE_LOGIN_BRAND_IMAGE = "/activemq-branding/plugin/img/activemq.png";
+
    public LoginTest(MutableCapabilities browserOptions) {
       super(browserOptions);
    }
 
    @Test
    public void testLogin() {
+      driver.get(serverUrl + "/console");
       LoginPage loginPage = new LoginPage(driver);
-      StatusPage statusPage = loginPage.loginValidUser(
-         SERVER_ADMIN_USERNAME, SERVER_ADMIN_PASSWORD, DEFAULT_TIMEOUT);
-
-      assertEquals(SERVER_ADMIN_USERNAME, statusPage.getUser());
+      loginPage.loginValidUser(SERVER_ADMIN_USERNAME, SERVER_ADMIN_PASSWORD, DEFAULT_TIMEOUT);
    }
 
    @Test
    public void testLoginBrand() {
       String expectedBrandImage = serverUrl + System.getProperty(
-         "artemis.console.brand.image", DEFAULT_CONSOLE_BRAND_IMAGE);
+         "artemis.console.login.brand.image", DEFAULT_CONSOLE_LOGIN_BRAND_IMAGE);
 
+      driver.get(serverUrl + "/console");
       LoginPage loginPage = new LoginPage(driver);
       assertEquals(expectedBrandImage, loginPage.getBrandImage(DEFAULT_TIMEOUT));
    }
diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/QueuesTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/QueuesTest.java
index 185ccd6..b5db6b1 100644
--- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/QueuesTest.java
+++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/QueuesTest.java
@@ -40,6 +40,7 @@ public class QueuesTest extends ConsoleTest {
 
    @Test
    public void testDefaultQueues() throws Exception {
+      driver.get(serverUrl + "/console");
       LoginPage loginPage = new LoginPage(driver);
       StatusPage statusPage = loginPage.loginValidUser(
          SERVER_ADMIN_USERNAME, SERVER_ADMIN_PASSWORD, DEFAULT_TIMEOUT);
@@ -58,6 +59,7 @@ public class QueuesTest extends ConsoleTest {
       final String queueName = "TEST";
       final String messageText = "TEST";
 
+      driver.get(serverUrl + "/console");
       LoginPage loginPage = new LoginPage(driver);
       StatusPage statusPage = loginPage.loginValidUser(
          SERVER_ADMIN_USERNAME, SERVER_ADMIN_PASSWORD, DEFAULT_TIMEOUT);
@@ -97,6 +99,6 @@ public class QueuesTest extends ConsoleTest {
 
       QueuesPage afterQueuesPage = messagePage.getQueuesPage(DEFAULT_TIMEOUT);
       Wait.assertEquals(1, () -> afterQueuesPage.countQueue("DLQ"));
-      Wait.assertEquals(0, () -> afterQueuesPage.countQueue(queueName));
+      Wait.assertEquals(0, () -> afterQueuesPage.getMessagesCount(queueName));
    }
 }
diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/IndexPage.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/IndexPage.java
new file mode 100644
index 0000000..219cd17
--- /dev/null
+++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/IndexPage.java
@@ -0,0 +1,35 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.activemq.artemis.tests.smoke.console.pages;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+
+public class IndexPage extends ConsolePage {
+   private By logoImageLocator = By.xpath("//div[@class='logo']/img");
+
+   public IndexPage(WebDriver driver) {
+      super(driver);
+   }
+
+   public String getLogoImage(int timeout) {
+      waitForElementToBeVisible(logoImageLocator, timeout);
+
+      return driver.findElement(logoImageLocator).getAttribute("src");
+   }
+}