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.mdsal.binding.java.api.generator.test;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assume.assumeFalse;
16 import org.junit.Test;
19 * Bug5151 involves adding <code>{@literal @}return</code> annotations to accessor methods.
21 public class Bug5151Test extends BaseCompilationTest {
23 private static final String BUG_ID = "bug5151";
26 public void test() throws Exception {
27 // Xtend code generation uses the "line.separator" system property to generate proper line endings
28 // in templates, leading to test failures running on Windows-type OS.
29 assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win"));
30 final File sourcesOutputDir = CompilationTestUtils.generatorOutput(BUG_ID);
31 final File compiledOutputDir = CompilationTestUtils.compilerOutput(BUG_ID);
32 generateTestSources(CompilationTestUtils.FS + "compilation" + CompilationTestUtils.FS + BUG_ID,
35 // Test if sources are compilable
36 CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
38 final Map<String, File> generatedFiles = FileSearchUtil.getFiles(sourcesOutputDir);
39 assertEquals(13, generatedFiles.size());
41 final File fooContainerFile = generatedFiles.get("FooContainer.java");
42 assertNotNull(fooContainerFile);
43 FileSearchUtil.assertFileContains(fooContainerFile,
44 "@return {@code String} fooInContainer, or {@code null} if it is not present");
46 final File fooDataFile = generatedFiles.get("FooData.java");
47 assertNotNull(fooDataFile);
48 FileSearchUtil.assertFileContains(fooDataFile,
49 "FooContainer} fooContainer, or {@code null} if it is not present");
51 CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);