Search in sources :

Example 56 with Reader

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

the class BuckConfigTest method testReferentialAliases.

@Test
public void testReferentialAliases() throws IOException, NoSuchBuildTargetException {
    Reader reader = new StringReader(Joiner.on('\n').join("[alias]", "foo            = //java/com/example:foo", "bar            = //java/com/example:bar", "foo_codename   = foo", "", "# Do not delete these: automation builds require these aliases to exist!", "automation_foo = foo_codename", "automation_bar = bar"));
    BuckConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
    assertEquals(ImmutableSet.of("//java/com/example:foo"), config.getBuildTargetForAliasAsString("foo"));
    assertEquals(ImmutableSet.of("//java/com/example:bar"), config.getBuildTargetForAliasAsString("bar"));
    assertEquals(ImmutableSet.of("//java/com/example:foo"), config.getBuildTargetForAliasAsString("foo_codename"));
    assertEquals(ImmutableSet.of("//java/com/example:foo"), config.getBuildTargetForAliasAsString("automation_foo"));
    assertEquals(ImmutableSet.of("//java/com/example:bar"), config.getBuildTargetForAliasAsString("automation_bar"));
    assertEquals(ImmutableSet.of(), config.getBuildTargetForAliasAsString("baz"));
}
Also used : StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 57 with Reader

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

the class BuckConfigTest method testGettingResourceAmountsPerRuleType.

@Test
public void testGettingResourceAmountsPerRuleType() throws IOException {
    Reader reader = new StringReader(Joiner.on('\n').join("[resources_per_rule]", "some_rule = 1, 20, 3, 4", "other_rule = 4,30,2,1"));
    BuckConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
    ImmutableMap<String, ResourceAmounts> result = config.getResourceAmountsPerRuleType();
    assertEquals(ImmutableMap.of("some_rule", ResourceAmounts.of(1, 20, 3, 4), "other_rule", ResourceAmounts.of(4, 30, 2, 1)), result);
}
Also used : ResourceAmounts(com.facebook.buck.util.concurrent.ResourceAmounts) StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 58 with Reader

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

the class BuckConfigTest method testGetBuildTargetForAlias.

@Test
public void testGetBuildTargetForAlias() throws IOException, NoSuchBuildTargetException {
    Reader reader = new StringReader(Joiner.on('\n').join("[alias]", "foo = //java/com/example:foo", "bar = //java/com/example:bar", "baz = //java/com/example:foo //java/com/example:bar", "bash = "));
    BuckConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
    assertEquals(ImmutableSet.of("//java/com/example:foo"), config.getBuildTargetForAliasAsString("foo"));
    assertEquals(ImmutableSet.of("//java/com/example:bar"), config.getBuildTargetForAliasAsString("bar"));
    assertEquals(ImmutableSet.of("//java/com/example:foo", "//java/com/example:bar"), config.getBuildTargetForAliasAsString("baz"));
    assertEquals(ImmutableSet.of(), config.getBuildTargetForAliasAsString("bash"));
    // Flavors on alias.
    assertEquals(ImmutableSet.of("//java/com/example:foo#src_jar"), config.getBuildTargetForAliasAsString("foo#src_jar"));
    assertEquals(ImmutableSet.of("//java/com/example:bar#fl1,fl2"), config.getBuildTargetForAliasAsString("bar#fl1,fl2"));
    assertEquals(ImmutableSet.of("//java/com/example:foo#fl1,fl2", "//java/com/example:bar#fl1,fl2"), config.getBuildTargetForAliasAsString("baz#fl1,fl2"));
    assertEquals(ImmutableSet.of(), config.getBuildTargetForAliasAsString("bash#fl1,fl2"));
    assertEquals("Invalid alias names, such as build targets, should be tolerated by this method.", ImmutableSet.of(), config.getBuildTargetForAliasAsString("//java/com/example:foo"));
    assertEquals(ImmutableSet.of(), config.getBuildTargetForAliasAsString("notathing"));
    assertEquals(ImmutableSet.of(), config.getBuildTargetForAliasAsString("notathing#src_jar"));
    Reader noAliasesReader = new StringReader("");
    BuckConfig noAliasesConfig = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, noAliasesReader);
    assertEquals(ImmutableSet.of(), noAliasesConfig.getBuildTargetForAliasAsString("foo"));
    assertEquals(ImmutableSet.of(), noAliasesConfig.getBuildTargetForAliasAsString("bar"));
    assertEquals(ImmutableSet.of(), noAliasesConfig.getBuildTargetForAliasAsString("baz"));
}
Also used : StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 59 with Reader

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

the class BuckConfigTest method testUnresolvedAliasThrows.

@Test
public void testUnresolvedAliasThrows() throws IOException, NoSuchBuildTargetException {
    Reader reader = new StringReader(Joiner.on('\n').join("[alias]", "foo = //java/com/example:foo", "bar = food"));
    try {
        BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
        fail("Should have thrown HumanReadableException.");
    } catch (HumanReadableException e) {
        assertEquals("No alias for: food.", 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 60 with Reader

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

the class BuckConfigTest method testGetMap.

@Test
public void testGetMap() throws IOException {
    Reader reader = new StringReader(Joiner.on('\n').join("[section]", "args_map = key0=>val0,key1=>val1"));
    BuckConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
    assertEquals(ImmutableMap.of("key0", "val0", "key1", "val1"), config.getMap("section", "args_map"));
}
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