The Artima Developer Community
Sponsored Link

Java Buzz Forum
Mocking Spring Security Context for Unit Testing

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
justin cater

Posts: 19616
Nickname: justin78
Registered: Mar, 2011

Justin Cater is executive editor at Java Code Geeks
Mocking Spring Security Context for Unit Testing Posted: May 20, 2017 5:27 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by justin cater.
Original Post: Mocking Spring Security Context for Unit Testing
Feed Title: Java Code Geeks
Feed URL: http://feeds.feedburner.com/JavaCodeGeeks
Feed Description: Java 2 Java Developers Resource Center
Latest Java Buzz Posts
Latest Java Buzz Posts by justin cater
Latest Posts From Java Code Geeks

Advertisement
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; ...

Read: Mocking Spring Security Context for Unit Testing

Topic: C program to display characters from a to z using loop Previous Topic   Next Topic Topic: Bubble sort algorithm in c with explanation

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use