View Javadoc

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