In some test scenarios, a Spring Bean can become corrupted, causing other test scenarios to fail. To prevent this, we can annotate a test class or test method with @DirtiesContext
, which tells the Spring Framework that the ApplicationContext is dirty, forcing the rebuilding of the Spring container and creating a new bean instances.
A JavaBean is a standard Java class with getter/setter methods, a no-arg constructor, and is serializable. And a Spring Bean is any Java object managed by Spring and can be automatically injected into other components. The Spring Dependency injection allows Spring to manage and inject beans where needed.
The Mockito framework has the ArgumentCaptor class that can be use to validate the arguments passed to a mocked method.
Install the jq
package:
macOS:
Linux:
How to use it:
String value = "a Á á É é Í 8 . - ? í Ó ó Ú ú ü / ! ¿";
Stream.of(value.split("")).filter(s -> s.matches("\\p{L}"))
.forEach(System.out::printf);
//ÁaáÉeéÍiíÓóoOÚúü
The regular expression uses a Unicode character class escape with a General category property for filter only the letters.