You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Hemang Ajmera (JIRA)" <ji...@apache.org> on 2019/07/18 09:34:00 UTC
[jira] [Created] (CAMEL-13766) Salesforce component Mocking does
not work correctly
Hemang Ajmera created CAMEL-13766:
-------------------------------------
Summary: Salesforce component Mocking does not work correctly
Key: CAMEL-13766
URL: https://issues.apache.org/jira/browse/CAMEL-13766
Project: Camel
Issue Type: Bug
Components: camel-salesforce
Affects Versions: 2.24.0
Reporter: Hemang Ajmera
In my unit test, I am replacing salesfoce component with a mock. However, still the component is getting activated with being replace with mock. Because of this test case fails in our Jenkins environment as from Jenkins server, there is no connectivity to salesforce.
Here is the part of unit test code
{code:java}
@EndpointInject(uri = "mock:salesforce:query")
private MockEndpoint sfMock;
String sfResponse = "{}"; // Expected response value from SF
RouteDefinition mainRoute = context.getRouteDefinition("main-route");
mainRoute.adviceWith(context, new AdviceWithRouteBuilder(){
@Override
public void configure() throws Exception {
mockEndpointsAndSkip("salesforce.*");
}
});
sfMock.whenAnyExchangeReceived(new Processor(){
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody(sfResponse);
}
});{code}
Here is the logs in my local machine
{quote}
2019-07-18 13:43:42.719 INFO 4288 --- [ main] org.eclipse.jetty.util.log : Logging initialized @22433ms to org.eclipse.jetty.util.log.Slf4jLog}}
{{2019-07-18 13:43:42.890 INFO 4288 --- [ main] o.a.c.util.jsse.SSLContextParameters : Available providers: SUN version 1.8.}}
{{2019-07-18 13:43:43.608 INFO 4288 --- [ main] o.a.c.c.s.internal.SalesforceSession : Login at Salesforce loginUrl: https://test.salesforce.com/services/oauth2/token}}
{{2019-07-18 13:43:46.514 INFO 4288 --- [ main] o.a.c.c.s.internal.SalesforceSession : Login successful}}
{{2019-07-18 13:43:46.519 INFO 4288 --- [ main] o.a.c.c.salesforce.SalesforceComponent : Found 0 generated classes in packages: [org.apache.camel.salesforce.dto]}}
{{2019-07-18 13:43:46.523 INFO 4288 --- [ main] .c.i.InterceptSendToMockEndpointStrategy : Adviced endpoint [salesforce://query?format=JSON&rawPayload=true&sObjectQuery=SELECT+Id%2C+OwnerId%2CLastModifiedById%2CLastModifiedDate+FROM+Account+WHERE+Id+IN%28%27abcd%27%29] with mock endpoint [mock:salesforce:query]
{quote}
We can clearly see the component is initiated first and then replaced with mock. The idea of replacing with mock is that we should be able to test even if component cannot be initiated.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)