Skip to content

Commit

Permalink
Merge branch 'master' of github.com:redhat-developer-demos/quarkus-tu…
Browse files Browse the repository at this point in the history
…torial
  • Loading branch information
kdubois committed May 23, 2024
2 parents edfe2ed + 4fa54b6 commit d82bcdc
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 44 deletions.
50 changes: 24 additions & 26 deletions documentation/modules/ROOT/pages/01_setup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ endif::workshop[]

[TIP]
====
Installing GraalVM is only required if you intend to build a https://quarkus.io/guides/building-native-image[native binary] for your local operating system and don't have a container runtime.
Installing GraalVM is only required if you intend to build a https://quarkus.io/guides/building-native-image[native binary] for your local operating system and don't have a container runtime.
Quarkus can simply build the native binary inside a container and this way you don't need to install and configure GraalVM on your machine.
====

NOTE: * You can also use Docker instead of Podman. The advantage of Podman is that it is 100% Free Open Source and does not need to run with elevated privileges.
NOTE: You can also use Docker instead of Podman. The advantage of Podman is that it is 100% Free Open Source and does not need to run with elevated privileges.


[tabs]
Expand All @@ -47,15 +47,15 @@ Please have them installed and configured before you get started with any of the
| https://podman-desktop.io/downloads[Podman Desktop for Mac, window="_blank"]
| https://podman-desktop.io/downloads[Podman Desktop for Linux, window="_blank"]
| https://podman-desktop.io/downloads[Podman Desktop for Windows, window="_blank"]
| **Java 17**
| `brew tap AdoptOpenJDK/openjdk && brew cask install adoptopenjdk17`
| `dnf install java-17-openjdk.x86_64`
| https://adoptopenjdk.net[Windows] (Make sure you set the `JAVA_HOME` environment variable and add `%JAVA_HOME%\bin` to your `PATH`)
| **Apache Maven 3.8.1+**
| **Java 21**
| `brew install --cask temurin@21`
| `dnf install java-21-openjdk.x86_64`
| https://adoptium.net[Windows] (Make sure you set the `JAVA_HOME` environment variable and add `%JAVA_HOME%\bin` to your `PATH`)
| **Apache Maven 3.8.6+**
| `brew install maven`
| `dnf install maven`
| https://maven.apache.org/download.cgi[Windows] (Make sure you set the `MAVEN_HOME` environment variable and add `%MAVEN_HOME%\bin` to your `PATH`)
| **Graal VM [Optional *]**
| **GraalVM [Optional *]**
| https://www.graalvm.org/latest/docs/getting-started/macos/[Download & install GraalVM for MacOS]
| https://www.graalvm.org/latest/docs/getting-started/linux/[Download & install GraalVM for Linux]
| https://www.graalvm.org/latest/docs/getting-started/windows/[Download & install GraalVM for Windows]
Expand All @@ -64,19 +64,19 @@ Please have them installed and configured before you get started with any of the
[TIP]
=====
If you are using Linux, MacOS or WSL on Windows you can also install the required tools using https://sdkman.io[SDKMAN!]. This allows easy version/distribution switching (and you can install the Quarkus CLI with it as well).
If you are using Linux, macOS or WSL on Windows, you can also install the required tools using https://sdkman.io[SDKMAN!]. This allows easy version/distribution switching (and you can install the Quarkus CLI with it as well).
Alternatively on Windows you can also try https://chocolatey.org/[Chocolatey] which works similarly.
[.console-input]
[source,bash,subs="+macros,+attributes"]
----
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
.
sdk install java
sdk install java
sdk install maven
sdk install quarkus
sdk install java 17.0.8-graalce
sdk install jbang
sdk install java 21.0.3-tem
sdk install jbang
----
=====
--
Expand Down Expand Up @@ -129,7 +129,7 @@ Before we start setting up the environment, let's clone the tutorial sources and
[#cloneRepo]
[source,bash,subs="+macros,+attributes"]
----
git clone https://github.com/redhat-developer-demos/quarkus-tutorial
git clone https://github.com/redhat-developer-demos/quarkus-tutorial
----
The `work` folder in `$TUTORIAL_HOME` can be used to download the demo application resources and refer to them during the exercises. The `work` folder has a README with instructions on the source code repo and git commands to clone the sources.
Expand All @@ -145,7 +145,7 @@ This tutorial was developed and tested with:
- Minikube `{minikube-version}`
- OpenShift `{openshift-version}`
- Minishift `{minishift-version}`
- Graal VM `{graalvm-version}`
- GraalVM `{graalvm-version}`
====
ifndef::workshop[]
Expand Down Expand Up @@ -183,10 +183,10 @@ oc new-project {tutorial-namespace}
[NOTE]
====
On macOS, you might need to install hyperkit and pass it as the main engine adding `--vm-driver=hyperkit` after `--disk-size=50g`.
On macOS, you might need to install hyperkit and pass it as the main engine by adding `--vm-driver=hyperkit` after `--disk-size=50g`.
====
Prepare your shell environment
Prepare your shell environment:
[#quarkus-tutorial-shell-env]
[source,bash,subs="+macros,+attributes"]
Expand All @@ -196,47 +196,45 @@ export TUTORIAL_HOME=pass:[`pwd`]
export GRAALVM_HOME='PUT THE LOCATION WHERE YOU HAVE EXTRACTED GRAAL VM'
----
Prepare your shell environment:
It is not necessary to install GraalVM as the native compilation can be done within a container.
The only limitation, in this case, is to have Podman/Docker installed and the produced native executable will only be runnable inside a container.
GraalVM is already installed in `tutorial-tools`.
If you installed GraalVM, make sure to also install `native-image`
If you installed GraalVM, make sure to also install `native-image`
[#quarkus-tutorial-graalvm-native]
[source,bash,subs="+macros,+attributes"]
----
gu install native-image
----
[#quarkus-tutorial-shell-env]
[source,bash,subs="+macros,+attributes"]
----
cd quarkus-tutorial
export TUTORIAL_HOME=pass:[`pwd`]
export WORKSHOP_USER='PUT YOUR USERNAME HERE'
export GRAALVM_HOME='PUT THE LOCATION WHERE YOU HAVE EXTRACTED GRAAL VM'
export WORKSHOP_OPENSHIFT_SERVER='PUT THE OPENSHIFT SEVER URL HERE'
export GRAALVM_HOME='PUT THE LOCATION WHERE YOU HAVE EXTRACTED GRAAL VM'
export WORKSHOP_OPENSHIFT_SERVER='PUT THE OPENSHIFT SERVER URL HERE'
----
Login into OpenShift
Login into OpenShift:
[#quarkus-tutorial-oc-login]
[source,bash,subs="+macros,+attributes"]
----
oc login --username pass:[$WORKSHOP_USER] --server pass:[$WORKSHOP_OPENSHIFT_SERVER] --insecure-skip-tls-verify=false
----
ifdef::openshift-console-url[]
You can also access the Openshift Console via url {openshift-console-url}
You can also access the OpenShift Console via {openshift-console-url}.
endif::[]
IMPORTANT: If you are in `MAC OSX`, the variable should point to `Home` sub-directory: `export GRAALVM_HOME=$HOME/Development/graalvm/Contents/Home/`
IMPORTANT: If you are using macOS, the variable should point to `Home` sub-directory: `export GRAALVM_HOME=$HOME/Development/graalvm/Contents/Home/`
endif::workshop[]
[#setup-work-folder]
== Work folder (Optional)
The work folder i.e `$TUTORIAL_HOME/work` can be used as a work directory during the build.
The work folder i.e `$TUTORIAL_HOME/work` can be used as a work directory during the build.
////
14 changes: 7 additions & 7 deletions documentation/modules/ROOT/pages/02_basics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The scaffolding process also creates a test case for the example endpoint.

Check the file `GreetingResourceTest.java` in the folder `src/test/java` to see what a Quarkus integration test looks like.

When running this test, the application is started once, then all tests are executed, and finally, the application stops. Although it is not mandatory, by default the RestAssured project is used to test Rest endpoints but it is up to you to change that.
When running this test, the application is started once, then all tests are executed, and finally, the application stops. Although it is not mandatory, by default the RestAssured project is used to test REST endpoints but it is up to you to change that.

You can run the test in your IDE or by running the following:

Expand All @@ -101,15 +101,15 @@ Quarkus CLI::
quarkus test
----
NOTE: `quarkus test` starts tests in continuous testing mode (more about this below) so to return to the command line after the tests ran you will need to press (q)
NOTE: `quarkus test` starts tests in continuous testing mode (more about this below) so to return to the command line after the tests ran you will need to press `q`.
--
====

== Open the Project in your IDE

Open or import the generated project into your IDE.

If you are using **vscode** you can open the project with:
If you are using VS Code, you can open the project with:

[.console-input]
[source,bash,subs="+macros,+attributes"]
Expand All @@ -121,13 +121,13 @@ NOTE: If you use `tutorial-tools`, your host `quarkus-tutorial/work` contains th

== Live Coding (Development mode)

Stop the Quarkus application that might be running in `jvm` or `native` mode.
Stop the Quarkus application that might be running in JVM or native mode.

_Live Coding_ or _Development mode_ enables hot deployment with background compilation, which means that when you modify your Java files and/or your resource files and refresh your browser, these changes will automatically take effect.

This is probably one of the best features of Quarkus: enabling a very fast and productive iterative feedback loop.

Let's start the _Live Coding_ mode by invoking `mvn`. You probably won't need to stop/start Quarkus again during this tutorial:
Let's start the _Live Coding_ mode by using the `dev` command. You probably won't need to stop/start Quarkus again during this tutorial:

[tabs%sync]
====
Expand Down Expand Up @@ -182,6 +182,6 @@ Press `r` and the tests will start running. You should see the status change dow
All 1 test is passing (0 skipped), 1 test was run in 11705ms. Tests completed at 16:02:32.
----

TIP: If you don’t want to have continuous testing enabled, you can change this by adding `quarkus.test.continuous-testing=disabled` in `application.properties`.
TIP: If you don’t want to have continuous testing enabled, you can change this by adding `quarkus.test.continuous-testing=disabled` to your `src/main/resources/application.properties`.

You can find more details about controlling continuous testing in https://quarkus.io/guides/continuous-testing#controlling-continuous-testing[this guide].
You can find more details about controlling continuous testing in https://quarkus.io/guides/continuous-testing#controlling-continuous-testing[this guide].
6 changes: 2 additions & 4 deletions documentation/modules/ROOT/pages/03_configuration.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
= Configuration

:project-name: fruits-app

Hardcoded values in your code is a no go, so let's see how to add configuration to your application.
Quarkus relies on the MicroProfile Config specification and the main configuration file is `application.properties`.

Expand Down Expand Up @@ -121,9 +119,9 @@ public class GreetingResourceTest {
}
----

NOTE: If you're still running in live testing mode you will already see that the tests pass again and you can ignore the rest of this page and move on to the next step.
NOTE: If you're still running in continuous testing mode, you will already see that the tests pass again and you can ignore the rest of this page and move on to the next step.

Stop your current Live Coding session of Quarkus in the terminal by sending a `CTRL+C`:
Stop your current Live Coding session of Quarkus in the terminal by sending a `Ctrl+C`:



Expand Down
8 changes: 4 additions & 4 deletions documentation/modules/ROOT/pages/04_panache.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[#quarkusp-demo-overview]
== Demo Overview

You'll learn how easy and productive is Quarkus with Hibernate with Panache. For this, we'll develop a simple CRUD REST API that handles information about fruits.
You'll learn how easy and productive Quarkus is with Hibernate with Panache. For this, we'll develop a simple CRUD REST API that handles information about fruits.

We'll use http://www.h2database.com[H2,window="_blank"] as our backing database in this section, but it's very easy to use other database engines with Quarkus as you will see in the Dev Services chapter. As an exercise for later, we suggest to try your favorite database engine with the documentation found https://quarkus.io/guides/datasource[here,window="_blank"].
Expand Down Expand Up @@ -57,7 +57,7 @@ quarkus extension add rest-jsonb jdbc-h2 hibernate-orm-panache smallrye-openapi
[INFO] ------------------------------------------------------------------------
----
You'll notice that by running this command the Quarkus maven plugin added some dependencies to your `pom.xml` file. And best of all: Quarkus will autodetect and apply the changes, and you don't even need to restart Quarkus!
You'll notice that by running this command the Quarkus Maven plugin added some dependencies to your `pom.xml` file. And best of all: Quarkus will autodetect and apply the changes, and you don't even need to restart Quarkus!
== Adding database properties to your configuration
Expand All @@ -75,7 +75,7 @@ quarkus.datasource.db-kind=h2
quarkus.hibernate-orm.database.generation=drop-and-create
----
NOTE: With <<Dev Services>> enabled, no JDBC URL needs to be provided in Dev Mode. In this case, we input the URL to ensure consistency across all application run modes.
NOTE: With <<Dev Services>> enabled, no JDBC URL needs to be provided in dev mode. In this case, we input the URL to ensure consistency across all application run modes.
== Create Fruit Entity
Expand Down Expand Up @@ -139,7 +139,7 @@ public class FruitResource {
}
----

Now we should everything in place to query our *GET* REST endpoint:
Now we should have everything in place to query our *GET* REST endpoint:

[.console-input]
[source,bash]
Expand Down
2 changes: 1 addition & 1 deletion documentation/modules/ROOT/pages/08_rest-client.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= REST Client

An atypical scenario in a Microservices architecture is the remote invocation of remote REST HTTP endpoints. Quarkus provides a typed REST client that follows the https://github.com/eclipse/microprofile-rest-client[MicroProfile REST Client, window=_blank] specification.
A typical scenario in a Microservices architecture is the remote invocation of remote REST HTTP endpoints. Quarkus provides a typed REST client that follows the https://github.com/eclipse/microprofile-rest-client[MicroProfile REST Client, window=_blank] specification.
Let's create a REST client that accesses https://fruityvice.com[window=_blank] to get nutrition information about our fruits. The endpoint we're interested in is this one:
Expand Down
2 changes: 1 addition & 1 deletion documentation/modules/ROOT/pages/09_fault-tolerance.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public interface FruityViceService {
Now, if 3 (4 x 0.75) failures occur among the rolling window of 4 consecutive invocations, then the circuit is opened for 5000 ms and then will be back to half open.
If the invocation succeeds, then the circuit is back to closed again.

Run the following command at least 5 times:
Run the following command at least 5 times (without network connectivity):

[.console-input]
[source,bash]
Expand Down
2 changes: 1 addition & 1 deletion documentation/modules/ROOT/pages/12_security.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ We are providing a valid token that can be verified by the configured public key

You can inject any defined claim into an object by using `@Claim` annotation:

Change the `SecureResource` Java class in `src/main/java` in the `com.redhat.developers` package with the following contents:
Create the `SecureResource` Java class in `src/main/java` in the `com.redhat.developers` package with the following contents:

[.console-input]
[source,java]
Expand Down

0 comments on commit d82bcdc

Please sign in to comment.