Hi

I have a production route with a groovy script I should test, is there a way to 
mock URL class or do something else to not really make a request to production 
API? The problem is that besides the request part it have some other stuff I 
would like to be tested.

I agree, this route is not as testable as it could be, but for now it comes "as 
is". Could you suggest something?


<route id="route.with.http.in.sctipt">

    <from uri="direct:in"/>
    <script>
        <groovy>
            ... some stuff I should test ...
            def r = new 
URL("http://someproductoinservice.com";).openConnection();
            r.with {
                setRequestMethod("POST")
                setConnectTimeout(60000)
                setReadTimeout(300000)
                setDoOutput(true)
                setRequestProperty("Content-Type", "application/json")
                
getOutputStream().write(request.getHeader('inMsg').getBytes("UTF-8"));
            }
            r.getResponseCode();
            ... more stuff ...
        </groovy>
    </script>
    ...
</route>

Reply via email to