2 * Copyright (c) 2016 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;
17 import com.google.common.collect.ImmutableSet;
19 import java.util.List;
20 import org.junit.Test;
21 import org.opendaylight.yangtools.sal.binding.model.api.Type;
22 import org.opendaylight.yangtools.sal.java.api.generator.GeneratorJavaFile;
23 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
26 * Test if generated classes from yang file is compilable, generated javadoc comments contains
27 * symbols as javadoc comment tag, which caused of compilation problem.
29 public class EncodingInJavaDocTest extends BaseCompilationTest {
32 public void testAugmentToUsesInAugment() throws Exception {
33 final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "encoding-javadoc");
34 assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
35 final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "encoding-javadoc");
36 assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
38 final List<File> sourceFiles = getSourceFiles("/compilation/encoding-javadoc");
39 final SchemaContext context = TestUtils.parseYangSources(sourceFiles);
40 final List<Type> types = bindingGenerator.generateTypes(context);
41 final GeneratorJavaFile generator = new GeneratorJavaFile(ImmutableSet.copyOf(types));
42 generator.generateToFile(sourcesOutputDir);
44 // Test if sources are compilable
45 testCompilation(sourcesOutputDir, compiledOutputDir);
46 cleanUp(sourcesOutputDir, compiledOutputDir);