}
};
public void testGetSourceFiles() throws Exception {
// No sources specified.
Configuration config = createConfig();
assertTrue(config.getSourceFiles().isEmpty());
// Sources specified, but no source path.
String[] sources = new String[] {
"com" + SLASH + "google" + SLASH + "foo" + SLASH + "ford.gxp",
"com" + SLASH + "google" + SLASH + "foo" + SLASH + "zaphod.gxp",
"com" + SLASH + "google" + SLASH + "bar" + SLASH + "trillian.gxp"
};
config = createConfig(getCwd(), sources);
assertContentsAnyOrder(Iterables.transform(config.getSourceFiles(),
GET_NAME),
"/com/google/foo/ford.gxp",
"/com/google/foo/zaphod.gxp",
"/com/google/bar/trillian.gxp");
// Same as above, but with different defaultDir.
config = createConfig(getCwd().join("com/google"), sources);
assertContentsAnyOrder(Iterables.transform(config.getSourceFiles(),
GET_NAME),
"/foo/ford.gxp",
"/foo/zaphod.gxp",
"/bar/trillian.gxp");
// Sources specified, with source path.
config = createConfig(
"--source", "src_dir_1" + COLON + "src_dir_2",
"src_dir_1" + SLASH + "ford.gxp",
"src_dir_1" + SLASH + "zaphod.gxp",
"src_dir_2" + SLASH + "trillian.gxp");
assertContentsAnyOrder(Iterables.transform(config.getSourceFiles(),
GET_NAME),
"/ford.gxp",
"/zaphod.gxp",
"/trillian.gxp");
// Sources specified, with "overlapping" dirs in source path.
config = createConfig(
"--source",
"foo" + SLASH + "bar" + SLASH + "baz"
+ COLON
+ "foo" + SLASH + "bar",
"foo" + SLASH + "bar" + SLASH + "baz" + SLASH + "quux.gxp",
"foo" + SLASH + "bar" + SLASH + "zip" + SLASH + "zap.gxp"
);
assertContentsAnyOrder(
Iterables.transform(config.getSourceFiles(), GET_NAME),
"/quux.gxp",
"/zip/zap.gxp");
// Try the opposite order of items in the source path -- we should get the
// same result.
config = createConfig(
"--source",
"foo" + SLASH + "bar"
+ COLON
+ "foo" + SLASH + "bar" + SLASH + "baz",
"foo" + SLASH + "bar" + SLASH + "baz" + SLASH + "quux.gxp",
"foo" + SLASH + "bar" + SLASH + "zip" + SLASH + "zap.gxp"
);
assertContentsAnyOrder(
Iterables.transform(config.getSourceFiles(), GET_NAME),
"/quux.gxp",
"/zip/zap.gxp");
}