private OperationRequest createRequestWithContent(String content) { return this.requestFactory.create(URI.create("http://localhost"), HttpMethod.GET, content.getBytes(), new HttpHeaders(), new Parameters(), Collections.<OperationRequestPart>emptyList()); }
private OperationRequest createRequest(Parameters parameters) { return new OperationRequestFactory().create(URI.create("http://localhost:8080"), HttpMethod.GET, new byte[0], new HttpHeaders(), parameters, Collections.<OperationRequestPart>emptyList()); }
private OperationRequest createRequestWithHeader(String name, String value) { HttpHeaders headers = new HttpHeaders(); headers.add(name, value); return this.requestFactory.create(URI.create("http://localhost"), HttpMethod.GET, new byte[0], headers, new Parameters(), Collections.<OperationRequestPart>emptyList()); }
private OperationRequest buildRequest() { List<OperationRequestPart> parts = new ArrayList<>(); for (OperationRequestPartBuilder builder : this.partBuilders) { parts.add(builder.buildPart()); } return new OperationRequestFactory().create(this.requestUri, this.method, this.content, this.headers, this.parameters, parts, this.cookies); }
private OperationRequest createRequestWithUri(String uri) { return this.requestFactory.create(URI.create(uri), HttpMethod.GET, new byte[0], new HttpHeaders(), new Parameters(), Collections.<OperationRequestPart>emptyList()); }
private OperationRequest createRequestWithUri(String uri) { return this.requestFactory.create(URI.create(uri), HttpMethod.GET, new byte[0], new HttpHeaders(), new Parameters(), Collections.<OperationRequestPart>emptyList()); }
private OperationRequest createRequestWithContent(String content) { return this.requestFactory.create(URI.create("http://localhost"), HttpMethod.GET, content.getBytes(), new HttpHeaders(), new Parameters(), Collections.<OperationRequestPart>emptyList()); }
private OperationRequest createRequestWithHeader(String name, String value) { HttpHeaders headers = new HttpHeaders(); headers.add(name, value); return this.requestFactory.create(URI.create("http://localhost"), HttpMethod.GET, new byte[0], headers, new Parameters(), Collections.<OperationRequestPart>emptyList()); }
private static OperationRequest createRequest() { return new OperationRequestFactory().create(URI.create("http://localhost:8080"), null, null, new HttpHeaders(), null, null); }
private OperationRequest createRequestWithPartWithHeader(String name, String value) { HttpHeaders headers = new HttpHeaders(); headers.add(name, value); return this.requestFactory.create(URI.create("http://localhost"), HttpMethod.GET, new byte[0], new HttpHeaders(), new Parameters(), Arrays.asList(new OperationRequestPartFactory().create("part", "fileName", new byte[0], headers))); }
private OperationRequest createRequestWithPartWithHeader(String name, String value) { HttpHeaders headers = new HttpHeaders(); headers.add(name, value); return this.requestFactory.create(URI.create("http://localhost"), HttpMethod.GET, new byte[0], new HttpHeaders(), new Parameters(), Arrays.asList(new OperationRequestPartFactory().create("part", "fileName", new byte[0], headers))); }
private OperationRequest createRequestWithPartWithContent(String content) { return this.requestFactory.create(URI.create("http://localhost"), HttpMethod.GET, new byte[0], new HttpHeaders(), new Parameters(), Arrays.asList(new OperationRequestPartFactory().create("part", "fileName", content.getBytes(), new HttpHeaders()))); }
private OperationRequest createRequestWithPartWithContent(String content) { return this.requestFactory.create(URI.create("http://localhost"), HttpMethod.GET, new byte[0], new HttpHeaders(), new Parameters(), Arrays.asList(new OperationRequestPartFactory().create("part", "fileName", content.getBytes(), new HttpHeaders()))); }
@Test public void resultingRequestHasCookiesFromOriginalRequst() { List<RequestCookie> cookies = Arrays.asList(new RequestCookie("a", "alpha")); OperationRequest request = this.requestFactory.create( URI.create("http://localhost:12345"), HttpMethod.GET, new byte[0], new HttpHeaders(), new Parameters(), Collections.<OperationRequestPart>emptyList(), cookies); OperationRequest processed = this.preprocessor.preprocess(request); assertThat(processed.getCookies().size()).isEqualTo(1); }
@Test public void resultingRequestHasCookiesFromOriginalRequst() { List<RequestCookie> cookies = Arrays.asList(new RequestCookie("a", "alpha")); OperationRequest request = this.requestFactory.create( URI.create("http://localhost:12345"), HttpMethod.GET, new byte[0], new HttpHeaders(), new Parameters(), Collections.<OperationRequestPart>emptyList(), cookies); OperationRequest processed = this.preprocessor.preprocess(request); assertThat(processed.getCookies().size()).isEqualTo(1); }
@Test public void modifyRequestContent() { OperationRequest request = this.requestFactory.create( URI.create("http://localhost"), HttpMethod.GET, "content".getBytes(), new HttpHeaders(), new Parameters(), Collections.<OperationRequestPart>emptyList()); OperationRequest preprocessed = this.preprocessor.preprocess(request); assertThat(preprocessed.getContent()).isEqualTo("modified".getBytes()); }
@Test public void contentLengthIsUpdated() { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentLength(7); OperationRequest request = this.requestFactory.create( URI.create("http://localhost"), HttpMethod.GET, "content".getBytes(), httpHeaders, new Parameters(), Collections.<OperationRequestPart>emptyList()); OperationRequest preprocessed = this.preprocessor.preprocess(request); assertThat(preprocessed.getHeaders().getContentLength()).isEqualTo(8L); }
@Override public OperationRequest convert(FilterableRequestSpecification requestSpec) { return new OperationRequestFactory().create(URI.create(requestSpec.getURI()), HttpMethod.valueOf(requestSpec.getMethod()), extractContent(requestSpec), extractHeaders(requestSpec), extractParameters(requestSpec), extractParts(requestSpec), extractCookies(requestSpec)); }
@Test public void modifyRequestHeaders() { OperationRequest request = this.requestFactory.create( URI.create("http://localhost"), HttpMethod.GET, new byte[0], getHttpHeaders(), new Parameters(), Collections.<OperationRequestPart>emptyList()); OperationRequest preprocessed = this.preprocessor.preprocess(request); assertThat(preprocessed.getHeaders().size()).isEqualTo(2); assertThat(preprocessed.getHeaders()).containsEntry("a", Arrays.asList("alpha")); assertThat(preprocessed.getHeaders()).containsEntry("Host", Arrays.asList("localhost")); }
@Override public OperationRequest convert(ExchangeResult result) { HttpHeaders headers = extractRequestHeaders(result); return new OperationRequestFactory().create(result.getUrl(), result.getMethod(), result.getRequestBodyContent(), headers, extractParameters(result), extractRequestParts(result), extractCookies(headers)); }