Search in sources :

Example 66 with Reader

use of java.io.Reader in project buck by facebook.

the class JavaBuckConfigTest method whenJavacExistsAndIsExecutableThenCorrectPathIsReturned.

@Test
public void whenJavacExistsAndIsExecutableThenCorrectPathIsReturned() throws IOException {
    Path javac = temporaryFolder.newExecutableFile();
    Reader reader = new StringReader(Joiner.on('\n').join("[tools]", "    javac = " + javac.toString().replace("\\", "\\\\")));
    JavaBuckConfig config = createWithDefaultFilesystem(reader);
    assertEquals(Optional.of(javac), config.getJavacPath());
}
Also used : Path(java.nio.file.Path) StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 67 with Reader

use of java.io.Reader in project buck by facebook.

the class JavaBuckConfigTest method whenJavacJarDoesNotExistThenHumanReadableExceptionIsThrown.

@Test
public void whenJavacJarDoesNotExistThenHumanReadableExceptionIsThrown() throws IOException {
    String invalidPath = temporaryFolder.getRoot().toAbsolutePath() + "DoesNotExist";
    Reader reader = new StringReader(Joiner.on('\n').join("[tools]", "    javac_jar = " + invalidPath.replace("\\", "\\\\")));
    JavaBuckConfig config = createWithDefaultFilesystem(reader);
    try {
        config.getJavacJarPath();
        fail("Should throw exception as javac file does not exist.");
    } catch (HumanReadableException e) {
        assertEquals("Overridden tools:javac_jar path not found: " + invalidPath, e.getHumanReadableErrorMessage());
    }
}
Also used : HumanReadableException(com.facebook.buck.util.HumanReadableException) StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 68 with Reader

use of java.io.Reader in project buck by facebook.

the class ParserConfigTest method testGetTrackCellAgnosticTarget.

@Test
public void testGetTrackCellAgnosticTarget() throws IOException {
    assertTrue(FakeBuckConfig.builder().build().getView(ParserConfig.class).getTrackCellAgnosticTarget());
    Reader reader = new StringReader(Joiner.on('\n').join("[project]", "track_cell_agnostic_target = false"));
    ParserConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader).getView(ParserConfig.class);
    assertFalse(config.getTrackCellAgnosticTarget());
    reader = new StringReader(Joiner.on('\n').join("[project]", "track_cell_agnostic_target = true"));
    config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader).getView(ParserConfig.class);
    assertTrue(config.getTrackCellAgnosticTarget());
}
Also used : StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 69 with Reader

use of java.io.Reader in project buck by facebook.

the class ParserConfigTest method testGetBuildFileImportWhitelist.

@Test
public void testGetBuildFileImportWhitelist() throws IOException {
    assertTrue(FakeBuckConfig.builder().build().getView(ParserConfig.class).getBuildFileImportWhitelist().isEmpty());
    Reader reader = new StringReader(Joiner.on('\n').join("[project]", "build_file_import_whitelist = os, foo"));
    ParserConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader).getView(ParserConfig.class);
    assertEquals(ImmutableList.of("os", "foo"), config.getBuildFileImportWhitelist());
}
Also used : StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 70 with Reader

use of java.io.Reader in project buck by facebook.

the class ParserConfigTest method testGetWatchCells.

@Test
public void testGetWatchCells() throws IOException {
    assertTrue("watch_cells defaults to true", FakeBuckConfig.builder().build().getView(ParserConfig.class).getWatchCells());
    Reader reader = new StringReader(Joiner.on('\n').join("[project]", "watch_cells = false"));
    ParserConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader).getView(ParserConfig.class);
    assertFalse(config.getWatchCells());
    reader = new StringReader(Joiner.on('\n').join("[project]", "watch_cells = true"));
    config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader).getView(ParserConfig.class);
    assertTrue(config.getWatchCells());
}
Also used : StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) Test(org.junit.Test)

Aggregations

Reader (java.io.Reader)1498 InputStreamReader (java.io.InputStreamReader)526 StringReader (java.io.StringReader)498 IOException (java.io.IOException)348 BufferedReader (java.io.BufferedReader)242 InputStream (java.io.InputStream)219 TokenStream (org.apache.lucene.analysis.TokenStream)171 Test (org.junit.Test)170 SqlSessionFactoryBuilder (org.apache.ibatis.session.SqlSessionFactoryBuilder)159 Connection (java.sql.Connection)137 ScriptRunner (org.apache.ibatis.jdbc.ScriptRunner)126 FileReader (java.io.FileReader)108 FileInputStream (java.io.FileInputStream)107 File (java.io.File)105 BeforeClass (org.junit.BeforeClass)99 Tokenizer (org.apache.lucene.analysis.Tokenizer)91 SqlSession (org.apache.ibatis.session.SqlSession)83 StringWriter (java.io.StringWriter)81 ArrayList (java.util.ArrayList)77 Writer (java.io.Writer)63