*/
package org.opendaylight.mdsal.binding.java.api.generator.test;
-import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
final File fooContainerFile = generatedFiles.get("FooContainer.java");
assertNotNull(fooContainerFile);
- assertTrue(FileSearchUtil.findInFile(fooContainerFile,
- "@return <code>java.lang.String</code> <code>fooInContainer</code>, "
- + "or <code>null</code> if not present"));
+ FileSearchUtil.assertFileContains(fooContainerFile,
+ "@return <code>java.lang.String</code> <code>fooInContainer</code>, or <code>null</code> if not present");
final File fooDataFile = generatedFiles.get("FooData.java");
assertNotNull(fooDataFile);
- assertTrue(FileSearchUtil.findInFile(fooDataFile,
- "FooContainer</code> <code>fooContainer</code>, or <code>null</code> if not present"));
+ FileSearchUtil.assertFileContains(fooDataFile,
+ "FooContainer</code> <code>fooContainer</code>, or <code>null</code> if not present");
CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
}
// Hidden on purpose
}
- static boolean findInFile(final File file, final String searchText) throws FileNotFoundException {
+ static void assertFileContains(final File file, final String searchText) throws FileNotFoundException {
try (Scanner scanner = new Scanner(file)) {
while (scanner.hasNextLine()) {
- final String nextLine = scanner.nextLine();
- if (nextLine.contains(searchText)) {
- return true;
+ if (scanner.nextLine().contains(searchText)) {
+ return;
}
}
}
- return false;
+ throw new AssertionError("File " + file + " does not contain '" + searchText + "'");
}
static Map<String, File> getFiles(final File path) {