Codota Logo
ComponentTestUtils
Code IndexAdd Codota to your IDE (free)

How to use
ComponentTestUtils
in
com.nike.riposte.server.testutils

Best Java code snippets using com.nike.riposte.server.testutils.ComponentTestUtils (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: Nike-Inc/riposte

ErrorResponsePayloadTestingServerConfig() {
  try {
    port = ComponentTestUtils.findFreePort();
  } catch (IOException e) {
    throw new RuntimeException("Couldn't allocate port", e);
  }
}
origin: Nike-Inc/riposte

public static NettyHttpClientResponse executeRequest(
  FullHttpRequest request, int port, long incompleteCallTimeoutMillis, Consumer<ChannelPipeline> pipelineAdjuster
) throws InterruptedException, TimeoutException, ExecutionException {
  Bootstrap bootstrap = createNettyHttpClientBootstrap();
  try {
    // Connect to the proxyServer.
    Channel ch = connectNettyHttpClientToLocalServer(bootstrap, port);
    try {
      return executeNettyHttpClientCall(ch, request, incompleteCallTimeoutMillis, pipelineAdjuster);
    }
    finally {
      ch.close();
    }
  } finally {
    bootstrap.group().shutdownGracefully();
  }
}
origin: Nike-Inc/riposte

@Test
public void verify_compression_helper_methods_work_as_expected() {
  // given
  String orig = UUID.randomUUID().toString();
  // when
  byte[] gzipped = gzipPayload(orig);
  String ungzipped = ungzipPayload(gzipped);
  byte[] deflated = deflatePayload(orig);
  String inflated = inflatePayload(deflated);
  // then
  assertThat(gzipped).isNotEqualTo(orig.getBytes(UTF_8));
  assertThat(deflated).isNotEqualTo(orig.getBytes(UTF_8));
  assertThat(ungzipped).isEqualTo(orig);
  assertThat(inflated).isEqualTo(orig);
  assertThat(gzipped).isNotEqualTo(deflated);
}
origin: Nike-Inc/riposte

public static NettyHttpClientResponse executeNettyHttpClientCall(
  Channel ch, FullHttpRequest request, long incompleteCallTimeoutMillis, Consumer<ChannelPipeline> pipelineAdjuster
) throws ExecutionException, InterruptedException, TimeoutException {
  CompletableFuture<NettyHttpClientResponse> responseFuture = setupNettyHttpClientResponseHandler(ch, pipelineAdjuster);
  // Send the request.
  ch.writeAndFlush(request);
  // Wait for the response to be received
  return responseFuture.get(incompleteCallTimeoutMillis, TimeUnit.MILLISECONDS);
}
origin: Nike-Inc/riposte

throws IOException, InterruptedException, TimeoutException, ExecutionException {
Bootstrap bootstrap = createNettyHttpClientBootstrap();
Channel proxyServerChannel = connectNettyHttpClientToLocalServer(bootstrap, proxyServerConfig.endpointsPort());
      request()
        .withMethod(HttpMethod.POST)
        .withUri(RouterEndpointForwardingToDelayEndpoint.MATCHING_PATH)
    verifyErrorReceived(response.payload, response.statusCode,
              INTENTIONAL_EXPLOSION_AFTER_LAST_CHUNK_API_ERROR);
      request()
        .withMethod(HttpMethod.POST)
        .withUri(RouterEndpointForwardingToLongerDelayEndpoint.MATCHING_PATH);
origin: Nike-Inc/riposte

assertThat(response.asString()).isEqualTo(DeserializationEndpointWithDecompressionEnabled.RESPONSE_PAYLOAD);
assertThat(
  base64Decode(response.header(RECEIVED_PAYLOAD_BYTES_AS_BASE64_RESPONSE_HEADER_KEY))
).isEqualTo(origPayloadBytes);
assertThat(response.header(SOME_OBJ_FIELD_VALUE_HEADER_KEY)).isEqualTo(origPayload.someField);
origin: Nike-Inc/riposte

String rawBytesOnTheWireBody = extractBodyFromRawRequestOrResponse(rawBytesOnTheWireResponse);
HttpHeaders headersFromRawResponse = extractHeadersFromRawRequestOrResponse(rawBytesOnTheWireResponse);
origin: Nike-Inc/riposte

public static NettyHttpClientResponse executeRequest(
  FullHttpRequest request, int port, long incompleteCallTimeoutMillis
) throws InterruptedException, TimeoutException, ExecutionException {
  return executeRequest(request, port, incompleteCallTimeoutMillis, null);
}
origin: Nike-Inc/riposte

private void verifyRawRequestStuff(CallScenario scenario, String origRequestPayload) {
  verifyProxyAndDownstreamRequestHeaders();
  String downstreamRawRequestBody = extractBodyFromRawRequestOrResponse(downstreamServerRawRequest.toString());
  String proxyRawRequestBody = extractBodyFromRawRequestOrResponse(proxyServerRawRequest.toString());
  if (scenario.isChunkedRequest) {
    // Verify that the request was sent in chunks
    verifyChunked(downstreamRawRequestBody);
    verifyChunked(proxyRawRequestBody);
  }
  else {
    // Verify that the request was NOT sent in chunks
    verifyNotChunked(downstreamRawRequestBody);
    verifyNotChunked(proxyRawRequestBody);
  }
  // Verify that request bodies are functionally equal by removing the chunk metadata (if any) and comparing.
  verifyBodyEqualityMinusChunkMetadata(downstreamRawRequestBody, origRequestPayload);
  verifyBodyEqualityMinusChunkMetadata(proxyRawRequestBody, origRequestPayload);
  verifyBodyEqualityMinusChunkMetadata(proxyRawRequestBody, downstreamRawRequestBody);
}
origin: Nike-Inc/riposte

private void verifyBodyEqualityMinusChunkMetadata(String body1, String body2) {
  String body1MinusChunkMeta = extractFullBodyFromChunks(body1);
  String body2MinusChunkMeta = extractFullBodyFromChunks(body2);
  assertThat(body1MinusChunkMeta).isEqualTo(body2MinusChunkMeta);
}
origin: Nike-Inc/riposte

  public NettyHttpClientResponse execute(Channel ch, long incompleteCallTimeoutMillis) throws InterruptedException, ExecutionException, TimeoutException {
    return executeNettyHttpClientCall(ch, build(), incompleteCallTimeoutMillis, pipelineAdjuster);
  }
}
origin: Nike-Inc/riposte

private static HttpHeaders generateDefaultResponseHeaders(RequestInfo<?> request) {
  String base64EncodedPayload = base64Encode(request.getRawContentBytes());
  return new DefaultHttpHeaders()
    .set(RECEIVED_PAYLOAD_BYTES_AS_BASE64_RESPONSE_HEADER_KEY, base64EncodedPayload)
    .set(RECEIVED_CONTENT_ENCODING_HEADER, String.valueOf(request.getHeaders().get(CONTENT_ENCODING)))
    .set(RECEIVED_CONTENT_LENGTH_HEADER, String.valueOf(request.getHeaders().get(CONTENT_LENGTH)))
    .set(RECEIVED_TRANSFER_ENCODING_HEADER, String.valueOf(request.getHeaders().get(TRANSFER_ENCODING)));
  
}
origin: Nike-Inc/riposte

assertThat(response.asString()).isEqualTo(BasicEndpointWithDecompressionDisabled.RESPONSE_PAYLOAD);
assertThat(
  base64Decode(response.header(RECEIVED_PAYLOAD_BYTES_AS_BASE64_RESPONSE_HEADER_KEY))
).isEqualTo(compressedPayload);
verifyExpectedContentAndTransferHeaders(
origin: Nike-Inc/riposte

public NettyHttpClientResponse execute(int port, long incompleteCallTimeoutMillis) throws Exception {
  return executeRequest(build(), port, incompleteCallTimeoutMillis, pipelineAdjuster);
}
origin: Nike-Inc/riposte

verifyProxyAndDownstreamResponseHeaders(expectProxyToRemoveTransferEncoding);
String downstreamRawResponseBody = extractBodyFromRawRequestOrResponse(downstreamServerRawResponse.toString());
String proxyRawResponseBody = extractBodyFromRawRequestOrResponse(proxyServerRawResponse.toString());
origin: Nike-Inc/riposte

public SSLTestConfig() {
  try {
    port = ComponentTestUtils.findFreePort();
  } catch (IOException e) {
    throw new RuntimeException("Couldn't allocate port", e);
  }
}
origin: Nike-Inc/riposte

assertThat(response.asString()).isEqualTo(BasicEndpointWithDecompressionEnabled.RESPONSE_PAYLOAD);
assertThat(
  base64Decode(response.header(RECEIVED_PAYLOAD_BYTES_AS_BASE64_RESPONSE_HEADER_KEY))
).isEqualTo(origPayloadBytes);
verifyExpectedContentAndTransferHeaders(response, "null", "null", CHUNKED);
origin: Nike-Inc/riposte

public TimeoutsAndProxyTestServerConfig(long workerChannelIdleTimeoutMillis,
                    long cfTimeoutMillis,
                    long incompleteCallTimeoutMillis) {
  try {
    port = ComponentTestUtils.findFreePort();
  } catch (IOException e) {
    throw new RuntimeException("Couldn't allocate port", e);
  }
  this.workerChannelIdleTimeoutMillis = workerChannelIdleTimeoutMillis;
  this.cfTimeoutMillis = cfTimeoutMillis;
  this.incompleteCallTimeoutMillis = incompleteCallTimeoutMillis;
}
origin: Nike-Inc/riposte

assertThat(response.asString()).isEqualTo(BasicEndpointWithDecompressionDisabled.RESPONSE_PAYLOAD);
assertThat(
  base64Decode(response.header(RECEIVED_PAYLOAD_BYTES_AS_BASE64_RESPONSE_HEADER_KEY))
).isEqualTo(origPayloadBytes);
verifyExpectedContentAndTransferHeaders(response, "null", "null", CHUNKED);
origin: Nike-Inc/riposte

public RequestAndResponseFilterTestConfig() {
  try {
    port = ComponentTestUtils.findFreePort();
  } catch (IOException e) {
    throw new RuntimeException("Couldn't allocate port", e);
  }
}
com.nike.riposte.server.testutilsComponentTestUtils

Javadoc

Helper methods for working with component tests.

Most used methods

  • findFreePort
  • base64Decode
  • base64Encode
  • connectNettyHttpClientToLocalServer
  • createNettyHttpClientBootstrap
  • deflatePayload
  • executeNettyHttpClientCall
  • executeRequest
  • extractBodyFromRawRequestOrResponse
  • extractFullBodyFromChunks
  • extractHeadersFromRawRequestOrResponse
  • generatePayload
  • extractHeadersFromRawRequestOrResponse,
  • generatePayload,
  • gzipPayload,
  • headersToMap,
  • inflatePayload,
  • request,
  • setupNettyHttpClientResponseHandler,
  • ungzipPayload,
  • verifyErrorReceived

Popular in Java

  • Making http requests using okhttp
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • PrintStream (java.io)
    A PrintStream adds functionality to another output stream, namely the ability to print representatio
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
  • Collectors (java.util.stream)
  • Logger (org.slf4j)
    The main user interface to logging. It is expected that logging takes place through concrete impleme
  • Option (scala)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now