summaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2012-09-24 12:46:20 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2012-09-24 12:47:01 +0300
commit8bf280863e7a0b4c5414d214384345ce6f052c60 (patch)
tree3a0fbd010db7a8baa2b41ccfb57a04d42fb8f84d /server/tests
parent45332b5744d886e36bb999a48f0de26161458066 (diff)
downloadvaadin-framework-8bf280863e7a0b4c5414d214384345ce6f052c60.tar.gz
vaadin-framework-8bf280863e7a0b4c5414d214384345ce6f052c60.zip
Test error views and error providers (#9060)
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java45
1 files changed, 44 insertions, 1 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java b/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java
index f97c2fdeb5..fc36c77e56 100644
--- a/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java
+++ b/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java
@@ -77,7 +77,11 @@ public class NavigatorTest extends TestCase {
}
public View getView(String viewAndParameters) {
- navigateTo(viewAndParameters);
+ try {
+ navigateTo(viewAndParameters);
+ } catch (IllegalArgumentException e) {
+ // ignore
+ }
return ((TestDisplay) getDisplay()).getCurrentView();
}
}
@@ -593,4 +597,43 @@ public class NavigatorTest extends TestCase {
assertEquals("Incorrect view name found", TestView.class, navigator2
.getView("test").getClass());
}
+
+ public void testNavigateToUnknownView() {
+ TestNavigator navigator = new TestNavigator();
+
+ View errorView = EasyMock.createMock(View.class);
+ errorView.enter(EasyMock.anyObject(ViewChangeEvent.class));
+ EasyMock.replay(errorView);
+
+ try {
+ navigator.navigateTo("doesnotexist");
+ fail("Should throw IllegalArgumentException");
+ } catch (IllegalArgumentException iae) {
+ }
+
+ navigator.setErrorView(errorView);
+ navigator.navigateTo("doesnotexist");
+
+ View testView = EasyMock.createMock(View.class);
+ testView.enter(EasyMock.anyObject(ViewChangeEvent.class));
+ EasyMock.replay(testView);
+
+ navigator.addView("doesnotexist", testView);
+ navigator.navigateTo("doesnotexist");
+
+ View errorView2 = EasyMock.createMock(View.class);
+ errorView2.enter(EasyMock.anyObject(ViewChangeEvent.class));
+ EasyMock.replay(errorView2);
+
+ ViewProvider errorProvider = EasyMock.createMock(ViewProvider.class);
+ EasyMock.expect(errorProvider.getView("doesnotexist2")).andReturn(
+ errorView2);
+ EasyMock.expect(errorProvider.getViewName("doesnotexist2")).andReturn(
+ "doesnotexist2");
+ EasyMock.replay(errorProvider);
+
+ navigator.setErrorProvider(errorProvider);
+ navigator.navigateTo("doesnotexist2");
+
+ }
}