Skip to content

Commit

Permalink
Subhas/Faris | Set HTTP Socket and Connection timeout
Browse files Browse the repository at this point in the history
Conflicts:
	RapidFTR-Android/src/test/java/com/rapidftr/utils/http/FluentRequestTest.java
  • Loading branch information
Subhas Dandapani committed Feb 12, 2013
1 parent 7c86ba7 commit 22eeadc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public FluentRequest context(Context context) {
this.context = context;
host(getBaseUrl(context));
config(HttpConnectionParams.CONNECTION_TIMEOUT, getConnectionTimeout(context));
config(HttpConnectionParams.SO_TIMEOUT, getConnectionTimeout(context));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.ByteArrayBody;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.params.HttpConnectionParams;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.json.JSONException;
import org.junit.Before;
Expand Down Expand Up @@ -108,6 +109,19 @@ public void testBaseUrlFromContext() throws IOException {
assertThat(http.path("/test").context(context).get(), equalTo(response));
}

@Test
public void testTimeoutFromContext() {
Context context = mock(Context.class);
FluentRequest http = spy(http());

doReturn("example.com").when(http).getBaseUrl(context);
doReturn(1234).when(http).getConnectionTimeout(context);

http.context(context);
verify(http).config(HttpConnectionParams.CONNECTION_TIMEOUT, 1234);
verify(http).config(HttpConnectionParams.SO_TIMEOUT, 1234);
}

@Test
public void testGetShouldCallExecute() throws IOException {
FluentRequest http = spy(http().host("test"));
Expand Down

0 comments on commit 22eeadc

Please sign in to comment.