Unable to read the test data from CSV via ThucydidesParameterizedRunner - serenity-bdd

I am trying to print the value which I am feeding as input inside the CSV file. When run the below set of code through Junit and getting error.
Could some one please help me to come out of this error and print the values successfully
#RunWith(ThucydidesParameterizedRunner.class)
#UseTestDataFrom(value="test-data/simple-data.csv", separator=';')
public class SampleCSVDataDrivenScenario {
private String name;
private String age;
private String address;
public SampleCSVDataDrivenScenario() {
}
#Qualifier
public String getQualifier() {
return name;
}
#Test
public void data_driven() {
System.out.println(getName() + "/" + getAge());
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
Please find the full error log below
java.lang.NoSuchMethodError:
org.junit.runners.model.FrameworkMethod.getDeclaringClass()Ljava/lang/Class;
at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:421)
at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:55)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at net.serenitybdd.junit.runners.SerenityRunner.run(SerenityRunner.java:252)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at net.serenitybdd.junit.runners.SerenityParameterizedRunner.run(SerenityParameterizedRunner.java:206)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
And this is how my CSV file looks like

NoSuchMethodError usually indicates a dependency conflict. You are possibly running the tests with an incompatible version of JUnit - make sure you are using the version of JUnit compatible with the version of Serenity you are using (Serenity has been built with JUnit 4.12 for a while now).

Related

infinispan 9.4 - Listeners and event filter

