Subject: I am trying to run JUnit4 testcases via maven2 for Swings application.
JUnit Test Case: TableGuiUtilTest.java
@Override
public void setUp() throws Exception {
helper = new JFCTestHelper();
tables = new JTable[NB_TABLES];
int globalIndex = 0;
for (int i = 0; i < tables.length; i++) {
Object[][] rowData = new Object[][]{
{"1", "2", "3"},
{"4", "5", "6"},
};
Object[] columnNames = new Object[NB_COLUMNS_PER_TABLE];
for (int j = 0; j < columnNames.length; j++, globalIndex++) {
columnNames[j] = (char)('A' + globalIndex);
}
JTable table = new JTable(rowData, columnNames);
table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
for (int column = 0; column < table.getColumnCount(); column++) {
table.getColumnModel().getColumn(column).setMaxWidth(COLUMN_WIDTH);
}
tables[i] = table;
}
JPanel content = new JPanel(new GridLayout(1, tables.length));
for (JTable table : tables) {
content.add(new JScrollPane(table));
}
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(NB_TABLES * NB_COLUMNS_PER_TABLE * COLUMN_WIDTH + 20, 100);
frame.setContentPane(content);
frame.setVisible(true); //line# 63 Error: com.agf.outilfo.swing.table.typedTable.util.TableGuiUtilTest.setUp(TableGuiUtilTest.java:63)
}
@Override
public void tearDown() throws Exception {
helper = null;
tables = null;
frame.dispose();
frame = null;
}
Output error Stacktrace:
java.lang.Error: Unexpected window shown - this window should be handled with WindowInterceptor.
at org.uispec4j.interception.toolkit.UISpecDisplay.assertAcceptsWindow(UISpecDisplay.java:117)
at org.uispec4j.interception.toolkit.UISpecDisplay.processWindow(UISpecDisplay.java:95)
at org.uispec4j.interception.toolkit.UISpecDisplay.showFrame(UISpecDisplay.java:34)
at org.uispec4j.interception.toolkit.UISpecDisplay.showFrame(UISpecDisplay.java:39)
at org.uispec4j.interception.toolkit.UISpecFramePeer.show(UISpecFramePeer.java:13)
at org.uispec4j.interception.toolkit.Empty$WindowPeeer.setVisible(Empty.java:240)
at org.uispec4j.interception.toolkit.UISpecFramePeer.setVisible(UISpecFramePeer.java:5)
at java.awt.Component.show(Component.java:1621)
at java.awt.Window.show(Window.java:1042)
at java.awt.Component.show(Component.java:1654)
at java.awt.Component.setVisible(Component.java:1606)
at java.awt.Window.setVisible(Window.java:1014)
at com.agf.outilfo.swing.table.typedTable.util.TableGuiUtilTest.setUp(TableGuiUtilTest.java:63)
at junit.extensions.jfcunit.JFCTestCase$1.run(JFCTestCase.java:314)
at junit.extensions.jfcunit.JFCTestCase$3.run(JFCTestCase.java:478)
at java.lang.Thread.run(Thread.java:745)
Error stack trace is pointing to: frame.setVisible(true);
Note: If I run testcase directly with JUnit in eclipse, I am able to get the pop-up window. But, while maven, it is getting above error.
Aucun commentaire:
Enregistrer un commentaire