2 * Copyright (c) 2015 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.yangtools.sal.java.api.generator.test;
11 import static org.junit.Assert.assertTrue;
12 import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.COMPILER_OUTPUT_PATH;
13 import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.FS;
14 import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.GENERATOR_OUTPUT_PATH;
15 import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.cleanUp;
16 import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.getSourceFiles;
17 import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.testCompilation;
19 import com.google.common.collect.ImmutableSet;
21 import java.util.List;
22 import org.junit.Test;
23 import org.opendaylight.yangtools.sal.binding.model.api.Type;
24 import org.opendaylight.yangtools.sal.java.api.generator.GeneratorJavaFile;
25 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
28 * Test if generated classes from yang file is compilable, generated javadoc comments contains
29 * symbols as javadoc comment tag, which caused of compilation problem.
31 public class EndodingInJavaDocTest extends BaseCompilationTest {
34 public void testJavadocEncodingCompilation() throws Exception {
35 final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "encoding-javadoc");
36 assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
37 final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "encoding-javadoc");
38 assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
40 final List<File> sourceFiles = getSourceFiles("/compilation/encoding-javadoc");
41 final SchemaContext context = parser.parseFiles(sourceFiles);
42 final List<Type> types = bindingGenerator.generateTypes(context);
43 final GeneratorJavaFile generator = new GeneratorJavaFile(ImmutableSet.copyOf(types));
44 generator.generateToFile(sourcesOutputDir);
46 // Test if sources are compilable
47 testCompilation(sourcesOutputDir, compiledOutputDir);
48 cleanUp(sourcesOutputDir, compiledOutputDir);