Merge "Fix checkstyle warnings in yang-jmx-generator-plugin"
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / test / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / JMXGeneratorFileNamesValidationTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.config.yangjmxgenerator.plugin;
9
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertThat;
13 import static org.junit.Assert.assertTrue;
14 import static org.junit.Assert.fail;
15
16 import com.google.common.collect.Sets;
17 import org.junit.Test;
18 import org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants;
19 import org.opendaylight.controller.config.yangjmxgenerator.PackageTranslatorTest;
20
21 public class JMXGeneratorFileNamesValidationTest extends JMXGeneratorTest {
22
23     @Test
24     public void test() {
25         map.clear();
26         map.put(JMXGenerator.NAMESPACE_TO_PACKAGE_PREFIX + "1",
27                 ConfigConstants.CONFIG_NAMESPACE + ":test:files1"
28                         + JMXGenerator.NAMESPACE_TO_PACKAGE_DIVIDER
29                         + PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX);
30         map.put(JMXGenerator.NAMESPACE_TO_PACKAGE_PREFIX + "2",
31                 ConfigConstants.CONFIG_NAMESPACE + ":test:files"
32                         + JMXGenerator.NAMESPACE_TO_PACKAGE_DIVIDER
33                         + PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX);
34
35         map.put(JMXGenerator.MODULE_FACTORY_FILE_BOOLEAN, "randomValue");
36         jmxGenerator.setAdditionalConfig(map);
37         try {
38             jmxGenerator.generateSources(context, outputBaseDir,
39                     Sets.newHashSet(testFilesModule, testFiles1Module));
40             fail();
41         } catch (RuntimeException e) {
42             final Throwable cause = e.getCause();
43             assertNotNull(cause);
44             assertTrue(cause.toString() + " is unexpected", cause instanceof IllegalStateException);
45             assertThat(cause.getMessage(),
46                     containsString("Name conflict in generated files"));
47             assertThat(cause.getMessage(), containsString("DtoA.java"));
48         }
49     }
50
51 }