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