Package org.strecks.injection.handler.impl

Examples of org.strecks.injection.handler.impl.ActionWithMessageResourcesHelper


  @Test
  public void testNamedBundle()
  {

    ActionWithMessageResourcesHelper action = new ActionWithMessageResourcesHelper();
    reader.readAnnotations(action.getClass());
    inputs = reader.getInjectionMap();

    expect(request.getAttribute(Globals.MODULE_KEY)).andReturn(moduleConfig);
    expect(moduleConfig.getPrefix()).andReturn("/mymodule");
    expect(context.getAttribute("my.key/mymodule")).andReturn(messageResources);
    expect(request.getAttribute(Globals.LOCALE_KEY)).andReturn(locale);
   
    //expected from helper getMessage() invocation
    expect(messageResources.getMessage(eq(Locale.getDefault()), eq("some.key"))).andReturn("My Message");

    replay(context);
    replay(request);
    replay(moduleConfig);
    replay(messageResources);

    InjectionWrapper inputWrapper = inputs.get("namedHelper");

    ActionContext injectionContext = new TestContextImpl(request, null, context, null, null);
    inputWrapper.inject(action, injectionContext);
    MessageResourcesHelper namedHelper = action.getNamedHelper();
   
    namedHelper.getMessage("some.key");
   
    verify(context);
    verify(request);
View Full Code Here


  @Test
  public void testDefaultBundle()
  {

    ActionWithMessageResourcesHelper action = new ActionWithMessageResourcesHelper();
    reader.readAnnotations(action.getClass());
    inputs = reader.getInjectionMap();

    expect(request.getAttribute(Globals.MODULE_KEY)).andReturn(moduleConfig);
    expect(moduleConfig.getPrefix()).andReturn("");
    expect(context.getAttribute(Globals.MESSAGES_KEY)).andReturn(messageResources);
    expect(request.getAttribute(Globals.LOCALE_KEY)).andReturn(locale);
   
    //expected from helper getMessage() invocation
    expect(messageResources.getMessage(eq(Locale.getDefault()), eq("some.key"))).andReturn("My Message");

    replay(context);
    replay(request);
    replay(moduleConfig);
    replay(messageResources);

    InjectionWrapper inputWrapper = inputs.get("defaultHelper");

    ActionContext injectionContext = new TestContextImpl(request, null, context, null, null);
    inputWrapper.inject(action, injectionContext);
    MessageResourcesHelper defaultHelper = action.getDefaultHelper();
    defaultHelper.getMessage("some.key");

    verify(context);
    verify(request);
    verify(moduleConfig);
View Full Code Here

TOP

Related Classes of org.strecks.injection.handler.impl.ActionWithMessageResourcesHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.