Home » Archives for Alex Soto

Author Archives: Alex Soto

Auto-numbered Callouts in Asciidoctor

Asciidoctor 1.5.8 comes with a really nice feature which is called autonumber callouts, so you do not have to specify the number of the callout, but just a generic character (.) and then at rendering time, Asciidoctor will set the name correctly. See the next example shows the number and auto-number feature for callouts: = My Code :source-highlighter: highlightjs == ...

Read More »

Java Iterator to Java 8 Stream

Sometimes during my work, I need to integrate with other libraries which they return an Iterator object instead of a list. This is fine from the point of view of libraries but it might be a problem when you want to use Java 8 streams on the returned iterator. There is one way to transform the Iterator to Iterable and then ...

Read More »

Arquillian Chameleon. Simplifying your Arquillian tests

Arquillian Chameleon was born to simplify the configuration of Arquillian tests. I am proud to announce that with version 1.0.0.CR2 we have not only simplified how to configure Arquillian tests but also how to write them. With this new release, three new simplifications have been added: You only need to use 1 (or at most 2 dependencies just in case you want to ...

Read More »

Repeatable Annotations in Java 8

With Java 8 you are able to repeat the same annotation to a declaration or type. For example, to register that one class should only be accessible at runtime by specific roles, you could write something like: @Role("admin") @Role("manager") public class AccountResource { } Notice that now @Role is repeated several times. For compatibility reasons, repeating annotations are stored in a ...

Read More »

Secret Rotation for JWT tokens

java-interview-questions-answers

When you are using JSON Web Token (JWT), or any other token technology that requires to sign or encrypt payload information, it is important to set an expiration date to the token, so if the token expires, you can either assume that this might be considered a security breach and you refuse any communication using this token, or you decide to ...

Read More »

Cloud Native Applications with JWT

java-interview-questions-answers

A native cloud application is an application that is developed for a cloud computing environment. There is no specific answer to the question ” what is a cloud-native application” but different concepts that must be met. One of the most important in my opinion is the ability to scale up and down at a rapid rate. And this means that our applications cannot ...

Read More »

Writing end to end test for a microservices architecture

One of the main aspects of microservices architecture is that the application is formed as a collection of loosely coupled services each one deployable independently and communicated each other with some kind of light protocol. It is because of microservices architecture is a distributed system that makes writing end to end tests really hard. Suppose next simple example provided by ...

Read More »

Testing Code that requires a mail server

Almost all applications has one common requirement, they need to send an email notifying something to a registered user. It might be an invoice, a confirmation of an action or a password recovery. How to test this use case might be challenging, using mocks and stubs are ok for unit tests, but having a component test that tests the whole ...

Read More »

Lifecycle of JUnit 5 Extension Model

JUnit5 final release is around the corner (currently it is M4), and I have started playing with it a bit on how to write extensions. In JUnit5, instead of dealing with Runners, Rules, ClassRules and so on, you’ve got a single Extension API to implement your own extensions. JUnit5 provides several interfaces to hook in its lifecycle. For example you can hook to  Test Instance ...

Read More »