Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-13766

Salesforce component Mocking does not work correctly

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Not A Problem
    • Affects Version/s: 2.24.0
    • Fix Version/s: None
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      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

          @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);
                  }
              });

      Here is the logs in my local machine
       

      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]

      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.

        Attachments

        1. camel-13766.log.zip
          20 kB
          Hemang Ajmera
        2. CAMEL-13766-Code.zip
          5 kB
          Hemang Ajmera

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              hemangajmera Hemang Ajmera
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: