View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.config.spring;
8   
9   import org.mule.tck.junit4.AbstractMuleContextTestCase;
10  import org.mule.util.ClassUtils;
11  
12  import org.dom4j.Document;
13  import org.dom4j.Element;
14  import org.dom4j.io.SAXReader;
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertEquals;
18  
19  public class SchemaDefaultsTestCase extends AbstractMuleContextTestCase
20  {
21      private static String MULE_CORE_SCHEMA_FILE = "META-INF/mule.xsd";
22      private Document schema;
23  
24      @Override
25      protected void doSetUp() throws Exception
26      {
27          super.doSetUp();
28          SAXReader reader = new SAXReader();
29          schema = reader.read(ClassUtils.getResource(MULE_CORE_SCHEMA_FILE, this.getClass()).openStream());
30      }
31      
32      @Override
33      protected boolean isGracefulShutdown()
34      {
35          return true;
36      }
37  
38      @Test
39      public void testConfigurationDefaults()
40      {
41          Element configurationType = (Element) schema.selectSingleNode("/xsd:schema/xsd:complexType[@name='configurationType']");
42  
43          assertEquals(muleContext.getConfiguration().getDefaultResponseTimeout(),
44              configurationType.numberValueOf("xsd:attribute[@name='defaultResponseTimeout']/@default")
45                  .intValue());
46          assertEquals(muleContext.getConfiguration().getDefaultTransactionTimeout(),
47              configurationType.numberValueOf("xsd:attribute[@name='defaultTransactionTimeout']/@default")
48                  .intValue());
49          assertEquals(muleContext.getConfiguration().getShutdownTimeout(),
50              configurationType.numberValueOf("xsd:attribute[@name='shutdownTimeout']/@default")
51                  .intValue());
52      }
53  }