Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add 3 test cases #2030

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/test/java/org/jsoup/helper/HttpConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,14 @@ public void caseInsensitiveHeaders(Locale locale) {
String actual = connect.request().header("Key");
assertEquals(value, actual);
}

@Test void testHeadersMethod(){
Connection.Request req = new HttpConnection.Request();
req.addHeader("Accept", "Something");
req.addHeader("Foo", "Bar");

Map<String, String> headerMap = req.headers();
assertEquals("Something", headerMap.get("Accept"));
assertEquals("Bar", headerMap.get("Foo"));
}
}
21 changes: 21 additions & 0 deletions src/test/java/org/jsoup/nodes/AttributeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,25 @@ public void html() {
Document doc2 = Jsoup.parse(html, Parser.htmlParser().settings(ParseSettings.preserveCase));
assertEquals("<a href=\"autofocus\" REQUIRED>One</a>", doc2.selectFirst("a").outerHtml());
}

@Test
public void testEquals() {
Attributes attributes = new Attributes();
Attribute attribute = new Attribute("name", "value", attributes);
Attribute sameAttribute = new Attribute("name", "value", attributes);
Attribute differentAttribute = new Attribute("newName", "value", attributes);

assertTrue(attribute.equals(sameAttribute));
assertFalse(attribute.equals(differentAttribute));
}

@Test
public void testClone() {
Attributes attributes = new Attributes();
Attribute attribute = new Attribute("name", "value", attributes);
Attribute clonedAttribute = attribute.clone();
assertEquals(attribute.getKey(), clonedAttribute.getKey());
assertEquals(attribute.getValue(), clonedAttribute.getValue());
}

}