public void testOpeningIndexReaderUsingNullAsNameThrowsException() throws Exception {
   try {
     indexReaderAccessor.open((String) null);
     Assert.fail("should have failed");
   } catch (IllegalArgumentException e) {
     Assert.assertEquals("HSEARCH000113: 'null' is not a valid index name", e.getMessage());
   }
 }
 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());
   }
 }
 public void testOpeningIndexReaderUsingEmptyStringArrayThrowsException() throws Exception {
   try {
     indexReaderAccessor.open(new String[] {});
     Assert.fail("should have failed");
   } catch (IllegalArgumentException e) {
     Assert.assertEquals(
         "HSEARCH000111: At least one index name must be provided: can't open an IndexReader on nothing",
         e.getMessage());
   }
 }
 public void testOpeningIndexReaderByUnknownEntityThrowsException() throws Exception {
   try {
     indexReaderAccessor.open(this.getClass());
     Assert.fail("should have failed");
   } catch (IllegalArgumentException e) {
     Assert.assertEquals(
         "HSEARCH000109: org.hibernate.search.test.shards.DirectorySelectionTest is not an indexed type",
         e.getMessage());
   }
 }
  public void testDirectoryProviderForQuery() throws Exception {
    IndexReader indexReader = indexReaderAccessor.open(Product.class);
    try {
      Assert.assertEquals(2, indexReader.numDocs());
    } finally {
      indexReaderAccessor.close(indexReader);
    }

    indexReader = indexReaderAccessor.open("Products.0");
    try {
      Assert.assertEquals(1, indexReader.numDocs());
    } finally {
      indexReaderAccessor.close(indexReader);
    }

    indexReader = indexReaderAccessor.open("Products.1");
    try {
      Assert.assertEquals(1, indexReader.numDocs());
    } finally {
      indexReaderAccessor.close(indexReader);
    }
  }