Arasu
Arasu

Reputation: 2148

how to check @Before is working in play framework

I'm running play application.

I have

import org.junit.Before;
public class Frontpage extends Controller {
    @Before
    private static void commonData() {
            Map cacheMap = Cache.get("login_det",Map.class);
            System.out.println("commonData");
            if(cacheMap!=null)
            {
             renderArgs.put("login_det", cacheMap);
             System.out.println("renderArgs"+renderArgs.toString());
        }
    }
}

But commonData is never printed in my console. How can i check @Before is working

Upvotes: 1

Views: 1057

Answers (2)

i.am.michiel
i.am.michiel

Reputation: 10404

And instead of using System.out.println, try using Logger.info/debug/error/trace. They are the standard output for Play applications.

Upvotes: 2

Romain Linsolas
Romain Linsolas

Reputation: 81647

You are using the org.junit.Before annotation, which is used by JUnit to run a method before a unit test execution.

In your case, you should use the play.mvc.Before annotation instead.

Upvotes: 6

Related Questions