Skip to content

Commit

Permalink
Use new license checker (#973)
Browse files Browse the repository at this point in the history
* Read TestBench and Selenium version from the same, namespaced file

* Use new license checker
  • Loading branch information
Artur- authored and tuliogarcia committed Jan 18, 2018
1 parent 27abf95 commit 1cec574
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 1,223 deletions.
11 changes: 11 additions & 0 deletions vaadin-testbench/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
</license>
</licenses>

<repositories>
<repository>
<id>vaadin-prereleases</id>
<url>https://maven.vaadin.com/vaadin-prereleases</url>
</repository>
</repositories>
<profiles>
<profile>
<id>release</id>
Expand Down Expand Up @@ -187,6 +193,11 @@
<artifactId>javassist</artifactId>
<version>3.18.1-GA</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>license-checker</artifactId>
<version>1.0.0.alpha2</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-elemental</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import com.vaadin.pro.licensechecker.LicenseChecker;
import com.vaadin.testbench.commands.TestBenchCommandExecutor;
import com.vaadin.testbench.screenshot.ImageComparison;
import com.vaadin.testbench.screenshot.ReferenceNameGenerator;
import com.vaadin.testbench.tools.LicenseChecker;

import javassist.util.proxy.MethodFilter;
import javassist.util.proxy.MethodHandler;
Expand All @@ -34,7 +34,7 @@
*/
public class TestBench {

private static final Map<Class<?>, MethodFilter> methodFilters;
private static final Map<Class<?>, MethodFilter> methodFilters = new ConcurrentHashMap<>();

private static final class ElementMethodFilter implements MethodFilter {

Expand Down Expand Up @@ -84,8 +84,8 @@ public Object invoke(Object self, Method thisMethod, Method proceed,
}

static {
LicenseChecker.nag();
methodFilters = new ConcurrentHashMap<>();
LicenseChecker.checkLicenseFromStaticBlock("vaadin-testbench",
TestBenchTestCase.testbenchVersion);
}

public static TestBenchDriverProxy createDriver(WebDriver driver) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.WebDriverWait;

import com.vaadin.pro.licensechecker.LicenseChecker;
import com.vaadin.testbench.commands.TestBenchCommandExecutor;
import com.vaadin.testbench.commands.TestBenchCommands;
import com.vaadin.testbench.tools.LicenseChecker;

/**
* A superclass with some helpers to aid TestBench developers. This superclass
Expand All @@ -40,35 +40,35 @@
public abstract class TestBenchTestCase
implements HasDriver, HasTestBenchCommandExecutor, HasElementQuery {

public static final String testbenchVersion;
static {
// Check the license here, before any driver has been initialized
// (#15102)
LicenseChecker.nag();
}

static {
Properties properties = new Properties();
try {
String seleniumVersion = new BuildInfo().getReleaseLabel();

Properties properties = new Properties();
properties.load(TestBenchTestCase.class
.getResourceAsStream("testbench.properties"));
String expectedVersion = properties.getProperty("selenium.version");
if (seleniumVersion == null
|| !seleniumVersion.equals(expectedVersion)) {
Logger.getLogger(TestBenchTestCase.class.getName()).warning(
"This version of TestBench depends on Selenium version "
+ expectedVersion + " but version "
+ seleniumVersion
+ " was found. Make sure you do not have multiple versions of Selenium on the classpath.");
}
} catch (Exception e) {
Logger.getLogger(TestBenchTestCase.class.getName()).log(
Level.WARNING,
"Unable to validate that the correct Selenium version is in use",
Level.WARNING, "Unable to read TestBench properties file",
e);
throw new ExceptionInInitializerError(e);
}

String seleniumVersion = new BuildInfo().getReleaseLabel();
testbenchVersion = properties.getProperty("testbench.version");
String expectedVersion = properties.getProperty("selenium.version");
if (seleniumVersion == null
|| !seleniumVersion.equals(expectedVersion)) {
Logger.getLogger(TestBenchTestCase.class.getName()).warning(
"This version of TestBench depends on Selenium version "
+ expectedVersion + " but version "
+ seleniumVersion
+ " was found. Make sure you do not have multiple versions of Selenium on the classpath.");
}

LicenseChecker.checkLicenseFromStaticBlock("vaadin-testbench",
TestBenchTestCase.testbenchVersion);
}

/**
* Specifies retry count, which is used to run same test several times. Can
* be changed by setting "com.vaadin.testbench.Parameters.maxAttempts"
Expand Down
Loading

0 comments on commit 1cec574

Please sign in to comment.