View Javadoc

1   /*
2    * $Id: SchemaValidationTestCase.java 22387 2011-07-12 03:53:36Z dirk.olmes $
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.module.xml.filters;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleContext;
15  import org.mule.tck.junit4.AbstractMuleTestCase;
16  
17  import org.junit.Test;
18  
19  import static org.junit.Assert.assertFalse;
20  import static org.junit.Assert.assertTrue;
21  import static org.mockito.Mockito.mock;
22  
23  
24  public class SchemaValidationTestCase extends AbstractMuleTestCase
25  {
26      MuleContext muleContext = mock(MuleContext.class);
27  
28      /**
29       * tests validation
30       */
31      @Test
32      public void testValidate() throws Exception
33      {
34          SchemaValidationFilter filter = new SchemaValidationFilter();
35          filter.setSchemaLocations("schema1.xsd");
36          filter.initialise();
37          
38          assertTrue(filter.accept(new DefaultMuleMessage(getClass().getResourceAsStream("/validation1.xml"), muleContext)));
39          assertFalse(filter.accept(new DefaultMuleMessage(getClass().getResourceAsStream("/validation2.xml"), muleContext)));
40      }
41  
42  }