Search in sources :

Example 1 with RestliRequestOptionsBuilder

use of com.linkedin.restli.client.RestliRequestOptionsBuilder in project rest.li by linkedin.

the class TestRequestCompression method requestData.

@DataProvider(name = "requestData")
private Object[][] requestData() {
    int tiny = 10;
    int small = 100;
    int large = 1000;
    int huge = 10000;
    CompressionConfig tinyThresholdConfig = new CompressionConfig(tiny);
    CompressionConfig hugeThresholdConfig = new CompressionConfig(huge);
    String encodings = "unsupportedEncoding, x-snappy-framed, snappy, gzip";
    RestliRequestOptions forceOnOption = new RestliRequestOptionsBuilder().setProtocolVersionOption(ProtocolVersionOption.USE_LATEST_IF_AVAILABLE).setRequestCompressionOverride(CompressionOption.FORCE_ON).build();
    RestliRequestOptions forceOffOption = new RestliRequestOptionsBuilder().setProtocolVersionOption(ProtocolVersionOption.USE_LATEST_IF_AVAILABLE).setRequestCompressionOverride(CompressionOption.FORCE_OFF).build();
    return new Object[][] { // Compression depending on request size
    { null, encodings, RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_COMPRESSION }, { null, encodings, RestliRequestOptions.DEFAULT_OPTIONS, small, EXPECT_NO_COMPRESSION }, // Override the default threshold and cause even small requests to be compressed
    { tinyThresholdConfig, encodings, RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_COMPRESSION }, { tinyThresholdConfig, encodings, RestliRequestOptions.DEFAULT_OPTIONS, small, EXPECT_COMPRESSION }, // Override the default threshold and causes even large requests to be NOT compressed.
    { hugeThresholdConfig, encodings, RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_NO_COMPRESSION }, { hugeThresholdConfig, encodings, RestliRequestOptions.DEFAULT_OPTIONS, small, EXPECT_NO_COMPRESSION }, // Force on/off using RestliRequestOptions
    { null, encodings, forceOnOption, large, EXPECT_COMPRESSION }, { null, encodings, forceOnOption, small, EXPECT_COMPRESSION }, { hugeThresholdConfig, encodings, forceOnOption, small, EXPECT_COMPRESSION }, { null, encodings, forceOffOption, large, EXPECT_NO_COMPRESSION }, { null, encodings, forceOffOption, small, EXPECT_NO_COMPRESSION }, { tinyThresholdConfig, encodings, forceOffOption, large, EXPECT_NO_COMPRESSION }, // Force on/off using RequestCompressionConfig
    { new CompressionConfig(0), encodings, RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_COMPRESSION }, { new CompressionConfig(0), encodings, RestliRequestOptions.DEFAULT_OPTIONS, small, EXPECT_COMPRESSION }, { new CompressionConfig(Integer.MAX_VALUE), encodings, RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_NO_COMPRESSION }, { new CompressionConfig(Integer.MAX_VALUE), encodings, RestliRequestOptions.DEFAULT_OPTIONS, small, EXPECT_NO_COMPRESSION }, // RestliRequestOptions takes precedence over RequestCompressionConfig
    { new CompressionConfig(0), encodings, forceOffOption, large, EXPECT_NO_COMPRESSION }, { new CompressionConfig(Integer.MAX_VALUE), encodings, forceOnOption, small, EXPECT_COMPRESSION }, // Can't compress if no encodings are available
    { null, "unsupportedEncoding", RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_NO_COMPRESSION }, { null, "", RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_NO_COMPRESSION }, { new CompressionConfig(0), "unsupportedEncoding", RestliRequestOptions.DEFAULT_OPTIONS, large, EXPECT_NO_COMPRESSION }, { null, "", forceOnOption, large, EXPECT_NO_COMPRESSION } };
}
Also used : RestliRequestOptions(com.linkedin.restli.client.RestliRequestOptions) RestliRequestOptionsBuilder(com.linkedin.restli.client.RestliRequestOptionsBuilder) CompressionConfig(com.linkedin.r2.filter.CompressionConfig) DataProvider(org.testng.annotations.DataProvider)

Example 2 with RestliRequestOptionsBuilder

use of com.linkedin.restli.client.RestliRequestOptionsBuilder in project rest.li by linkedin.

the class TestResponseCompression method requestData.

