### Question:
LuceneConfigurations { public static final LuceneConfiguration using( File parent ) { CheckArg.isNotNull(parent, "parent"); return new FileSystemDirectoryFromNameFactory(parent); }  static final LuceneConfiguration inMemory(); static final LuceneConfiguration using( File parent ); static final LuceneConfiguration using( File parent,
                                                   LockFactory lockFactory ); static final LuceneConfiguration using( File parent,
                                                   TextEncoder workspaceNameEncoder,
                                                   TextEncoder indexNameEncoder ); static final LuceneConfiguration using( File parent,
                                                   LockFactory lockFactory,
                                                   TextEncoder workspaceNameEncoder,
                                                   TextEncoder indexNameEncoder );  }### Answer:
@Test public void shouldCreateConfigurationFromFileSystemStorage() { config = LuceneConfigurations.using(tempArea); assertThat(config, is(notNullValue())); directory = getDirectory(config, workspace, index); assertThat(directory, is(instanceOf(FSDirectory.class))); FSDirectory fsDirectory = (FSDirectory)directory; assertThat(fsDirectory.getFile().getName(), is(index)); assertThat(fsDirectory.getFile().getParentFile().getName(), is(workspace)); }
@Test public void shouldReturnSameDirectoryForSameWorkspaceAndIndexNamesFromFileSystemStorage() { config = LuceneConfigurations.using(tempArea); assertThat(config, is(notNullValue())); directory = getDirectory(config, workspace, index); assertThat(directory, is(instanceOf(FSDirectory.class))); FSDirectory fsDirectory = (FSDirectory)directory; assertThat(fsDirectory.getFile().getName(), is(index)); assertThat(fsDirectory.getFile().getParentFile().getName(), is(workspace)); for (int i = 0; i != 10; ++i) { assertThat(getDirectory(config, workspace, index), is(sameInstance(directory))); } assertThat(indexNamesByWorkspaceName.size(), is(1)); }
@Test public void shouldEncodeDirectoryNames() { FilenameEncoder encoder = new FilenameEncoder(); index = "some/special::/\nindex(name)"; workspace = "some/special::/\nworkspace(name)/illegalInWindows:\\/?%*|\"'<>.txt"; assertThat(index, is(not(encoder.encode(index)))); assertThat(workspace, is(not(encoder.encode(workspace)))); config = LuceneConfigurations.using(tempArea, null, encoder, encoder); assertThat(config, is(notNullValue())); directory = getDirectory(config, workspace, index); assertThat(directory, is(instanceOf(FSDirectory.class))); FSDirectory fsDirectory = (FSDirectory)directory; assertThat(fsDirectory.getFile().getName(), is(encoder.encode(index))); assertThat(fsDirectory.getFile().getParentFile().getName(), is(encoder.encode(workspace))); }