Home » Tag Archives: Spring (page 5)

Tag Archives: Spring

A quick look into Reactive Streams with Spring Data and MongoDB

This is a short post looking into Reactive Streams and how they can be used with MongoDB and Spring Data. This post won’t go into the depths of what Reactive Programming and Reactive Streams are as there have been plenty of posts covering that recently, such as What are Reactive Streams in Java and Reactive Spring 5 and Application Design Impact. ...

Read More »

Get Started with Spring Boot, SAML, and Okta

spring-interview-questions-answers

Build faster with Okta’s authentication and user management API. Register today for the free forever Developer Edition! Today I’d like to show you how build a Spring Boot application that leverages Okta’s Platform API for authentication via SAML. SAML (Security Assertion Markup Language) is an XML-based standard for securely exchanging authentication and authorization information between entities—specifically between identity providers, service ...

Read More »

Get Started with Spring Boot, OAuth 2.0, and Okta

spring-interview-questions-answers

Build faster with Okta’s authentication and user management API. Register today for the free forever Developer Edition! If you’re building a Spring Boot application, you’ll eventually need to add user authentication. You can do this with OAuth 2.0 (henceforth: OAuth). OAuth is a standard that applications can use to provide client applications with “secure delegated access”. It works over HTTP ...

Read More »

Mocking Spring Security Context for Unit Testing

spring-interview-questions-answers

Today, while writing unit test case for one of the Java method which looks like below: public ApplicationUser getApplicationUser() { ApplicationUser applicationUser = (ApplicationUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); return applicationUser; } I want to mock Spring Security Context to get the Principal, to achieve the same I mocked each level of method calls as follows: import org.junit.Before; import org.junit.Rule; import org.junit.Test; import static org.mockito.Mockito.when; ...

Read More »

Handling Events in React

spring-interview-questions-answers

In post Rendering RESTful service with React we created simple UI which render employee list fetched from RESTful service. As part of this post we will extend the same app to support add and delete employees operation. We will start with updating react-app backend api with add/delete employee operation along with modifying the existing get employee method to return the list of employees following ...

Read More »

Testing Spring Data + Spring Boot applications with Arquillian (Part 2)

In previous post, I wrote about how to test Spring Data application using Docker with Arquillian Cube. The test looked like: @RunWith(SpringRunner.class) @SpringBootTest(classes = PingPongController.class, webEnvironment = RANDOM_PORT) @ContextConfiguration(initializers = PingPongSpringBootTest.Initializer.class) public class PingPongSpringBootTest { @ClassRule public static ContainerDslRule redis = new ContainerDslRule("redis:3.2.6") .withPortBinding(6379); @Autowired TestRestTemplate restTemplate; @Test public void should_get_pongs() { // given restTemplate.postForObject("/ping", "pong", String.class); restTemplate.postForObject("/ping", "pung", String.class); // when final List<String> ...

Read More »

Clean Code from the trenches

spring-interview-questions-answers

Clean Code from the trenches – Validation Let’s directly start with an example. Consider a simple web service which allows clients to place order to a shop. A very simplified version of the order controller could look something like below – @RestController @RequestMapping(value = "/", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public class OrderController { private final OrderService orderService; public ...

Read More »