I am working on microservices contract testing with Pact and was executing consumer micro service file with Pactflow as the publisher to provider and when i was executing the consumer file the contract file is not getting published to Pactbroker i.e Pactflow from which provider has to pick when it executes
Pre-requisites:
1.In pom.xml, my pactflow configuration is like below:
<configuration>
<pactBrokerUrl>pactflow url</pactBrokerUrl>
<pactBrokerToken>API token to get from Pactflow</pactBrokerToken>
</configuration>
2.Under PactProviderTest file,i have annotation like this:
#PactBroker(url="pact url",
authentication= #PactBrokerAuth(token="API token to get from pactflow"))
Please let me know with the resolution for this
Thank you,
Shiva
Related
Currently I'm using Spring Cloud Contract to test my publishing of events from one microservices to another. After the test run succesfully, I would publish the stubs to be use by other microservices.
In the publisher microservice, I write a Groovy test with Contract.make and specify the input and outputMessage like below.
input {
triggeredBy "triggerEventMethod()"
}
outputMessage {
sentTo "somewhere"
body """
{
"field": "sampleData"
}
"""
headers {
header("contentType", applicationJson())
header("eventName", "SampleEventName")
}
}
In my BaseClass, I annotated the class with #ImportAutoConfiguration(NoOpContractVerifierAutoConfiguration::class) to configure the MessageVerifier and declare my triggerEventMethod() to run some method which would trigger the ApplicationContext to publish the SampleEventName. I have my own custom implementation class of MessageVerifierReceiver which would listen to the SampleEventName and store the message in a ThreadLocal then my override of the receive method just try to retrieve the message available in the ThreadLocal. Then the generated test by spring-cloud-contract would just verify the content of the body and headers of the event.
As far as it goes, this test has been working for more than 2 years and currently after upgrading spring-cloud-contract from 2.2.3.RELEASE to 3.1.1, I'm experiencing errors while running the generated test.
My observation on the newly generated version of test is that it would generate a YAML version of my Groovy contract and place it relatively with the generated test class in generated-test-sources folder. When running the test, it would try to reference the .yml file and hit FileNotFoundException of the .yml file. I try manually remove the the logic where it look for the file and my test case would pass after that, but since it is a generated test, it technically should not be edited this way. Sample referencing of the .yml file as below.
ContractVerifierMessage response = contractVerifierMessaging.receive("somewhere",
contract(this, "sampleEvent.yml"));
Does anyone know any way which I could exclude the generation of .yml or referencing of the YAML contract in my generated test? Or if you have better suggestions of how I could refactor my test of ensuring applicationContext publishing works?
The Groovy files are then generated to stubs for my other microservices to do contract testing and serve as mock data.
I'm new to springboot development and JAVA, I'll be needing your help.
I have created a REST service using springboot to accept and produce message of XML format.
I have generated JAVA class files for XSD schema using JAXB plugin.
I'm able to pass the XML request to the REST service and display the values as well, but in response of service i'm getting 406 HTTP response.
I tried checking stackoverflow for any hint, i found that adding below dependency in pom will resolve the issue. When i added below dependency then i was able to get the proper XML response but then i was unable to get the input XML in the service, i want getting "NULL" object as input to service after adding dependency
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
Can you please help me and let me know how can i pass input XML request and get output XML response as well. Currently either one of the case is working for me.
Thank you
I have resolved this issue by adding #XmlRootElement annotation in all the JAXB generated java class files.
Hope this will help someone!
We have a soap-webservice defined through the Spring(spring-ws) and Spring is generating the wsdl through our config. And we have defined the end-point in our code as:
wsdl11Definition.setLocationUri(http://xyz:8080/dev/ws/abc);
and so the wsdl got generated with the Spring is :
http://xyz:8080/dev/ws/def.wsdl
and the below is what am seeing as the endpoint in the generated wsdl
<soap:address location="http://xyz:8080/dev/ws/abc"/>
But our clients are able to access our service with both of the below.
http://xyz:8080/dev/ws/def.wsdl http://xyz:8080/dev/ws/abc.
How does this work or is working.
Does Spring/tomcat routes or able to route the web-service calls coming in with either the endpoint-path of .wsdl name (def in above) too and also the one with the endpoint (abc in the above) to the end soap web service.
please share any insights, if any have on this. thanks much.
I'm using Spring Security (4.0.1) and Spring Social (1.1.2) to implement authentication to a Spring MVC application using either a Form of using an existing facebook account. Form authentication is working perfectly. However, facebook authentication is not working.
As far as I can see, I've setup the pieces needed to make this work:
created a class that implements SocialConfigurer, adding the facebook connection factory, useridsource (existing AuthenticationNameUserIdSource) and usersconnectionrepository (custom made for use with OrientDB)
Added a line to apply SpringSocialConfigurer in my WebSecurityConfigurerAdapter
Added a SocialUserDetailsService bean
This seems to be working for the most part, but the authentication is not completed. When calling /auth/facebook, the following happens:
redirect to facebook.com oauth (login mechanism)
callback to /auth/facebook on my application, with a lengthy code variable and state variable
redirect to my defaultFailureUrl, without warning, error or any message in log or request variables
So there is something going wrong, but I can't determine what or where exactly.
I've tried to set logging for org.springframework.social to FINEST, but that doesn't show any messages.
Does anyone have any tips how to determine the cause of this failure to complete authentication using facebook?
Thanks in advance,
Sem
I found the answer to my question, I had to configure log4j correctly in order to receive all of Spring's log messages in my default server log.
These log messages helped me to determine the issue at hand: my app signature had been changed. Quite an awkward issue to be stuck with for a long time ..
Hope this helps someone else struggling with Spring issues, make sure you have log4j included in your project, create a log4j properties file and make sure it is available to your container.
For me the following configuration worked:
log4j.rootLogger=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%5p [%t] (%F:%L) - %m%n
I put it in the domain config for my glassfish domain, and added it to the JVM options using the Dlog4j.configuration property.
Regards,
Sem
I am using jmeter jms point to point queue for load testing.
But I am getting the following error:
javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed]
I am using jmeter 2.11 version
I add user name and password in jndi properties. But still it is not working. Here is the configuration i am using:
QueueConnectionFactory: RemoteConnectionFactory
initial context factory: org.jboss.naming.remote.client.InitialContextFactory
url : remote://localhost:4447
JNDI Prpperties:
username: ..............
password: ...........
Your Jndi properties seem wrong, check this:
http://docs.oracle.com/cd/E19182-01/820-7853/ghyco/index.html
Login / password props are :
java.naming.security.principal
The identity of the principal for authenticating the caller to the service. For more information, see the Java API documentation for javax.naming.Context.SECURITY_PRINCIPAL.
java.naming.security.credentials
The credentials of the principal for authenticating the caller to the service. For more information, see the Java API documentation for javax.naming.Context.SECURITY_CREDENTIALS.
I have encountered similar problem while using jmeter for solace, hope this help to someone having similar issue.
For solace jms testing need to use jndi properties since there is no place holder for VPN name. JNDI properties file will look something like this:
java.naming.factory.initial=com.solacesystems.jndi.SolJNDIInitialContextFactory
java.naming.provider.url=<IP:port><br>
Solace_JMS_VPN=<VPN Name><br>
java.naming.security.principal=<username><br>
java.naming.security.credentials=<password>
Here the jndi properties has to be packaged as a jar file and placed in the jmeter lib folder in order to be picked at runtime.
jar cvf my-jndi-properties.jar jndi.properties
Hope this helps.