You might also look at the MVP pattern as Ray described: http://code.google.com/events/io/sessions/GoogleWebToolkitBestPractices.html
Fred On Thu, Jul 9, 2009 at 4:22 AM, Miroslav Genov <[email protected]>wrote: > > You could create a mock view which is listening for such events. For > example: > > class MockAddressView implements AddressView, > HasValueChangeHandlers<...> { > .... > .. > } > and in your test: > > testUpdateUserDataNotifiesViewThatUserDataHasBeenUpdated() { > HandlerManager eventBus = new HandlerManager(); > AddressModel model = new AddressModel (eventBus); > final MockAddressView view = new MockAddressView(eventBus); > view.addValueChangeHandler(new ValueChangeHandler() { > void onValueChange(ValueChangeEvet<String> event) { > view.notified = true; > } > }); > > model.updateUserData(); > > assertTrue(view.isNotified()); > > } > > > > Regards, > Miroslav > > > corpios wrote: > > I'm designing an application following the MVC pattern. > > Each view have its own controller and model. > > The view know about the model and the controller. The controller know > > about the model. > > > > The Observer pattern is used to handle the model - view relation. The > > model notifies the view about changes in the model. > > > > When I try to unit test the application logic, i.e the controller and > > model, then I face a problem with the changehandlers. The model will > > try to update the view, but there is no view to update.. and as a > > result a NullPointerException is thrown. > > > > Does that tell me that I can't unit test application logic where the > > model send notifications to its observers? Or is there a better way to > > do this? > > > > BR > > Tor > > > > > > > > > > > > -- Fred Sauer [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
