}
@Test
public void shouldEncodeDirectoryNames() {
// Set up an encoder and make sure that the names for the index and workspace can't be used as file system names ...
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)));
}