2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.config.yangjmxgenerator.plugin;
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;
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;
21 public class JMXGeneratorFileNamesValidationTest extends JMXGeneratorTest {
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);
35 map.put(JMXGenerator.MODULE_FACTORY_FILE_BOOLEAN, "randomValue");
36 jmxGenerator.setAdditionalConfig(map);
38 jmxGenerator.generateSources(context, outputBaseDir,
39 Sets.newHashSet(testFilesModule, testFiles1Module));
41 } catch (RuntimeException e) {
42 final Throwable cause = e.getCause();
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"));