1   /***
2    * @(#)ServiceTest.java
3    * 
4    * JFoxSOAF, Service-Oriented Application Framework
5    * 
6    * Copyright(c) JFoxSOAF Team
7    * 
8    * Licensed under the GNU LGPL, Version 2.1 (the "License"); 
9    * you may not use this file except in compliance with the License. 
10   * You may obtain a copy of the License at  
11   * 
12   * http://www.gnu.org/copyleft/lesser.html
13   * 
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, 
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
17   * See the License for the specific language governing permissions and 
18   * limitations under the License. 
19   * 
20   * For more information, please visit:
21   * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
22   * http://www.huihoo.org/jfox/jfoxsoaf
23   */
24  
25  package org.huihoo.jfox.soaf.schema.service;
26  
27  import java.io.InputStream;
28  import java.io.InputStreamReader;
29  
30  import junit.framework.TestCase;
31  
32  import org.exolab.castor.xml.MarshalException;
33  import org.exolab.castor.xml.ValidationException;
34  
35  /***
36   * JUnit test case for the {@link org.huihoo.jfox.soaf.schema.service.Service).
37   * 
38   * @author <a href="mailto:founder_chen@yahoo.com">Peter Cheng </a>
39   * @version $Revision: 1.4 $ $Date: 2005/01/17 14:11:41 $
40   * @version Revision: 1.0
41   */
42  
43  public class ServiceTest extends TestCase {
44  
45      private ClassLoader cl = null;
46  
47      private InputStream is = null;
48  
49      private InputStreamReader isr = null;
50  
51      /***
52       * @see TestCase#setUp()
53       */
54      protected void setUp() throws Exception {
55          super.setUp();
56          cl = Thread.currentThread().getContextClassLoader();
57          is = cl.getResourceAsStream("system-service.xml");
58          isr = new InputStreamReader(is);
59      }
60  
61      /***
62       * @see TestCase#tearDown()
63       */
64      protected void tearDown() throws Exception {
65          super.tearDown();
66          is.close();
67          isr.close();
68      }
69  
70      /***
71       * Class under test for org.huihoo.jfox.soaf.schema.service.ServiceEntry[]
72       * getServiceEntry()
73       */
74      public void testGetServiceEntry() {
75          Service service = null;
76          try {
77              service = Service.unmarshal(isr);
78          } catch (MarshalException e) {
79              e.printStackTrace();
80          } catch (ValidationException e) {
81              e.printStackTrace();
82          }
83  
84          ServiceEntry[] serviceEntry = service.getServiceEntry();
85  
86          assertNotNull(serviceEntry[0].getImplementation());
87      }
88  
89  }