use of com.facebook.buck.jvm.java.ResourcesRootPackageFinder in project buck by facebook.
the class JavaPackageFinderSerializerTest method testSerializingAndDeserializing.
@Test
public void testSerializingAndDeserializing() throws Exception {
DefaultJavaPackageFinder defaultFinder = new DefaultJavaPackageFinder(ImmutableSortedSet.of("paths", "from", "root"), ImmutableSet.of("path", "elements"));
ResourcesRootPackageFinder resourcesRootFinder = new ResourcesRootPackageFinder(Paths.get("/path/to/res/root"), defaultFinder);
Map<String, Object> data = JavaPackageFinderSerializer.serialize(resourcesRootFinder);
JavaPackageFinder result = JavaPackageFinderSerializer.deserialize(data);
assertThat(result, Matchers.instanceOf(ResourcesRootPackageFinder.class));
ResourcesRootPackageFinder outResFinder = (ResourcesRootPackageFinder) result;
assertThat(outResFinder.getResourcesRoot(), Matchers.equalToObject(resourcesRootFinder.getResourcesRoot()));
JavaPackageFinder chainedFinder = outResFinder.getFallbackFinder();
assertThat(chainedFinder, Matchers.instanceOf(DefaultJavaPackageFinder.class));
DefaultJavaPackageFinder outDefFinder = (DefaultJavaPackageFinder) chainedFinder;
assertThat(outDefFinder.getPathElements(), Matchers.equalToObject(defaultFinder.getPathElements()));
assertThat(outDefFinder.getPathsFromRoot(), Matchers.equalToObject(defaultFinder.getPathsFromRoot()));
}
use of com.facebook.buck.jvm.java.ResourcesRootPackageFinder in project buck by facebook.
the class ResourcesRootPackageFinderTest method testResourcesPath.
@Test
public void testResourcesPath() {
Path resourcesRoot = Paths.get("java/example/resources");
ResourcesRootPackageFinder finder = new ResourcesRootPackageFinder(resourcesRoot, new FakeJavaPackageFinder());
assertEquals(Paths.get("com/facebook/"), finder.findJavaPackageFolder(Paths.get("java/example/resources/com/facebook/bar.txt")));
assertEquals("com.facebook", finder.findJavaPackage(Paths.get("java/example/resources/com/facebook/bar.txt")));
}
use of com.facebook.buck.jvm.java.ResourcesRootPackageFinder in project buck by facebook.
the class ResourcesRootPackageFinderTest method testNonmatchingPath.
@Test
public void testNonmatchingPath() {
Path resourcesRoot = Paths.get("java/example/resources");
ResourcesRootPackageFinder finder = new ResourcesRootPackageFinder(resourcesRoot, new FakeJavaPackageFinder());
assertNull("Should fall back to the FakeJavaPackageFinder and return null.", finder.findJavaPackageFolder(Paths.get("does/not/match.txt")));
}
Aggregations