HHH-10009 - Unable to parse cfg.xml file with explicit xsi:schemaLocation

This commit is contained in:
Steve Ebersole 2015-09-01 09:22:57 -05:00
parent d85fd04eb0
commit 74d2d33012
3 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,38 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.boot.cfgXml;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.internal.util.config.ConfigurationException;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test;
import static org.junit.Assert.fail;
/**
* @author Steve Ebersole
*/
public class CfgXmlParsingTest extends BaseUnitTestCase {
@Test
public void testCfgXmlWithSchemaLocation() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
.configure( "org/hibernate/test/boot/cfgXml/hibernate.cfg.xml" )
.build();
StandardServiceRegistryBuilder.destroy( ssr );
}
@Test(expected = ConfigurationException.class )
public void testCfgXmlWithBadNamespaceAndSchemaLocation() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
.configure( "org/hibernate/test/boot/cfgXml/badnamespace.cfg.xml" )
.build();
StandardServiceRegistryBuilder.destroy( ssr );
fail( "Expecting the bad namespace to fail" );
}
}

View File

@ -0,0 +1,8 @@
<hibernate-configuration
xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<session-factory>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
</session-factory>
</hibernate-configuration>

View File

@ -0,0 +1,14 @@
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<hibernate-configuration
xmlns="http://www.hibernate.org/xsd/orm/cfg"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hibernate.org/xsd/orm/cfg hibernate-configuration-4.0.xsd">
<session-factory>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
</session-factory>
</hibernate-configuration>