@Configuration
  public Option[] config() throws Exception {
    final Properties paxExamEnvironment = loadPaxExamEnvironmentProperties();

    final boolean debug =
        ConfigurationHelper.getBoolean(
            "org.hibernate.testing.osgi.paxExam.debug", Environment.getProperties(), DEBUG);

    return options(
        when(debug).useOptions(debugConfiguration("5005", true)),
        karafDistributionConfiguration()
            .frameworkUrl(
                paxExamEnvironment.getProperty("org.ops4j.pax.exam.container.karaf.distroUrl"))
            .karafVersion(
                paxExamEnvironment.getProperty("org.ops4j.pax.exam.container.karaf.version"))
            .name("Apache Karaf")
            .unpackDirectory(
                new File(
                    paxExamEnvironment.getProperty("org.ops4j.pax.exam.container.karaf.unpackDir")))
            .useDeployFolder(false),
        editConfigurationFileExtend(
            "etc/org.ops4j.pax.url.mvn.cfg",
            "org.ops4j.pax.url.mvn.repositories",
            "https://repository.jboss.org/nexus/content/groups/public/"),
        configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
        when(debug).useOptions(keepRuntimeFolder()),
        logLevel(LogLevelOption.LogLevel.INFO),
        features(featureXmlUrl(paxExamEnvironment), "hibernate-orm"),
        features(testingFeatureXmlUrl(), "hibernate-osgi-testing"));
  }
 private static Properties createProperties() {
   final Properties properties = new Properties();
   // If configured in the environment, add configuration file name to properties.
   final String cfgFileName =
       (String)
           Environment.getProperties()
               .get(InfinispanRegionFactory.INFINISPAN_CONFIG_RESOURCE_PROP);
   if (cfgFileName != null) {
     properties.put(InfinispanRegionFactory.INFINISPAN_CONFIG_RESOURCE_PROP, cfgFileName);
   }
   return properties;
 }
  private SessionFactory buildSessionFactory() {
    // Extra options located in src/test/resources/hibernate.properties
    Properties envProps = Environment.getProperties();
    envProps.setProperty(Environment.DIALECT, "HSQL");
    envProps.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
    envProps.setProperty(
        Environment.CONNECTION_PROVIDER, JtaAwareConnectionProviderImpl.class.getName());
    envProps.setProperty(Environment.JNDI_CLASS, "org.jnp.interfaces.NamingContextFactory");
    envProps.setProperty(Environment.TRANSACTION_STRATEGY, "jta");
    envProps.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "jta");
    envProps.setProperty(Environment.RELEASE_CONNECTIONS, "auto");
    envProps.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
    envProps.setProperty(Environment.USE_QUERY_CACHE, "true");
    envProps.put(AvailableSettings.JTA_PLATFORM, new JBossStandAloneJtaPlatform());
    envProps.setProperty(
        Environment.CACHE_REGION_FACTORY,
        "org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase$TestInfinispanRegionFactory");
    serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry(envProps);

    MetadataSources sources = new MetadataSources(serviceRegistry);

    String[] mappings =
        new String[] {"org/hibernate/test/cache/infinispan/functional/Item.hbm.xml"};
    for (String mapping : mappings) {
      sources.addResource(mapping);
    }
    Metadata metadata = sources.buildMetadata();
    Iterator<EntityBinding> entityIter = metadata.getEntityBindings().iterator();
    while (entityIter.hasNext()) {
      EntityBinding binding = entityIter.next();
      binding.getHierarchyDetails().getCaching().setAccessType(AccessType.TRANSACTIONAL);
      binding.getHierarchyDetails().getCaching().setRequested(TruthValue.TRUE);
      binding.getHierarchyDetails().getCaching().setRegion(binding.getEntityName());
      binding.getHierarchyDetails().getCaching().setCacheLazyProperties(true);
    }
    Iterator<PluralAttributeBinding> collectionIter = metadata.getCollectionBindings().iterator();
    while (collectionIter.hasNext()) {
      PluralAttributeBinding binding = collectionIter.next();
      binding.getCaching().setAccessType(AccessType.TRANSACTIONAL);
      binding.getCaching().setRequested(TruthValue.TRUE);
      binding
          .getCaching()
          .setRegion(
              StringHelper.qualify(
                  binding.getContainer().seekEntityBinding().getEntityName(),
                  binding.getAttribute().getName()));
      binding.getCaching().setCacheLazyProperties(true);
    }
    return metadata.buildSessionFactory();
  }
  public SchemaFilterTest() {
    Map settings = new HashMap();
    settings.putAll(Environment.getProperties());
    settings.put(AvailableSettings.DIALECT, SQLServerDialect.class.getName());

    this.serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry(settings);

    MetadataSources ms = new MetadataSources(serviceRegistry);
    ms.addAnnotatedClass(SchemaNoneEntity0.class);
    ms.addAnnotatedClass(Schema1Entity1.class);
    ms.addAnnotatedClass(Schema1Entity2.class);
    ms.addAnnotatedClass(Schema2Entity3.class);
    ms.addAnnotatedClass(Schema2Entity4.class);
    this.metadata = ms.buildMetadata();
  }
 protected void setUp() {
   serviceRegistryHolder = new ServiceRegistryHolder(Environment.getProperties());
 }
 /**
  * Discription:[已过时]
  *
  * @return
  * @author:[代超]
  * @update:[日期YYYY-MM-DD] [更改人姓名][变更描述]
  */
 public static Properties getHibernateProperties() {
   return Environment.getProperties();
 }
 @Before
 public void setUp() {
   serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry(Environment.getProperties());
 }
 public String getDialect() {
   return Environment.getProperties().getProperty(Environment.DIALECT);
 }
 protected void setUp() {
   serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry(Environment.getProperties());
 }