-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
...src/test/java/org/hibernate/search/test/backend/lucene/SyncWorkProcessorShutDownTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.test.backend.lucene; | ||
|
||
import org.hibernate.search.backend.spi.Work; | ||
import org.hibernate.search.backend.spi.WorkType; | ||
import org.hibernate.search.testsupport.junit.SearchFactoryHolder; | ||
import org.hibernate.search.testsupport.setup.TransactionContextForTest; | ||
import org.jboss.byteman.contrib.bmunit.BMRule; | ||
import org.jboss.byteman.contrib.bmunit.BMUnitRunner; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* Tests for exception during the {@link org.hibernate.search.backend.impl.lucene.SyncWorkProcessor} | ||
* shutdown. | ||
* | ||
* @author gustavonalle | ||
*/ | ||
@RunWith(BMUnitRunner.class) | ||
public class SyncWorkProcessorShutDownTest { | ||
|
||
@Rule | ||
public SearchFactoryHolder sfAsyncExclusiveIndex = new SearchFactoryHolder( Quote.class ) | ||
.withProperty( "hibernate.search.default.exclusive_index_use", "true" ); | ||
|
||
@Test | ||
@BMRule(targetClass = "org.apache.lucene.index.IndexWriter", | ||
targetMethod = "commit", | ||
action = "throw new Error(\"error!\")", | ||
name = "commitError") | ||
public void testErrorHandlingDuringCommit() throws Exception { | ||
writeData( sfAsyncExclusiveIndex ); | ||
sfAsyncExclusiveIndex.getSearchFactory().close(); | ||
} | ||
|
||
private void writeData(SearchFactoryHolder sfHolder) { | ||
Quote quote = new Quote( 1, "description" ); | ||
Work work = new Work( quote, 1, WorkType.ADD, false ); | ||
TransactionContextForTest tc = new TransactionContextForTest(); | ||
sfHolder.getSearchFactory().getWorker().performWork( work, tc ); | ||
tc.end(); | ||
} | ||
|
||
} |