... | @@ -81,6 +81,7 @@ class MockHttpServer extends NanoHTTPD { |
... | @@ -81,6 +81,7 @@ class MockHttpServer extends NanoHTTPD { |
|
}
|
|
}
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
### Unit test setup
|
|
### Unit test setup
|
|
```java
|
|
```java
|
|
public class HttpUrlConnectionNetworkTests extends AndroidTestCase {
|
|
public class HttpUrlConnectionNetworkTests extends AndroidTestCase {
|
... | @@ -108,6 +109,53 @@ public class HttpUrlConnectionNetworkTests extends AndroidTestCase { |
... | @@ -108,6 +109,53 @@ public class HttpUrlConnectionNetworkTests extends AndroidTestCase { |
|
}
|
|
}
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### serving assets with NanoHttp
|
|
|
|
Passing in the TestContext allows you to isolate assets to the androidTest apk.
|
|
|
|
|
|
|
|
```
|
|
|
|
mstevens@lt-mstevens-mac2:bztsitecore$ cd src/androidTest/
|
|
|
|
mstevens@lt-mstevens-mac2:androidTest$ tree
|
|
|
|
..
|
|
|
|
|-- assets
|
|
|
|
| |-- soap_GetSiteConfigurationRequest.xml
|
|
|
|
| |-- soap_GetSiteConfigurationResponse.xml
|
|
|
|
| |-- soap_GetSiteInfoRequest.xml
|
|
|
|
| |-- soap_GetSiteInfoResponse.xml
|
|
|
|
| |-- soap_GetTabletConfigurationRequest.xml
|
|
|
|
| |-- soap_GetTabletConfigurationResponse.xml
|
|
|
|
| |-- soap_GetTabletSiteDeviceListRequest.xml
|
|
|
|
| |-- soap_GetTabletSiteDeviceListResponse.xml
|
|
|
|
| |-- w3_xml_to_json.xml
|
|
|
|
| |-- xml_to_json.xml
|
|
|
|
| |-- xml_to_json2.xml
|
|
|
|
| |-- xslt_identity.xml
|
|
|
|
| |-- xslt_outline.xml
|
|
|
|
| `-- xslt_strip_comments.xml
|
|
|
|
`-- java
|
|
|
|
`-- com
|
|
|
|
`-- buzztime
|
|
|
|
|-- net
|
|
|
|
| `-- volley
|
|
|
|
| |-- BTNetVolleyDefaultStackTests.java
|
|
|
|
| |-- BTNetVolleyTests.java
|
|
|
|
| |-- HttpUrlConnectionNetworkTests.java
|
|
|
|
| |-- MockHttpServer.java
|
|
|
|
| `-- SoapRequestTests.java
|
|
|
|
|-- site
|
|
|
|
| `-- core
|
|
|
|
| |-- ApplicationTest.java
|
|
|
|
| |-- BTSiteContentProviderTests.java
|
|
|
|
| |-- BTSiteDBHelperTests.java
|
|
|
|
| |-- BTSiteRoutesTests.java
|
|
|
|
| `-- services
|
|
|
|
| `-- BtStartupServiceTests.java
|
|
|
|
`-- test
|
|
|
|
|-- Repeat.java
|
|
|
|
`-- RepeatRule.java
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
### Simple synchronous network call
|
|
### Simple synchronous network call
|
|
```java
|
|
```java
|
|
public void testSimpleEcho() throws Exception {
|
|
public void testSimpleEcho() throws Exception {
|
... | @@ -135,8 +183,6 @@ The pattern is to initialize the Semaphore with no permits. |
... | @@ -135,8 +183,6 @@ The pattern is to initialize the Semaphore with no permits. |
|
after the async call.. wait with tryAcquire() for a timeout period
|
|
after the async call.. wait with tryAcquire() for a timeout period
|
|
When the listener is called, it releases a permit and tryAcquire() will return.
|
|
When the listener is called, it releases a permit and tryAcquire() will return.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```java
|
|
```java
|
|
public void testStringRequest() throws Exception {
|
|
public void testStringRequest() throws Exception {
|
|
final Semaphore semaphore = new Semaphore(0);
|
|
final Semaphore semaphore = new Semaphore(0);
|
... | | ... | |