Skip java-api-generator tests when running on windows-type OS
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / test / java / org / opendaylight / mdsal / binding / java / api / generator / test / Bug5151Test.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.java.api.generator.test;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assume.assumeFalse;
13
14 import java.io.File;
15 import java.util.Map;
16 import org.junit.Test;
17
18 /**
19  * Bug5151 involves adding <code>{@literal @}return</code> annotations to accessor methods.
20  */
21 public class Bug5151Test extends BaseCompilationTest {
22
23     private static final String BUG_ID = "bug5151";
24
25     @Test
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,
33             sourcesOutputDir);
34
35         // Test if sources are compilable
36         CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
37
38         final Map<String, File> generatedFiles = FileSearchUtil.getFiles(sourcesOutputDir);
39         assertEquals(13, generatedFiles.size());
40
41         final File fooContainerFile = generatedFiles.get("FooContainer.java");
42         assertNotNull(fooContainerFile);
43         FileSearchUtil.assertFileContains(fooContainerFile,
44             "@return {@code java.lang.String} fooInContainer, or {@code null} if it is not present");
45
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");
50
51         CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
52     }
53 }