Configure the org.jooq.conf.Settings.backslashEscaping property - jooq

In the book "Beginning jOOQ" by Tayo Koleoso it is written:
Caution For your own peace of mind, go ahead and configure the
org.jooq.conf.Settings.backslashEscaping property on
your Settings object. MySQL and some versions of PostgreSQL
support non-standard escape characters that can cause you a lot of
grief when you least expect it. This property lets jOOQ properly handle
this “feature” from MySQL.
The problem is that to the best of my ability I can't find in the book how toconfigure this.
Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>jooq</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>jooq</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jooq</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
application.properties
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/testdb
spring.datasource.username=testdb
spring.datasource.password=testdb
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
Controller
#Controller
#RequestMapping("/start")
public class StartController {
#GetMapping("/")
public void start() {
try (Connection connection = DriverManager.
getConnection("jdbc:mysql://localhost/test?user=testdb&password=testdb")) {
DSLContext context = DSL.using(connection, SQLDialect.MYSQL);
ResultQuery resultQuery = context.
resultQuery("SELECT * FROM edens_car.complete_car_listing");
List<CompleteVehicleRecord> allVehicles =
resultQuery.fetchInto(CompleteVehicleRecord.class);
} catch (SQLException sqlex) {
assert true;
}
}
}
I just organised the Spring Controller for my convenience, don't pay attention to it.

Adapting your example code
You can pass custom Settings to one of the DSL.using() overloads, specifically:
DSLContext context = DSL.using(connection, SQLDialect.MYSQL, settings);
Noting that these methods are just convenience for creating your own DefaultConfiguration
A Spring Boot DefaultConfigurationCustomizer
Alternatively, if you're using Spring Boot, then this article shows how to use a DefaultConfigurationCustomizer, e.g.:
#Bean
public DefaultConfigurationCustomizer configurationCustomiser() {
return (DefaultConfiguration c) -> c.settings()
.withBackslashEscaping(...);
}

Related

NoSuchMethodErro:org.apache.hadoop.hive.ql.exec.Utilities.copyTableJobPropertiesToConf

Every Hi:
There is a exception i have never encountered,Pls see the below:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.hive.ql.exec.Utilities.copyTableJobPropertiesToConf(Lorg/apache/hadoop/hive/ql/plan/TableDesc;Lorg/apache/hadoop/conf/Configuration;)V
at org.apache.spark.sql.hive.HadoopTableReader$.initializeLocalJobConfFunc(TableReader.scala:399)
at org.apache.spark.sql.hive.HadoopTableReader.$anonfun$createOldHadoopRDD$1(TableReader.scala:314)
at org.apache.spark.sql.hive.HadoopTableReader.$anonfun$createOldHadoopRDD$1$adapted(TableReader.scala:314)
at org.apache.spark.rdd.HadoopRDD.$anonfun$getJobConf$8(HadoopRDD.scala:181)
at org.apache.spark.rdd.HadoopRDD.$anonfun$getJobConf$8$adapted(HadoopRDD.scala:181)
What's the code is:
import org.apache.spark.sql.SparkSession
object test {
def main(args:Array[String]): Unit = {
System.setProperty("HADOOP_USER_NAME", "nuochengze")
val spark: SparkSession = SparkSession.builder()
.appName("Test")
.master("local[*]")
.config("hadoop.home.dir", "hdfs://pc001:8082/user/hive/warehouse")
.enableHiveSupport()
.getOrCreate()
spark.sql("use test")
spark.sql(
"""
|select * from emp
|""".stripMargin).show
spark.close()
}
}
A thing that made me at a loss happended when i used spark to operate hive:
I can perform DDL operations through spark.sql(...).But when i try perform DML operations,such as select ,the above Exception will be reported,I know the lock of this method.But after searching the internet,i did not find any related blogs that if this method is missing,how can solve it?
Have you encountered it? if ture, can i ask for help?
Thinks!!!
I have found the cause of the error. Due to my negligence, when importing modules into pom.xml, there are some inconsistencies between the versions of some modules. If you encounter similar errors, you can refer to my current maven configuration:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.25</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.12</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hive_2.12</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-auth</artifactId>
<version>3.1.2</version>
</dependency>
</dependencies>
</project>

