}
@Test
public void testScopedAnalyzersFromSearchFactory() throws Exception {
FullTextSession session = Search.getFullTextSession( openSession() );
SearchFactory searchFactory = session.getSearchFactory();
Analyzer analyzer = searchFactory.getAnalyzer( MyEntity.class );
// you can pass what so ever into the analysis since the used analyzers are
// returning the same tokens all the time. We just want to make sure that
// the right analyzers are used.
Token[] tokens = AnalyzerUtils.tokensFromAnalysis( analyzer, "entity", "" );
assertTokensEqual( tokens, new String[] { "alarm", "dog", "performance" } );
tokens = AnalyzerUtils.tokensFromAnalysis( analyzer, "property", "" );
assertTokensEqual( tokens, new String[] { "sound", "cat", "speed" } );
tokens = AnalyzerUtils.tokensFromAnalysis( analyzer, "field", "" );
assertTokensEqual( tokens, new String[] { "music", "elephant", "energy" } );
tokens = AnalyzerUtils.tokensFromAnalysis( analyzer, "component.componentProperty", "" );
assertTokensEqual( tokens, new String[] { "noise", "mouse", "light" } );
// test border cases
try {
searchFactory.getAnalyzer( (Class) null );
}
catch (IllegalArgumentException iae) {
log.debug( "success" );
}
try {
searchFactory.getAnalyzer( String.class );
}
catch (IllegalArgumentException iae) {
log.debug( "success" );
}