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