@Override public String getPath(Request request) { return request.getPath(); }
public boolean isContentBodyChecksum(String checksum) { if (! contentBodyChecksum.toUpperCase().equals(checksum.toUpperCase())) { addViolation(String.format("パス %s のcontent bodyの内容が一致しません", response.getRequest().getPath())); return wrap(false); } return wrap(true); }
public void isContentLength(long bytes) { String value = response.getHeaders().get("Content-Length"); if (value == null) { addViolation(String.format("リクエストパス %s に対して Content-Length がありませんでした", response.getRequest().getPath())); } else if (Long.parseLong(value) == bytes) { // ok } else { addViolation(String.format("パス %s に対するレスポンスのサイズが正しくありません: %s bytes", response.getRequest().getPath(), value)); } }
String path = request.getPath(); String uri = (query == null) ? path : path + "?" + query; String A2 = request.getMethod() + ":" + uri;
public void isStatus(int status) { if (response.getStatus() != status) { addViolation(String.format("パス '%s' へのレスポンスコード %d が期待されていましたが %d でした", response.getRequest().getPath(), status, response.getStatus())); } }
public boolean isContentLength(long bytes) { String value = response.getHeaders().get("Content-Length"); if (value == null) { addViolation(String.format("リクエストパス %s に対して Content-Length がありませんでした", response.getRequest().getPath())); return wrap(false); } else if (Long.parseLong(value) == bytes) { return wrap(true); } else { addViolation(String.format("パス %s に対するレスポンスのサイズが正しくありません: %s bytes", response.getRequest().getPath(), value)); return wrap(false); } }
public boolean isStatus(int status) { if (response.getStatus() != status) { String msg = "パス '%s' へのレスポンスコード %d が期待されていましたが %d でした"; addViolation(String.format(msg, response.getRequest().getPath(), status, response.getStatus())); return wrap(false); } return wrap(true); }
@Test public void testExtraction() { HttpFields fields = new HttpFields(); fields.add(new HttpField("User-Agent", "Test 1.0")); Request request = mock(Request.class); Response response = mock(Response.class); OcJettyHttpClientExtractor extractor = new OcJettyHttpClientExtractor(); when(request.getHost()).thenReturn("localhost"); when(request.getMethod()).thenReturn("GET"); when(request.getHeaders()).thenReturn(fields); when(request.getPath()).thenReturn("/test"); when(request.getURI()).thenReturn(uri); when(response.getStatus()).thenReturn(0); assertThat(extractor.getHost(request)).contains("localhost"); assertThat(extractor.getMethod(request)).contains("GET"); assertThat(extractor.getPath(request)).contains("/test"); assertThat(extractor.getUrl(request)).contains(URI_STR); assertThat(extractor.getRoute(request)).contains(""); assertThat(extractor.getUserAgent(request)).contains("Test 1.0"); assertThat(extractor.getStatusCode(response)).isEqualTo(0); } }
String path = request.getPath(); if (path.trim().length() == 0)
String path = request.getPath(); if (path.trim().length() == 0)
requestInfo = new HttpGenerator.RequestInfo(request.getVersion(), request.getHeaders(), contentLength, request.getMethod().asString(), request.getPath()); break;
String path = request.getPath(); if (path.trim().length() == 0)
requestInfo = new HttpGenerator.RequestInfo(request.getVersion(), request.getHeaders(), contentLength, request.getMethod().asString(), request.getPath()); break;