01: package org.uispec4j;
02:
03: import javax.swing.SpinnerModel;
04: import javax.swing.JSpinner;
05: import javax.swing.SpinnerListModel;
06:
07: public class ListSpinnerTest extends SpinnerTestCase {
08: private ListSpinner listSpinner;
09:
10: protected void setUp() throws Exception {
11: super .setUp();
12: listSpinner = (ListSpinner) spinner;
13: }
14:
15: protected SpinnerModel createSpinnerModel() throws Exception {
16: return new SpinnerListModel(new String[] { "1", "2", "3" });
17: }
18:
19: protected Spinner createSpinner(JSpinner jSpinner) {
20: return new ListSpinner(jSpinner);
21: }
22:
23: public void testContentsEquals() throws Exception {
24: assertTrue(listSpinner.contentEquals(new String[] { "1", "2",
25: "3" }));
26: assertFalse(listSpinner.contentEquals(new String[] { "2", "3",
27: "1" }));
28: };
29:
30: public void testUsingListSpinnerWithOtherModelThanSpinnerListModelThrowsAnException()
31: throws Exception {
32: try {
33: new ListSpinner(new JSpinner());
34: fail();
35: } catch (ItemNotFoundException e) {
36: assertEquals("Expected JSpinner using a SpinnerListModel",
37: e.getMessage());
38: }
39: }
40: }
|