@Override @Deprecated public Flash flash() { return wrapped.flash(); }
@Override @Deprecated public Flash flash() { return wrapped.flash(); }
@Override @Deprecated public Flash flash() { return wrapped.flash(); }
@Override public String getUsername(Http.Context context) { final User user; if ( !context.args.containsKey("user") ) { user = ExtranetUser.findByEmail(context.session().get("username")); context.args.put("user", user); } else { user = (User) context.args.get("user"); } if(user != null){ final String counterStr = context.session().get("counter"); if (user.getSessionCounter() > NumberUtils.toInt(counterStr, 0)) { Logger.debug("Session invalidated for " + user + " had session " + counterStr + " but latest session is " + user.getSessionCounter()); context.flash().put("session", "user.duplicateSession"); context.session().clear(); return null; // results in redirect to login page with flash } return user.getEmail(); } else { return null; } }
@Test public void indexTest() { //setup HTTP Context Http.Context context = Mockito.mock(Http.Context.class); //mocking flash session, request, etc... as required Http.Flash flash = Mockito.mock(Http.Flash.class); when(context.flash()).thenReturn(flash); Http.Context.current.set(context); //run your test Content html = views.html.index.render("Coco"); assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains("Coco"); }
import play.mvc.Http; import static org.mockito.Mockito.*; @Before public void setUp() throws Exception { Http.Context context = mock(Http.Context.class); Http.Flash flash = mock(Http.Flash.class); when(context.flash()).thenReturn(flash); Http.Context.current.set(context); }
/** * @param wrapped the context the created instance will wrap */ public WrappedContext(Context wrapped) { super(wrapped.id(), wrapped.request().asScala(), wrapped.request(), wrapped.session(), wrapped.flash(), wrapped.args, wrapped.lang, wrapped.components); this.args = wrapped.args; this.wrapped = wrapped; }
/** * Returns the current HTTP flash scope. * * @return the flash scope * * @deprecated Deprecated as of 2.7.0. Use {@link Request#flash()} and {@link Result} instead. */ @Deprecated public static Flash flash() { return Http.Context.current().flash(); }
/** * Returns the current HTTP flash scope. * * @return the flash scope * * @deprecated Deprecated as of 2.7.0. Use {@link Request#flash()} and {@link Result} instead. */ @Deprecated public static Flash flash() { return Http.Context.current().flash(); }
/** * Returns the current flash scope. * * @return the current flash scope. * * @deprecated Deprecated as of 2.7.0. Use {@link Result} instead. */ @Deprecated public static Flash flash() { return Context.current().flash(); }
@Override public Flash flash() { return wrapped.flash(); }
/** * Returns the current HTTP flash scope. * * @return the flash scope * * @deprecated Deprecated as of 2.7.0. Use {@link Request#flash()} and {@link Result} instead. */ @Deprecated public static Flash flash() { return Http.Context.current().flash(); }
/** * @param wrapped the context the created instance will wrap */ public WrappedContext(Context wrapped) { super(wrapped.id(), wrapped.request().asScala(), wrapped.request(), wrapped.session(), wrapped.flash(), wrapped.args, wrapped.lang, wrapped.components); this.args = wrapped.args; this.wrapped = wrapped; }
/** * Returns the current HTTP flash scope. */ public static Flash flash() { return Http.Context.current().flash(); }
/** * Returns the current flash scope. * * @return the current flash scope. * * @deprecated Deprecated as of 2.7.0. Use {@link Result} instead. */ @Deprecated public static Flash flash() { return Context.current().flash(); }
/** * Returns the current flash scope. * * @return the current flash scope. * * @deprecated Deprecated as of 2.7.0. Use {@link Result} instead. */ @Deprecated public static Flash flash() { return Context.current().flash(); }
/** * @param wrapped */ public WrappedContext(Context wrapped) { super(wrapped.id(), wrapped._requestHeader(), wrapped.request(), wrapped.session(), wrapped.flash(), wrapped.args); this.args = wrapped.args; this.wrapped = wrapped; }
/** * @param wrapped the context the created instance will wrap */ public WrappedContext(Context wrapped) { super(wrapped.id(), wrapped.request().asScala(), wrapped.request(), wrapped.session(), wrapped.flash(), wrapped.args, wrapped.lang, wrapped.components); this.args = wrapped.args; this.wrapped = wrapped; }
/** * Returns the current flash scope. */ public static Flash flash() { return Context.current().flash(); }