forked from victorwon/mopub-android-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nassar Stoertz and Nathan Shayefar
committed
Oct 22, 2014
1 parent
d98c2b8
commit 29c1b8f
Showing
8 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
mopub-sdk/src/test/java/com/mopub/common/DownloadResponseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.mopub.common; | ||
|
||
import com.mopub.common.test.support.SdkTestRunner; | ||
import com.mopub.common.util.ResponseHeader; | ||
import com.mopub.mobileads.test.support.TestHttpResponseWithHeaders; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.Locale; | ||
|
||
import static org.junit.Assert.assertArrayEquals; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNull; | ||
|
||
@RunWith(SdkTestRunner.class) | ||
public class DownloadResponseTest { | ||
|
||
DownloadResponse subject; | ||
TestHttpResponseWithHeaders mockHttpResponse; | ||
|
||
@Before | ||
public void setup() throws Exception { | ||
mockHttpResponse = new TestHttpResponseWithHeaders(200, "abcde".getBytes()); | ||
mockHttpResponse.addHeader(ResponseHeader.CUSTOM_EVENT_NAME.getKey(), "testCustomEvent"); | ||
mockHttpResponse.addHeader(ResponseHeader.CLICKTHROUGH_URL.getKey().toLowerCase(Locale.US), "http://example.com/"); | ||
mockHttpResponse.addHeader(ResponseHeader.FAIL_URL.getKey().toUpperCase(Locale.US), "http://mopub.com/"); | ||
subject = new DownloadResponse(mockHttpResponse); | ||
} | ||
|
||
@Test | ||
public void testGetByteArray() throws Exception { | ||
assertArrayEquals("abcde".getBytes(), subject.getByteArray()); | ||
} | ||
|
||
@Test | ||
public void testGetStatusCode() throws Exception { | ||
assertEquals(200, subject.getStatusCode()); | ||
} | ||
|
||
@Test | ||
public void testGetContentLength() throws Exception { | ||
assertEquals("abcde".getBytes().length, subject.getContentLength()); | ||
} | ||
|
||
@Test | ||
public void testGetFirstHeader_caseInsensitive() throws Exception { | ||
assertEquals("testCustomEvent", subject.getFirstHeader(ResponseHeader.CUSTOM_EVENT_NAME)); | ||
assertEquals("http://example.com/", subject.getFirstHeader(ResponseHeader.CLICKTHROUGH_URL)); | ||
assertEquals("http://mopub.com/", subject.getFirstHeader(ResponseHeader.FAIL_URL)); | ||
assertNull(subject.getFirstHeader(ResponseHeader.CUSTOM_EVENT_DATA)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters