myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hno...@apache.org
Subject [myfaces-tobago] branch master updated: refactor because of checkstyle
Date Fri, 25 May 2018 08:23:26 GMT
This is an automated email from the ASF dual-hosted git repository.

hnoeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new 1a35bf9  refactor because of checkstyle
1a35bf9 is described below

commit 1a35bf99a39d6c5e6fd40662430ad823a797ca98
Author: Henning Noeth <hnoeth@apache.org>
AuthorDate: Fri May 25 10:23:09 2018 +0200

    refactor because of checkstyle
---
 .../example/demo/qunit/AccessAllPagesTest.java     | 22 ++++++++--------------
 .../tobago/example/demo/qunit/SeleniumBase.java    | 16 +++++++++++-----
 .../tobago/example/demo/qunit/StandardTest.java    |  8 ++------
 3 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/qunit/AccessAllPagesTest.java
b/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/qunit/AccessAllPagesTest.java
index 9485052..2323ff5 100644
--- a/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/qunit/AccessAllPagesTest.java
+++ b/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/qunit/AccessAllPagesTest.java
@@ -61,10 +61,10 @@ class AccessAllPagesTest extends SeleniumBase {
     final String path = "error/exception.xhtml";
     setupWebDriver(portContextPath, path, true);
 
-    WebElement qunitBanner = webDriver.findElement(By.id("qunit-banner"));
-    WebElement qunitTests = webDriver.findElement(By.id("qunit-tests"));
+    WebElement qunitBanner = getWebDriver().findElement(By.id("qunit-banner"));
+    WebElement qunitTests = getWebDriver().findElement(By.id("qunit-tests"));
 
-    new FluentWait(webDriver)
+    new FluentWait(getWebDriver())
         .withTimeout(Duration.ofSeconds(90))
         .pollingEvery(Duration.ofSeconds(1))
         .until(ExpectedConditions.attributeToBeNotEmpty(qunitBanner, "class"));
@@ -78,8 +78,6 @@ class AccessAllPagesTest extends SeleniumBase {
       }
     }
     Assert.assertTrue("Could not verify 'has no exception' test.", testException);
