@Test public void should_fail_if_io_error_occurs_when_reading_cql_script() { CqlExecCassandraMojo cqlExecCassandraMojo = builder.cqlScript(file("emptyfile.cql")).build(); mockToThrows(new IOException()); try { cqlExecCassandraMojo.execute(); fail(); } catch (MojoExecutionException e) { assertEquals("Could not parse or load cql file", e.getMessage()); } catch (MojoFailureException e) { fail(e.getMessage()); } }
@Test public void should_fail_if_file_not_found_occurs_when_reading_cql_script() { CqlExecCassandraMojo cqlExecCassandraMojo = builder.cqlScript(file("emptyfile.cql")).build(); mockToThrows(new FileNotFoundException()); try { cqlExecCassandraMojo.execute(); fail(); } catch (MojoExecutionException e) { assertThat( e.getMessage(), allOf( startsWith("Cql file '"), endsWith("emptyfile.cql' was deleted before I could read it"))); } catch (MojoFailureException e) { fail(e.getMessage()); } }