01: package org.uispec4j.interception;
02:
03: import junit.framework.AssertionFailedError;
04: import org.uispec4j.utils.AssertionFailureNotDetectedError;
05: import org.uispec4j.utils.Utils;
06:
07: import javax.swing.*;
08:
09: public class WindowInterceptionTest extends InterceptionTestCase {
10:
11: public void testShowingAnUnexpectedWindow() throws Exception {
12: JFrame frame = new JFrame();
13: String frameTitle = "frame(" + getName() + ")";
14: frame.setTitle(frameTitle);
15: frame.getContentPane().add(new JButton("OK"));
16: try {
17: frame.setVisible(true);
18: throw new AssertionFailureNotDetectedError();
19: } catch (AssertionFailedError e) {
20: assertEquals(
21: "Unexpected window shown - this window should be handled with WindowInterceptor. "
22: + "Window contents:"
23: + "<window title=\""
24: + frameTitle
25: + "\">"
26: + "<button label=\"OK\"/></window>", e
27: .getMessage().replaceAll(
28: Utils.LINE_SEPARATOR, ""));
29: }
30: }
31: }
|