Skip to content

Commit ec66388

Browse files
committed
Merge pull request #19 from shipunyc/master
Fixes typos and bugs.
2 parents ac78c4b + 79e26b4 commit ec66388

File tree

5 files changed

+15
-25
lines changed

5 files changed

+15
-25
lines changed

src/com/microsoft/azure/documentdb/ConnectionPolicy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void setMediaRequestTimeout(int mediaRequestTimeout) {
7373
private ConnectionMode connectionMode;
7474

7575
/**
76-
* Gets the connection mode used in the client. Currently only Gateway in supported.
76+
* Gets the connection mode used in the client. Currently only Gateway is supported.
7777
*
7878
* @return the connection mode.
7979
*/
@@ -82,7 +82,7 @@ public ConnectionMode getConnectionMode() {
8282
}
8383

8484
/**
85-
* Sets the connection mode used in the client. Currently only Gateway in supported.
85+
* Sets the connection mode used in the client. Currently only Gateway is supported.
8686
*
8787
* @param connectionMode the connection mode.
8888
*/

src/com/microsoft/azure/documentdb/DocumentClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private void initialize(URI serviceEndpoint,
129129
this.desiredConsistencyLevel = desiredConsistencyLevel;
130130

131131
UserAgentContainer userAgentContainer = new UserAgentContainer();
132-
String userAgentSuffix = connectionPolicy.getUserAgentSuffix();
132+
String userAgentSuffix = this.connectionPolicy.getUserAgentSuffix();
133133
if(userAgentSuffix != null && userAgentSuffix.length() > 0) {
134134
userAgentContainer.setSuffix(userAgentSuffix);
135135
}

src/com/microsoft/azure/documentdb/DocumentServiceRequest.java

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package com.microsoft.azure.documentdb;
66

77
import java.io.InputStream;
8-
import java.io.UnsupportedEncodingException;
8+
import java.nio.charset.StandardCharsets;
99
import java.util.HashMap;
1010
import java.util.Map;
1111

@@ -98,12 +98,8 @@ public static DocumentServiceRequest create(ResourceType resourceType,
9898
String relativePath,
9999
Resource resource,
100100
Map<String, String> headers) {
101-
try {
102-
HttpEntity body = new StringEntity(resource.toString());
103-
return new DocumentServiceRequest(resourceType, relativePath, body, headers);
104-
} catch (UnsupportedEncodingException e) {
105-
throw new IllegalArgumentException("Failed to get HttpEntity from resource.", e);
106-
}
101+
HttpEntity body = new StringEntity(resource.toString(), StandardCharsets.UTF_8);
102+
return new DocumentServiceRequest(resourceType, relativePath, body, headers);
107103
}
108104

109105
/**
@@ -119,12 +115,8 @@ public static DocumentServiceRequest create(ResourceType resourceType,
119115
String relativePath,
120116
String query,
121117
Map<String, String> headers) {
122-
try {
123-
HttpEntity body = new StringEntity(query);
124-
return new DocumentServiceRequest(resourceType, relativePath, body, headers);
125-
} catch (UnsupportedEncodingException e) {
126-
throw new IllegalArgumentException("Failed to get HttpEntity from resource.", e);
127-
}
118+
HttpEntity body = new StringEntity(query, StandardCharsets.UTF_8);
119+
return new DocumentServiceRequest(resourceType, relativePath, body, headers);
128120
}
129121

130122
/**
@@ -160,12 +152,8 @@ public static DocumentServiceRequest create(ResourceType resourceType,
160152
break;
161153
}
162154

163-
try {
164-
HttpEntity body = new StringEntity(queryText);
165-
return new DocumentServiceRequest(resourceType, relativePath, body, headers);
166-
} catch (UnsupportedEncodingException e) {
167-
throw new IllegalArgumentException("Failed to get HttpEntity from resource.", e);
168-
}
155+
HttpEntity body = new StringEntity(queryText, StandardCharsets.UTF_8);
156+
return new DocumentServiceRequest(resourceType, relativePath, body, headers);
169157
}
170158

171159
/**

src/com/microsoft/azure/documentdb/FeedResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public long getPermissionUsage()
9595
/**
9696
* Max Quota.
9797
*
98-
* @return the document size quota.
98+
* @return the collection size quota.
9999
*/
100100
public long getCollectionSizeQuota() {
101101
return this.getMaxQuotaHeader(Constants.Quota.COLLECTION_SIZE);
@@ -104,7 +104,7 @@ public long getCollectionSizeQuota() {
104104
/**
105105
* Current Usage.
106106
*
107-
* @return the current document size usage.
107+
* @return the current collection size usage.
108108
*/
109109
public long getCollectionSizeUsage() {
110110
return this.getCurrentQuotaHeader(Constants.Quota.COLLECTION_SIZE);

src/com/microsoft/azure/documentdb/test/GatewayTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ public void testDocumentCrud() throws DocumentClientException {
541541
Document documentDefinition = new Document(
542542
"{" +
543543
" 'name': 'sample document'," +
544-
" 'foo': 'bar'," +
544+
" 'foo': 'bar 你好'," + // foo contains some UTF-8 characters.
545545
" 'key': 'value'" +
546546
"}");
547547

@@ -559,6 +559,8 @@ public void testDocumentCrud() throws DocumentClientException {
559559
null,
560560
false).getResource();
561561
Assert.assertEquals(documentDefinition.getString("name"), document.getString("name"));
562+
Assert.assertEquals(documentDefinition.getString("foo"), document.getString("foo"));
563+
Assert.assertEquals(documentDefinition.getString("bar"), document.getString("bar"));
562564
Assert.assertNotNull(document.getId());
563565

564566
// Read documents after creation.

0 commit comments

Comments
 (0)