1 Reply Latest reply on Jul 10, 2013 11:15 AM by tcunning

    JUnit 4 test case for JBossESB action class

    sbutt

      Hi Guys,

                    I have a jbossesb project which has a few action classes. I need to prepare as a starting point some very basic junit test case for it. I am using pom to build my project.

       

      I have written some standard java test cases (for a very standard j2se class) using junit 4 via junit eclipse plugin.

       

      But I have no idea how to write junit test case for my esb action class? And then how to execute the test case and see the output of the test results in somewhere. I have read somewhere that i need arquillian (for esb dependencies) and sonar frameworks for seeing the output of junit tests, but I have no idea how all this work together and what i need to put in my project pom file as dependencies?

       

      Here is one example of my esb action class.

       

      public class checkLocationDetailResponse implements ActionLifecycle {
      
      
                private static Log logger = LogFactory.getLog(checkLocationDetailResponse.class);
      
      
                  public checkLocationDetailResponse(ConfigTree config)
                  {
                  }
                  
                  public Message process(Message message)
                  {
                            String response = (String)message.getBody().get();
                      
                      if (response != null && response.indexOf("Station") > 0 && response.indexOf("BookingId") <= 0)
                      {
                            
                        String [][] params = (String [][])message.getProperties().getProperty("xsl-params");
                        
                        if (params == null)
                        {
                          message.getProperties().setProperty("xsl-params", new String [] []{{"locationDetailMsgResponseNode", response}});
                        }
                        else
                        {
                          String [][] paramsNew = new String [params.length + 1] [2];
                          for (int i = 0; i < params.length; i ++ )
                          {
                            paramsNew [i] [0] = params [i] [0];
                            paramsNew [i] [1] = params [i] [1];
                          }
                          paramsNew [params.length] [0] = "locationDetailMsgResponseNode";
                          paramsNew [params.length] [1] = response;
                          message.getProperties().setProperty("xsl-params", paramsNew);
                        }
                        
                                
                        message.getBody().add(response);
                        
                      }
                    
                    return message;
      
      
                        
                  }
      
      
        
                  public void destroy() throws ActionLifecycleException
                  {
                    // TODO Auto-generated method stub
                  }
      
      
                  public void initialise() throws ActionLifecycleException
                  {
                    // TODO Auto-generated method stub
                  }
                }
      

       

      Could someone please help get me started by writing any 'basic' test case for this above action class, just for me to get some idea? I would make proper test cases for my other action classes.

       

      Thanks.