Skip to content

Commit

Permalink
HSEARCH-2179 Added reproducer
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavonalle authored and Sanne committed Mar 12, 2016
1 parent 8bcc32c commit d40070e
Showing 1 changed file with 50 additions and 0 deletions.
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();
}

}

0 comments on commit d40070e

Please sign in to comment.