Skip to content

Commit

Permalink
Quarkus 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
lordofthejars committed Feb 8, 2022
1 parent 6dd4733 commit e1402c1
Show file tree
Hide file tree
Showing 12 changed files with 4,110 additions and 2,070 deletions.
3,226 changes: 1,560 additions & 1,666 deletions docs/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/quarkus-cheat-sheet/attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
:logo: quarkus.png
:version: 1.13.0.Final
:version: 2.7.0.Final
:source-highlighter: highlightjs
:sectlinks:
:linkattrs:
:sectanchors:
:toc: macro
:nofooter:
:pdf-download: https://github.com/lordofthejars/quarkus-cheat-sheet/releases/download/1.0.24/quarkus-cheat-sheet.pdf
:pdf-download: https://github.com/lordofthejars/quarkus-cheat-sheet/releases/download/1.0.25/quarkus-cheat-sheet.pdf
52 changes: 49 additions & 3 deletions examples/quarkus-cheat-sheet/cloud.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Now `docker` (default) and `podman` are the valid options.
To configure native application, you can create a `config` directory at the same place as the native file and place an `application.properties` file inside. `config/application.properties`.
// end::update_1_6[]

To produce a native executable with native excutable use `-Dquarkus.native.additional-build-args=-J--enable-preview`.

*SSL*

// tag::update_14_28[]
Expand Down Expand Up @@ -244,6 +246,9 @@ Boolean to set if image should be built. (default: `false`)
`push`::
Boolean to set if image should be pushed. (default: `false`)

`labels`::
Custom labels to add to the generated image.

*Jib*

[source, bash]
Expand Down Expand Up @@ -281,8 +286,8 @@ A custom entry point of the container image in JVM mode.
A custom entry point of the container image in native mode.
// end::update_17_7[]

`labels`::
Custom labels to add to the generated image.
`offline-mode`::
Whether or not to operate offline. (default: `false`)

`base-registry-username`::
The username to use to authenticate with the registry used to pull the base JVM image.
Expand All @@ -305,6 +310,9 @@ When AppCDS generation is enabled, if this property is set, then the JVM used to
`platforms`::
List of target platforms. (ie `linux/amd64`).

`docker-executable-ame`::
Name of binary used to execute the docker commands.

*Docker*

