[TEST] expand RequestLoggerTests to all the supported http methods

This commit is contained in:
javanna 2016-06-03 18:23:52 +02:00 committed by Luca Cavanna
parent c48b7a7a97
commit 29eee328fe
1 changed files with 13 additions and 1 deletions

View File

@ -24,9 +24,12 @@ import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.ProtocolVersion; import org.apache.http.ProtocolVersion;
import org.apache.http.client.methods.HttpHead; import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpOptions;
import org.apache.http.client.methods.HttpPatch;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.methods.HttpTrace;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicHttpResponse; import org.apache.http.message.BasicHttpResponse;
import org.apache.http.message.BasicStatusLine; import org.apache.http.message.BasicStatusLine;
@ -46,7 +49,7 @@ public class RequestLoggerTests extends LuceneTestCase {
URI uri = new URI("/index/type/_api"); URI uri = new URI("/index/type/_api");
HttpRequestBase request; HttpRequestBase request;
int requestType = RandomInts.randomIntBetween(random(), 0, 4); int requestType = RandomInts.randomIntBetween(random(), 0, 7);
switch(requestType) { switch(requestType) {
case 0: case 0:
request = new HttpGetWithEntity(uri); request = new HttpGetWithEntity(uri);
@ -63,6 +66,15 @@ public class RequestLoggerTests extends LuceneTestCase {
case 4: case 4:
request = new HttpHead(uri); request = new HttpHead(uri);
break; break;
case 5:
request = new HttpTrace(uri);
break;
case 6:
request = new HttpOptions(uri);
break;
case 7:
request = new HttpPatch(uri);
break;
default: default:
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }