Merge "Fix duplicate dependency warnings"
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / test / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / module / AbstractGeneratedObjectTest.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
9 package org.opendaylight.controller.config.yangjmxgenerator.plugin.module;
10
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import java.io.File;
15 import java.io.FileReader;
16 import java.io.IOException;
17 import net.sourceforge.pmd.lang.Parser;
18 import net.sourceforge.pmd.lang.ParserOptions;
19 import net.sourceforge.pmd.lang.ast.Node;
20 import net.sourceforge.pmd.lang.java.Java17Parser;
21 import org.apache.commons.io.FileUtils;
22 import org.opendaylight.controller.config.yangjmxgenerator.plugin.AbstractGeneratorTest;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 public class AbstractGeneratedObjectTest extends AbstractGeneratorTest {
27     private static final Logger LOG = LoggerFactory.getLogger(AbstractGeneratedObjectTest.class);
28
29     protected void assertHasMethodNamed(Node c, String method) {
30         assertTrue(c.hasDescendantMatchingXPath("//MethodDeclaration[MethodDeclarator[@Image='" +
31                 method +
32                 "']]"));
33     }
34
35     protected Node parse(File dstFile) throws IOException {
36         assertNotNull(dstFile);
37         LOG.debug(FileUtils.readFileToString(dstFile));
38         Parser parser = new Java17Parser(new ParserOptions());
39         return parser.parse(dstFile.toString(), new FileReader(dstFile));
40     }
41
42
43 }