Since Asciidoctor 2.0.0 we can add the collapsible
option to an example block. When the markup is generated to HTML we get a HTML details
and summary
section. The content of the example block is collapsed (default behaviour because it is in a details
section) and a clickable text is available to open the collapsed block (the summary
section), so we can see the actual content. The text we can click on is by default Details, but we can change that by setting the title of the example block. Then the title is used as the text to click on to open the collapsed content.
Continue reading →
With the release of Asciidoctor 2.0.0 we get nice help on the basic syntax of Asciidoc with the command-line option --help syntax
.
This gives us samples of the syntax in Asciidoc markup.
As mentioned by Dan Allen on Twitter we can pipe the syntax sample to Asciidoctor itself to get a HTML page:
Continue reading →
Micronaut can convert String values defined as a number followed by (case-insensitive) KB/MB/GB
to a number value in certain cases.
The conversion service in Micronaut supports the @ReadableBytes
annotation that we can apply to a method parameter.
Micronaut will then parse the String value and convert it to a number.
The value 1Kb
is converted to 1024
.
We can use this for example in a configuration class or path variable in a controller.
Continue reading →
Micronaut supports the RFC-6570 URI template specification to define URI variables in a path definition.
The path definition can be a value of the @Controller
annotation or any of the routing annotations for example @Get
or @Post
.
We can define a path variable as {?binding*}
to support binding of request parameters to all properties of an object type that is defined as method argument with the name binding
.
We can even use the Bean Validation API (JSR380) to validate the values of the request parameters if we add an implementation of this API to our class path.
Continue reading →
Working with SQL database from Groovy code is very easy using the groovy.sql.Sql
class. The class has several methods to execute a SQL query, but we have to take special care if we use methods from Sql
that take a GString
argument. Groovy will extract all variable expressions and use them as values for placeholders in a PreparedStatement
constructed from the SQL query. If we have variable expressions that should not be extracted as parameters for a PreparedStatement
we must use the Sql.expand
method. This method will make the variable expression a groovy.sql.ExpandedVariable
object. This object is not used as parameter for a PreparedStatement
query, but the value is evaluated as GString
variable expression.
Continue reading →
Spring Boot 2.1 introduced log groups. A log group is a logical name for one or more loggers. We can define log groups in our application configuration. Then we can set the log level for a group, so all loggers in the group will get the same log level. This can be very useful to change a log level for multiple loggers that belong together with one setting. Spring Boot already provides two log groups by default: web and sql. In the following list we see which loggers are part of the default log groups:
- web
-
org.springframework.core.codec
, org.springframework.http
, org.springframework.web
, org.springframework.boot.actuate.endpoint.web
, org.springframework.boot.web.servlet.ServletContextInitializerBeans
- sql
-
org.springframework.jdbc.core
, org.hibernate.SQL
Continue reading →
To get an overview of all Gradle tasks in our project we need to run the tasks
task. Since Gradle 5.1 we can use the --group
option followed by a group name. Gradle will then show all tasks belonging to the group and not the other tasks in the project.
Suppose we have a Gradle Java project and want to show the tasks that belong to the build group:
Continue reading →
In a previous post we learned how to include parts of a document in the generated output.
The included parts are defined using tags.
The start of a tag is defined in a comment with the format tag::_tagName_[]
and the end has the format end::_tagName_[]
.
Next we must use the tags
attribute for the include
macro followed by the tagName.
If we don’t want to include a tag we must prefix it with an exclamation mark (!
).
Continue reading →
Cucumber-JVM is a framework for writing end to end tests in natural language, with each line backed by a Java method. Each Java method has a regular expression of natural language lines to match, and lines should only match one such pattern. On a recent assignment I was tasked with modernizing a fairly large cucumber test suite, and going through the steps I found a lot of Java methods that were not being called from the natural language feature files anymore. To identify and remove these unused steps, and prevent any new unused steps in the future, I contributed the following plugin to Cucumber 4.4.0 through:
- https://github.com/cucumber/cucumber-jvm/pull/1648
- https://github.com/cucumber/cucumber-jvm/pull/1634
It can be run easily through:
Continue reading →