1   /*
2    * $Id: CheckExclusiveAttributesTestCase.java 10256 2008-01-08 15:20:25Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.parsers.processors;
12  
13  import org.mule.config.spring.parsers.PreProcessor;
14  
15  import javax.xml.parsers.ParserConfigurationException;
16  
17  public class CheckExclusiveAttributesTestCase extends AbstractPreProcessorTestCase
18  {
19  
20      public void testAttributes() throws ParserConfigurationException
21      {
22          String[][] a1b2 = new String[][]{new String[]{"a1"}, new String[]{"b1", "b2"}};
23          String text = "cannot appear with the attribute";
24          assertOk(a1b2, "");
25          assertOk(a1b2, "x");
26          assertOk(a1b2, "b2");
27          assertOk(a1b2, "x b1");
28          assertOk(a1b2, "a1");
29          assertOk(a1b2, "a1 x");
30          assertOk(a1b2, "b1 b2");
31          assertBad(a1b2, "a1 b1", text);
32          assertBad(a1b2, "a1 b2", text);
33          assertBad(a1b2, "a1 b1 b2", text);
34          assertBad(a1b2, "a1 b2 x", text); 
35          String[][] a1b0 = new String[][]{new String[]{"a1"}, new String[]{}};
36          assertOk(a1b0, "");
37          assertOk(a1b0, "x");
38          assertOk(a1b0, "b2");
39          assertOk(a1b0, "x b1");
40          assertOk(a1b0, "a1");
41          assertOk(a1b0, "a1 x");
42          assertOk(a1b0, "b1 b2");
43          assertOk(a1b0, "a1 b1");
44          assertOk(a1b0, "a1 b2");
45          assertOk(a1b0, "a1 b1 b2");
46          assertOk(a1b0, "a1 b2 x"); 
47      }
48  
49      protected PreProcessor createCheck(String[][] constraint)
50      {
51          return new CheckExclusiveAttributes(constraint);
52      }
53  
54  }