@DataProvider(name = "requestData")
private Object[][] requestData() {
    Integer zero = 0;
    Integer tiny = 100;
    Integer huge = 1000000;
    Integer max = Integer.MAX_VALUE;
    int largeIdCount = 100;
    int smallIdCount = 1;
    RestliRequestOptions forceOnOption = new RestliRequestOptionsBuilder().setProtocolVersionOption(ProtocolVersionOption.USE_LATEST_IF_AVAILABLE).setResponseCompressionOverride(CompressionOption.FORCE_ON).build();
    RestliRequestOptions forceOffOption = new RestliRequestOptionsBuilder().setProtocolVersionOption(ProtocolVersionOption.USE_LATEST_IF_AVAILABLE).setResponseCompressionOverride(CompressionOption.FORCE_OFF).build();
    return new Object[][] { // Large responses are compressed
    { true, null, RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, DEFAULT_ACCEPT_ENCODING, null, true }, { true, null, RestliRequestOptions.DEFAULT_OPTIONS, smallIdCount, DEFAULT_ACCEPT_ENCODING, null, false }, // Override the default threshold and cause small responses to be compressed
    { true, new CompressionConfig(tiny), RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, DEFAULT_ACCEPT_ENCODING, tiny.toString(), true }, { true, new CompressionConfig(tiny), RestliRequestOptions.DEFAULT_OPTIONS, smallIdCount, DEFAULT_ACCEPT_ENCODING, tiny.toString(), true }, // Override the default threshold and cause large responses to be NOT compressed
    { true, new CompressionConfig(huge), RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, DEFAULT_ACCEPT_ENCODING, huge.toString(), false }, { true, new CompressionConfig(huge), RestliRequestOptions.DEFAULT_OPTIONS, smallIdCount, DEFAULT_ACCEPT_ENCODING, huge.toString(), false }, // Force on/off using RestliRequestOptions
    { true, null, forceOnOption, largeIdCount, DEFAULT_ACCEPT_ENCODING, zero.toString(), true }, { true, null, forceOnOption, smallIdCount, DEFAULT_ACCEPT_ENCODING, zero.toString(), true }, { true, new CompressionConfig(huge), forceOnOption, smallIdCount, DEFAULT_ACCEPT_ENCODING, zero.toString(), true }, { true, null, forceOffOption, largeIdCount, NONE, null, false }, { true, null, forceOffOption, smallIdCount, NONE, null, false }, { true, new CompressionConfig(huge), forceOffOption, largeIdCount, NONE, null, false }, // Force on/off using ResponseCompressionConfig
    { true, new CompressionConfig(0), RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, DEFAULT_ACCEPT_ENCODING, zero.toString(), true }, { true, new CompressionConfig(0), RestliRequestOptions.DEFAULT_OPTIONS, smallIdCount, DEFAULT_ACCEPT_ENCODING, zero.toString(), true }, { true, new CompressionConfig(Integer.MAX_VALUE), RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, DEFAULT_ACCEPT_ENCODING, max.toString(), false }, { true, new CompressionConfig(Integer.MAX_VALUE), RestliRequestOptions.DEFAULT_OPTIONS, smallIdCount, DEFAULT_ACCEPT_ENCODING, max.toString(), false }, // RestliRequestOptions takes precedence over ResponseCompressionConfig
    { true, new CompressionConfig(0), forceOffOption, largeIdCount, NONE, null, false }, { true, new CompressionConfig(Integer.MAX_VALUE), forceOnOption, smallIdCount, DEFAULT_ACCEPT_ENCODING, zero.toString(), true }, // If http.useResponseCompression is false or null, Accept-Encoding header is not sent and response is not compressed
    { false, null, RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, NONE, null, false }, { false, new CompressionConfig(tiny), RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, NONE, null, false }, { false, null, forceOnOption, largeIdCount, NONE, null, false }, { null, new CompressionConfig(0), RestliRequestOptions.DEFAULT_OPTIONS, largeIdCount, NONE, null, false }, { null, new CompressionConfig(Integer.MAX_VALUE), forceOnOption, smallIdCount, NONE, null, false } };
}
Also used : RestliRequestOptions(com.linkedin.restli.client.RestliRequestOptions) RestliRequestOptionsBuilder(com.linkedin.restli.client.RestliRequestOptionsBuilder) CompressionConfig(com.linkedin.r2.filter.CompressionConfig) DataProvider(org.testng.annotations.DataProvider)

Example 3 with RestliRequestOptionsBuilder

use of com.linkedin.restli.client.RestliRequestOptionsBuilder in project rest.li by linkedin.

the class TestStreamingGreetings method requestBuilderDataProvider.

@DataProvider(name = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
private static Object[][] requestBuilderDataProvider() {
    final RestliRequestOptions defaultOptions = new RestliRequestOptionsBuilder().setProtocolVersionOption(ProtocolVersionOption.USE_LATEST_IF_AVAILABLE).setAcceptResponseAttachments(true).build();
    final RestliRequestOptions nextOptions = new RestliRequestOptionsBuilder().setProtocolVersionOption(ProtocolVersionOption.FORCE_USE_NEXT).setAcceptResponseAttachments(true).build();
    return new Object[][] { { new RootBuilderWrapper<Long, Greeting>(new StreamingGreetingsBuilders(defaultOptions)) }, { new RootBuilderWrapper<Long, Greeting>(new StreamingGreetingsBuilders(nextOptions)) } };
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) RestliRequestOptions(com.linkedin.restli.client.RestliRequestOptions) StreamingGreetingsBuilders(com.linkedin.restli.examples.greetings.client.StreamingGreetingsBuilders) RestliRequestOptionsBuilder(com.linkedin.restli.client.RestliRequestOptionsBuilder) DataProvider(org.testng.annotations.DataProvider)

Aggregations

RestliRequestOptions (com.linkedin.restli.client.RestliRequestOptions)3 RestliRequestOptionsBuilder (com.linkedin.restli.client.RestliRequestOptionsBuilder)3 DataProvider (org.testng.annotations.DataProvider)3 CompressionConfig (com.linkedin.r2.filter.CompressionConfig)2 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)1 StreamingGreetingsBuilders (com.linkedin.restli.examples.greetings.client.StreamingGreetingsBuilders)1