Migrade JUnitMatchers references
[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 org.junit.Test;
17 import org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants;
18 import org.opendaylight.controller.config.yangjmxgenerator.PackageTranslatorTest;
19
20 import com.google.common.collect.Sets;
21
22 public class JMXGeneratorFileNamesValidationTest extends JMXGeneratorTest {
23
24     @Test
25     public void test() {
26         map.clear();
27         map.put(JMXGenerator.NAMESPACE_TO_PACKAGE_PREFIX + "1",
28                 ConfigConstants.CONFIG_NAMESPACE + ":test:files1"
29                         + JMXGenerator.NAMESPACE_TO_PACKAGE_DIVIDER
30                         + PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX);
31         map.put(JMXGenerator.NAMESPACE_TO_PACKAGE_PREFIX + "2",
32                 ConfigConstants.CONFIG_NAMESPACE + ":test:files"
33                         + JMXGenerator.NAMESPACE_TO_PACKAGE_DIVIDER
34                         + PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX);
35
36         map.put(JMXGenerator.MODULE_FACTORY_FILE_BOOLEAN, "randomValue");
37         jmxGenerator.setAdditionalConfig(map);
38         try {
39             jmxGenerator.generateSources(context, outputBaseDir,
40                     Sets.newHashSet(testFilesModule, testFiles1Module));
41             fail();
42         } catch (RuntimeException e) {
43             final Throwable cause = e.getCause();
44             assertNotNull(cause);
45             assertTrue(cause.toString() + " is unexpected", cause instanceof IllegalStateException);
46             assertThat(cause.getMessage(),
47                     containsString("Name conflict in generated files"));
48             assertThat(cause.getMessage(), containsString("DtoA.java"));
49         }
50     }
51
52 }