public void testQueryOnAllEntities() throws Exception { FullTextSession s = Search.getFullTextSession(openSession()); Transaction tx = s.beginTransaction(); Person person = new Person(); person.setName("Jon Doe"); s.save(person); tx.commit(); tx = s.beginTransaction(); QueryParser parser = new QueryParser( TestConstants.getTargetLuceneVersion(), "name", TestConstants.standardAnalyzer); Query query = parser.parse("name:foo"); FullTextQuery hibQuery = s.createFullTextQuery(query); try { hibQuery.list(); fail(); } catch (SearchException e) { assertTrue("Wrong message", e.getMessage().startsWith("There are no mapped entities")); } tx.rollback(); s.close(); }
public void testOpeningIndexReaderByUnknownNameThrowsException() throws Exception { try { indexReaderAccessor.open("Products.1", "hoa?"); Assert.fail("should have failed"); } catch (SearchException se) { Assert.assertEquals("HSEARCH000107: Index names hoa? is not defined", se.getMessage()); } }
@Test public void testInvalidPath() throws Exception { try { bridgeUnderTest.set(testFieldName, "/foo", testDocument, options); } catch (SearchException e) { assertTrue("Wrong error type", e.getMessage().startsWith("HSEARCH000152")); } }
@Test public void testUnknownTikaMetadataProcessor() throws Exception { try { bridgeUnderTest.setMetadataProcessorClass(this.getClass()); fail(); } catch (SearchException e) { assertEquals( "Wrong error message", "Wrong configuration of Tika parse context provider: class org.hibernate.search.test.bridge.builtin.TikaBridgeTest does not implement interface org.hibernate.search.bridge.TikaMetadataProcessor", e.getMessage()); } }