-
-    webDriver.quit();
   }
 
   /**
@@ -96,10 +94,10 @@ class AccessAllPagesTest extends SeleniumBase {
     final String path = "error/404.xhtml";
     setupWebDriver(portContextPath, path, true);
 
-    WebElement qunitBanner = webDriver.findElement(By.id("qunit-banner"));
-    WebElement qunitTests = webDriver.findElement(By.id("qunit-tests"));
+    WebElement qunitBanner = getWebDriver().findElement(By.id("qunit-banner"));
+    WebElement qunitTests = getWebDriver().findElement(By.id("qunit-tests"));
 
-    new FluentWait(webDriver)
+    new FluentWait(getWebDriver())
         .withTimeout(Duration.ofSeconds(90))
         .pollingEvery(Duration.ofSeconds(1))
         .until(ExpectedConditions.attributeToBeNotEmpty(qunitBanner, "class"));
@@ -113,8 +111,6 @@ class AccessAllPagesTest extends SeleniumBase {
       }
     }
     Assert.assertTrue("Could not verify 'has no 404' test.", test404);
-
-    webDriver.quit();
   }
 
   @ParameterizedTest
@@ -127,15 +123,13 @@ class AccessAllPagesTest extends SeleniumBase {
     setupWebDriver(portContextPath, path, true);
 
     parseQUnitResults(browser, portContextPath, path);
-
-    webDriver.quit();
   }
 
   private static Stream<Arguments> verifyNoException404TestProvider() throws IOException
{
     List<Arguments> arguments = new LinkedList<>();
 
     for (Browser browser : Browser.values()) {
-      for (String portWithContextPath : serverPortWithContextPath) {
+      for (String portWithContextPath : getServerPortWithContextPath()) {
         arguments.add(Arguments.of(browser, portWithContextPath));
       }
     }
@@ -157,7 +151,7 @@ class AccessAllPagesTest extends SeleniumBase {
     List<Arguments> arguments = new LinkedList<>();
 
     for (Browser browser : Browser.values()) {
-      for (String portWithContextPath : serverPortWithContextPath) {
+      for (String portWithContextPath : getServerPortWithContextPath()) {
         for (String path : paths) {
           arguments.add(Arguments.of(browser, portWithContextPath, path));
         }
diff --git a/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/qunit/SeleniumBase.java
b/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/qunit/SeleniumBase.java
index fa9224d..e110078 100644
--- a/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/qunit/SeleniumBase.java
+++ b/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/qunit/SeleniumBase.java
@@ -47,7 +47,7 @@ abstract class SeleniumBase {
 
   private static final Logger LOG = LoggerFactory.getLogger(SeleniumBase.class);
 
-  WebDriver webDriver;
+  private WebDriver webDriver;
 
   @AfterEach
   void tearDown() {
@@ -60,9 +60,9 @@ abstract class SeleniumBase {
     chrome, firefox
   }
 
-  static String[] serverPortWithContextPath = {
-      "8081/tobago-example-demo"
-  };
+  static String[] getServerPortWithContextPath() {
+    return new String[]{"8081/tobago-example-demo"};
+  }
 
   void setupBrowser(final Browser browser) throws MalformedURLException {
     MutableCapabilities options = null;
@@ -71,6 +71,7 @@ abstract class SeleniumBase {
         options = new ChromeOptions();
         break;
       case firefox:
+      default:
         options = new FirefoxOptions();
         break;
     }
@@ -87,7 +88,12 @@ abstract class SeleniumBase {
     webDriver.get(url);
   }
 
-  void parseQUnitResults(final Browser browser, final String portContextPath, final String
path) throws UnknownHostException {
+  WebDriver getWebDriver() {
+    return webDriver;
+  }
+
+  void parseQUnitResults(final Browser browser, final String portContextPath, final String
path)
+      throws UnknownHostException {
     WebElement qunitBanner = webDriver.findElement(By.id("qunit-banner"));
     WebElement qunitTestResult = webDriver.findElement(By.id("qunit-testresult"));
     WebElement qunitTests = webDriver.findElement(By.id("qunit-tests"));
diff --git a/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/qunit/StandardTest.java
b/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/qunit/StandardTest.java
index 1d2d6e6..59deba1 100644
--- a/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/qunit/StandardTest.java
+++ b/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/qunit/StandardTest.java
@@ -49,7 +49,7 @@ class StandardTest extends SeleniumBase {
   @Test
   void testSinglePage() throws MalformedURLException, UnknownHostException, UnsupportedEncodingException
{
     final Browser browser = Browser.chrome;
-    final String portContextPath = serverPortWithContextPath[0];
+    final String portContextPath = getServerPortWithContextPath()[0];
     final String path = "content/10-intro/intro.xhtml";
 
     LOG.info("browser: " + browser + " - port and context path: " + portContextPath + " -
path: " + path);
@@ -58,8 +58,6 @@ class StandardTest extends SeleniumBase {
     setupWebDriver(portContextPath, path, false);
 
     parseQUnitResults(browser, portContextPath, path);
-
-    webDriver.quit();
   }
 
   @ParameterizedTest
@@ -72,8 +70,6 @@ class StandardTest extends SeleniumBase {
     setupWebDriver(portContextPath, path, false);
 
     parseQUnitResults(browser, portContextPath, path);
-
-    webDriver.quit();
   }
 
   private static Stream<Arguments> standardTestProvider() throws IOException {
@@ -89,7 +85,7 @@ class StandardTest extends SeleniumBase {
     List<Arguments> arguments = new LinkedList<>();
 
     for (Browser browser : Browser.values()) {
-      for (String portWithContextPath : serverPortWithContextPath) {
+      for (String portWithContextPath : getServerPortWithContextPath()) {
         for (String path : paths) {
           arguments.add(Arguments.of(browser, portWithContextPath, path));
         }

-- 
To stop receiving notification emails like this one, please contact
hnoeth@apache.org.

Mime
View raw message