- Map<File, String> testedFilesToYangModules = new HashMap<>();
- Map<String, String> testedYangModulesToExpectedConflictingName = new HashMap<>();
-
- @Test
- public void testNameConflicts() throws Exception {
- prepareSamples();
- prepareExceptionAssertions();
-
- for (Map.Entry<File, String> currentTestEntry : testedFilesToYangModules
- .entrySet()) {
- final String moduleName = currentTestEntry.getValue();
- final File yangFile = currentTestEntry.getKey();
- Module testedModule = loadYangs(yangFile, moduleName);
-
- try {
- logger.debug("Testing {}", yangFile);
- ModuleMXBeanEntry.create(testedModule,
- new HashMap<QName, ServiceInterfaceEntry>(), context,
- new TypeProviderWrapper(new TypeProviderImpl(context)),
- PACKAGE_NAME);
- fail(yangFile.toString()
- + " did not cause a name conflict and should");
- } catch (NameConflictException e) {
- assertEquals(
- testedYangModulesToExpectedConflictingName
- .get(moduleName),
- e.getConflictingName());
- }
- }
- }
-
- private void prepareSamples() {
- File first = new File(getClass().getResource(
- "/duplicates/config-test-duplicate-attribute-in-list.yang")
- .getFile());
- File dir = first.getParentFile();