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
9 package org.opendaylight.controller.config.yangjmxgenerator.plugin.module;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
14 import com.google.common.io.Files;
16 import java.io.FileReader;
17 import java.io.IOException;
18 import java.nio.charset.StandardCharsets;
19 import net.sourceforge.pmd.lang.Parser;
20 import net.sourceforge.pmd.lang.ParserOptions;
21 import net.sourceforge.pmd.lang.ast.Node;
22 import net.sourceforge.pmd.lang.java.Java17Parser;
23 import org.opendaylight.controller.config.yangjmxgenerator.plugin.AbstractGeneratorTest;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
27 public class AbstractGeneratedObjectTest extends AbstractGeneratorTest {
28 private static final Logger LOG = LoggerFactory.getLogger(AbstractGeneratedObjectTest.class);
30 protected void assertHasMethodNamed(Node c, String method) {
31 assertTrue(c.hasDescendantMatchingXPath("//MethodDeclaration[MethodDeclarator[@Image='" +
36 protected Node parse(File dstFile) throws IOException {
37 assertNotNull(dstFile);
38 LOG.debug(Files.toString(dstFile, StandardCharsets.UTF_8));
39 Parser parser = new Java17Parser(new ParserOptions());
40 return parser.parse(dstFile.toString(), new FileReader(dstFile));