-
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.
Add helper methods and test coverage to FindProxyDirective
- Loading branch information
1 parent
915852a
commit 6de38eb
Showing
2 changed files
with
78 additions
and
1 deletion.
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
41 changes: 41 additions & 0 deletions
41
src/test/java/com/mabl/net/proxy/FindProxyDirectiveTest.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,41 @@ | ||
package com.mabl.net.proxy; | ||
|
||
import org.junit.Test; | ||
|
||
import java.net.InetSocketAddress; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class FindProxyDirectiveTest { | ||
@Test | ||
public void direct() throws Exception { | ||
final FindProxyDirective directive = FindProxyDirective.parse("DIRECT"); | ||
assertTrue(directive.isDirect()); | ||
assertFalse(directive.isProxy()); | ||
assertEquals(ConnectionType.DIRECT, directive.connectionType()); | ||
assertNull(directive.proxyHostAndPort()); | ||
assertNull(directive.proxyHost()); | ||
assertNull(directive.proxyPort()); | ||
assertEquals("DIRECT", directive.toString()); | ||
assertEquals(directive, FindProxyDirective.parse(" DIRECT ")); | ||
} | ||
|
||
@Test | ||
public void proxy() throws Exception { | ||
final FindProxyDirective directive = FindProxyDirective.parse("PROXY 10.0.0.1:8080"); | ||
assertFalse(directive.isDirect()); | ||
assertTrue(directive.isProxy()); | ||
assertEquals(ConnectionType.PROXY, directive.connectionType()); | ||
assertEquals("10.0.0.1:8080", directive.proxyHostAndPort()); | ||
assertEquals("10.0.0.1", directive.proxyHost()); | ||
assertEquals(new Integer(8080), directive.proxyPort()); | ||
assertEquals(InetSocketAddress.createUnresolved("10.0.0.1", 8080), directive.proxyAddress()); | ||
assertEquals("10.0.0.1", directive.proxyAddress().getHostString()); | ||
assertEquals(8080, directive.proxyAddress().getPort()); | ||
assertEquals("PROXY 10.0.0.1:8080", directive.toString()); | ||
assertEquals(directive, FindProxyDirective.parse(" PROXY 10.0.0.1:8080 ")); | ||
} | ||
} |