Skip to content

Commit

Permalink
backfill some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ryber committed Feb 23, 2020
1 parent 4e51997 commit 666faee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
7 changes: 7 additions & 0 deletions unirest/src/test/java/kong/unirest/CookieParsingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ public void secure() {
assertEquals("color=blue;Secure", c.toString());
}

@Test
public void futurePropsDontBreak() {
String v = "color=blue;TheFuture";
Cookie c = new Cookie(v);
assertEquals("color=blue", c.toString());
}

@Test
public void emptyValue() {
String v = "SignOnDefault=; domain=.admin.virginia.edu; path=/; HttpOnly";
Expand Down
28 changes: 21 additions & 7 deletions unirest/src/test/java/kong/unirest/HeadersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,29 @@

import org.junit.Test;

import java.util.Arrays;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

public class HeadersTest {
private String ls = System.lineSeparator();

@Test
public void canGetApacheHeaders() {
public void canGetHeaders() {
Headers headers = new Headers();
headers.add("foo","bar");
headers.add("Accepts","application/json");

Header h = headers.all().get(0);

assertEquals("foo", h.getName());
assertEquals("bar", h.getValue());
assertEquals("Accepts", h.getName());
assertEquals("application/json", h.getValue());
}

@Test
public void dontBombOnNull(){
Headers h = new Headers();
h.add(null, "foo");
h.add(null, "application/json");

assertEquals(0, h.size());
}
Expand All @@ -68,10 +71,10 @@ public void toStringOverride() {
@Test
public void headersAreEqualIfEntryListIsEqual() {
Headers h = new Headers();
h.add("foo", "bar");
h.add("Accepts", "application/json");

Headers j = new Headers();
j.add("foo", "bar");
j.add("Accepts", "application/json");

assertEquals(h, j);
}
Expand All @@ -88,4 +91,15 @@ public void headersAreEqualIfEntryListIsEqual_orderMatters() {

assertNotEquals(h, j);
}

@Test
public void canCreateHeadersFromACollection() {
Headers h = new Headers(Arrays.asList(
new Headers.Entry("Accepts", "application/json"),
new Headers.Entry("Content-Type", "application/xml"))
);

assertEquals("application/json", h.getFirst("Accepts"));
assertEquals("application/xml", h.getFirst("Content-Type"));
}
}

0 comments on commit 666faee

Please sign in to comment.