GroovyFileValidater { public GroovyFileCompilationResult validateFile(final File groovyFile) { try { this.groovyShell.parse(groovyFile); return GroovyFileCompilationResult.SUCCESS; } catch (final CompilationFailedException e) { return new GroovyFileCompilationResult(false, e.getMessage(), "Failed to parse groovy file " + groovyFile.getName() + ": " + e.getMessage(), e); } catch (final IOException e) { return new GroovyFileCompilationResult(false, e.getMessage(), "Failed to parse groovy file " + groovyFile.getName() + ": " + e.getMessage(), e); } catch (final Throwable t) { return new GroovyFileCompilationResult(false, t.getMessage(), "Failed to parse groovy file " + groovyFile.getName() + ": " + t.getMessage(), t); } } GroovyFileValidater(); GroovyFileCompilationResult validateFile(final File groovyFile);  }
@Test public void testEmptyFile() throws Exception { GroovyFileCompilationResult result = validator.validateFile(new File("src/test/resources/groovyFileValidation/empty.groovy")); Assert.assertEquals(Boolean.TRUE, result.isSuccess()); }
@Test public void testSimpleFile() throws Exception { GroovyFileCompilationResult result = validator.validateFile(new File("src/test/resources/groovyFileValidation/simple.groovy")); Assert.assertEquals(Boolean.TRUE, result.isSuccess()); }
@Test public void testBadImportFile() throws Exception { GroovyFileCompilationResult result = validator.validateFile(new File("src/test/resources/groovyFileValidation/badImport.groovy")); Assert.assertEquals(Boolean.FALSE, result.isSuccess()); }