use of org.testng.annotations.DataProvider in project rest.li by linkedin.
the class TestRestLiRouting method nKeyAssociationRoutingBatch.
@DataProvider(name = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "nKeyAssociationRoutingBatch")
public Object[][] nKeyAssociationRoutingBatch() {
CompoundKey key1 = new CompoundKey();
key1.append("foo", "1,1").append("bar", "1:2");
CompoundKey key2 = new CompoundKey();
key2.append("foo", "2,1").append("bar", "2;2");
Set<CompoundKey> keys = new HashSet<CompoundKey>();
keys.add(key1);
keys.add(key2);
return new Object[][] { { "/test?ids=bar%3D1%253A2%26foo%3D1%252C1&ids=bar%3D2%253B2%26foo%3D2%252C1", AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion(), "GET", ResourceMethod.BATCH_GET, "batchGet", keys }, { "/test?ids=List((bar:1%3A2,foo:1%2C1),(bar:2;2,foo:2%2C1))", AllProtocolVersions.RESTLI_PROTOCOL_2_0_0.getProtocolVersion(), "GET", ResourceMethod.BATCH_GET, "batchGet", keys } };
}
use of org.testng.annotations.DataProvider in project rest.li by linkedin.
the class TestRestCompressionEcho method compressionEchoData.
@DataProvider
public Object[][] compressionEchoData() {
EncodingType[] encodings = new EncodingType[] { EncodingType.GZIP, EncodingType.SNAPPY, EncodingType.IDENTITY };
Object[][] args = new Object[4 * encodings.length * encodings.length][2];
int cur = 0;
for (EncodingType requestEncoding : encodings) {
for (EncodingType acceptEncoding : encodings) {
RestFilter clientCompressionFilter = new ClientCompressionFilter(requestEncoding, new CompressionConfig(THRESHOLD), new EncodingType[] { acceptEncoding }, new CompressionConfig(THRESHOLD), Arrays.asList(new String[] { "*" }));
TransportClientFactory factory = new HttpClientFactory.Builder().setFilterChain(FilterChains.createRestChain(clientCompressionFilter)).build();
Client http1Client = new TransportClientAdapter(factory.getClient(getHttp1ClientProperties()), REST_OVER_STREAM);
Client http2Client = new TransportClientAdapter(factory.getClient(getHttp2ClientProperties()), REST_OVER_STREAM);
args[cur][0] = http1Client;
args[cur][1] = LARGE_BYTES_NUM;
args[cur + 1][0] = http2Client;
args[cur + 1][1] = LARGE_BYTES_NUM;
cur += 2;
_clientFactories.add(factory);
_clients.add(http1Client);
_clients.add(http2Client);
}
}
// test data that won't trigger compression
for (EncodingType requestEncoding : encodings) {
for (EncodingType acceptEncoding : encodings) {
RestFilter clientCompressionFilter = new ClientCompressionFilter(requestEncoding, new CompressionConfig(THRESHOLD), new EncodingType[] { acceptEncoding }, new CompressionConfig(THRESHOLD), Arrays.asList(new String[] { "*" }));
TransportClientFactory factory = new HttpClientFactory.Builder().setFilterChain(FilterChains.createRestChain(clientCompressionFilter)).build();
Client http1Client = new TransportClientAdapter(factory.getClient(getHttp1ClientProperties()), REST_OVER_STREAM);
Client http2Client = new TransportClientAdapter(factory.getClient(getHttp2ClientProperties()), REST_OVER_STREAM);
args[cur][0] = http1Client;
args[cur][1] = SMALL_BYTES_NUM;
args[cur + 1][0] = http2Client;
args[cur + 1][1] = SMALL_BYTES_NUM;
cur += 2;
_clientFactories.add(factory);
_clients.add(http1Client);
_clients.add(http2Client);
}
}
return args;
}
use of org.testng.annotations.DataProvider in project rest.li by linkedin.
the class TestRequestCompression method requestCompressionData.
@DataProvider
public Object[][] requestCompressionData() {
StreamEncodingType[] encodings = new StreamEncodingType[] { StreamEncodingType.GZIP, StreamEncodingType.DEFLATE, StreamEncodingType.SNAPPY_FRAMED, StreamEncodingType.BZIP2 };
String[] protocols = new String[] { HttpProtocolVersion.HTTP_1_1.name(), HttpProtocolVersion.HTTP_2.name() };
Object[][] args = new Object[encodings.length * protocols.length][2];
int cur = 0;
for (StreamEncodingType requestEncoding : encodings) {
for (String protocol : protocols) {
StreamFilter clientCompressionFilter = new ClientStreamCompressionFilter(requestEncoding, new CompressionConfig(THRESHOLD), null, new CompressionConfig(THRESHOLD), Arrays.asList(new String[] { "*" }), _executor);
TransportClientFactory factory = new HttpClientFactory.Builder().setFilterChain(FilterChains.createStreamChain(clientCompressionFilter)).build();
HashMap<String, String> properties = new HashMap<>();
properties.put(HttpClientFactory.HTTP_PROTOCOL_VERSION, protocol);
Client client = new TransportClientAdapter(factory.getClient(properties), true);
args[cur][0] = client;
args[cur][1] = URI.create("/" + requestEncoding.getHttpName());
cur++;
_clientFactories.add(factory);
_clients.add(client);
}
}
return args;
}
use of org.testng.annotations.DataProvider in project rest.li by linkedin.
the class TestClientStreamCompressionFilter method provideRequestData.
@DataProvider(name = "requestData")
private Object[][] provideRequestData() {
CompressionConfig smallThresholdConfig = new CompressionConfig(1);
CompressionConfig largeThresholdConfig = new CompressionConfig(10000);
return new Object[][] { { new CompressionConfig(Integer.MAX_VALUE), CompressionOption.FORCE_OFF, false, "" }, { new CompressionConfig(Integer.MAX_VALUE), CompressionOption.FORCE_ON, true, "" }, { new CompressionConfig(Integer.MAX_VALUE), null, false, "" }, { new CompressionConfig(0), CompressionOption.FORCE_OFF, false, "" }, { new CompressionConfig(0), CompressionOption.FORCE_ON, true, "" }, { new CompressionConfig(0), null, true, "" }, { smallThresholdConfig, CompressionOption.FORCE_OFF, false, "" }, { smallThresholdConfig, CompressionOption.FORCE_ON, true, "" }, { smallThresholdConfig, null, true, "" }, { largeThresholdConfig, CompressionOption.FORCE_OFF, false, "" }, { largeThresholdConfig, CompressionOption.FORCE_ON, true, "" }, { largeThresholdConfig, null, false, "" }, // The same tests, but with null instead of an empty string
{ new CompressionConfig(Integer.MAX_VALUE), CompressionOption.FORCE_OFF, false, null }, { new CompressionConfig(Integer.MAX_VALUE), CompressionOption.FORCE_ON, true, null }, { new CompressionConfig(Integer.MAX_VALUE), null, false, null }, { new CompressionConfig(0), CompressionOption.FORCE_OFF, false, null }, { new CompressionConfig(0), CompressionOption.FORCE_ON, true, null }, { new CompressionConfig(0), null, true, null }, { smallThresholdConfig, CompressionOption.FORCE_OFF, false, null }, { smallThresholdConfig, CompressionOption.FORCE_ON, true, null }, { smallThresholdConfig, null, true, null }, { largeThresholdConfig, CompressionOption.FORCE_OFF, false, null }, { largeThresholdConfig, CompressionOption.FORCE_ON, true, null }, { largeThresholdConfig, null, false, null } };
}
use of org.testng.annotations.DataProvider in project rest.li by linkedin.
the class TestHttpClient method configs.
@DataProvider
public Object[][] configs() {
Map<String, String> http1ClientProperties = new HashMap<>();
http1ClientProperties.put(HttpClientFactory.HTTP_PROTOCOL_VERSION, HttpProtocolVersion.HTTP_1_1.name());
http1ClientProperties.put(HttpClientFactory.HTTP_REQUEST_TIMEOUT, Integer.toString(REQUEST_TIMEOUT));
Map<String, String> http2ClientProperties = new HashMap<>();
http2ClientProperties.put(HttpClientFactory.HTTP_PROTOCOL_VERSION, HttpProtocolVersion.HTTP_2.name());
http2ClientProperties.put(HttpClientFactory.HTTP_REQUEST_TIMEOUT, Integer.toString(REQUEST_TIMEOUT));
TransportDispatcher dispatcher = new TransportDispatcherBuilder().addRestHandler(DISPATCHER_URI, new EchoHandler()).build();
return new Object[][] { { new HttpServerFactory().createH2cServer(PORT, dispatcher, REST_OVER_STREAM), new TransportClientAdapter(_clientFactory.getClient(http1ClientProperties), REST_OVER_STREAM) }, { new HttpServerFactory().createH2cServer(PORT, dispatcher, REST_OVER_STREAM), new TransportClientAdapter(_clientFactory.getClient(http2ClientProperties), REST_OVER_STREAM) }, { new HttpServerFactory().createH2cServer(PORT, dispatcher, NOT_REST_OVER_STREAM), new TransportClientAdapter(_clientFactory.getClient(http1ClientProperties), NOT_REST_OVER_STREAM) }, { new HttpServerFactory().createH2cServer(PORT, dispatcher, NOT_REST_OVER_STREAM), new TransportClientAdapter(_clientFactory.getClient(http2ClientProperties), NOT_REST_OVER_STREAM) } };
}
Aggregations