Closed ayuk23 closed 7 years ago
Doesn't look like you're missing something obvious. Are you using https at all?
@cowboygneox Yes it is definitely making http calls in my test method.
http or https? SSL?
http
What http client?
Are you sure that your http client is correctly proxying to Betamax?
HttpClientDefinition definition = HttpClientDefinition.builder()
.serviceName("service")
.url(url)
.connectionTimeout(Duration.parse("PT2S"))
.readTimeout(Duration.parse("PT2S"))
.writeTimeout(Duration.parse("PT2S"))
.build();
this.client = OkHttpClientConfig.build(definition, new MetricRegistry());
Request request = new Request.Builder().url(url).build();
How can I check that it is correctly proxying? I first get software.betamax.handler.NonWritableTapeException: Tape is not writable
then my program disconnects the proxy to server connection and I get a SocketTimeoutException and then finally a NullPOinterException. If it is the case where I am not correctly proxying to Betamax, how could I fix this? I thought all that was required was to include the betamax annotation.
If you're getting non-writeable tape, that's a good thing, because it means the tape isn't writeable :).
You have to change the TAPE_MODE in the @Betamax
notation. You only rarely want to commit a test with writeable tests; usually you want to write once, and then fix the test to stop writing. Try changing the TAPE_MODE.
Awesome. That definitely worked! Just a heads up though, the documentation at http://betamax.software says that READ_WRITE is the default tape mode, but it doesn't seem like this is the case since not setting mode=TapeMode.READ_WRITE doesn't seem to work.
Thanks again for your help!
That documentation is super old now, but I'll leave this open until I make an actionable item on how to make that more intuitive. I thought about just having local.properties
that allow developers to write to it, but then CI won't. I'll probably move in a direction like that.
Moving this to our Documentation Trello Card: https://trello.com/c/9jdBEGaR
My pom includes this dependency:
and my tests has the following lines of code:
(Note I'm using the Configuration class instead of ProxyConfiguration because there doesn't seem to be a ProxyConfiguration class like in the example like in the examples in this repo)
From the console output, the ProxyServer clearly starts and intercepts my request because I get this warning:
Dec 15, 2016 11:23:39 PM software.betamax.proxy.BetamaxFilters onRequestIntercepted WARNING: no matching request found on my tape
However I get a SocketTimeoutException which shuts down the proxy server and I end up with a null pointer exception:
Am I missing something obvious here? Thanks in advance for the help.