View Javadoc

1   /*
2    * $Id: InvalidSchemaValidationTestCase.java 22966 2011-09-16 15:12:44Z evangelinamrm $
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 java.io.IOException;
14  
15  import org.junit.Test;
16  import org.junit.After;
17  import org.xml.sax.SAXException;
18  import org.apache.commons.collections.map.HashedMap;
19  import static org.junit.Assert.assertTrue;
20  
21  public class InvalidSchemaValidationTestCase extends AbstractSchemaValidationTestCase
22  {
23      @After
24      public void doCleanUp()
25      {
26          schemas = new HashedMap();
27      }
28  
29      @Test(expected = SAXException.class)
30      public void testTransformerReference() throws SAXException, IOException
31      {
32          addSchema("http://www.mulesoft.org/schema/mule/vm","META-INF/mule-vm.xsd");
33          doTest("org/mule/config/spring/schema-validation-transformer-ref-test.xml");
34      }
35  
36      @Test(expected = SAXException.class)
37      public void testFilterReference() throws SAXException, IOException
38      {
39          addSchema("http://www.mulesoft.org/schema/mule/vm","META-INF/mule-vm.xsd");
40          doTest("org/mule/config/spring/schema-validation-filter-ref-test.xml");
41      }
42  
43      @Test
44      public void testTransactedConnectors() throws SAXException, IOException
45      {
46          addSchema("http://www.mulesoft.org/schema/mule/vm","META-INF/mule-vm.xsd");
47          addSchema("http://www.mulesoft.org/schema/mule/jdbc","META-INF/mule-jdbc.xsd");
48          addSchema("http://www.springframework.org/schema/beans","http://www.springframework.org/schema/beans/spring-beans-3.0.xsd");
49          doTest("org/mule/config/spring/schema-validation-transacted-connectors-test.xml");
50      }
51  
52      @Test(expected = SAXException.class)
53      public void testNotTransactedFileConnector() throws SAXException, IOException
54      {
55          addSchema("http://www.mulesoft.org/schema/mule/file", "META-INF/mule-file.xsd");
56          doTest("org/mule/config/spring/schema-validation-not-transacted-file-connector-test.xml");
57      }
58  
59      @Test(expected = SAXException.class)
60      public void testNotTransactedFtpConnector() throws SAXException, IOException
61      {
62          addSchema("http://www.mulesoft.org/schema/mule/ftp", "META-INF/mule-ftp.xsd");
63          doTest("org/mule/config/spring/schema-validation-not-transacted-ftp-connector-test.xml");
64      }
65  
66      @Test
67      public void testJdbcInvalidPollingFrequencyInOutboundEndpoint() throws SAXException, IOException
68      {
69          addSchema("http://www.mulesoft.org/schema/mule/jdbc","META-INF/mule-jdbc.xsd");
70          addSchema("http://www.mulesoft.org/schema/mule/test", "http://www.mulesoft.org/schema/mule/test/3.1/mule-test.xsd");
71          try
72          {
73              doTest("org/mule/config/spring/schema-validation-jdbc-invalid-polling-frequency.xml");
74          }
75          catch(SAXException e)
76          {
77              // Check that the pollingFrequency exception is because of the outbound endpoint and not the inbound
78              assertTrue(e.getMessage() != null && e.getMessage().contains("jdbc:outbound-endpoint"));
79          }
80      }
81  
82  
83  }