本文整理汇总了Java中com.puppycrawl.tools.checkstyle.DefaultConfiguration.addChild方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultConfiguration.addChild方法的具体用法?Java DefaultConfiguration.addChild怎么用?Java DefaultConfiguration.addChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.puppycrawl.tools.checkstyle.DefaultConfiguration
的用法示例。
在下文中一共展示了DefaultConfiguration.addChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dependencyCycle
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
/**
* Read a file with a cycle in the dependency definition.
*
* @throws Exception
* in case of an unexpected test execution
*/
@Test
public void dependencyCycle() throws Exception {
DefaultConfiguration main = createCheckConfig(TreeWalker.class);
final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
checkConfig.addAttribute("file", "src/test/resources/stereotypeCycle.xml");
main.addChild(checkConfig);
final String[] expected = {};
try {
verify(main, getPath(SampleIs.class), expected);
fail("IllegalArgumentException should have been thrown");
} catch (IllegalArgumentException ex) {
assertThat(ex).hasMessageContaining("There is a cycle in dependency-configuration:")
.hasMessageContaining("dto").hasMessageContaining("view").hasMessageContaining("transformer");
}
}
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:23,代码来源:StereotypeCheckConfigurationReaderTest.java
示例2: fileStereotypeXmlNotExist
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
/**
* Checks if the configuration file exists.
*
* @throws Exception
* in case of an unexpected test execution
*/
@Test
public void fileStereotypeXmlNotExist() throws Exception {
DefaultConfiguration main = createCheckConfig(TreeWalker.class);
final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
checkConfig.addAttribute("file", "src/test/resources/stereotypeNotExist.xml");
main.addChild(checkConfig);
final String[] expected = {};
try {
verify(main, getPath(SampleIs.class), expected);
fail("IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertThat(ex)
.hasMessageStartingWith(
"File defined in property 'file' of Check info.novatec.ita.check.StereotypeCheck does not exist")
.hasMessageEndingWith("src/test/resources/stereotypeNotExist.xml");
}
}
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:24,代码来源:StereotypeCheckConfigurationReaderTest.java
示例3: testCacheWhenFileExternalResourceContentDoesNotChange
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void testCacheWhenFileExternalResourceContentDoesNotChange() throws Exception {
final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class);
checkConfig.addAttribute("file", getPath("InputImportControlOneRegExp.xml"));
final DefaultConfiguration treeWalkerConfig = createModuleConfig(TreeWalker.class);
treeWalkerConfig.addChild(checkConfig);
final DefaultConfiguration checkerConfig = createRootConfig(treeWalkerConfig);
final File cacheFile = temporaryFolder.newFile();
checkerConfig.addAttribute("cacheFile", cacheFile.getPath());
final String filePath = temporaryFolder.newFile("EmptyFile.java").getPath();
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(checkerConfig, filePath, expected);
// One more time to use cache.
verify(checkerConfig, filePath, expected);
assertTrue("External resource is not present in cache",
new String(Files7.readAllBytes(new Path(cacheFile)),
StandardCharsets.UTF_8).contains("InputImportControlOneRegExp.xml"));
}
示例4: verifySuppressed
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
private void verifySuppressed(Configuration moduleConfig, String fileName,
String[] expectedViolations, String... suppressedViolations) throws Exception {
final DefaultConfiguration memberNameCheckConfig =
createModuleConfig(MemberNameCheck.class);
memberNameCheckConfig.addAttribute("id", "ignore");
final DefaultConfiguration constantNameCheckConfig =
createModuleConfig(ConstantNameCheck.class);
constantNameCheckConfig.addAttribute("id", null);
final DefaultConfiguration treewalkerConfig = createModuleConfig(TreeWalker.class);
treewalkerConfig.addChild(memberNameCheckConfig);
treewalkerConfig.addChild(constantNameCheckConfig);
treewalkerConfig.addChild(createModuleConfig(IllegalCatchCheck.class));
if (moduleConfig != null) {
treewalkerConfig.addChild(moduleConfig);
}
final DefaultConfiguration checkerConfig = createRootConfig(treewalkerConfig);
verify(checkerConfig, fileName,
removeSuppressed(expectedViolations, suppressedViolations));
}
示例5: verifySuppressed
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
private void verifySuppressed(Configuration moduleConfig, String fileName,
String[] expectedViolations, String... suppressedViolations) throws Exception {
final DefaultConfiguration memberNameCheckConfig =
createModuleConfig(MemberNameCheck.class);
memberNameCheckConfig.addAttribute("id", "ignore");
final DefaultConfiguration constantNameCheckConfig =
createModuleConfig(ConstantNameCheck.class);
constantNameCheckConfig.addAttribute("id", null);
final DefaultConfiguration treewalkerConfig = createModuleConfig(TreeWalker.class);
treewalkerConfig.addChild(memberNameCheckConfig);
treewalkerConfig.addChild(constantNameCheckConfig);
treewalkerConfig.addChild(createModuleConfig(IllegalCatchCheck.class));
if (moduleConfig != null) {
treewalkerConfig.addChild(moduleConfig);
}
final DefaultConfiguration checkerConfig = createRootConfig(treewalkerConfig);
verify(checkerConfig,
fileName,
removeSuppressed(expectedViolations, suppressedViolations));
}
示例6: CheckstyleRunner
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
public CheckstyleRunner(String configLocation, String suppressionLocation)
throws CheckstyleException {
// create a configuration
DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration(
configLocation, new PropertiesExpander(System.getProperties()));
// add the suppression file to the configuration
DefaultConfiguration suppressions = new DefaultConfiguration("SuppressionFilter");
suppressions.addAttribute("file", suppressionLocation);
config.addChild(suppressions);
this.config = config;
}
示例7: readValidConfigurationFile
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
/**
* Successfully read a valid configuration file.
*
* @throws Exception
* in case of an unexpected test execution
*/
@Test
public void readValidConfigurationFile() throws Exception {
DefaultConfiguration main = createCheckConfig(TreeWalker.class);
final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
checkConfig.addAttribute("file", "src/test/resources/stereotype.xml");
main.addChild(checkConfig);
final String[] expected = {};
verify(main, getPath(SampleIs.class), expected);
}
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:16,代码来源:StereotypeCheckConfigurationReaderTest.java
示例8: noPropertyFileDefined
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
/**
* A configuration file must be specified to execute the stereotype check.
*
* @throws Exception
* in case of an unexpected test execution
*/
@Test
public void noPropertyFileDefined() throws Exception {
DefaultConfiguration main = createCheckConfig(TreeWalker.class);
final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
main.addChild(checkConfig);
final String[] expected = {};
try {
verify(main, getPath(SampleIs.class), expected);
fail("IllegalArgumentException");
} catch (IllegalArgumentException ex) {
assertThat(ex).hasMessage("No Property 'file' defined for Check info.novatec.ita.check.StereotypeCheck");
}
}
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:20,代码来源:StereotypeCheckConfigurationReaderTest.java
示例9: checkEntityOverrideOk
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void checkEntityOverrideOk() throws Exception {
DefaultConfiguration main = createCheckConfig(TreeWalker.class);
final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
checkConfig.addAttribute("file", "src/test/resources/stereotype-allowoverride.xml");
main.addChild(checkConfig);
final String[] expected = {};
verify(main, getPath(AdditionalOperation.class), expected);
}
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:10,代码来源:StereotypeCheckConfigurationReaderTest.java
示例10: checkEntityOverrideFail
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void checkEntityOverrideFail() throws Exception {
DefaultConfiguration main = createCheckConfig(TreeWalker.class);
final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
checkConfig.addAttribute("file", "src/test/resources/stereotype-allowoverride-fail.xml");
main.addChild(checkConfig);
String expectedFail = "Stereotype entity: does not extend info.novatec.ita.check.testclasses.core.fwk.api.data.dto.Pojo";
verify(main, getPath(AdditionalOperation.class), expectedFail);
}
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:10,代码来源:StereotypeCheckConfigurationReaderTest.java
示例11: checkInterfaceOverrideOk
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void checkInterfaceOverrideOk() throws Exception {
DefaultConfiguration main = createCheckConfig(TreeWalker.class);
final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
checkConfig.addAttribute("file", "src/test/resources/stereotype-allowoverride.xml");
main.addChild(checkConfig);
final String[] expected = {};
verify(main, getPath(SampleApiBs.class), expected);
}
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:10,代码来源:StereotypeCheckConfigurationReaderTest.java
示例12: checkInterfaceOverrideFail
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void checkInterfaceOverrideFail() throws Exception {
DefaultConfiguration main = createCheckConfig(TreeWalker.class);
final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
checkConfig.addAttribute("file", "src/test/resources/stereotype-allowoverride-fail.xml");
main.addChild(checkConfig);
final String expectedFail = "Stereotype businessservice: does not extend info.novatec.ita.check.testclasses.core.fwk.api.bl.bs.BusinessService";
verify(main, getPath(SampleApiBs.class), expectedFail);
}
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:10,代码来源:StereotypeCheckConfigurationReaderTest.java
示例13: checkAnnotationOverrideOk
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void checkAnnotationOverrideOk() throws Exception {
DefaultConfiguration main = createCheckConfig(TreeWalker.class);
final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
checkConfig.addAttribute("file", "src/test/resources/stereotype-allowoverride.xml");
main.addChild(checkConfig);
final String[] expected = {};
verify(main, getPath(SampleApp1View.class), expected);
}
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:10,代码来源:StereotypeCheckConfigurationReaderTest.java
示例14: checkAnnotationOverrideFail
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
@Test
public void checkAnnotationOverrideFail() throws Exception {
DefaultConfiguration main = createCheckConfig(TreeWalker.class);
final DefaultConfiguration checkConfig = createCheckConfig(StereotypeCheck.class);
checkConfig.addAttribute("file", "src/test/resources/stereotype-allowoverride-fail.xml");
main.addChild(checkConfig);
final String expectedFail = "Stereotype view: missing annotation info.novatec.ita.check.testclasses.core.fwk.common.ul.ViewStereotype";
verify(main, getPath(SampleApp1View.class), expectedFail);
}
开发者ID:NovaTecConsulting,项目名称:stereotype-check,代码行数:10,代码来源:StereotypeCheckConfigurationReaderTest.java
示例15: createTreeWalkerConfig
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; //导入方法依赖的package包/类
/**
* Creates {@link DefaultConfiguration} or the {@link Checker}.
* based on the given {@link Configuration}.
* @param config {@link Configuration} instance.
* @return {@link DefaultConfiguration} for the {@link Checker}.
*/
protected static DefaultConfiguration createTreeWalkerConfig(Configuration config) {
final DefaultConfiguration dc =
new DefaultConfiguration("configuration");
final DefaultConfiguration twConf = createModuleConfig(TreeWalker.class);
// make sure that the tests always run with this charset
dc.addAttribute("charset", "iso-8859-1");
dc.addChild(twConf);
twConf.addChild(config);
return dc;
}