Open jamesnetherton opened 2 years ago
At first I thought this was going to be a fairly quick task based on the Geocoder tests, but I found myself heading down a warren of rabbit holes with this.
In order to test the Dropbox extension with Wiremock, the wiremock server URL must be passed to the dropbox client within the Camel component.
I first tried creating an instance of DbxClientV2
(the client supplied by the Dropbox SDK), but it had limited support for passing in a new host - I had to access a private constructor via reflection to be able to pass in the Wiremock URL as well as the credentials.
The next issue was setting the client in the Camel component. I had to create a sub-class of the DropboxComponent
and register that in place of the original. The sub-class overrode the createEndpoint
method that first called the parent implementation and then accessed the DropboxConfiguration
object, to which I could pass the DbxClientV2
object.
However, this still did not work as the DbxClientV2
object doesn't handle port numbers - it only expects hostnames, so URL creation fails.
I don't know if the Wiremock proxy support can be used to create an alias that can be used instead of localhost:{randomPort}
, but I've spent more time than I'd intended on this already.
Thanks for your patient investigation, @djcoleman !
We should perhaps try our luck asking the Dropbox client team for a proper base URI support? https://github.com/dropbox/dropbox-sdk-java/issues
I found a question from 2019 on dropboxforum.com requesting WireMock support. The responder acknowledged the problem and promised to submit a feature request, although he didn't make any commitments to implementing it.
I don't see any tickets in the dropbox-sdk-java issues list already though, so I can submit a request myself and see if anything happens.
@djcoleman could you please paste the Dropbox issue URL here?
Not sure if it is possible or not but it'd be worth investigating to see if we have the tests run on the CI build without requiring real credentials.