Skip to content

Commit

Permalink
Merge branch 'ileler-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
spencergibb committed Jul 5, 2018
2 parents 281a6cb + 98e76f6 commit 6962065
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public B uri(String uri) {

public B uri(URI uri) {
this.uri = uri;
if (this.uri.getPort() < 0 && this.uri.getScheme().startsWith("http")) {
String scheme = this.uri.getScheme();
Assert.hasText(scheme, "The parameter [" + this.uri + "] format is incorrect, scheme can not be empty");
if (this.uri.getPort() < 0 && scheme.startsWith("http")) {
// default known http ports
int port = this.uri.getScheme().equals("https") ? 443 : 80;
this.uri = UriComponentsBuilder.fromUri(this.uri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@

package org.springframework.cloud.gateway.route;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static org.assertj.core.api.Assertions.assertThat;

public class RouteTests {

@Rule
public ExpectedException exception = ExpectedException.none();

@Test
public void defeaultHttpPort() {
Route route = Route.async().id("1")
Expand All @@ -47,7 +52,6 @@ public void defeaultHttpsPort() {
.hasPort(443);
}


@Test
public void fullUri() {
Route route = Route.async().id("1")
Expand All @@ -59,4 +63,12 @@ public void fullUri() {
.hasScheme("http")
.hasPort(8080);
}

@Test
public void nullScheme() {
exception.expect(IllegalArgumentException.class);
Route.async().id("1")
.predicate(exchange -> true)
.uri("/pathonly");
}
}

0 comments on commit 6962065

Please sign in to comment.