1 package com.sri.emo.wizard.wizardgateway;
2
3 import java.util.HashMap;
4 import com.jcorporate.expresso.core.controller.ControllerException;
5 import com.jcorporate.expresso.core.controller.ExpressoResponse;
6 import com.jcorporate.expresso.core.controller.Input;
7 import com.jcorporate.expresso.core.controller.Transition;
8 import com.jcorporate.expresso.core.db.DBException;
9 import com.jcorporate.expresso.services.test.ControllerTestFixture;
10 import com.jcorporate.expresso.services.test.TestSystemInitializer;
11 import com.sri.emo.test.DatabaseTestFixture;
12 import com.sri.emo.test.EmoTestSuite;
13 import org.jmock.MockObjectTestCase;
14
15 /***
16 *
17 * @author Michael Rimov
18 * @version 1.0
19 */
20 public class TestPromptAddWizard extends MockObjectTestCase {
21
22
23 /***
24 * DBUnit wrapping test fixture.
25 */
26 private DatabaseTestFixture databaseTestFixture;
27
28 /***
29 * Controller test fixture. Used for invoking controllers.
30 */
31 private ControllerTestFixture testFixture;
32
33 protected void setUp() throws Exception {
34 super.setUp();
35
36 databaseTestFixture = new DatabaseTestFixture(TestSystemInitializer.getTestContext(),
37 EmoTestSuite.class.getResourceAsStream("WizardTestData.xml"));
38
39 databaseTestFixture.setUp();
40
41 testFixture = new ControllerTestFixture();
42 testFixture.setUp();
43 }
44
45 protected void tearDown() throws Exception {
46 databaseTestFixture.tearDown();
47 databaseTestFixture = null;
48
49 testFixture.tearDown();
50 testFixture = null;
51 super.tearDown();
52 }
53
54 public void testHandleRequest() throws DBException, ControllerException {
55 ExpressoResponse response = testFixture.invokeFacade(WizardGatewayController.class, new HashMap(),PromptAddWizard.STATE_NAME);
56 assertEquals("Choose Type of Wizard", response.getTitle());
57 Transition cancel = response.getTransition("cancel");
58 assertTrue(cancel != null);
59 Transition submit = response.getTransition("next");
60 assertTrue(submit != null);
61
62 Input selectionInput = response.getInput(AddWizardHandler.PARAM_WIZARD_TYPE);
63 assertTrue(selectionInput != null);
64 assertTrue(selectionInput.getDefaultValue() != null);
65 assertTrue(selectionInput.getValidValuesList().size() == 2);
66
67 }
68
69 }