### Question:
FilerImpl implements Filer { @Override public FileObject getResource(Location location, CharSequence pkg, CharSequence relativeName) throws IOException { FileObject file = fileManager.getFileForInput(location, pkg.toString(), relativeName.toString()); if (file == null) { throw new FileNotFoundException("Resource does not exist " + location + '/' + pkg + '/' + relativeName); } if (createdResources.contains(file.toUri())) { throw new FilerException("Resource already created " + pkg + "." + relativeName); } return file; } FilerImpl(CompilerBuildContext context, StandardJavaFileManager fileManager, CompilerJdt incrementalCompiler, ProcessingEnvImpl processingEnv); @Override JavaFileObject createSourceFile(CharSequence name, Element... originatingElements); @Override JavaFileObject createClassFile(CharSequence name, Element... originatingElements); @Override FileObject createResource(Location location, CharSequence pkg, CharSequence relativeName, Element... originatingElements); @Override FileObject getResource(Location location, CharSequence pkg, CharSequence relativeName); void incrementalIterationReset(); Set<File> getWrittenFiles();  }### Answer:
@Test public void testGetResource_unsupportedLocation() throws Exception { EclipseFileManager fileManager = new EclipseFileManager(null, Charsets.UTF_8); FilerImpl filer = new FilerImpl(null , fileManager, null , null ); try { filer.getResource(StandardLocation.SOURCE_PATH, "", "test"); Assert.fail(); } catch (IllegalArgumentException expected) { } }
@Test public void testGetResource_location_classpath() throws Exception { EclipseFileManager fileManager = new EclipseFileManager(null, Charsets.UTF_8); List<File> classpath = new ArrayList<>(); classpath.add(new File("src/test/projects/compile-jdt-proc/getresource-location-classpath/classes")); classpath.add(new File("src/test/projects/compile-jdt-proc/getresource-location-classpath/dependency.zip")); fileManager.setLocation(StandardLocation.CLASS_PATH, classpath); FilerImpl filer = new FilerImpl(null , fileManager, null , null ); Assert.assertEquals("dir resource", toString(filer.getResource(StandardLocation.CLASS_PATH, "", "dirresource.txt"))); Assert.assertEquals("pkg jar resource", toString(filer.getResource(StandardLocation.CLASS_PATH, "pkg", "jarresource.txt"))); }
@Test public void testResourceDoesNotExist() throws Exception { EclipseFileManager fileManager = new EclipseFileManager(null, Charsets.UTF_8); File outputDir = temp.newFolder(); fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(outputDir)); FilerImpl filer = new FilerImpl(null , fileManager, null , null ); try { filer.getResource(StandardLocation.SOURCE_OUTPUT, "", "does-not-exist"); Assert.fail(); } catch (IOException expected) { } }