Skip to content

Commit

Permalink
feat: Add a link to the git repository defined on a documentation page
Browse files Browse the repository at this point in the history
  • Loading branch information
aelamrani committed Feb 11, 2019
1 parent 2a9c741 commit 734a859
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<name>Gravitee.io APIM - Fetcher - HTTP</name>

<properties>
<gravitee-fetcher-api.version>1.0.0</gravitee-fetcher-api.version>
<gravitee-fetcher-api.version>1.1.0-SNAPSHOT</gravitee-fetcher-api.version>
<maven-assembly-plugin.version>2.5.5</maven-assembly-plugin.version>
<assertj-core.version>3.5.1</assertj-core.version>
</properties>
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/io/gravitee/fetcher/http/HttpFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.gravitee.common.http.HttpStatusCode;
import io.gravitee.fetcher.api.Fetcher;
import io.gravitee.fetcher.api.FetcherException;
import io.gravitee.fetcher.api.Resource;
import io.gravitee.fetcher.http.vertx.VertxCompletableFuture;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
Expand All @@ -33,7 +34,6 @@
import org.springframework.beans.factory.annotation.Value;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
import java.util.concurrent.CompletableFuture;

Expand Down Expand Up @@ -82,13 +82,15 @@ public HttpFetcher(HttpFetcherConfiguration httpFetcherConfiguration) {
}

@Override
public InputStream fetch() throws FetcherException {
public Resource fetch() throws FetcherException {
try {
Buffer buffer = fetchContent().join();
if (buffer == null) {
throw new FetcherException("Unable to fetch Http content '" + httpFetcherConfiguration.getUrl() + "': no content", null);
}
return new ByteArrayInputStream(buffer.getBytes());
final Resource resource = new Resource();
resource.setContent(new ByteArrayInputStream(buffer.getBytes()));
return resource;
} catch (Exception ex) {
throw new FetcherException("Unable to fetch Http content (" + ex.getMessage() + ")", ex);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/io/gravitee/fetcher/http/HttpFetcherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void shouldGetExistingFile() throws Exception {
HttpFetcher httpFetcher = new HttpFetcher(httpFetcherConfiguration);
ReflectionTestUtils.setField(httpFetcher, "httpClientTimeout", 1_000);
httpFetcher.setVertx(Vertx.vertx());
InputStream is = httpFetcher.fetch();
InputStream is = httpFetcher.fetch().getContent();
assertThat(is).isNotNull();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line;
Expand All @@ -76,7 +76,7 @@ public void shouldGetInexistingFile() throws Exception {
httpFetcher.setVertx(Vertx.vertx());
InputStream is = null;
try {
is = httpFetcher.fetch();
is = httpFetcher.fetch().getContent();
fail("should not happen");
} catch (FetcherException fetcherException) {
assertThat(fetcherException.getMessage()).contains("Unable to fetch");
Expand Down

0 comments on commit 734a859

Please sign in to comment.