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 8673879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:34:10+00:00 2026-06-12T19:34:10+00:00

It seems that when a public static method of a controller calls another public

  • 0

It seems that when a public static method of a controller calls another public static method of the same controller explicitly (with a Java call), Play! doesn’t know to just execute the code or redirect in functional tests.

If I have:

public class ApplicationTest extends FunctionalTest {
    @Test
    public void testProvesThatFunctionalTestsDoesntCallControllerMethods() {
        Response response = GET("/");

        assertEquals("", getContent(response));
    }

    @Test
    public void testProvesThatCallingItDirectlyWorksAsExpected() throws Exception {
        Response response = GET("/another");

        assertEquals("ok!", getContent(response));

    }

}

And:

public class Application extends Controller {
    public static void index() {
        another();
    }

    public static void another() {
        renderText("ok!");
    }
}

But if I run play run or play start and call “/” in my web browser then it returns “ok!”, shouldn’t FunctionalTest work exactly like running it in production or as if the real server? It pushes me to avoid functional test or have a huge manual setup and dependency of a pre-running web server, that’s not cool.

Thanks in advance.

  • 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-12T19:34:11+00:00Added an answer on June 12, 2026 at 7:34 pm

    In your browser, when you call “/” it returns “ok” but not on the first response. It firsts return a redirect (302) and then returns a 200 (ok).

    In your functional test, it is the same, You have to do something like

    Response response = GET("/");
    assertStatus(302, response);
    response = GET(response.headers.get("Location").value())
    assertIsOk(response);
    assertEquals("ok!", getContent(response));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an example that seems strange to me. public class Join { public
It seems that runClasses() doesn't terminate the code being tested even after the test
I'm working on a CLR stored procedure that calls a controller action in an
Reading Effective Java, it seems that there are many advantages, and very few disadvantages,
In my Java EE (Glassfish 3.1.1) application I register a security provider: public static
I started to write my first Java program . class HelloWorldApp { public static
I assume that public or private static targets must have reduced memory usage, due
I use an extension method to convert float arrays into byte arrays: public static
EDIT 2: Confirmed that my performance problems were due to the static function call
In Play, it seems that if an exception is thrown inside a Job<T> ,

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.