Skip to content

Instantly share code, notes, and snippets.

@ecerulm
Created February 11, 2010 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecerulm/301901 to your computer and use it in GitHub Desktop.
Save ecerulm/301901 to your computer and use it in GitHub Desktop.
public class NoteFinderLuceneImplTest implements Lookup.Provider {
private static NoteFinderLuceneImpl instance;
private Lookup lookup;
private InstanceContent ic = new InstanceContent (); // see http://bit.ly/aL7q9M for more details
public NoteFinderLuceneImplTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
//to check that you actually replaced the default lookup
System.out.println(Lookup.getDefault());
ic.add(new TestNoteRepository()); //TestNoteRepository will show up in the
//default lookup.
//a lookup for NoteRepository.class should return the TestNoteRepository that we
//just created (TestNoteRepository implements NoteRepository)
NoteRepository testNoteRepository = Lookup.getDefault().lookup(NoteRepository.class);
//add some test data to the NoteRepository
//testNoteRepository.add(note1)
//testNoteRepository.add(note1)
instance = new NoteFinderLuceneImpl();
instance.rebuildIndex(); //rebuilIndex actually
//calls Lookup.getDefault().lookup(NoteRepository.class)
}
@Test
public void testFind() {
// TODO
// instance.findNote(xxx);
}
public Lookup getLookup() {
if (lookup == null) {
//TestNoteRepository implements NoteRepository
lookup = new AbstractLookup (ic);
}
return lookup;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment