diff --git a/httpclient-2/README.md b/httpclient-2/README.md index 49adf470e9..695a92ce00 100644 --- a/httpclient-2/README.md +++ b/httpclient-2/README.md @@ -12,5 +12,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Reading an HTTP Response Body as a String in Java](https://www.baeldung.com/java-http-response-body-as-string) - [How To Get Cookies From the Apache HttpClient Response](https://www.baeldung.com/java-apache-httpclient-cookies) - [Enabling Logging for Apache HttpClient](https://www.baeldung.com/apache-httpclient-enable-logging) -- [Unshorten URLs with HttpClient](https://www.baeldung.com/unshorten-url-httpclient) +- [Expand Shortened URLs with Apache HttpClient](https://www.baeldung.com/unshorten-url-httpclient) - More articles: [[<-- prev]](../httpclient) diff --git a/httpclient-2/src/test/java/com/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java b/httpclient-2/src/test/java/com/baeldung/httpclient/expandurl/HttpClientExpandUrlLiveTest.java similarity index 91% rename from httpclient-2/src/test/java/com/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java rename to httpclient-2/src/test/java/com/baeldung/httpclient/expandurl/HttpClientExpandUrlLiveTest.java index efa7953ba8..fb3d730ec4 100644 --- a/httpclient-2/src/test/java/com/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java +++ b/httpclient-2/src/test/java/com/baeldung/httpclient/expandurl/HttpClientExpandUrlLiveTest.java @@ -1,4 +1,4 @@ -package com.baeldung.httpclient.rare; +package com.baeldung.httpclient.expandurl; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; @@ -22,35 +22,29 @@ import java.util.List; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; -public class HttpClientUnshortenLiveTest { +public class HttpClientExpandUrlLiveTest { private CloseableHttpClient client; - // fixtures - @Before public final void before() { client = HttpClientBuilder.create().disableRedirectHandling().build(); } - // tests - @Test - public final void givenShortenedOnce_whenUrlIsUnshortened_thenCorrectResult() throws IOException { + public final void givenShortenedOnce_whenUrlIsExpanded_thenCorrectResult() throws IOException { final String expectedResult = "http://www.baeldung.com/rest-versioning"; final String actualResult = expandSingleLevel("http://bit.ly/13jEoS1"); assertThat(actualResult, equalTo(expectedResult)); } @Test - public final void givenShortenedMultiple_whenUrlIsUnshortened_thenCorrectResult() throws IOException { - final String expectedResult = "http://www.baeldung.com/rest-versioning"; + public final void givenShortenedMultiple_whenUrlIsExpanded_thenCorrectResult() throws IOException { + final String expectedResult = "https://www.baeldung.com/rest-versioning"; final String actualResult = expand("http://t.co/e4rDDbnzmk"); assertThat(actualResult, equalTo(expectedResult)); } - // API - private String expand(final String urlArg) throws IOException { String originalUrl = urlArg; String newUrl = expandSingleLevel(originalUrl);