### Question:
MemoryFileManager extends ForwardingJavaFileManager<JavaFileManager> { public JavaFileObject createSourceFileObject(Object origin, String name, String code) { return new MemoryJavaFileObject(origin, name, JavaFileObject.Kind.SOURCE, code); } MemoryFileManager(JavaFileManager fileManager, ClassLoader parentClassLoader); JavaFileObject createSourceFileObject(Object origin, String name, String code); ClassLoader getClassLoader(JavaFileManager.Location location); @Override Iterable<JavaFileObject> list(
            JavaFileManager.Location location,
            String packageName,
            Set<JavaFileObject.Kind> kinds,
            boolean recurse); @Override String inferBinaryName(JavaFileManager.Location location, JavaFileObject file); @Override JavaFileObject getJavaFileForOutput(
            JavaFileManager.Location location,
            String className,
            JavaFileObject.Kind kind,
            FileObject sibling);  }### Answer:
@Test public void testCreateSourceFileObject() throws IOException { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager standardFileManager = compiler.getStandardFileManager(null, null, null); try (MemoryFileManager memoryFileManager = new MemoryFileManager(standardFileManager, null)) { String code = "public class XXX {}"; JavaFileObject javaFileObject = memoryFileManager.createSourceFileObject("origin", "XXX", code); assertThat(javaFileObject.getKind()).isEqualTo(JavaFileObject.Kind.SOURCE); assertThat(javaFileObject.getCharContent(true)).isEqualTo(code); assertThat(javaFileObject).isInstanceOf(MemoryFileManager.MemoryJavaFileObject.class); MemoryFileManager.MemoryJavaFileObject memoryJavaFileObject = (MemoryFileManager.MemoryJavaFileObject) javaFileObject; assertThat(memoryJavaFileObject.getOrigin()).isEqualTo("origin"); } }