Java Mailing List Archive

http://www.gg3721.com/

Home » user.jmock »

[jmock-user] How to mock web service call?

gurm

2009-08-27

Replies: Find Java Web Hosting

Author LoginPost Reply

Hi,
I am new to Jmock.
Could you please tell me how to test below code?


publi Interface AccountWebService
{
 void addAccount(String accountDetails) throws Exception;
}

public class AccountWebServiceImpl implements AccountWebService
{
 public void addAccount(final String accountDetails) throws Exception
 {
    // Here web service actual implementation.
 }
}


public Interface AccountManager
{
  void addAccount(String accountDetails) throws Exception;
 // Some other methods

}

public class AccountManagerImpl implements AccountManager
{

public AccountManagerImpl()
{
}

public void addAccount(String accountDetails) throws Exception
{
  AccountWebService accountService = new AccountWebServiceImpl();
  // In some cases getting web service implementation with static
methods.
  //Do validation on input parameter.
  //.......
  accountService.addAccount(somerequest)
 
}
}

How to mock AccountWebService here?
If we are creating objects within method instead of passing as parameters ,
How to test?

Thanks,
Guru

--
Sent from the jMock - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email


©2008 gg3721.com - Jax Systems, LLC, U.S.A.