Exception in thread "main" after updating cucumber version

i have updated my cucumber version after that it is giving following exception:
WARNING: You are using deprecated Main class. Please use
io.cucumber.core.api.cli.Main
Exception in thread "main" cucumber.runtime.CucumberException: Failed to
instantiate public
cucumber.runtime.java.JavaBackend(cucumber.runtime.io.ResourceLoader,io.cucum
ber.stepexpression.TypeRegistry)
My runner Class:
package hgtest.runner;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
#CucumberOptions(plugin = "json:target/cucumber-report.json",
features="classpath:features",
glue="hgtest.stepdefinitions"
)
public abstract class CustomCucumberAbstractTestng extends AbstractTestNGCucumberTests {
public CustomCucumberAbstractTestng() {
}
#Test(
groups = {"cucumber"},
description = "Runs Cucumber Feature",
dataProvider = "features"
)
#Override
#DataProvider(parallel = true)
public Object[][] scenarios() {
return super.scenarios();
}
}
Pom.xml is following:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>4.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java8 -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java8</artifactId>
<version>4.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>4.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>4.1.3</version>
</dependency>
I have updated the cucumber version from info.cuke to io.cucumber. After that it is saying Exception in thread "main" cucumber.runtime.CucumberException. There is no io.cucumber.core.api.cli.Main. I am using intellij Idea
I managed to force IntelliJ-cucumber plugin template to use the suggested io.cucumber.core.api.cli.Main, and it works.
As stated by #mpkorstanje:
The correct class to use is io.cucumber.core.api.Main
I had the same problem.
I put the dependencies below in pom.xml and implements the En interface in the class of steps the problem was solved.
<!-- cucumber -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java8</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
In the official SmartBear forum, the creator and lead developer of Cucumber Open says:
"You can safely ignore this warning. All it means is that cucumber-eclipse has not yet been updated to use Cucumber's new package structure. We have an open issue about this. If you feel strongly about it you can help us by submitting a pull request to cucumber-eclipse."
https://community.smartbear.com/t5/Cucumber-Open/deprecated-Main-class-error-while-using-Cucumber-6-1-1/td-p/203642

How to skip a specific scenario having unique tag from TestNG runner

