Skip to content

Commit

Permalink
Add xml() method to the FetchResponse.
Browse files Browse the repository at this point in the history
  • Loading branch information
javadev committed Nov 1, 2016
1 parent d6c5107 commit ed96021
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2592,6 +2592,10 @@ public String text() {
public Object json() {
return $.fromJson(text());
}

public Object xml() {
return $.fromXml(text());
}
}

public static FetchResponse fetch(final String url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ public void fetchGet() {
resultChain.item());
}

@SuppressWarnings("unchecked")
@Test
public void fetchGetWithTimeouts() {
$.FetchResponse result = $.fetch("http://www.dragonsofmugloar.com/api/game/483159", 30000, 30000);
Expand All @@ -534,6 +533,13 @@ public void fetchGetWithTimeouts() {
result.text());
}

@SuppressWarnings("unchecked")
@Test
public void fetchGetXml() {
$.FetchResponse result = $.fetch("http://www.dragonsofmugloar.com/weather/api/report/7614759");
assertEquals("NMR", (String) $.get((Map<String, Object>) result.xml(), "code"));
}

@Test(expected = UnsupportedOperationException.class)
public void fetchResponseError() {
java.io.ByteArrayOutputStream stream = new java.io.ByteArrayOutputStream() {
Expand Down

0 comments on commit ed96021

Please sign in to comment.