JFlexMojo extends AbstractMojo { public void execute() throws MojoExecutionException, MojoFailureException { this.outputDirectory = getAbsolutePath(this.outputDirectory); project.addCompileSourceRoot(outputDirectory.getPath()); List<File> filesIt; if (lexDefinitions == null) { getLog().debug("Use lexer files found in (default) " + SRC_MAIN_JFLEX); filesIt = new ArrayList<>(); File defaultDir = getAbsolutePath(new File(SRC_MAIN_JFLEX)); if (defaultDir.isDirectory()) { filesIt.add(defaultDir); } } else { filesIt = Arrays.asList(lexDefinitions); getLog() .debug( "Parsing " + lexDefinitions.length + " jflex files or directories given in configuration"); } for (File lexDefinition : filesIt) { lexDefinition = getAbsolutePath(lexDefinition); parseLexDefinition(lexDefinition); } }  void execute();  }
@Test public void testSingleFile() throws Exception { JFlexMojo mojo = newMojo("single-file-test"); mojo.execute(); File produced = getExpectedOutputFile(mojo); assertWithMessage("produced file is a file: " + produced).that(produced.isFile()).isTrue(); long size = produced.length(); boolean correctSize = (size > 26624) && (size < 36696); assertWithMessage("size of produced file between 26k and 36k. Actual is " + size) .that(correctSize) .isTrue(); }
@Test public void testSingleDir() throws Exception { JFlexMojo mojo = newMojo("single-dir-test"); mojo.execute(); File produced = getExpectedOutputFile(mojo); assertWithMessage("produced file is a file: " + produced).that(produced.isFile()).isTrue(); }
@Test public void testRecursion() throws Exception { JFlexMojo mojo = newMojo("recursion-test"); mojo.execute(); File produced = getExpectedOutputFile(mojo); assertWithMessage("produced file is a file: " + produced).that(produced.isFile()).isTrue(); }