Skip to content

Commit

Permalink
Update REST client guide to use https://stage.code.quarkus.io instead…
Browse files Browse the repository at this point in the history
… of https://restcountries.eu

Update native-and-ssl guide to work with https://stage.code.quarkus.io/api

Update REST Client reactive guide to work with https://stage.code.quarkus.io/api

Update config-yaml guide to work with https://stage.code.quarkus.io/api
  • Loading branch information
xstefank committed Nov 8, 2021
1 parent 6f76614 commit 3dccf81
Show file tree
Hide file tree
Showing 4 changed files with 320 additions and 345 deletions.
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/config-yaml.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ quarkus:
# REST Client configuration property
quarkus:
rest-client:
org.acme.restclient.CountriesService:
url: https://restcountries.eu/rest
org.acme.rest.client.ExtensionsService:
url: https://stage.code.quarkus.io/api
----

[source,yaml]
Expand Down
20 changes: 14 additions & 6 deletions docs/src/main/asciidoc/native-and-ssl.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@ If you open the application's configuration file (`src/main/resources/applicatio

[source,properties]
----
quarkus.rest-client."org.acme.restclient.CountriesService".url=https://restcountries.eu/rest
quarkus.rest-client."org.acme.rest.client.ExtensionsService".url=https://stage.code.quarkus.io/api
----
which configures our REST client to connect to an SSL REST service.

For the purposes of this guide, we also need to remove the configuration that starts the embedded WireMock server that stubs REST client responses so the tests actually propagate calls to the https://stage.code.quarkus.io/api. Update the test file `src/test/java/org/acme/rest/client/ExtensionsResourceTest.java` and remove the line:
[source,java]
----
@QuarkusTestResource(WireMockExtensions.class)
----
from the `ExtensionsResourceTest` class.

Now let's build the application as a native executable and run the tests:

[source,bash]
Expand All @@ -64,7 +71,7 @@ It's not. The magic happens when building the native executable:
[INFO] [io.quarkus.creator.phase.nativeimage.NativeImagePhase] /opt/graalvm/bin/native-image -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dcom.sun.xml.internal.bind.v2.bytecode.ClassTailor.noOptimize=true -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -jar rest-client-1.0.0-SNAPSHOT-runner.jar -J-Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -H:+PrintAnalysisCallTree -H:EnableURLProtocols=http,https -H:-SpawnIsolates -H:+JNI --no-server -H:-UseServiceLoaderFeature -H:+StackTrace
----

The important elements are these 3 options that were automatically added by Quarkus:
The important elements are these 2 options that were automatically added by Quarkus:

[source,bash]
----
Expand Down Expand Up @@ -148,7 +155,7 @@ The native executable tests will fail with the following error:

[source]
----
Exception handling request to /country/name/greece: com.oracle.svm.core.jdk.UnsupportedFeatureError: Accessing an URL protocol that was not enabled. The URL protocol https is supported but not enabled by default. It must be enabled by adding the --enable-url-protocols=https option to the native-image command.
Caused by: java.net.MalformedURLException: Accessing an URL protocol that was not enabled. The URL protocol https is supported but not enabled by default. It must be enabled by adding the --enable-url-protocols=https option to the native-image command..
----

This error is the one you obtain when trying to use SSL while it was not explicitly enabled in your native executable.
Expand All @@ -157,14 +164,15 @@ Now, let's change the REST service URL to **not** use SSL in `src/main/resources

[source,properties]
----
quarkus.rest-client."org.acme.restclient.CountriesService".url=http://restcountries.eu/rest
quarkus.rest-client."org.acme.rest.client.ExtensionsService".url=http://stage.code.quarkus.io/api
----
and since http://stage.code.quarkus.io/api responds with 302 status code we need to also skip the tests with `-DskipTests`.

And build again:
Now we can build again:

[source,bash]
----
./mvnw clean install -Pnative
./mvnw clean install -Pnative -DskipTests
----

If you check carefully the native executable build options, you can see that the SSL related options are gone:
Expand Down
Loading

0 comments on commit 3dccf81

Please sign in to comment.