Package org.hivedb.hibernate.simplified.session

Source Code of org.hivedb.hibernate.simplified.session.SingletonHiveSessionFactoryBuilderTest

package org.hivedb.hibernate.simplified.session;

import org.hibernate.shards.strategy.access.SequentialShardAccessStrategy;
import org.hivedb.util.Lists;
import org.hivedb.util.database.test.HiveTest;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

@HiveTest.Config("hive_default")
public class SingletonHiveSessionFactoryBuilderTest extends HiveTest {
  SingletonHiveSessionFactoryBuilder builder;

  public void setup() {
    builder = new SingletonHiveSessionFactoryBuilder(getHive(), Lists.newList(getMappedClasses()), new SequentialShardAccessStrategy());
  }

  @Test
  public void shouldBuildAProperlyConfiguredSessionFactory() throws Exception {
    HiveSessionFactoryImpl factory = (HiveSessionFactoryImpl) builder.getSessionFactory();
    assertNotNull(factory);
  }

  @Test
  public void shouldOnlyBuildASessionFactoryOnce() throws Exception {
    HiveSessionFactoryImpl factory = (HiveSessionFactoryImpl) builder.getSessionFactory();
    HiveSessionFactoryImpl anotherFactory = (HiveSessionFactoryImpl) builder.getSessionFactory();
    assertTrue(factory == anotherFactory);
  }

  @Test
  public void shouldRebuildTheSessionFactoryWhenTheObservableUpdates() throws Exception {
    HiveSessionFactoryImpl factory = (HiveSessionFactoryImpl) builder.getSessionFactory();
    builder.update(null,null);
    HiveSessionFactoryImpl anotherFactory = (HiveSessionFactoryImpl) builder.getSessionFactory();
    assertTrue(factory != anotherFactory);
  }
}
TOP

Related Classes of org.hivedb.hibernate.simplified.session.SingletonHiveSessionFactoryBuilderTest

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.