// when we get here
httpSessionLock.lock();// simulating servlet container's
// session lock
- mockService.fireSessionDestroy(session);
- httpSessionLock.unlock();
+ try {
+ mockService.fireSessionDestroy(session);
+ } finally {
+ httpSessionLock.unlock();
+ }
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
};
session.getLockInstance().lock();
+ try {
+ UI ui = new UI() {
+ @Override
+ protected void init(VaadinRequest request) {
+ }
+ };
+ ui.setSession(session);
+
+ VerticalLayout layout = new VerticalLayout();
+ ui.setContent(layout);
+ return layout;
+ } finally {
+ session.getLockInstance().unlock();
+ }
- UI ui = new UI() {
- @Override
- protected void init(VaadinRequest request) {
- }
- };
- ui.setSession(session);
-
- VerticalLayout layout = new VerticalLayout();
- ui.setContent(layout);
-
- session.getLockInstance().unlock();
- return layout;
}
@Test
try {
target.addComponent(testComponent);
throw new AssertionError(
- "Moving component when not holding its sessions's lock should throw");
+ "Moving component when not holding its sessions's lock should throw");
} catch (IllegalStateException e) {
Assert.assertEquals(
- "Cannot remove from parent when the session is not locked.",
- e.getMessage());
+ "Cannot remove from parent when the session is not locked.",
+ e.getMessage());
}
}
try {
lockedComponent.addComponent(notLockedComponent);
throw new AssertionError(
- "Moving component when not holding its sessions's lock should throw");
+ "Moving component when not holding its sessions's lock should throw");
} catch (IllegalStateException e) {
Assert.assertEquals(
- "Cannot remove from parent when the session is not locked."
- + " Furthermore, there is another locked session, indicating that the component might be about to be moved from one session to another.",
- e.getMessage());
+ "Cannot remove from parent when the session is not locked."
+ + " Furthermore, there is another locked session, indicating that the component might be about to be moved from one session to another.",
+ e.getMessage());
}
}