I have feature file with lots of scenarios, which run on multiple countries. To run on different countries I have created different TestNG runner classes.
Here my question is how can I skip a scenario to run from a specific runner file. I am running scenario's using a feature level tag.
For Example :
Feature file is having #regression tag and I am using this tag in
all runner classes to across the countries. Since data issue for some
countries I want skip some scenario for some countries.(I am using TestNG
runner). I have seen that in JUnit runner you can use not to skip but the
same is not working in TestNG runner.
I tried below :
#CucumberOptions(
plugin = "com.cucumber.listener.ExtentCucumberFormatter:",
monochrome = true,
features = "src/features/Cart",
tags = { "#regression and not #invalid"}
#regression
Feature: Validate login functionality for all countries
#valid
Scenario Outline: login with valid user access
Given site launched
And user enters "<username>"
And user enters "<password>"
When user clicks Sign In button
Then display user home page
Examples:
| username | password |
| xyz | xyz123 |
| abc | abc123 |
#invalid
Scenario Outline: login with invalid user access
Given site launched
And user enters "<username>"
And user enters "<password>"
When user clicks Sign In button
Then display user home page
Examples:
| username | password |
| xyz | xyz123 |
| abc | abc123 |
Below is my runner class file :
package runner;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.junit.runner.RunWith;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import com.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.AbstractTestNGCucumberTests;
import utils.ConfigManagement;
import utils.ExcelSheetManager;
import utils.ExtentReportUtills;
#CucumberOptions(plugin = "com.cucumber.listener.ExtentCucumberFormatter:",
monochrome = true, features = "src/features/Cart", tags = { "#regression and not #invalid"},
format = { "html:cucumber-html-reports1",
"json:cucumber-html-reports/cucumber.json" }, dryRun = false, glue = "steps")
public class EU_IR_EN extends AbstractTestNGCucumberTests {
public static Map<String, String> configDetails = new HashMap<>();
#BeforeClass
public static void setup() throws Exception {
Map<String, String> SheetData = new HashMap<>();
String key = "Cart";
SheetData.put("SHEETNAME", key);
configDetails = ConfigManagement.GetConfigDetailsForRCL(key);
SheetData.putAll(configDetails);
System.out.println("map at class level of runner1" + SheetData);
ExcelSheetManager.setData(SheetData);
System.out.println("first statement");
}
#AfterClass
public static void prepareReport() throws Exception {
ExtentReportUtills.UpdateExtentReport();
}
}
Below is my POM.xml
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>cucumberTest</groupId>
<artifactId>FSCartUIAutomation</artifactId>
<version>1</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.6</version>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>selenium-jupiter</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.14</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.14</version>
</dependency>
<!-- For excel file handling -->
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>hindsighttesting.release</id>
<name>Hindsight Software Release Repository</name>
<url>http://repo.hindsightsoftware.com/public-maven</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>com.hindsighttesting.behave</groupId>
<artifactId>behave-maven-plugin</artifactId>
<version>1.0.4</version>
<executions>
<execution>
<id>install6</id>
<phase>package</phase>
<goals>
<goal>features</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>GFSCart.xml</suiteXmlFile>
</suiteXmlFiles>
<printSummary>true</printSummary>
<forkCount>4</forkCount>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- <source>${jdk.level}</source> <target>${jdk.level}</target> -->
</configuration>
</plugin>
</plugins>
</build>
You can use tags to run / skip specific scenarios.
From the docs:
You can tell Cucumber to ignore scenarios with a particular tag:
Using JUnit runner class:
#CucumberOptions(tags = "not #smoke")
class RunCucumberTest {}

Exception in thread "main" java.lang.NoClassDefFoundError: gherkin/formatter/Formatter

I am learning how to write BDD test scripts in JAVA using Cucumber. However, I keep getting the above error and not sure why. I have the Cukes Gherkin as a dependency.
POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Cucumber</groupId>
<artifactId>Cucumber</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</exclusion>
<exclusion>
<groupId>com.googlecode.java-diff-utils</groupId>
<artifactId>diffutils</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.picocontainer</groupId>
<artifactId>picocontainer</artifactId>
<version>2.15</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>codehaus</id>
<url>http://repository.codehaus.org</url>
</repository>
</repositories>
<profiles>
<profile>
<id>junit-4.12</id>
<properties>
<junit.version>4.12</junit.version>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.6.1</version>
<configuration>
<filesets>
<fileset>
<directory>.</directory>
<includes>
<include>**/*.ser</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>
</project>
Feature
Feature: Letter
Scenario: Check Letter
Given I have the letter "A"
When Icheck the letter "A"
Then I should see an output
Steps
package cucumber.steps;
import cucumber.api.CucumberOptions;
import cucumber.api.java.en.*;
import cucumber.api.junit.Cucumber;
import org.junit.Assert;
import org.junit.runner.RunWith;
/**
* Created by Dustin on 8/31/2015.
*/
#RunWith(Cucumber.class)
#CucumberOptions(
plugin = {"json-pretty", "html:target/cucumber"},
features = "src/main/java/cucumber/steps/LetterStepDefs"
)
public class LetterStepDefs {
private String letter;
private String message;
#Given("^I have the letter \"([^\"]*)\"$")
public void I_have_the_letter(String letter) throws Throwable {
// Express the Regexp above with the code you wish you had
this.letter = letter;
}
#When("^Icheck the letter \"([^\"]*)\"$")
public void Icheck_the_letter(String letter) throws Throwable {
// Express the Regexp above with the code you wish you had
try
{
Assert.assertEquals(this.letter, letter);
}
catch (Exception exc)
{
message = exc.getMessage();
}
}
#Then("^I should see an output$")
public void I_should_see_an_output() throws Throwable {
// Express the Regexp above with the code you wish you had
System.out.println(message);
}
}
Output
Testing started at 4:41 PM ...
Connected to the target VM, address: '127.0.0.1:58473', transport: 'socket'
JUnit version 4.12
Exception in thread "main" java.lang.NoClassDefFoundError: gherkin/formatter/Formatter
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at org.junit.internal.Classes.getClass(Classes.java:16)
at org.junit.runner.JUnitCommandLineParseResult.parseParameters(JUnitCommandLineParseResult.java:100)
at org.junit.runner.JUnitCommandLineParseResult.parseArgs(JUnitCommandLineParseResult.java:50)
at org.junit.runner.JUnitCommandLineParseResult.parse(JUnitCommandLineParseResult.java:44)
at org.junit.runner.JUnitCore.runMain(JUnitCore.java:72)
at org.junit.runner.JUnitCore.main(JUnitCore.java:36)
Caused by: java.lang.ClassNotFoundException: gherkin.formatter.Formatter
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 20 more
Disconnected from the target VM, address: '127.0.0.1:58473', transport: 'socket'
Process finished with exit code 1
Any help is much appreciated!
I was working with cucumber with some selenium scripts today and came across a similar issue whenever I was using gherkin3 jar file.
Once I switch back to using gherkin 2.12.2, the issue went away.
You can download the jar from the following location:
http://search.maven.org/#search%7Cga%7C1%7Cgherkin
It is certainly worth trying this and checking if you get the same issue.
I would also try running your feature file without any methods to check if you get it to return the methods you need to create, similar to the what is detailed in the document here:
http://www.toolsqa.com/cucumber/first-cucumber-selenium-java-test/
You don't need the glue option though like detailed in the example when you just what to run the feature file.

