Package org.hibernate.search.test.bridge

Source Code of org.hibernate.search.test.bridge.UnresolvedBridgeTest

//$Id: UnresolvedBridgeTest.java 20106 2010-08-04 06:31:38Z stliu $
package org.hibernate.search.test.bridge;

import junit.framework.TestCase;

import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.search.SearchException;
import org.hibernate.search.store.RAMDirectoryProvider;

/**
* @author Emmanuel Bernard
*/
public class UnresolvedBridgeTest extends TestCase {
  public void testSerializableType() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();

    for (int i = 0; i < getMappings().length; i++) {
      cfg.addAnnotatedClass( getMappings()[i] );
    }
    cfg.setProperty( "hibernate.search.default.directory_provider", RAMDirectoryProvider.class.getName() );
    try {
      cfg.buildSessionFactory();
      fail("Undefined bridge went through");
    }
    catch( Exception e ) {
      Throwable ee = e;
      boolean hasSearchException = false;
      for (;;) {
        if (ee == null) {
          break;
        }
        else if (ee instanceof SearchException) {
          hasSearchException = true;
          break;
        }
        ee = ee.getCause();
      }
      assertTrue( hasSearchException );
    }
  }

  @SuppressWarnings("unchecked")
  protected Class[] getMappings() {
    return new Class[] {
        Gangster.class
    };
  }
}
TOP

Related Classes of org.hibernate.search.test.bridge.UnresolvedBridgeTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.