File tree Expand file tree Collapse file tree 8 files changed +22
-24
lines changed
hibernate-search/src/test/java/org/hibernate/search/test Expand file tree Collapse file tree 8 files changed +22
-24
lines changed Original file line number Diff line number Diff line change 34
34
import org .hibernate .HibernateException ;
35
35
import org .hibernate .cfg .Configuration ;
36
36
import org .hibernate .search .Environment ;
37
+ import org .hibernate .search .SearchException ;
37
38
import org .hibernate .search .cfg .SearchMapping ;
38
39
import org .hibernate .search .test .SearchTestCase ;
39
40
import org .hibernate .search .util .logging .impl .Log ;
@@ -61,9 +62,9 @@ public void testDuplicatedAnalyzerDefinitionThrowsException() throws Exception {
61
62
config .buildSessionFactory ();
62
63
fail ( "Session creation should have failed due to duplicate analyzer definition" );
63
64
}
64
- catch ( HibernateException e ) { // the SearchException will be wrapped in a HibernateException
65
+ catch ( SearchException e ) { // the SearchException will be wrapped in a HibernateException
65
66
assertTrue (
66
- e .getCause (). getMessage ().equals (
67
+ e .getMessage ().equals (
67
68
"Multiple analyzer definitions with the same name: my-analyzer"
68
69
)
69
70
);
@@ -78,9 +79,9 @@ public void testDuplicatedProgrammaticAnalyzerDefinitionThrowsException() throws
78
79
config .buildSessionFactory ();
79
80
fail ( "Session creation should have failed due to duplicate analyzer definition" );
80
81
}
81
- catch ( HibernateException e ) { // the SearchException will be wrapped in a HibernateException
82
+ catch ( SearchException e ) { // the SearchException will be wrapped in a HibernateException
82
83
assertTrue (
83
- e . getCause () .getMessage ().equals ( "Multiple analyzer definitions with the same name: english" )
84
+ e .getMessage ().equals ( "Multiple analyzer definitions with the same name: english" )
84
85
);
85
86
}
86
87
}
Original file line number Diff line number Diff line change @@ -53,11 +53,8 @@ public void testIllegalAnalyzerDefinition() {
53
53
.build ();
54
54
Assert .fail ( "should not reach this" );
55
55
}
56
- catch ( org .hibernate .HibernateException initException ) {
57
- Throwable causeException = initException .getCause ();
58
- Assert .assertTrue ( causeException instanceof SearchException );
59
- SearchException searchException = (SearchException ) causeException ;
60
- String message = searchException .getMessage ();
56
+ catch ( SearchException initException ) {
57
+ String message = initException .getMessage ();
61
58
Assert .assertEquals ( "Resource not found: non-existent-resourcename.file" , message );
62
59
}
63
60
}
Original file line number Diff line number Diff line change 23
23
*/
24
24
package org .hibernate .search .test .directoryProvider ;
25
25
26
+ import org .hibernate .search .SearchException ;
26
27
import org .hibernate .search .test .util .FullTextSessionBuilder ;
27
28
import org .junit .Test ;
28
29
import static org .junit .Assert .*;
31
32
* @author Sanne Grinovero
32
33
*/
33
34
public class CustomLockProviderTest {
34
-
35
+
35
36
@ Test
36
37
public void testUseOfCustomLockingFactory () {
37
38
assertNull ( CustomLockFactoryFactory .optionValue );
@@ -57,11 +58,8 @@ public void testFailOnInexistentLockingFactory() {
57
58
builder .close ();
58
59
fail ();
59
60
}
60
- catch (org .hibernate .HibernateException e ) {
61
- Throwable causeSearch = e .getCause ();
62
- assertNotNull ( causeSearch );
63
- assertTrue ( causeSearch instanceof org .hibernate .search .SearchException );
64
- assertEquals ( "Unable to find locking_strategy implementation class: org.hibernate.NotExistingFactory" , causeSearch .getMessage () );
61
+ catch (SearchException e ) {
62
+ assertEquals ( "Unable to find locking_strategy implementation class: org.hibernate.NotExistingFactory" , e .getMessage () );
65
63
}
66
64
}
67
65
Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ public void testInvalidDirectoryType() throws Exception {
65
65
createSessionFactoryUsingDirectoryType ( "foobar" );
66
66
fail ( "Factory creation should fail with invalid 'hibernate.search.default.filesystem_access_type' parameter " );
67
67
}
68
- catch ( HibernateException e ) {
69
- assertTrue ( e . getCause () instanceof SearchException );
68
+ catch ( SearchException e ) {
69
+ //success
70
70
}
71
71
}
72
72
Original file line number Diff line number Diff line change @@ -254,8 +254,7 @@ public void testSourceNotReady() throws Exception {
254
254
try {
255
255
cfg .buildSessionFactory ();
256
256
}
257
- catch ( HibernateException e ) {
258
- assertTrue ( "expected configuration failure" , e .getCause () instanceof SearchException );
257
+ catch ( SearchException e ) {
259
258
final long elapsedTime = TimeUnit .NANOSECONDS .toSeconds ( System .nanoTime () - start );
260
259
assertTrue ( "Should be around 10 seconds: " + elapsedTime , elapsedTime > retries *5 - 1 ); // -1 for safety
261
260
}
Original file line number Diff line number Diff line change 25
25
import org .apache .lucene .store .FSDirectory ;
26
26
import org .apache .lucene .store .RAMDirectory ;
27
27
import org .hibernate .HibernateException ;
28
+ import org .hibernate .search .SearchException ;
28
29
import org .hibernate .search .store .DirectoryProvider ;
29
30
import org .hibernate .search .test .util .FullTextSessionBuilder ;
30
31
@@ -67,7 +68,7 @@ public void testStandardInitialization() {
67
68
slave = createSlaveNode ( false );
68
69
}
69
70
70
- @ Test (expected =HibernateException .class )
71
+ @ Test (expected =SearchException .class )
71
72
public void testInitiallyFailing () {
72
73
slave = createSlaveNode ( false );
73
74
}
Original file line number Diff line number Diff line change 24
24
package org .hibernate .search .test .id ;
25
25
26
26
import org .hibernate .HibernateException ;
27
+ import org .hibernate .search .SearchException ;
27
28
import org .hibernate .search .test .SearchTestCase ;
28
29
29
30
/**
@@ -45,10 +46,10 @@ public void testDuplicateDocumentId() throws Exception {
45
46
buildConfiguration ();
46
47
fail ( "Building of configuration should fail, because Foo defines multiple document ids." );
47
48
}
48
- catch ( HibernateException e ) { // getting a HibernateException here, because the listener registration fails
49
+ catch ( SearchException e ) { // getting a HibernateException here, because the listener registration fails
49
50
assertEquals (
50
51
"More than one @DocumentId specified on entity org.hibernate.search.test.id.Foo" ,
51
- e .getCause (). getMessage ()
52
+ e .getMessage ()
52
53
);
53
54
}
54
55
}
Original file line number Diff line number Diff line change 26
26
import java .util .List ;
27
27
28
28
import org .hibernate .HibernateException ;
29
+ import org .hibernate .search .SearchException ;
29
30
import org .hibernate .search .test .SearchTestCase ;
30
31
import org .hibernate .search .Search ;
31
32
import org .hibernate .search .FullTextSession ;
@@ -52,9 +53,9 @@ public void testIndexLevelSimilarity() throws Exception {
52
53
config .buildSessionFactory ();
53
54
fail ( "Session creation should have failed due to duplicate similarity definition" );
54
55
}
55
- catch ( HibernateException e ) { // the SearchException will be wrapped in a HibernateException
56
+ catch ( SearchException e ) { // the SearchException will be wrapped in a HibernateException
56
57
assertTrue (
57
- e .getCause (). getMessage ().startsWith (
58
+ e .getMessage ().startsWith (
58
59
"Multiple similarities defined"
59
60
)
60
61
);
You can’t perform that action at this time.
0 commit comments