Posts tagged ‘Asynchronous services’

May 12, 2011

Testing asynchronous services with Mockito

by Stefan

Programming asynchronous services can be really challenging. Examples are asynchronous webservices, GWT server calls or event-based systems like widget toolkits. Usually, clients have to pass a callback to the service on which a method is called on success or error containing the data to proceed or an error message.
A typical asynchronous system is your local pizza service:

package cleancodematters;

public class PizzaService {

  public interface PizzaEvent {
    void pizzaAvailable( Pizza pizza );
  }

  public void orderPizza( String name, PizzaEvent event ) {
    // some async processing, calls event on finish
  }
}

read more »

Advertisements