Update URLNormalizationUnitTest.java (baeldung-articles BAEL-6777) (#15779)
This commit is contained in:
parent
4bde015e08
commit
9c8cbf668c
@ -22,7 +22,7 @@ public class URLNormalizationUnitTest {
|
|||||||
String normalizedUri = originalUrl.split("\\?")[0];
|
String normalizedUri = originalUrl.split("\\?")[0];
|
||||||
assertEquals(expectedNormalizedUrl, normalizedUri);
|
assertEquals(expectedNormalizedUrl, normalizedUri);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Invalid URL: " + originalUrl);
|
fail(originalUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class URLNormalizationUnitTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenOriginalUrl_whenUsingRegularExpression_thenNormalizedUrl() throws URISyntaxException, UnsupportedEncodingException {
|
public void givenOriginalUrl_whenUsingRegularExpression_thenNormalizedUrl() {
|
||||||
String regex = "^(https?://[^/]+/[^?#]+)";
|
String regex = "^(https?://[^/]+/[^?#]+)";
|
||||||
Pattern pattern = Pattern.compile(regex);
|
Pattern pattern = Pattern.compile(regex);
|
||||||
Matcher matcher = pattern.matcher(originalUrl);
|
Matcher matcher = pattern.matcher(originalUrl);
|
||||||
@ -44,7 +44,7 @@ public class URLNormalizationUnitTest {
|
|||||||
String normalizedUrl = matcher.group(1);
|
String normalizedUrl = matcher.group(1);
|
||||||
assertEquals(expectedNormalizedUrl, normalizedUrl);
|
assertEquals(expectedNormalizedUrl, normalizedUrl);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Invalid URL: " + originalUrl);
|
fail(originalUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user