@Override
    public Map<String, Set<String>> read() {
        Map<String, Set<String>> extensions = new HashMap<>();

        for (String extensionPoint : processor.getExtensions().keySet()) {
            try {
                FileObject file = getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", EXTENSIONS_RESOURCE
                    + "/" + extensionPoint);
                Set<String> entries = new HashSet<>();
                ExtensionStorage.read(file.openReader(true), entries);
                extensions.put(extensionPoint, entries);
            } catch (FileNotFoundException | NoSuchFileException e) {
                // doesn't exist, ignore
            } catch (FilerException e) {
                // re-opening the file for reading or after writing is ignorable
            } catch (IOException e) {
                error(e.getMessage());
            }
        }

        return extensions;
    }
@Test
    public void ensureReadingExtensionsProducesCorrectListOfExtensions() {
        final StringReader file = new StringReader("#hello\n    World");
        final ExtensionAnnotationProcessor processor = mock(ExtensionAnnotationProcessor.class);
        final Map<String, Set<String>> extensions = new HashMap<>();
        extensions.put("hello", Collections.singleton("world"));

        given(processor.getExtensions()).willReturn(extensions);
        ServiceProviderExtensionStorage extensionStorage = new ServiceProviderExtensionStorage(processor) {

            @Override
            protected Filer getFiler() {
                try {
                    Filer filer = mock(Filer.class);
                    FileObject fileObject = mock(FileObject.class);
                    given(fileObject.openReader(true)).willReturn(file);
                    given(filer.getResource(
                        any(StandardLocation.class),
                        any(String.class),
                        any(String.class)
                    )).willReturn(fileObject);
                    return filer;
                } catch(IOException ex) {
                    throw new IllegalStateException("Shouldn't have gotten here");
                }
            }

        };

        Map<String, Set<String>> read = extensionStorage.read();
        assertThat(read.containsKey("hello"), is(true));
        assertThat(read.get("hello"), is(Collections.singleton("World")));
    }