Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8202115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:03:34+00:00 2026-06-07T07:03:34+00:00

In Grails 2.0.4, I’m trying to write a controller unit test which invokes the

  • 0

In Grails 2.0.4, I’m trying to write a controller unit test which invokes the static SpringSecurityUtils.reauthenticate. The test returns a NullPointerException on that invocation. In a debugger, I can see that none of the Groovy dynamic properties (declaredMethods,etc.) of SpringSecurityUtils are populated.

I do note that when running the tests, the “Configuring Spring Security Core” log message is emitted after the unit-test failure. Here is a sample test:

class ReproTest {
    void testSpringSecurityUtils() {
        String.valueOf(true) // OK: a public final class from the JDK
        URLUtils.isRelativeURL("foo")  // OK: a class from another plugin
        SpringSecurityUtils.reauthenticate "user", "pw" // fails, NPE
    }
}

My initial reaction is that maybe plugins aren’t accessible during unit tests, but if so, why is the URLUtils call working? And why does the test get “far enough” to initialize the plugin, but after the tests have completed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:03:37+00:00Added an answer on June 7, 2026 at 7:03 am

    For a unit test the container isn’t starting up. No Spring injection or “grails goodness” is happening. You see in the logs that the plugin is initializing after the unit tests run, because it [container] does start for the integration tests. If you want to test the SpringSecurityUtils, although guessing it is already tested properly in the plugin, you would want to write an integration test.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Grails tends to write out the URL for everything that uses its tags as
I have a RestFull grails api that i expose through grails Controller. I need
In grails, I have a Controller that expects a 'options' parameter that is sent
My grails Unit Test mocks out the MailService using an Expando and redefining the
Grails uses mailService from Spring. That service is synchronous, which means if SMTP goes
The Grails framework has a lot of constructs/features that allows for adhering to the
In Grails, one can 'bindData' in controller: Book b = new Book() bindData(b, params)
Grails has a war command to create a Web Application Archive (WAR) file which
Grails provides an isDirty method that can be called on domain objects. How would
My Grails 2.0 app has a User domain object defined: class User { static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.