congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
ComponentTestUtils
Code IndexAdd Tabnine 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)

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

  • Finding current android device location
  • getExternalFilesDir (Context)
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (Timer)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now