/** * Build the RestTemplate used to make HTTP requests. * @return RestTemplate */ protected RestTemplate buildRestTemplate() { RestTemplate restTemplate = new RestTemplate(); // This allows us to read the response more than once - Necessary for debugging. restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(restTemplate.getRequestFactory())); return restTemplate; }
@Override protected ClientHttpRequestFactory createRequestFactory() { return new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()); }
@Override public MockRestServiceServer build(RequestExpectationManager manager) { MockRestServiceServer server = new MockRestServiceServer(manager); MockClientHttpRequestFactory factory = server.new MockClientHttpRequestFactory(); if (this.restTemplate != null) { if (this.bufferContent) { this.restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(factory)); } else { this.restTemplate.setRequestFactory(factory); } } if (this.asyncRestTemplate != null) { this.asyncRestTemplate.setAsyncRequestFactory(factory); } return server; } }
/** * Decorates a request factory to buffer responses so that the responses may be repeatedly read. * @param requestFactory the request factory to be decorated for buffering * @return a buffering request factory */ public static ClientHttpRequestFactory bufferRequests(ClientHttpRequestFactory requestFactory) { return new BufferingClientHttpRequestFactory(requestFactory); }
/** * Decorates a request factory to buffer responses so that the responses may be repeatedly read. * @param requestFactory the request factory to be decorated for buffering * @return a buffering request factory */ public static ClientHttpRequestFactory bufferRequests(ClientHttpRequestFactory requestFactory) { return new BufferingClientHttpRequestFactory(requestFactory); }
/** * Decorates a request factory to buffer responses so that the responses may be repeatedly read. * @param requestFactory the request factory to be decorated for buffering * @return a buffering request factory */ public static ClientHttpRequestFactory bufferRequests(ClientHttpRequestFactory requestFactory) { return new BufferingClientHttpRequestFactory(requestFactory); }
private RamlRestTemplate(RamlChecker ramlChecker, boolean notSending, ReportStore reportStore, ClientHttpRequestFactory requestFactory) { this.ramlChecker = ramlChecker; this.notSending = notSending; this.reportStore = reportStore; this.originalRequestFactory = requestFactory; final RamlRequestInterceptor interceptor = new RamlRequestInterceptor(ramlChecker, notSending, reportStore); setRequestFactory(new InterceptingClientHttpRequestFactory( new BufferingClientHttpRequestFactory(requestFactory), Collections.<ClientHttpRequestInterceptor>singletonList(interceptor))); }
private RamlRestTemplate(RamlChecker ramlChecker, boolean notSending, ReportStore reportStore, ClientHttpRequestFactory requestFactory) { this.ramlChecker = ramlChecker; this.notSending = notSending; this.reportStore = reportStore; this.originalRequestFactory = requestFactory; final RamlRequestInterceptor interceptor = new RamlRequestInterceptor(ramlChecker, notSending, reportStore); setRequestFactory(new InterceptingClientHttpRequestFactory( new BufferingClientHttpRequestFactory(requestFactory), Collections.<ClientHttpRequestInterceptor>singletonList(interceptor))); }
@Override public MockRestServiceServer build(RequestExpectationManager manager) { MockRestServiceServer server = new MockRestServiceServer(manager); MockClientHttpRequestFactory factory = server.new MockClientHttpRequestFactory(); if (this.restTemplate != null) { if (this.bufferContent) { this.restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(factory)); } else { this.restTemplate.setRequestFactory(factory); } } if (this.asyncRestTemplate != null) { this.asyncRestTemplate.setAsyncRequestFactory(factory); } return server; } }