Skip to content
Advertisement

Handle anonymous class with Generics in Mockito

I am trying to write unit test using Powermockito for following method – I have written test method as – When I run this test I always get it failed saying – It looks like stub is not working as I always get “null” for this line – Is it because anonymous instantiation of TypeReference class? Answer Yes, it’s because

Split string containg dash/hyphen character in Java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 8 months ago. Improve this question I have a string May 1988 – June 1992 I want to split this string in such way that I

Test if an exception is caught with Junit

I’ll begin with a code example; I have to test a function, which handles data-packets. In this function, the data-packet is opened and when it doesn’t contain all expected data, an InvalidParameterExeption is thrown which is logged. So, if everything goes well, my exception is printed in my terminal. But how can I test this? I can’t use this: (because

Jackson is ignoring spring.jackson.properties in my spring boot application

Jackson is ignoring spring.jackson.property-naming-strategy=SNAKE_CASE. I am using springBootVersion 1.4.2.RELEASE. In my application.properties file, I have added spring.jackson.property-naming-strategy=SNAKE_CASE But Jackson is not honoring this property, and my REST response is still camelCase. Interestingly, this annotation works just fine @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) With this annotation, I am getting snake_case response. But I don’t want to annotate each response class, it’s a bit annoying. Edit

What is the Compatible version of Spring-security with spring-4.3.0-release?

Which version of spring security is compatible with Spring-4.3.0-release. my jars are as follows spring-aop-4.3.0.RELEASE.jar spring-beans-4.3.0.RELEASE.jar spring-context-4.3.0.RELEASE.jar spring-context-support-4.3.0.RELEASE.jar spring-core-4.3.0.RELEASE.jar spring-expression-4.3.0.RELEASE.jar spring-jdbc-4.3.0.RELEASE.jar spring-orm-4.3.0.RELEASE.jar spring-oxm-4.3.0.RELEASE.jar spring-tx-4.3.0.RELEASE.jar spring-web-4.3.0.RELEASE.jar With Security jars spring-security-config-3.2.5.RELEASE.jar spring-security-core-3.2.5.RELEASE.jar spring-security-web-3.2.5.RELEASE.jar Answer The documentation for spring security 4.2.x says that the current spring security version 4.2.x is compatible with 4.3.26 and 4.0.x. For spring security 3.2.5 you should use spring

Non-terminal forEach() in a stream?

Sometimes when processing a Java stream() I find myself in need of a non-terminal forEach() to be used to trigger a side effect but without terminating processing. I suspect I could do this with something like .map(item -> f(item)) where the method f performs the side effect and returns the item to the stream, but it seems a tad hokey.

Advertisement