1   package com.sri.emo.wizard.defaults;
2   
3   import junit.framework.TestCase;
4   
5   import com.jcorporate.expresso.core.controller.ErrorCollection;
6   import com.sri.emo.wizard.ValidValueWithComment;
7   import com.sri.emo.wizard.WizardException;
8   
9   /***
10   * Fills in untested code in the default wizard page.
11   * @author Michael Rimov
12   */
13  public class TestEmoWizardPage extends TestCase {
14      private EmoWizardPage emoWizardPage = null;
15  
16      private static final Integer pageId = new Integer(11);
17  
18      private static final ValidValueWithComment[] menu = new ValidValueWithComment[]{
19          new ValidValueWithComment("test","Test 1", "This is a test comment"),
20      };
21  
22      protected void setUp() throws Exception {
23          super.setUp();
24          emoWizardPage = new EmoWizardPage(pageId, null, menu);
25      }
26  
27      protected void tearDown() throws Exception {
28          emoWizardPage = null;
29          super.tearDown();
30      }
31  
32      public void testAddError() {
33          final String message = "Test";
34          emoWizardPage.addError(message);
35          ErrorCollection ec = emoWizardPage.getPageErrors();
36          assertNotNull(ec);
37          assertEquals(1,ec.getErrorCount());
38          assertEquals(message, ec.getErrorStrings()[0]);
39      }
40  
41      public void testGetPrintableData() throws WizardException {
42          emoWizardPage.setData("test");
43          assertEquals("Test 1", emoWizardPage.getPrintableData());
44  
45          emoWizardPage = new EmoWizardPage(pageId, null, null);
46          emoWizardPage.setData("test");
47          assertEquals("test", emoWizardPage.getPrintableData());
48  
49  
50      }
51  
52      public void testHashCode() {
53          assertEquals(pageId.hashCode(), emoWizardPage.hashCode());
54      }
55  
56      public void testRemoveErrors() {
57          emoWizardPage.addError("Test");
58          emoWizardPage.removeErrors();
59          ErrorCollection ec = emoWizardPage.getPageErrors();
60          assertNull(ec);
61      }
62  
63  }