forked from Netflix/ribbon
-
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.
Merge pull request Netflix#340 from mattnelson/server_scheme
Support configuring scheme for Server
- Loading branch information
Showing
5 changed files
with
141 additions
and
8 deletions.
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
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
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
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
65 changes: 65 additions & 0 deletions
65
ribbon-loadbalancer/src/test/java/com/netflix/loadbalancer/ServerTest.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,65 @@ | ||
package com.netflix.loadbalancer; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNull; | ||
|
||
import org.junit.Test; | ||
|
||
public class ServerTest { | ||
|
||
@Test | ||
public void createSchemeHost() { | ||
Server server = new Server("http://netflix.com"); | ||
assertEquals("http", server.getScheme()); | ||
assertEquals("netflix.com", server.getHost()); | ||
assertEquals(80, server.getPort()); | ||
} | ||
|
||
@Test | ||
public void createSchemeHostPort() { | ||
Server server = new Server("http://netflix.com:8080"); | ||
assertEquals("http", server.getScheme()); | ||
assertEquals("netflix.com", server.getHost()); | ||
assertEquals(8080, server.getPort()); | ||
} | ||
|
||
@Test | ||
public void createSecureSchemeHost() { | ||
Server server = new Server("https://netflix.com"); | ||
assertEquals("https", server.getScheme()); | ||
assertEquals("netflix.com", server.getHost()); | ||
assertEquals(80, server.getPort()); | ||
} | ||
|
||
@Test | ||
public void createSecureSchemeHostPort() { | ||
Server server = new Server("https://netflix.com:443"); | ||
assertEquals("https", server.getScheme()); | ||
assertEquals("netflix.com", server.getHost()); | ||
assertEquals(443, server.getPort()); | ||
} | ||
|
||
@Test | ||
public void createSecureSchemeHostPortExplicit() { | ||
Server server = new Server("https", "netflix.com", 443); | ||
assertEquals("https", server.getScheme()); | ||
assertEquals("netflix.com", server.getHost()); | ||
assertEquals(443, server.getPort()); | ||
} | ||
|
||
@Test | ||
public void createHost() { | ||
Server server = new Server("netflix.com"); | ||
assertNull(server.getScheme()); | ||
assertEquals("netflix.com", server.getHost()); | ||
assertEquals(80, server.getPort()); | ||
} | ||
|
||
@Test | ||
public void createHostPort() { | ||
Server server = new Server("netflix.com:8080"); | ||
assertNull(server.getScheme()); | ||
assertEquals("netflix.com", server.getHost()); | ||
assertEquals(8080, server.getPort()); | ||
} | ||
} |