@Override public boolean equals(Object o){ if(this == o){ return true; } if(o instanceof Response){ final Response bean = (Response)o; boolean isEqual = true; // Do not check executionTime: because when constructing ResponseBean // from the UI, it is not possible to get this value: // isEqual = isEqual && (this.executionTime == bean.executionTime); isEqual = isEqual && (this.statusCode == bean.getStatusCode()); isEqual = isEqual && (this.statusLine == null? bean.getStatusLine() == null: this.statusLine.equals(bean.getStatusLine())); isEqual = isEqual && (this.headers == null? bean.getHeaders() == null: this.headers.equals(bean.getHeaders())); isEqual = isEqual && (this.responseBody == null? bean.getResponseBody() == null: Arrays.equals(this.responseBody, bean.getResponseBody())); isEqual = isEqual && (this.testResult == null? bean.getTestResult() == null: this.testResult.equals(bean.getTestResult())); return isEqual; } return false; }
@Override public void setUIFromResponse(final Response response){ // Clear first clearUIResponse(); // Response status line jp_res_status.setStatus(response.getStatusLine()); // Response header jp_res_headers.setHeaders(response.getHeaders()); // Response body if(response.getResponseBody() != null) { jp_res_body.setBody(response.getResponseBody(), response.getContentType()); } // Response test result jp_res_test.setTestResult(response.getTestResult()); // Stats: jp_res_stats.setBodySize(response.getResponseBody().length); jp_res_stats.setExecutionTime(response.getExecutionTime()); }
@Override public void doResponse(final Response response) { SwingUtilities.invokeLater(() -> { // Update the UI: setUIFromResponse(response); // Set lastResponse: lastResponse = response; // Update status message final int bodyLength = response.getResponseBody() != null? response.getResponseBody().length: 0; setStatusMessage("Response time: " + response.getExecutionTime() + " ms" + "; body-size: " + bodyLength + " byte(s)"); }); }
TestResult testResult = response.getTestResult(); if(testResult != null){ failureCount += testResult.getFailureCount(); FileUtil.writeBytes(resFile, response.getResponseBody());
@Override public void doResponse(Response response) { System.out.println("in doResponse()..."); byte[] bodyByte = response.getResponseBody(); String body = new String(bodyByte, Charsets.UTF_8); if(!body.contains("Authorization: Basic c3ViaGFzaDpzdWJoYXNo")){ fail("Pre-emptive Authorization does not happen"); } }
return; if(response.getResponseBody() == null) { JOptionPane.showMessageDialog(view.getContainer(), "Last response does not have body.", if(f != null){ try{ FileUtil.writeBytes(f, response.getResponseBody());
respChildSubElement.appendChild(String.valueOf(bean.getExecutionTime())); respElement.appendChild(respChildSubElement); Attribute codeAttributes = new Attribute("code", String.valueOf(bean.getStatusCode())); respChildSubElement.addAttribute(codeAttributes); respChildSubElement.appendChild(bean.getStatusLine()); respElement.appendChild(respChildSubElement); MultiValueMap<String, String> headers = bean.getHeaders(); if (!headers.isEmpty()) { Attribute keyAttribute = null; byte[] responseBody = bean.getResponseBody(); if (responseBody != null) { TestResult testResult = bean.getTestResult(); if (testResult != null) {