Skip to content

Commit

Permalink
Merge pull request Azure#34 from chetanmeh/large-response-test
Browse files Browse the repository at this point in the history
Increase response chunk size limit to 2 MB
  • Loading branch information
moderakh authored Apr 24, 2018
2 parents 294a774 + df5cd0c commit 8878e52
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static com.microsoft.azure.cosmosdb.BridgeInternal.toFeedResponsePage;
import static com.microsoft.azure.cosmosdb.BridgeInternal.toResourceResponse;
import static com.microsoft.azure.cosmosdb.BridgeInternal.toStoredProcedureResponse;
import static org.apache.commons.io.FileUtils.ONE_MB;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -271,7 +272,7 @@ private PipelineConfigurator createClientPipelineConfigurator() {
MAX_REQUEST_HEADER_SIZE,
HttpClientPipelineConfigurator.MAX_CHUNK_SIZE_DEFAULT,
true),
new HttpObjectAggregationConfigurator<>());
new HttpObjectAggregationConfigurator((int)(ONE_MB * 2)));
return clientPipelineConfigurator;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import org.apache.commons.lang3.StringUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Factory;
Expand All @@ -43,6 +44,8 @@

import rx.Observable;

import static org.apache.commons.io.FileUtils.ONE_MB;

public class DocumentCrudTest extends TestSuiteBase {

public final static String DATABASE_ID = getDatabaseId(DocumentCrudTest.class);
Expand Down Expand Up @@ -72,6 +75,24 @@ public void createDocument() throws Exception {
validateSuccess(createObservable, validator);
}

@Test(groups = { "simple" }, timeOut = TIMEOUT)
public void createLargeDocument() throws Exception {
Document docDefinition = getDocumentDefinition();

//Keep size as ~ 1.5MB to account for size of other props
int size = (int) (ONE_MB * 1.5);
docDefinition.set("largeString", StringUtils.repeat("x", size));

Observable<ResourceResponse<Document>> createObservable = client
.createDocument(getCollectionLink(), docDefinition, null, false);

ResourceResponseValidator<Document> validator = new ResourceResponseValidator.Builder<Document>()
.withId(docDefinition.getId())
.build();

validateSuccess(createObservable, validator);
}

@Test(groups = { "simple" }, timeOut = TIMEOUT)
public void createDocument_AlreadyExists() throws Exception {
Document docDefinition = getDocumentDefinition();
Expand Down

0 comments on commit 8878e52

Please sign in to comment.