Search in sources :

Example 61 with Reader

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

the class BuckConfigTest method testGetBuildTargetListResolvesAliases.

@Test
public void testGetBuildTargetListResolvesAliases() throws IOException, NoSuchBuildTargetException {
    Reader reader = new StringReader(Joiner.on('\n').join("[alias]", "foo = //java/com/example:foo", "[section]", "some_list = \\", "foo, \\", "//java/com/example:bar"));
    BuckConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
    ImmutableList<String> expected = ImmutableList.of("//java/com/example:foo", "//java/com/example:bar");
    ImmutableList<String> result = ImmutableList.copyOf(FluentIterable.from(config.getBuildTargetList("section", "some_list")).transform(Object::toString));
    assertThat(result, Matchers.equalTo(expected));
}
Also used : StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 62 with Reader

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

the class BuckConfigTest method testExcludedLabels.

@Test
public void testExcludedLabels() throws IOException {
    Reader reader = new StringReader(Joiner.on('\n').join("[test]", "excluded_labels = windows, linux"));
    BuckConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
    assertEquals(ImmutableList.of("windows", "linux"), config.getDefaultRawExcludedLabelSelectors());
}
Also used : StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 63 with Reader

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

the class InstallCommandOptionsTest method getAdbOptions.

private AdbOptions getAdbOptions(boolean multiInstallModeConfig, String... args) throws CmdLineException, IOException {
    Reader reader = new StringReader(Joiner.on('\n').join("[adb]", "multi_install_mode = " + multiInstallModeConfig));
    BuckConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
    return getCommand(args).adbOptions(config);
}
Also used : StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader)

Example 64 with Reader

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

the class RawConfigTest method entriesAreStoredInFileOrder.

@Test
public void entriesAreStoredInFileOrder() throws Exception {
    Reader reader = new StringReader(Joiner.on('\n').join("[alias]", "one =   //foo:one", "two =   //foo:two", "three = //foo:three", "four  = //foo:four"));
    RawConfig rawConfig = RawConfig.builder().putAll(Inis.read(reader)).build();
    assertThat("entries are sorted in the order that they appear in the file", rawConfig.getSection("alias").keySet(), contains("one", "two", "three", "four"));
}
Also used : StringReader(java.io.StringReader) StringReader(java.io.StringReader) Reader(java.io.Reader) Test(org.junit.Test)

Example 65 with Reader

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

the class JavaBuckConfigTest method whenJavacIsNotExecutableThenHumanReadableExeceptionIsThrown.

@Test
public void whenJavacIsNotExecutableThenHumanReadableExeceptionIsThrown() throws IOException {
    assumeThat("Files on Windows are executable by default.", Platform.detect(), is(not(Platform.WINDOWS)));
    Path javac = temporaryFolder.newFile();
    Reader reader = new StringReader(Joiner.on('\n').join("[tools]", "    javac = " + javac.toString()));
    JavaBuckConfig config = createWithDefaultFilesystem(reader);
    try {
        config.getJavacPath();
        fail("Should throw exception as javac file is not executable.");
    } catch (HumanReadableException e) {
        assertEquals(e.getHumanReadableErrorMessage(), "javac is not executable: " + javac);
    }
}
Also used : Path(java.nio.file.Path) HumanReadableException(com.facebook.buck.util.HumanReadableException) 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