KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencrx > test > kernel > layer > application > TestOpenCrxKernel_1


1 /*
2  * ====================================================================
3  * Project: opencrx, http://www.opencrx.org/
4  * Name: $Id: TestOpenCrxKernel_1.java,v 1.1 2004/07/29 17:00:57 wfro Exp $
5  * Description: TestOpenCrxKernel_1
6  * Revision: $Revision: 1.1 $
7  * Owner: CRIXP AG, Switzerland, http://www.crixp.com
8  * Date: $Date: 2004/07/29 17:00:57 $
9  * ====================================================================
10  *
11  * This software is published under the BSD license
12  * as listed below.
13  *
14  * Copyright (c) 2004, CRIXP Corp., Switzerland
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  *
21  * * Redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer.
23  *
24  * * Redistributions in binary form must reproduce the above copyright
25  * notice, this list of conditions and the following disclaimer in
26  * the documentation and/or other materials provided with the
27  * distribution.
28  *
29  * * Neither the name of CRIXP Corp. nor the names of the contributors
30  * to openCRX may be used to endorse or promote products derived
31  * from this software without specific prior written permission
32  *
33  *
34  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
35  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
36  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
37  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
39  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
40  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
41  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
43  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
45  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46  * POSSIBILITY OF SUCH DAMAGE.
47  *
48  * ------------------
49  *
50  * This product includes software developed by the Apache Software
51  * Foundation (http://www.apache.org/).
52  *
53  * This product includes software developed by contributors to
54  * openMDX (http://www.openmdx.org/)
55  */

56 package org.opencrx.test.kernel.layer.application;
57
58 import java.net.URL JavaDoc;
59 import java.util.ArrayList JavaDoc;
60 import java.util.Arrays JavaDoc;
61 import java.util.Iterator JavaDoc;
62 import java.util.List JavaDoc;
63
64 import junit.framework.Test;
65 import junit.framework.TestCase;
66 import junit.framework.TestSuite;
67 import junit.textui.TestRunner;
68
69 import org.openmdx.application.log.AppLog;
70 import org.openmdx.base.exception.ServiceException;
71 import org.openmdx.kernel.application.configuration.Report;
72 import org.openmdx.kernel.application.container.lightweight.LightweightContainer;
73 import org.openmdx.kernel.exception.BasicException;
74 import org.openmdx.kernel.log.SysLog;
75 import org.openmdx.kernel.text.format.IndentingFormatter;
76
77 //---------------------------------------------------------------------------
78
public class TestOpenCrxKernel_1
79   extends TestCase {
80
81   //---------------------------------------------------------------------------
82
public TestOpenCrxKernel_1(String JavaDoc name) {
83       super(name);
84   }
85   
86   //---------------------------------------------------------------------------
87
public static void main(
88     String JavaDoc[] args
89   ){
90       TestRunner.run(suite());
91   }
92      
93   //---------------------------------------------------------------------------
94
public static Test suite(
95   ) {
96     TestSuite suite = new TestSuite();
97     for(
98       Iterator JavaDoc i = TestOpenCrxKernel_1.providerNames.iterator();
99       i.hasNext();
100     ) {
101       suite.addTest(new TestOpenCrxKernel_1((String JavaDoc)i.next()));
102     }
103     return suite;
104   }
105   
106   //---------------------------------------------------------------------------
107
protected void setUp(
108   ) throws Exception JavaDoc {
109       if(! deployed){
110          System.out.println("Deploying...");
111          LightweightContainer container = LightweightContainer.getInstance();
112          List JavaDoc reports = new ArrayList JavaDoc();
113          reports.add(
114             container.deployConnector(new URL JavaDoc(CONNECTOR_URL))
115          );
116          reports.addAll(
117             Arrays.asList(
118                 container.deployApplication(new URL JavaDoc(PROVIDER_URL))
119             )
120          );
121          SysLog.info(
122             "Deployment Reports", new IndentingFormatter(reports)
123          );
124          for(
125             Iterator JavaDoc i = reports.iterator();
126             i.hasNext();
127          ) if(((Report)i.next()).isSuccess()) i.remove();
128          if(!reports.isEmpty()) throw new ServiceException(
129             BasicException.Code.DEFAULT_DOMAIN,
130             BasicException.Code.INVALID_CONFIGURATION,
131             new BasicException.Parameter[]{
132                 new BasicException.Parameter("connector", CONNECTOR_URL),
133                 new BasicException.Parameter("application", PROVIDER_URL),
134                 new BasicException.Parameter("failures", reports)
135             },
136             "Deployment failed"
137          );
138          deployed = true;
139     }
140     System.out.println(">>>> **** Start Test: " + this.getName());
141   }
142
143   //---------------------------------------------------------------------------
144
protected void tearDown(
145   ) {
146     try {
147       String JavaDoc testName = "<<<< **** End Test: " + this.getName();
148       System.out.println(testName);
149       AppLog.info(testName);
150     }
151     catch(Exception JavaDoc e) {
152       System.out.println("error in deactivating");
153     }
154   }
155   
156   //---------------------------------------------------------------------------
157
public void runTest(
158   ) throws Throwable JavaDoc {
159   }
160   
161   //---------------------------------------------------------------------------
162
static private boolean deployed = false;
163   static private List JavaDoc providerNames = Arrays.asList(
164     new String JavaDoc[]{
165       "CRX"
166     }
167   );
168   static private final String JavaDoc PROVIDER_URL = "file:src/ear/opencrx-core-CRX.ear";
169   static private final String JavaDoc CONNECTOR_URL = "file:src/connector/openmdx-2/maxdb-7.rar";
170   
171 }
172
173 //--- End of File -----------------------------------------------------------
174
Popular Tags