1   /* ===================================================================
2    * Copyright 2002-04 SRI International.
3    * Released under the MOZILLA PUBLIC LICENSE Version 1.1
4    * which can be obtained at http://www.mozilla.org/MPL/MPL-1.1.html
5    *
6    * This program is distributed in the hope that it will be useful, but
7    * WITHOUT ANY WARRANTY; without even the implied warranty of
8    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9    * See the MOZILLA PUBLIC LICENSE for more details.
10   * =================================================================== */
11  package com.sri.emo.test;
12  
13  import java.util.Vector;
14  import com.jcorporate.expresso.core.registry.MutableRequestRegistry;
15  import com.jcorporate.expresso.core.security.SuperUser;
16  import com.jcorporate.expresso.services.test.DBTestSuite;
17  import com.jcorporate.expresso.services.test.TestSystemInitializer;
18  import com.sri.emo.wizard.completion.persistence.TestExpressoCompletionRepository;
19  import com.sri.emo.wizard.completion.TestCompletionMementoConverter;
20  import com.sri.emo.commandline.defaults.DefaultSQLGeneratorTestCase;
21  
22  /***
23   * JUnit Test suite for EMO.  Includes DB integration, but not servlet
24   * integration.
25   */
26  public class EmoTestSuite
27          extends DBTestSuite {
28  
29      /***
30       * Default Constructor.
31       */
32  
33      public EmoTestSuite() {
34          super();
35      }
36  
37  
38      /***
39       * The full gamut of tests that are run for EMO.
40       *
41       * @return Test the constructed test.
42       * @throws Exception upon construction error.
43       */
44      public static junit.framework.Test suite() throws Exception {
45  
46          System.out.println("---------------------------------------------");
47          System.out.println(" ");
48          System.out.println("       Initializing Test Suite               ");
49          System.out.println(" ");
50          System.out.println("junit.argv.configDir: " + System.getProperty("junit.argv.configDir"));
51          System.out.println("junit.argv.webAppDir: " + System.getProperty("junit.argv.webAppDir"));
52          System.out.println("   junit.argv.logDir: " + System.getProperty("junit.argv.logDir"));
53          System.out.println(" ");
54          System.out.println("---------------------------------------------");
55  
56          TestSystemInitializer.setUp();
57  
58          EmoTestSuite ts = new EmoTestSuite();
59          ts.addTest(com.sri.emo.dbobj.TestSchema.suite());
60          ts.addTestSuite(com.sri.emo.TestEmoSchema.class);
61          ts.addTestSuite(com.sri.emo.test.TestDatabaseTestFixture.class);
62  
63          ts.addTestSuite(com.sri.common.util.TestPicklistCombinator.class);
64          ts.addTestSuite(com.sri.common.controller.TestControllerUtil.class);
65          ts.addTestSuite(com.sri.common.controller.TestContainerController.class);
66  
67          ts.addTestSuite(com.sri.emo.dbobj.model_tree.TestDefaultModel.class);
68  
69          ts.addTestSuite(com.sri.emo.wizard.TestWizardException.class);
70          ts.addTestSuite(com.sri.emo.wizard.expressoimpl.TestWizardController.class);
71          ts.addTestSuite(com.sri.emo.wizard.selection.TestSelectionWizardRepository.class);
72          ts.addTestSuite(com.sri.emo.wizard.selection.TestSelectionWizardFactory.class);
73          ts.addTestSuite(com.sri.emo.wizard.defaults.TestSequentialWizard.class);
74          ts.addTestSuite(com.sri.emo.wizard.TestWizardException.class);
75          ts.addTestSuite(com.sri.emo.controller.TestTreeViewVisitor.class);
76          ts.addTestSuite(com.sri.emo.controller.TestSelectionManager.class);
77          ts.addTestSuite(com.sri.emo.controller.TestWizardAction.class);
78          ts.addTestSuite(com.sri.emo.controller.TestDecisionMatrix.class);
79          ts.addTestSuite(com.sri.emo.controller.TestImportExportModel.class);
80  
81  
82  
83          //Test case for misc. wizard stuff..
84          ts.addTestSuite(com.sri.emo.wizard.TestValidValueWithComment.class);
85          ts.addTestSuite(com.sri.emo.wizard.TestAbstractWizard.class);
86  
87          ts.addTestSuite(com.sri.emo.wizard.defaults.TestEmoWizardPage.class);
88          ts.addTestSuite(com.sri.emo.wizard.defaults.TestEmoWizardMetadata.class);
89  
90      //Selection Wizard Management.
91          ts.addTestSuite(com.sri.emo.wizard.selection.management.TestWizardStepController.class);
92          ts.addTestSuite(com.sri.emo.wizard.selection.management.TestPromptInstructions.class);
93  
94  
95          //Test Wizard Gateway
96          ts.addTestSuite(com.sri.emo.wizard.wizardgateway.TestPromptAddWizard.class);
97          ts.addTestSuite(com.sri.emo.wizard.wizardgateway.TestDoAddWizard.class);
98          ts.addTestSuite(com.sri.emo.wizard.wizardgateway.TestListWizards.class);
99          ts.addTestSuite(com.sri.emo.wizard.wizardgateway.TestEditWizard.class);
100         ts.addTestSuite(com.sri.emo.wizard.wizardgateway.TestPromptDeleteWizard.class);
101         ts.addTestSuite(com.sri.emo.wizard.wizardgateway.TestDoDeleteWizard.class);
102         ts.addTestSuite(com.sri.emo.wizard.wizardgateway.TestRunWizard.class);
103 
104         //Test Step Editor
105         ts.addTestSuite(com.sri.emo.wizard.selection.management.TestPromptStepType.class);
106 
107         //Completion Wizard Stuff
108         ts.addTestSuite(com.sri.emo.wizard.completion.persistence.TestEmoCompletionDBObjConverter.class);
109         ts.addTestSuite(TestExpressoCompletionRepository.class);
110         ts.addTestSuite(com.sri.emo.wizard.completion.TestEmoCompletionFactory.class);
111         ts.addTestSuite(com.sri.emo.wizard.completion.TestEmoCompletionWizardTestModel.class);
112         ts.addTestSuite(com.sri.emo.wizard.completion.TestMinMaxPageMetadata.class);
113         ts.addTestSuite(TestCompletionMementoConverter.class);
114 
115 
116         //Test Completion Wizard Manager
117         ts.addTestSuite(com.sri.emo.wizard.completion.management.TestPromptChooseNode.class);
118         ts.addTestSuite(com.sri.emo.wizard.completion.management.TestDoChooseNodeStep.class);
119         ts.addTestSuite(com.sri.emo.wizard.completion.model.TestCompletionBean.class);
120         ts.addTestSuite(com.sri.emo.wizard.completion.management.TestPromptChooseParts.class);
121         ts.addTestSuite(com.sri.emo.wizard.completion.management.TestDoChooseCriteria.class);
122         ts.addTestSuite(com.sri.emo.wizard.completion.management.TestPromptChooseCriteria.class);
123         ts.addTestSuite(com.sri.emo.wizard.completion.persistence.TestWizDefinition.class);
124 
125 
126         ts.addTestSuite(com.sri.emo.annotations.NodeTagsTestCase.class);
127 
128 
129         //
130         //Test Tree Deletion
131         //
132         ts.addTestSuite(com.sri.emo.dbobj.selectiontree.TreeDeletionSelectorTestCase.class);
133 
134 
135         //Test sql generation.
136         ts.addTestSuite(DefaultSQLGeneratorTestCase.class);
137 
138         return ts;
139     }
140 
141     /***
142      * Dynamic addition of background schema to be deleted when this
143      * suite is over
144      *
145      * @param schemas a vector of Schema instances.
146      * @throws Exception upon error.
147      */
148     protected void addSchema(Vector schemas)
149             throws Exception {
150         TestSystemInitializer.setUp();
151         schemas.add(com.sri.emo.EmoSchema.class.newInstance());
152 
153 
154         //Set the request registry to the test data context
155         //for the course of the testing.
156         new MutableRequestRegistry(TestSystemInitializer.getTestContext(),
157                 SuperUser.INSTANCE);
158 
159         super.addSchema(schemas);
160     }
161 
162 
163     public static void main(String[] args)
164             throws Exception {
165 
166         //Set the system properties we need
167         junit.textui.TestRunner.run(suite());
168     }
169 }