* the requested view name is found.
*
* @param provider
- * provider to register
+ * provider to register, not <code>null</code>
+ * @throws IllegalArgumentException
+ * if the provided view provider is <code>null</code>
*/
public void addProvider(ViewProvider provider) {
+ if (provider == null) {
+ throw new IllegalArgumentException(
+ "Cannot add a null view provider");
+ }
providers.add(provider);
}
navigator.addView("view", view);
navigator.navigateTo("view");
}
+
+ public void testNullViewProvider() {
+ IMocksControl control = EasyMock.createControl();
+ NavigationStateManager manager = control
+ .createMock(NavigationStateManager.class);
+ ViewDisplay display = control.createMock(ViewDisplay.class);
+
+ // create navigator to test
+ Navigator navigator = createNavigator(manager, display);
+
+ try {
+ navigator.addProvider(null);
+ fail("Should not be allowed to add a null view provider");
+ } catch (IllegalArgumentException e) {
+ // Expected
+ }
+ }
}