I'm trying to use Listeners with filters in a distributed cache with two instances of Infinispan 9.4.0 and Hot Rod Client. When I try to put a new entry in cache, I get the following exception:
[Server:instance-one] 13:09:57,468 ERROR [stderr] (HotRod-ServerHandler-4-2) Exception in thread "HotRod-ServerHandler-4-2" org.infinispan.commons.CacheException: ISPN000936: Class 'com.cm.broadcaster.infinispan.entity.EntityDemo' blocked by deserialization white list. Adjust the configuration serialization white list regular expression to include this class.
This is the cache configuration:
<distributed-cache name="entityCache" remote-timeout="3000" statistics-available="false">
<memory>
<object size="20" strategy="LRU" />
</memory>
<compatibility enabled="true"/>
<file-store path="entity-store" passivation="true"/>
<indexing index="NONE"/>
<state-transfer timeout="60000" chunk-size="1024"/>
</distributed-cache>
This is my demo class:
public class EntityDemo implements Serializable {
private static final long serialVersionUID = 1L;
private long id;
private String name;
private String value;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
The EventFilterFactory:
#NamedFactory(name="entity-event-filter-factory")
public class EntityEventFilterFactory implements CacheEventFilterFactory {
#Override
public CacheEventFilter<String, EntityDemo> getFilter(Object[] params) {
return new EntityEventFilter(params);
}
}
The EventFilter:
public class EntityEventFilter implements Serializable, CacheEventFilter<String, EntityDemo> {
private static final long serialVersionUID = 1L;
private final long filter;
public EntityEventFilter(Object[] params) {
this.filter = Long.valueOf(String.valueOf(params[0]));
}
#Override
public boolean accept(String key, EntityDemo oldValue, Metadata oldMetadata, EntityDemo newValue, Metadata newMetadata, EventType eventType) {
if (eventType.isCreate()) {
if (oldValue.getId() % filter == 0)
return true;
}
return false;
}
}
My test code:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.addServers("localhost:11222");
RemoteCacheManager rcm = new RemoteCacheManager(cb.build());
RemoteCache<String, EntityDemo> rc = rcm.<String,
EntityDemo>getCache("entityCache");
rc.addClientListener(new CustomListener(), new Object[]{"1"}, null);
EntityDemo e = new EntityDemo();
e.setId(1);
e.setName("Demo");
e.setValue("Demo");
rc.put("1", e);
The listener:
#ClientListener(filterFactoryName="entity-event-filter-factory")
public class CustomListener {
#ClientCacheEntryCreated
public void entryCreated(ClientCacheEntryCreatedEvent<String> event) {
System.out.println("Entry created!");
System.out.println(event.getKey());
}
}
I have looked about white list for serialization, but I have found nothing.
I tried changing object in memory configuration for binary and disabling compatibility, but then I get a new exception:
[Server:instance-one] 13:56:42,131 ERROR [org.infinispan.interceptors.impl.InvocationContextInterceptor] (HotRod-ServerHandler-4-2) ISPN000136: Error executing command PutKeyValueCommand, writing keys [WrappedByteArray{bytes=[B0x01012903033E0131, hashCode=1999574342}]: java.lang.ClassCastException: java.lang.String cannot be cast to com.cm.broadcaster.infinispan.entity.EntityDemo
Can anyone help me with this?
Have you tried this? Passing the -Dinfinispan.deserialization.whitelist.classes property to the server.
http://infinispan.org/docs/stable/upgrading/upgrading.html#deserialization_whitelist

How to resolve org.testng.internal.reflect.MethodMatcherException in TestNG?

ContactsPage Class:-
public class ContactsPage extends TestBase {
public ContactsPage()
{
PageFactory.initElements(driver, this);
}
public boolean contactsLabel()
{
return contactsLabel.isDisplayed();
}
public void createNewContact1(String subject, String fName, String lName, String petname ) throws InterruptedException, AWTException
{
.....
}
public void createNewContact2(String comp, String comPos, String dept, String conLookSup ) throws InterruptedException
{
.....
}
public void createNewContact3(String conLookAss, String conLookRef ) throws InterruptedException
{
.....
}
}
ContactsPageTest Class:-
public class ContactsPageTest extends TestBase {
TestUtil testUtil;
LoginPage loginpage;
HomePage homepage;
ContactsPage contactsPage;
String sheetName = "Contacts";
public ContactsPageTest() {
super();
}
#BeforeMethod()
public void setUp() throws InterruptedException {
initialzation();
testUtil = new TestUtil();
loginpage = new LoginPage();
homepage = loginpage.login(prop.getProperty("username"), prop.getProperty("password"));
contactsPage = new ContactsPage();
}
/*
* #Test(priority = 1) public void contactsLabelTest() throws
* InterruptedException { testUtil.switchToFrame(); contactsPage =
* homepage.contactsLink(); Thread.sleep(3000);
* Assert.assertTrue(contactsPage.contactsLabel(), "Exception has caught!"); }
*/
#DataProvider
public Object[][] getCRMTestData() {
Object data[][] = TestUtil.getTestData("Contacts");
return data;
}
#Test(priority = 2, dataProvider = "getCRMTestData")
public void createNewContactTest1(String subject, String fName, String lName, String petname)
throws InterruptedException, AWTException {
testUtil.switchToFrame();
homepage.moveToNewContact();
contactsPage.createNewContact1(subject, fName, lName, petname);
}
#Test(priority = 3, dataProvider = "getCRMTestData")
public void createNewContactTest2(String comp, String comPos, String dept, String conLookSup)
throws InterruptedException, AWTException
{
contactsPage.createNewContact2(comp, comPos, dept, conLookSup);
}
#Test(priority = 4, dataProvider = "getCRMTestData")
public void createNewContactTest3(String conLookAss, String conLookRef)
throws InterruptedException, AWTException
{
contactsPage.createNewContact3(conLookAss, conLookRef);
}
#AfterMethod
public void close() {
driver.close();
}
}
Error Message:
FAILED: createNewContactTest1
org.testng.internal.reflect.MethodMatcherException:
Data provider mismatch
Method: createNewContactTest1([Parameter{index=0, type=java.lang.String, declaredAnnotations=[]}, Parameter{index=1, type=java.lang.String, declaredAnnotations=[]}, Parameter{index=2, type=java.lang.String, declaredAnnotations=[]}, Parameter{index=3, type=java.lang.String, declaredAnnotations=[]}])
Arguments: [(java.lang.String) Mr,(java.lang.String) Manideep,(java.lang.String) Latchupatula,(java.lang.String) Deep,(java.lang.String) Accenture,(java.lang.String) ASE,(java.lang.String) CSE,(java.lang.String) TL,(java.lang.String) NA,(java.lang.String) NA]
at org.testng.internal.reflect.DataProviderMethodMatcher.getConformingArguments(DataProviderMethodMatcher.java:45)
at org.testng.internal.Parameters.injectParameters(Parameters.java:796)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:982)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Description: I am working to develop Hybrid Framework by using Selenium. I started off on a positive note but I've been stuck at:
org.testng.internal.reflect.MethodMatcherException.
I have tried for some time but I am clueless. So here, I am.
Could you please let me know where the issue is?
It is throwing MethodMatcherException because you are passing same Data provider to different #Test Method, And Each test method has different Parameter value. Parameters return by #DataProvider and #Test Method should must match in order to retrieve and assign data.
You need to make sure what Data provider is returning, And you can assign it according those Parameters to Test method.
Here your Data Provider is returning Parameters as Following: Its 10
Parameter [Mr,Manideep,Latchupatula,Deep, Accenture, ASE, CSE,TL, NA,
NA]
And You are binding it with 4 Parameters of #Test createNewContactTest1 method:
createNewContactTest1(String subject, String fName, String lName, String petname)
You need to Manage
Your Data provider retrieval code as according to your required Parameters OR
You can create different sheet with required parameters OR
You can add all 10 Parameters to #Test method as according to DP returns

No converter found capable of converting from type [java.lang.String] to type [org.springframework.data.solr.core.geo.Point]

I am trying to use spring-data-solr in order to access to my Solr instance through my Spring boot application. I have the following bean class:
#SolrDocument(solrCoreName = "associations")
public class Association implements PlusimpleEntityI {
#Id
#Indexed
private String id;
#Indexed
private String name;
#Indexed
private Point location;
#Indexed
private String description;
#Indexed
private Set<String> tags;
#Indexed
private Set<String> topics;
#Indexed
private Set<String> professionals;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Point getLocation() {
return location;
}
public void setLocation(Point location) {
this.location = location;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Set<String> getTags() {
return tags;
}
public void setTags(Set<String> tags) {
this.tags = tags;
}
public Set<String> getTopics() {
return topics;
}
public void setTopics(Set<String> topics) {
this.topics = topics;
}
public Set<String> getProfessionals() {
return professionals;
}
public void setProfessionals(Set<String> professionals) {
this.professionals = professionals;
}
}
I have implemented the following repository in order to access to the related information:
public interface AssociationsRepository extends SolrCrudRepository<Association, String> {
}
I have created a configuration class which looks like the following one:
#Configuration
#EnableSolrRepositories(basePackages = {"com.package.repositories"}, multicoreSupport = true)
public class SolrRepositoryConfig {
#Value("${solr.url}")
private String solrHost;
#Bean
public SolrConverter solrConverter() {
MappingSolrConverter solrConverter = new MappingSolrConverter(new SimpleSolrMappingContext());
solrConverter.setCustomConversions(new CustomConversions(null));
return solrConverter;
}
#Bean
public SolrClientFactory solrClientFactory () throws Exception {
return new MulticoreSolrClientFactory(solrClient());
}
#Bean
public SolrClient solrClient() throws Exception {
return new HttpSolrClient.Builder(solrHost).build();
}
#Bean
public SolrOperations associationsTemplate() throws Exception {
SolrTemplate solrTemplate = new SolrTemplate(solrClient());
solrTemplate.setSolrConverter(solrConverter());
return solrTemplate;
}
}
Unfortunately, when I try to read an association from my Solr instance I got the following error:
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [org.springframework.data.solr.core.geo.Point]
I don't understand why it is not able to find a converter if I have explicitly defined it in the solrTemplate() method.
This is my POM definition:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-solr</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
Thank you for your help.
EDIT:
I've also tried with different BUILD-RELEASEs but they are highly unstable and I've found a lot of errors using them.
Alessandro, as you can see directly in the GeoConverters class on GitHub, the implemented converters are only for:
org.springframework.data.geo.Point
and not for:
org.springframework.data.solr.core.geo.Point
Simply use this class and you don't even need a custom converter for this. Spring Data for Solr will perform the conversion for you.
I'm using a slightly patched version of the 3.0.0 M4, but I'm pretty sure this solution should apply seamlessly also to your case.

Getting org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException when parsing fiql expression containing java.util.Calendar attribute

I use FIQL to query a web service built using Apache CXF 3.0.0-milestone1. When I attempt to reference any attribute of type java.util.Calendar I get a org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException. I have tracked down the behavior to the FiqlParser.parse(String expression) call and I am able to reproduce it with the simple code below.
Search bean :
import java.util.Calendar;
import java.util.Date;
public class Book {
private Long id;
private String title;
private Date published;
private Calendar created;
public Book() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Date getPublished() {
return published;
}
public void setPublished(Date published) {
this.published = published;
}
public Calendar getCreated() {
return created;
}
public void setCreated(Calendar created) {
this.created = created;
}
}
Executable class :
import org.apache.cxf.jaxrs.ext.search.SearchCondition;
import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
public class PlayGround {
public static void main(String[] args) {
FiqlParser<Book> parser = new FiqlParser(Book.class);
SearchCondition<Book> condition1 = parser.parse("id=ge=0");
SearchCondition<Book> condition2 = parser.parse("title==*wind*");
SearchCondition<Book> condition3 = parser.parse("published=ge=2014-01-01");
SearchCondition<Book> condition4 = parser.parse("created=ge=2013-01-01");
}
}
PlayGround fails on the following line :
SearchCondition<Book> condition4 = parser.parse("created=ge=2013-01-01");
Stack trace:
Exception in thread "main" org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException
at org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser.parseComparison(FiqlParser.java:294)
at org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser.parseAndsOrsBrackets(FiqlParser.java:252)
at org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser.parse(FiqlParser.java:187)
at PlayGround.main(PlayGround.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
If you put a breakpoint in catch block in method org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser.parseType(String, String, String) you'll see this message for the exception:
org.apache.cxf.jaxrs.ext.search.SearchParseException: Cannot convert String value "2013-01-01" to a value of class java.util.Calendar

schemagen NullpointerException

Java class:
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "user", propOrder = {
"id",
"name" })
public class User {
#XmlAttribute(required=true)
private long id;
#XmlAttribute(required=true)
private String name;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#Override
public String toString() {
return "User [id=" + id + ", name=" + name + "]";
}
}
JDK version : 1.6.0_31
Exception Stack Trace schemagen User.java
C:\anirban\work_eclipse_juno\RestfulWSDemo\src\com\domain>schemagen User.java
An exception has occurred in apt (1.6.0_31). Please file a bug at the Java Devel
oper Connection (http://java.sun.com/webapps/bugreport) after checking the Bug
Parade for duplicates. Include your program and the following diagnostic in your
report. Thank you.
java.lang.NullPointerException
at com.sun.tools.apt.main.CommandLine.parse(CommandLine.java:42)
at com.sun.tools.apt.main.Main.compile(Main.java:775)
at com.sun.tools.apt.Main.processing(Main.java:95)
at com.sun.tools.apt.Main.process(Main.java:85)
at com.sun.tools.apt.Main.process(Main.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.tools.internal.jxc.SchemaGenerator$Runner.main(SchemaGenerato
r.java:215)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.tools.internal.jxc.SchemaGenerator.run(SchemaGenerator.java:1
53)
at com.sun.tools.internal.jxc.SchemaGenerator.run(SchemaGenerator.java:6
3)
at com.sun.tools.internal.jxc.SchemaGenerator.main(SchemaGenerator.java:
55)
Can anyone please help me out here?
Try adding the classpath.
schemagen -cp "%java_home%\lib\tools.jar" User.java