View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code for adherence to a set of rules.
3   // Copyright (C) 2001-2018 the original author or authors.
4   //
5   // This library is free software; you can redistribute it and/or
6   // modify it under the terms of the GNU Lesser General Public
7   // License as published by the Free Software Foundation; either
8   // version 2.1 of the License, or (at your option) any later version.
9   //
10  // This library is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  // Lesser General Public License for more details.
14  //
15  // You should have received a copy of the GNU Lesser General Public
16  // License along with this library; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  ////////////////////////////////////////////////////////////////////////////////
19  
20  package com.puppycrawl.tools.checkstyle;
21  
22  import static org.junit.Assert.assertEquals;
23  import static org.junit.Assert.assertTrue;
24  import static org.junit.Assert.fail;
25  import static org.powermock.api.mockito.PowerMockito.when;
26  
27  import java.io.File;
28  import java.io.FileInputStream;
29  import java.lang.reflect.Constructor;
30  import java.lang.reflect.InvocationTargetException;
31  import java.lang.reflect.Method;
32  import java.util.ArrayList;
33  import java.util.List;
34  import java.util.Properties;
35  
36  import org.junit.Test;
37  import org.junit.runner.RunWith;
38  import org.powermock.api.mockito.PowerMockito;
39  import org.powermock.core.classloader.annotations.PrepareForTest;
40  import org.powermock.modules.junit4.PowerMockRunner;
41  import org.powermock.reflect.Whitebox;
42  import org.xml.sax.Attributes;
43  import org.xml.sax.InputSource;
44  
45  import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
46  import com.puppycrawl.tools.checkstyle.api.Configuration;
47  
48  /**
49   * Unit test for ConfigurationLoader.
50   * @author Rick Giles
51   * @author lkuehne
52   */
53  @RunWith(PowerMockRunner.class)
54  @PrepareForTest({DefaultConfiguration.class, ConfigurationLoader.class})
55  public class ConfigurationLoaderTest extends AbstractPathTestSupport {
56  
57      @Override
58      protected String getPackageLocation() {
59          return "com/puppycrawl/tools/checkstyle/configurationloader";
60      }
61  
62      private Configuration loadConfiguration(String name) throws Exception {
63          return loadConfiguration(name, new Properties());
64      }
65  
66      private Configuration loadConfiguration(
67          String name, Properties props) throws Exception {
68          final String fName = getPath(name);
69  
70          return ConfigurationLoader.loadConfiguration(fName, new PropertiesExpander(props));
71      }
72  
73      /**
74       * Non meaningful javadoc just to contain "noinspection" tag.
75       * Till https://youtrack.jetbrains.com/issue/IDEA-187209
76       * @return method class
77       * @throws Exception if smth wrong
78       * @noinspection JavaReflectionMemberAccess
79       */
80      private static Method getReplacePropertiesMethod() throws Exception {
81          final Class<?>[] params = new Class<?>[3];
82          params[0] = String.class;
83          params[1] = PropertyResolver.class;
84          params[2] = String.class;
85          final Class<ConfigurationLoader> configurationLoaderClass = ConfigurationLoader.class;
86          final Method replacePropertiesMethod =
87              configurationLoaderClass.getDeclaredMethod("replaceProperties", params);
88          replacePropertiesMethod.setAccessible(true);
89          return replacePropertiesMethod;
90      }
91  
92      @Test
93      public void testResourceLoadConfiguration() throws Exception {
94          final Properties props = new Properties();
95          props.setProperty("checkstyle.basedir", "basedir");
96  
97          // load config that's only found in the classpath
98          final DefaultConfiguration config =
99              (DefaultConfiguration) ConfigurationLoader.loadConfiguration(
100                 getPath("InputConfigurationLoaderChecks.xml"), new PropertiesExpander(props));
101 
102         //verify the root, and property substitution
103         final Properties attributes = new Properties();
104         attributes.setProperty("tabWidth", "4");
105         attributes.setProperty("basedir", "basedir");
106         verifyConfigNode(config, "Checker", 3, attributes);
107     }
108 
109     @Test
110     public void testResourceLoadConfigurationWithMultiThreadConfiguration() throws Exception {
111         final Properties props = new Properties();
112         props.setProperty("checkstyle.basedir", "basedir");
113 
114         final PropertiesExpander propertiesExpander = new PropertiesExpander(props);
115         final String configPath = getPath("InputConfigurationLoaderChecks.xml");
116         final ThreadModeSettings multiThreadModeSettings =
117             new ThreadModeSettings(4, 2);
118 
119         try {
120             ConfigurationLoader.loadConfiguration(
121                 configPath, propertiesExpander, multiThreadModeSettings);
122             fail("An exception is expected");
123         }
124         catch (IllegalArgumentException ex) {
125             assertEquals("Invalid exception message",
126                 "Multi thread mode for Checker module is not implemented",
127                 ex.getMessage());
128         }
129     }
130 
131     @Test
132     public void testResourceLoadConfigurationWithSingleThreadConfiguration() throws Exception {
133         final Properties props = new Properties();
134         props.setProperty("checkstyle.basedir", "basedir");
135 
136         final PropertiesExpander propertiesExpander = new PropertiesExpander(props);
137         final String configPath = getPath("InputConfigurationLoaderChecks.xml");
138         final ThreadModeSettings singleThreadModeSettings =
139             ThreadModeSettings.SINGLE_THREAD_MODE_INSTANCE;
140 
141         final DefaultConfiguration config =
142             (DefaultConfiguration) ConfigurationLoader.loadConfiguration(
143                 configPath, propertiesExpander, singleThreadModeSettings);
144 
145         final Properties attributes = new Properties();
146         attributes.setProperty("tabWidth", "4");
147         attributes.setProperty("basedir", "basedir");
148         verifyConfigNode(config, "Checker", 3, attributes);
149     }
150 
151     @Test
152     public void testEmptyConfiguration() throws Exception {
153         final DefaultConfiguration config =
154             (DefaultConfiguration) loadConfiguration("InputConfigurationLoaderEmpty.xml");
155         verifyConfigNode(config, "Checker", 0, new Properties());
156     }
157 
158     @Test
159     public void testEmptyModuleResolver() throws Exception {
160         final DefaultConfiguration config =
161             (DefaultConfiguration) loadConfiguration(
162                 "InputConfigurationLoaderEmpty.xml", new Properties());
163         verifyConfigNode(config, "Checker", 0, new Properties());
164     }
165 
166     @Test
167     public void testMissingPropertyName() throws Exception {
168         try {
169             loadConfiguration("InputConfigurationLoaderMissingPropertyName.xml");
170             fail("missing property name");
171         }
172         catch (CheckstyleException ex) {
173             assertTrue("Invalid exception message: " + ex.getMessage(),
174                     ex.getMessage().contains("\"name\""));
175             assertTrue("Invalid exception message: " + ex.getMessage(),
176                     ex.getMessage().contains("\"property\""));
177             assertTrue("Invalid exception message: " + ex.getMessage(),
178                     ex.getMessage().endsWith(":8:41"));
179         }
180     }
181 
182     @Test
183     public void testMissingPropertyNameInMethodWithBooleanParameter() throws Exception {
184         try {
185             final String fName = getPath("InputConfigurationLoaderMissingPropertyName.xml");
186             ConfigurationLoader.loadConfiguration(fName, new PropertiesExpander(new Properties()),
187                     false);
188 
189             fail("missing property name");
190         }
191         catch (CheckstyleException ex) {
192             assertTrue("Invalid exception message: " + ex.getMessage(),
193                     ex.getMessage().contains("\"name\""));
194             assertTrue("Invalid exception message: " + ex.getMessage(),
195                     ex.getMessage().contains("\"property\""));
196             assertTrue("Invalid exception message: " + ex.getMessage(),
197                     ex.getMessage().endsWith(":8:41"));
198         }
199     }
200 
201     @Test
202     public void testMissingPropertyValue() throws Exception {
203         try {
204             loadConfiguration("InputConfigurationLoaderMissingPropertyValue.xml");
205             fail("missing property value");
206         }
207         catch (CheckstyleException ex) {
208             assertTrue("Invalid exception message: " + ex.getMessage(),
209                     ex.getMessage().contains("\"value\""));
210             assertTrue("Invalid exception message: " + ex.getMessage(),
211                     ex.getMessage().contains("\"property\""));
212             assertTrue("Invalid exception message: " + ex.getMessage(),
213                     ex.getMessage().endsWith(":8:43"));
214         }
215     }
216 
217     @Test
218     public void testMissingConfigName() throws Exception {
219         try {
220             loadConfiguration("InputConfigurationLoaderMissingConfigName.xml");
221             fail("missing module name");
222         }
223         catch (CheckstyleException ex) {
224             assertTrue("Invalid exception message: " + ex.getMessage(),
225                     ex.getMessage().contains("\"name\""));
226             assertTrue("Invalid exception message: " + ex.getMessage(),
227                     ex.getMessage().contains("\"module\""));
228             assertTrue("Invalid exception message: " + ex.getMessage(),
229                     ex.getMessage().endsWith(":7:23"));
230         }
231     }
232 
233     @Test
234     public void testMissingConfigParent() throws Exception {
235         try {
236             loadConfiguration("InputConfigurationLoaderMissingConfigParent.xml");
237             fail("missing module parent");
238         }
239         catch (CheckstyleException ex) {
240             assertTrue("Invalid exception message: " + ex.getMessage(),
241                     ex.getMessage().contains("\"property\""));
242             assertTrue("Invalid exception message: " + ex.getMessage(),
243                     ex.getMessage().contains("\"module\""));
244             assertTrue("Invalid exception message: " + ex.getMessage(),
245                     ex.getMessage().endsWith(":8:38"));
246         }
247     }
248 
249     @Test
250     public void testCheckstyleChecks() throws Exception {
251         final Properties props = new Properties();
252         props.setProperty("checkstyle.basedir", "basedir");
253 
254         final DefaultConfiguration config =
255             (DefaultConfiguration) loadConfiguration(
256                 "InputConfigurationLoaderChecks.xml", props);
257 
258         //verify the root, and property substitution
259         final Properties atts = new Properties();
260         atts.setProperty("tabWidth", "4");
261         atts.setProperty("basedir", "basedir");
262         verifyConfigNode(config, "Checker", 3, atts);
263 
264         //verify children
265         final Configuration[] children = config.getChildren();
266         atts.clear();
267         verifyConfigNode(
268             (DefaultConfiguration) children[1], "JavadocPackage", 0, atts);
269         verifyConfigNode(
270             (DefaultConfiguration) children[2], "Translation", 0, atts);
271         atts.setProperty("testName", "testValue");
272         verifyConfigNode(
273             (DefaultConfiguration) children[0],
274             "TreeWalker",
275             8,
276             atts);
277 
278         //verify TreeWalker's first, last, NoWhitespaceAfterCheck
279         final Configuration[] grandchildren = children[0].getChildren();
280         atts.clear();
281         verifyConfigNode(
282             (DefaultConfiguration) grandchildren[0],
283             "AvoidStarImport",
284             0,
285             atts);
286         atts.setProperty("format", "System.out.println");
287         verifyConfigNode(
288             (DefaultConfiguration) grandchildren[grandchildren.length - 1],
289             "GenericIllegalRegexp",
290             0,
291             atts);
292         atts.clear();
293         atts.setProperty("tokens", "DOT");
294         atts.setProperty("allowLineBreaks", "true");
295         verifyConfigNode(
296             (DefaultConfiguration) grandchildren[6],
297             "NoWhitespaceAfter",
298             0,
299             atts);
300     }
301 
302     @Test
303     public void testCustomMessages() throws Exception {
304         final Properties props = new Properties();
305         props.setProperty("checkstyle.basedir", "basedir");
306 
307         final DefaultConfiguration config =
308             (DefaultConfiguration) loadConfiguration(
309                 "InputConfigurationLoaderCustomMessages.xml", props);
310 
311         final Configuration[] children = config.getChildren();
312         final Configuration[] grandchildren = children[0].getChildren();
313 
314         final String expectedKey = "name.invalidPattern";
315         assertTrue("Messages should contain key: " + expectedKey,
316             grandchildren[0].getMessages()
317             .containsKey(expectedKey));
318     }
319 
320     private static void verifyConfigNode(
321         DefaultConfiguration config, String name, int childrenLength,
322         Properties atts) throws Exception {
323         assertEquals("name.", name, config.getName());
324         assertEquals(
325             "children.length.",
326             childrenLength,
327             config.getChildren().length);
328 
329         final String[] attNames = config.getAttributeNames();
330         assertEquals("attributes.length", atts.size(), attNames.length);
331 
332         for (String attName : attNames) {
333             assertEquals(
334                 "attribute[" + attName + "]",
335                 atts.getProperty(attName),
336                 config.getAttribute(attName));
337         }
338     }
339 
340     @Test
341     public void testReplacePropertiesNoReplace() throws Exception {
342         final String[] testValues = {null, "", "a", "$a", "{a",
343                                      "{a}", "a}", "$a}", "$", "a$b", };
344         final Properties props = initProperties();
345         for (String testValue : testValues) {
346             final String value = (String) getReplacePropertiesMethod().invoke(
347                 null, testValue, new PropertiesExpander(props), null);
348             assertEquals("\"" + testValue + "\"", value, testValue);
349         }
350     }
351 
352     @Test
353     public void testReplacePropertiesSyntaxError() throws Exception {
354         final Properties props = initProperties();
355         try {
356             final String value = (String) getReplacePropertiesMethod().invoke(
357                 null, "${a", new PropertiesExpander(props), null);
358             fail("expected to fail, instead got: " + value);
359         }
360         catch (InvocationTargetException ex) {
361             assertEquals("Invalid exception cause message",
362                 "Syntax error in property: ${a", ex.getCause().getMessage());
363         }
364     }
365 
366     @Test
367     public void testReplacePropertiesMissingProperty() throws Exception {
368         final Properties props = initProperties();
369         try {
370             final String value = (String) getReplacePropertiesMethod().invoke(
371                 null, "${c}", new PropertiesExpander(props), null);
372             fail("expected to fail, instead got: " + value);
373         }
374         catch (InvocationTargetException ex) {
375             assertEquals("Invalid exception cause message",
376                 "Property ${c} has not been set", ex.getCause().getMessage());
377         }
378     }
379 
380     @Test
381     public void testReplacePropertiesReplace() throws Exception {
382         final String[][] testValues = {
383             {"${a}", "A"},
384             {"x${a}", "xA"},
385             {"${a}x", "Ax"},
386             {"${a}${b}", "AB"},
387             {"x${a}${b}", "xAB"},
388             {"${a}x${b}", "AxB"},
389             {"${a}${b}x", "ABx"},
390             {"x${a}y${b}", "xAyB"},
391             {"${a}x${b}y", "AxBy"},
392             {"x${a}${b}y", "xABy"},
393             {"x${a}y${b}z", "xAyBz"},
394             {"$$", "$"},
395         };
396         final Properties props = initProperties();
397         for (String[] testValue : testValues) {
398             final String value = (String) getReplacePropertiesMethod().invoke(
399                 null, testValue[0], new PropertiesExpander(props), null);
400             assertEquals("\"" + testValue[0] + "\"",
401                 testValue[1], value);
402         }
403     }
404 
405     private static Properties initProperties() {
406         final Properties props = new Properties();
407         props.setProperty("a", "A");
408         props.setProperty("b", "B");
409         return props;
410     }
411 
412     @Test
413     public void testExternalEntity() throws Exception {
414         final Properties props = new Properties();
415         props.setProperty("checkstyle.basedir", "basedir");
416 
417         final DefaultConfiguration config =
418             (DefaultConfiguration) loadConfiguration(
419                 "InputConfigurationLoaderExternalEntity.xml", props);
420 
421         final Properties atts = new Properties();
422         atts.setProperty("tabWidth", "4");
423         atts.setProperty("basedir", "basedir");
424         verifyConfigNode(config, "Checker", 2, atts);
425     }
426 
427     @Test
428     public void testExternalEntitySubdirectory() throws Exception {
429         final Properties props = new Properties();
430         props.setProperty("checkstyle.basedir", "basedir");
431 
432         final DefaultConfiguration config =
433             (DefaultConfiguration) loadConfiguration(
434                 "subdir/InputConfigurationLoaderExternalEntitySubDir.xml", props);
435 
436         final Properties attributes = new Properties();
437         attributes.setProperty("tabWidth", "4");
438         attributes.setProperty("basedir", "basedir");
439         verifyConfigNode(config, "Checker", 2, attributes);
440     }
441 
442     @Test
443     public void testExternalEntityFromUri() throws Exception {
444         final Properties props = new Properties();
445         props.setProperty("checkstyle.basedir", "basedir");
446 
447         final File file = new File(
448                 getPath("subdir/InputConfigurationLoaderExternalEntitySubDir.xml"));
449         final DefaultConfiguration config =
450             (DefaultConfiguration) ConfigurationLoader.loadConfiguration(
451                     file.toURI().toString(), new PropertiesExpander(props));
452 
453         final Properties atts = new Properties();
454         atts.setProperty("tabWidth", "4");
455         atts.setProperty("basedir", "basedir");
456         verifyConfigNode(config, "Checker", 2, atts);
457     }
458 
459     @Test
460     public void testIncorrectTag() throws Exception {
461         try {
462             final Class<?> aClassParent = ConfigurationLoader.class;
463             final Constructor<?> ctorParent = aClassParent.getDeclaredConstructor(
464                     PropertyResolver.class, boolean.class, ThreadModeSettings.class);
465             ctorParent.setAccessible(true);
466             final Object objParent = ctorParent.newInstance(null, true, null);
467 
468             final Class<?> aClass = Class.forName("com.puppycrawl.tools.checkstyle."
469                     + "ConfigurationLoader$InternalLoader");
470             final Constructor<?> constructor = aClass.getConstructor(objParent.getClass());
471             constructor.setAccessible(true);
472 
473             final Object obj = constructor.newInstance(objParent);
474 
475             final Class<?>[] param = new Class<?>[] {String.class, String.class,
476                 String.class, Attributes.class, };
477             final Method method = aClass.getDeclaredMethod("startElement", param);
478 
479             method.invoke(obj, "", "", "hello", null);
480 
481             fail("Exception is expected");
482         }
483         catch (InvocationTargetException ex) {
484             assertTrue("Invalid exception cause",
485                 ex.getCause() instanceof IllegalStateException);
486             assertEquals("Invalid exception cause message",
487                 "Unknown name:" + "hello" + ".", ex.getCause().getMessage());
488         }
489     }
490 
491     @Test
492     public void testNonExistentPropertyName() throws Exception {
493         try {
494             loadConfiguration("InputConfigurationLoaderNonexistentProperty.xml");
495             fail("exception in expected");
496         }
497         catch (CheckstyleException ex) {
498             assertEquals("Invalid exception message",
499                 "unable to parse configuration stream", ex.getMessage());
500             assertEquals("Invalid exception cause message",
501                 "Property ${nonexistent} has not been set",
502                     ex.getCause().getMessage());
503         }
504     }
505 
506     @Test
507     public void testConfigWithIgnore() throws Exception {
508         final DefaultConfiguration config =
509                 (DefaultConfiguration) ConfigurationLoader.loadConfiguration(
510                         getPath("InputConfigurationLoaderModuleIgnoreSeverity.xml"),
511                         new PropertiesExpander(new Properties()), true);
512 
513         final Configuration[] children = config.getChildren();
514         assertEquals("Invalid children count", 0, children[0].getChildren().length);
515     }
516 
517     @Test
518     public void testConfigWithIgnoreUsingInputSource() throws Exception {
519         final DefaultConfiguration config =
520                 (DefaultConfiguration) ConfigurationLoader.loadConfiguration(new InputSource(
521                         new File(getPath("InputConfigurationLoaderModuleIgnoreSeverity.xml"))
522                             .toURI().toString()),
523                         new PropertiesExpander(new Properties()), true);
524 
525         final Configuration[] children = config.getChildren();
526         assertEquals("Invalid children count", 0, children[0].getChildren().length);
527     }
528 
529     @Test
530     public void testConfigCheckerWithIgnore() throws Exception {
531         final DefaultConfiguration config =
532                 (DefaultConfiguration) ConfigurationLoader.loadConfiguration(
533                         getPath("InputConfigurationLoaderCheckerIgnoreSeverity.xml"),
534                         new PropertiesExpander(new Properties()), true);
535 
536         final Configuration[] children = config.getChildren();
537         assertEquals("Invalid children count", 0, children.length);
538     }
539 
540     @Test
541     public void testLoadConfigurationWrongUrl() {
542         try {
543             final DefaultConfiguration config =
544                     (DefaultConfiguration) ConfigurationLoader.loadConfiguration(
545                             ";InputConfigurationLoaderModuleIgnoreSeverity.xml",
546                             new PropertiesExpander(new Properties()), true);
547 
548             final Configuration[] children = config.getChildren();
549             assertEquals("Invalid children count", 0, children[0].getChildren().length);
550             fail("Exception is expected");
551         }
552         catch (CheckstyleException ex) {
553             assertEquals("Invalid exception message",
554                     "Unable to find: ;InputConfigurationLoaderModuleIgnoreSeverity.xml",
555                     ex.getMessage());
556         }
557     }
558 
559     @Test
560     public void testLoadConfigurationDeprecated() throws Exception {
561         final DefaultConfiguration config =
562                 (DefaultConfiguration) ConfigurationLoader.loadConfiguration(
563                         new FileInputStream(
564                             getPath("InputConfigurationLoaderModuleIgnoreSeverity.xml")),
565                         new PropertiesExpander(new Properties()), true);
566 
567         final Configuration[] children = config.getChildren();
568         assertEquals("Invalid children count",
569             0, children[0].getChildren().length);
570     }
571 
572     @Test
573     public void testReplacePropertiesDefault() throws Exception {
574         final Properties props = new Properties();
575         final String defaultValue = "defaultValue";
576 
577         final String value = (String) getReplacePropertiesMethod().invoke(
578             null, "${checkstyle.basedir}", new PropertiesExpander(props), defaultValue);
579 
580         assertEquals("Invalid property value", defaultValue, value);
581     }
582 
583     @Test
584     public void testLoadConfigurationFromClassPath() throws Exception {
585         final DefaultConfiguration config =
586                 (DefaultConfiguration) ConfigurationLoader.loadConfiguration(
587                         getPath("InputConfigurationLoaderModuleIgnoreSeverity.xml"),
588                         new PropertiesExpander(new Properties()), true);
589 
590         final Configuration[] children = config.getChildren();
591         assertEquals("Invalid children count",
592             0, children[0].getChildren().length);
593     }
594 
595     @Test
596     public void testConfigWithIgnoreExceptionalAttributes() throws Exception {
597         // emulate exception from unrelated code, but that is same try-catch
598         final DefaultConfiguration tested = PowerMockito.mock(DefaultConfiguration.class);
599         when(tested.getAttributeNames()).thenReturn(new String[] {"severity"});
600         when(tested.getName()).thenReturn("MemberName");
601         when(tested.getAttribute("severity")).thenThrow(CheckstyleException.class);
602         // to void creation of 2 other mocks for now reason, only one moc is used for all cases
603         PowerMockito.whenNew(DefaultConfiguration.class)
604                 .withArguments("MemberName", ThreadModeSettings.SINGLE_THREAD_MODE_INSTANCE)
605                 .thenReturn(tested);
606         PowerMockito.whenNew(DefaultConfiguration.class)
607                 .withArguments("Checker", ThreadModeSettings.SINGLE_THREAD_MODE_INSTANCE)
608                 .thenReturn(tested);
609         PowerMockito.whenNew(DefaultConfiguration.class)
610                 .withArguments("TreeWalker", ThreadModeSettings.SINGLE_THREAD_MODE_INSTANCE)
611                 .thenReturn(tested);
612 
613         try {
614             ConfigurationLoader.loadConfiguration(
615                     getPath("InputConfigurationLoaderModuleIgnoreSeverity.xml"),
616                     new PropertiesExpander(new Properties()), true);
617             fail("Exception is expected");
618         }
619         catch (CheckstyleException expected) {
620             assertEquals("Invalid exception cause message",
621                 "Problem during accessing 'severity' attribute for MemberName",
622                     expected.getCause().getMessage());
623         }
624     }
625 
626     @Test
627     public void testParsePropertyString() throws Exception {
628         final List<String> propertyRefs = new ArrayList<>();
629         final List<String> fragments = new ArrayList<>();
630 
631         Whitebox.invokeMethod(ConfigurationLoader.class,
632                 "parsePropertyString", "$",
633                fragments, propertyRefs);
634         assertEquals("Fragments list has unexpected amount of items",
635                 1, fragments.size());
636     }
637 
638     @Test
639     public void testConstructors() throws Exception {
640         final Properties props = new Properties();
641         props.setProperty("checkstyle.basedir", "basedir");
642         final String fName = getPath("InputConfigurationLoaderChecks.xml");
643 
644         final Configuration configuration = ConfigurationLoader.loadConfiguration(fName,
645                 new PropertiesExpander(props), ConfigurationLoader.IgnoredModulesOptions.OMIT);
646         assertEquals("Name is not expected", "Checker", configuration.getName());
647 
648         final DefaultConfiguration configuration1 =
649                 (DefaultConfiguration) ConfigurationLoader.loadConfiguration(
650                         new InputSource(new FileInputStream(
651                             getPath("InputConfigurationLoaderModuleIgnoreSeverity.xml"))),
652                         new PropertiesExpander(new Properties()),
653                         ConfigurationLoader.IgnoredModulesOptions.EXECUTE);
654 
655         final Configuration[] children = configuration1.getChildren();
656         assertEquals("Unexpected children size", 1, children[0].getChildren().length);
657     }
658 
659 }