Geb, Spock, Groovy - Issue in executing methods from other groovy classes in Test class

I have set up Geb + Spock + Groovy and able to run a one sample script successfully. Now I have created one method in another groovy class (this class I have putted in resource folder) which I am calling in my test class but it giving me below error :
Unable to resolve FileHandling as content for Page, or as a property
on its Navigator context. Is FileHandling a class you forgot to
import?
"FileHandling" is name of my class which contains the method.I am able to run this method successfully as separate entity but when I am calling it in my test class and running it through pom.xml, I am getting above error.
Please let me know how this can be resolved. The code which is causing issue is below.
package test.groovy
import geb.spock.GebReportingSpec
import spock.lang.*
import FileHandling.*
#Stepwise
public class RateTest extends GebReportingSpec {
def "open application home page"() {
when:
go() // uses base url system property
def path_act = "C:/Users/abc.xlsx"
def cellArrayActual = FileHandling.returnExcelResults(path_act, "MEMBER_PREMIUM")
then:
title == "Welcome"
}
}
I feel the problem is not in code, something wrong in POM.xml dependencies, Please let me know what is wrong in it.
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Automation</groupId>
<artifactId>Automation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-1.8</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.1.8</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.gebish</groupId>
<artifactId>geb-spock</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>0.7-groovy-2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.37.1</version>
</dependency>
</dependencies>
If FileHandling is your class, shouldn't your import be import FileHandle rather than import FileHandle.*?
Import the FileHandling class with its package name, like
import test.groovy.FileHandling.*
If FileHandling is not extending Page class of GEB then you have to instantiate the class as below.
static def fileHandle = new FileHandling()
And call the method inside FileHandling class using the above def fileHandle object,
def cellArrayActual = fileHandle.returnExcelResults(path_act, "MEMBER_PREMIUM")
If FileHandling is extending Page class of GEB
class FileHandling extends Page{}
then you have to use At checker before calling the method.
when:
go() // uses base url system property
def path_act = "C:/Users/abc.xlsx"
at FileHandling
def cellArrayActual = FileHandling.returnExcelResults(path_act, "MEMBER_PREMIUM")

Resources