Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/RuntimeCollective/webapps/test/RuntimeTestCase.java


1   /* $Header: /home/CVS/rjp/src/com/RuntimeCollective/webapps/test/RuntimeTestCase.java,v 1.3 2003/09/30 15:13:19 joe Exp $
2    * $Revision: 1.3 $
3    * $Date: 2003/09/30 15:13:19 $
4    *
5    * ====================================================================
6    *
7    * Josephine : http://www.runtime-collective.com/josephine/index.html
8    *
9    * Copyright (C) 2003 Runtime Collective
10   * 
11   * This product includes software developed by the
12   * Apache Software Foundation (http://www.apache.org/).
13   *
14   * This library is free software; you can redistribute it and/or
15   * modify it under the terms of the GNU Lesser General Public
16   * License as published by the Free Software Foundation; either
17   * version 2.1 of the License, or (at your option) any later version.
18   *
19   * This library is distributed in the hope that it will be useful,
20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22   * Lesser General Public License for more details.
23   *
24   * You should have received a copy of the GNU Lesser General Public
25   * License along with this library; if not, write to the Free Software
26   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27   *
28   */
29  
30  package com.RuntimeCollective.webapps.test;
31  
32  import com.RuntimeCollective.webapps.EntityBeanStore;
33  import com.RuntimeCollective.webapps.EntityBeanStoreHandler;
34  import com.RuntimeCollective.webapps.RuntimeDataSource;
35  import com.RuntimeCollective.webapps.RuntimeParameters;
36  
37  import junit.framework.Test;
38  import junit.framework.TestCase;
39  import junit.framework.TestSuite;
40  
41  public class RuntimeTestCase extends TestCase {
42  
43      /**
44       * RuntimeTestCase is a basic TestCase, which sets up a database in RuntimeDataSource and RuntimeParameters.
45       *
46       * In each module, it should be extended into a ModuleTestCase.
47       * The ModuleTestCase will add module-specific RuntimeParameters, and register the required beans.
48       *
49       * Finally, each module will define one or many actual test cases, by extending ModuleTestCase.
50       * <p>When called as an application, this takes the following command line parameters in order:
51       * <ol>
52       * <li> default db alias
53       * <li> JDBC driver class
54       * <li> max connections
55       * <li> min connections
56       * <li> db user
57       * <li> db password
58       * <li> db url
59       * <li> db type eg: postgresql
60       * <li> page root eg: localhost:8080/se
61       * <li> webapps home eg: /home/fabrice/java/tomcat/webapps/se
62       * <li> tomcatHome, eg: /home/fabrice/java/tomcat
63       * </ol>
64       *
65       * Example:
66       *   - com.RuntimeCollective.content.test.ContentTestCase implements com.RuntimeCollective.webapps.RuntimeTestCase
67       *   - com.RuntimeCollective.content.test.FileTest implements com.RuntimeCollective.content.test.ContentTestCase
68       *   - com.RuntimeCollective.content.test.ImageTest implements com.RuntimeCollective.content.test.ContentTestCase
69       */
70      public static void main(String args[]) { 
71      }
72  
73  
74      public static void setupRuntime(String args[]) {
75  
76    if (args.length < 11) {
77        System.out.println("RuntimeTestCase was not called with its compulsory 11 parameters.\n\nYou should specify :\n- db0.alias (default db), eg: RC\n- db0.JDBCDriverClass, eg: org.postgresql.Driver\n- db0.maxConnections, eg: 3\n- db0.minConnections, eg: 1\n- db0.user, eg: se\n- db0.password, eg: the_password\n- db0.url, eg: jdbc:postgresql://localhost:5432/sedb\n- db0.type, eg: postgresql\n-  pageRoot, eg: localhost:8080/se\n- webappsHome, eg: /home/fabrice/java/tomcat/webapps/se\n- tomcatHome, eg: /home/fabrice/java/tomcat \n\n");
78        return;
79    }
80  
81    try {
82        RuntimeDataSource.addDb(0, args[0], args[1], Integer.valueOf(args[2]).intValue(), Integer.valueOf(args[3]).intValue(), args[4], args[5], args[6], args[7]);
83    } catch (RuntimeException e) {
84        fail("Couldn't add db 0 : "+e);
85    }
86  
87    RuntimeParameters.set("db.alias", args[0]);
88  
89    RuntimeDataSource.doneAdding();
90  
91    RuntimeParameters.set("pageRoot", args[8]);
92    RuntimeParameters.set("webappsHome", args[9]);
93    RuntimeParameters.set("tomcatHome", args[10]);
94      }
95  
96      public RuntimeTestCase(String name) {
97    super(name);
98      }
99  
100     protected void setUp() {
101     }
102 
103     protected void tearDown() { 
104     }
105 
106     public void LogTestSection(String message) {
107   String separator = "\n\n-----------------------------------\n\n";
108   System.out.println(separator+message+separator);
109     }
110 }