1   /***
2    * JFoxSOAF, Service-Oriented Application Framework
3    * 
4    * Copyright (C) www.huihoo.org
5    * 
6    * Distributable under GNU LGPL For more information, please visit:
7    * http://www.huihoo.org/jfox/jfoxsoaf
8    */
9   
10  package org.huihoo.jfox.soaf.schema.config;
11  
12  import java.io.InputStream;
13  import java.io.InputStreamReader;
14  
15  import junit.framework.TestCase;
16  
17  import org.exolab.castor.xml.MarshalException;
18  import org.exolab.castor.xml.ValidationException;
19  
20  /***
21   * JUnit test case for the
22   * {@link org.huihoo.jfox.soaf.schema.config.Configration).
23   * 
24   * @author <a href="mailto:founder_chen@yahoo.com">Yong.Cheng </a>
25   * @version $Revision: 1.2 $ $Date: 2004/10/17 15:22:46 $
26   * @version Revision: 1.0
27   */
28  
29  public class ConfigurationTest extends TestCase {
30  
31      private ClassLoader cl = null;
32  
33      private InputStream is = null;
34  
35      private InputStreamReader isr = null;
36  
37      private Configuration configuration = null;
38  
39      /***
40       * @see TestCase#setUp()
41       */
42      protected void setUp() throws Exception {
43          super.setUp();
44          cl = Thread.currentThread().getContextClassLoader();
45          is = cl.getResourceAsStream("jfoxsoaf-config.xml");
46          isr = new InputStreamReader(is);
47          try {
48              configuration = Configuration.unmarshal(isr);
49          } catch (MarshalException e) {
50              e.printStackTrace();
51          } catch (ValidationException e) {
52              e.printStackTrace();
53          }
54      }
55  
56      /***
57       * @see TestCase#tearDown()
58       */
59      protected void tearDown() throws Exception {
60          super.tearDown();
61          is.close();
62          isr.close();
63      }
64  
65      /***
66       * Test for ServiceConfiguration getServiceConfiguration()
67       */
68      public void testGetServiceConfiguration() {
69          ConfigurationEntry[] cofiguraitonEntry = configuration
70                  .getServiceConfiguration().getConfigurationEntry();
71  
72          assertNotNull(cofiguraitonEntry[0].getValue());
73      }
74  
75      /***
76       * Test for SystemInterceptor getSystemInterceptor()
77       */
78      public void testGetSystemInterceptor() {
79  
80          Interceptor[] interceptor = configuration.getSystemInterceptor()
81                  .getInterceptor();
82  
83          assertNotNull(interceptor[0].getValue());
84      }
85  
86  }