[source, bash]
Expand All @@ -321,6 +329,43 @@ Path to the JVM Dockerfile. (default: `${project.root}/src/main/docker/Dockerfil
`dockerfile-native-path`::
Path to the native Dockerfile. (default: `${project.root}/src/main/docker/Dockerfile.native`)

*Buildpacks*

[source, bash]
----
./mvnw quarkus:add-extensions
-Dextensions="quarkus-container-image-buildpack"
----

Prefix is `quarkus.buildpack`:

`jvm-builder-image`::
The buildpacks builder image to use when building the project in jvm mode.

`native-builder-image`::
The buildpacks builder image to use when building the project in native mode.

`builder-env`::
Environment key/values to pass to buildpacks.

`run-image`::
The buildpacks run image to use when building the project.

`pull-timeout-seconds`::
Max pull timeout for builder/run images, in seconds (default: `300`)

`docker-host`::
DOCKER_HOST value to use.

`log-level`::
Log level to use. (default `info`)

`base-registry-username`::
The username to use to authenticate with the registry used to pull the base image.

`base-registry-password`::
The password to use to authenticate with the registry used to pull the base image.

*S2I*

[source, bash]
Expand Down Expand Up @@ -516,14 +561,15 @@ The following Quarkus extensions support this feature:
* quarkus-jdbc-postgresql
* quarkus-kafka-client
* quarkus-smallrye-reactive-messaging-kafka
* quarkus-mongodb

[source, bash]
----
./mvnw quarkus:add-extensions
-Dextensions="quarkus-kubernetes-service-binding"
----

Datasource configuration part is absent as it is aut-discovered by Quarkus.
Datasource configuration part is absent as it is auto-discovered by Quarkus.
// end::update_24_7[]

== Minikube
Expand Down
134 changes: 134 additions & 0 deletions examples/quarkus-cheat-sheet/core.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,37 @@ String[] args;
----
// end::update_15_16[]

*Testing*

Command Mode applications can be tested using the `@QuarkusMainTest` and `@QuarkusMainIntegrationTest` annotations.

[source, java]
----
import io.quarkus.test.junit.main.Launch;
import io.quarkus.test.junit.main.LaunchResult;
import io.quarkus.test.junit.main.QuarkusMainLauncher;
import io.quarkus.test.junit.main.QuarkusMainTest;
@QuarkusMainTest
public class HelloTest {
@Test
@Launch("World")
public void testLaunchCommand(LaunchResult result) {
Assertions.assertEquals("Hello World", result.getOutput());
}
@Test
@Launch(value = {}, exitCode = 1)
public void testLaunchCommandFailed() {
}
@Test
public void testManualLaunch(QuarkusMainLauncher launcher) {
LaunchResult result = launcher.launch("Everyone");
Assertions.assertEquals(0, result.exitCode());
Assertions.assertEquals("Hello Everyone", result.getOutput());
}
}
----

// tag::update_16_15[]
*Picocli*

Expand Down Expand Up @@ -303,6 +334,20 @@ Endpoints are registered automatically to provide some basic debug info in dev m
* `HTTP GET /quarkus/arc/observers`
// end::update_17_14[]

== Dev Services

Quarkus supports the automatic provisioning of unconfigured services in development and test mode.

General configuration properties:

`quarkus.devservices.enabled`::
If you want to disable all Dev Services. (default: `true`)

`quarkus.devservices.timeout`::
Startup timeout. (default: `60S`)

Set `DOCKER_HOST` env var to a remote Docker Host to use it instead the local one.

== Dev UI

// tag::update_22_11[]
Expand All @@ -311,6 +356,17 @@ Quarkus adds a Dev UI console to expose extension features.
The Dev UI is available in dev mode only and accessible at the `/q/dev` endpoint by default.
// end::update_22_11[]

== Continuous Testing

Quarkus supports continuous testing, where tests run immediately after code changes have been saved. This allows you to get instant feedback on your code changes. Quarkus detects which tests cover which code, and uses this information to only run the relevant tests when code is changed.

Start Quarkus in Dev Mode to run it.

Also, you can start continuous testing and not dev mode by running `mvn quarkus:test`.

`quarkus.test.exclude-pattern`::
Tests that should be excluded with continuous testing default: `.*\.IT[^.]+|.*IT|.*ITCase`

== Adding Configuration Parameters

To add configuration to your application, Quarkus relies on https://github.com/eclipse/microprofile-config[MicroProfile Config, window="_blank"] spec.
Expand Down Expand Up @@ -460,6 +516,18 @@ This class maps `greeting.message` property defined in `application.properties`.

You can inject this class by using CDI `@Inject GreetingConfiguration greeting;`.

`@IfBuildProfile`, `@UnlessBuildProfile`, `@IfBuildProperty` and `@UnlessBuildProperty` annotations are used to define when configuration properties are valid.

[source, java]
----
@UnlessBuildProfile("test")
@ConfigProperties
public class ServiceConfiguration {
public String user;
public String password;
}
----

Also you can use an interface approach:

[source, java]
Expand Down Expand Up @@ -770,6 +838,21 @@ Message message;
----
// end::update_15_10[]

`@LookupIfProperty` indicates that a bean should only be obtained if a runtime configuration property matches the provided value.
`@LookupUnlessProperty`, on the other hand, indicates that a bean should only be obtained if a runtime configuration property does not match the provided value.

[source, java]
----
@LookupIfProperty(name = "service.foo.enabled", stringValue = "true")
@ApplicationScoped
class ServiceFoo implements Service {
public String name() {
return "foo";
}
}
----

*Alternatives*

// tag::update_15_11[]
Expand Down Expand Up @@ -1167,6 +1250,9 @@ Minimum log level (default: `INFO`)
`console.color`::
Allow color rendering (default: `true`)

`console.stderr`::
If console logging should go to System#err instead of System#out (default: `false`)

`file.enable`::
File logging enabled (default: `false`)

Expand Down Expand Up @@ -1756,6 +1842,22 @@ public class MyCustomTestResource
public int order() {
return 0;
}
// optional
@Override
public void setContext(Context context) {
}
@Override
public void inject(TestInjector testInjector) {
testInjector.injectIntoFields(wireMockServer,
new TestInjector.AnnotatedAndMatchesType(InjectWireMock.class, WireMockServer.class));
}
}
public class MyTest {
@InjectWireMock
WireMockServer wireMockServer;
}
----

Expand Down Expand Up @@ -1847,6 +1949,8 @@ public class ExampleResource {

Mock is automatically injected and only valid for the defined test class.

`@InjectMock` has `convertScopes` parameter that if true, then Quarkus will change the scope of the target from `Singleton` bean to `ApplicationScoped` to make the mockable.

// tag::update_16_25[]
Also `spy` is supported:

Expand Down Expand Up @@ -1899,6 +2003,34 @@ public class TestStereotypeTestCase {}
----
// end::update_5_5[]

*Decorator*

Quarkus also supports CDI Decorators:

[source, java]
----
@Priority(10)
@Decorator
public class LargeTxAccount implements Account {
@Inject
@Any
@Delegate
Account delegate;
@Inject
LogService logService;
void withdraw(BigDecimal amount) {
delegate.withdraw(amount);
if (amount.compareTo(1000) > 0) {
logService.logWithdrawal(delegate, amount);
}
}
}
----

*Test Coverage*

// tag::update_6_3[]
Expand Down Expand Up @@ -1949,4 +2081,6 @@ To test native executables annotate the test with `@NativeImageTest`.
// tag::update_24_2[]
`@QuarkusIntegrationTest` should be used to launch and test the artifact produced by the Quarkus build.
If the result of a Quarkus build is a JAR then the app is launched as `java -jar`, if native is launched as `./application`, if container image is created (JiB, Docker extensions) is launched as `docker run`.

You can connect to already running application by using the following properties: `quarkus.http.test-host=1.2.3.4` `quarkus.http.test-port=4321`
// end::update_24_2[]
Loading

0 comments on commit e1402c1

Please sign in to comment.