I am facing one issue while writing the junit of my struts 2 action
class.My action class has following code
    snippet

    getText("customerLabel")

While execution of junit i get below error though works fine thru
application(i think
    Struts controller loads it while normal web flow which does not happen
during junit)

    java.lang.NullPointerException
at
com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:361)
at
com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:208)
at
com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:123)
at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:103)

I could get it working with a workaround by below code sniipet in my test
class and asiign it to my my action annotated with  annotation TestedObject



      action = new Myction()
        {
          @Override
          public String getText(String textName)
          {
            return "mockedLabel";
          }
        };

 But i am looking for clean solution?

Reply via email to