fixing test code only
This commit is contained in:
parent
34c3cec657
commit
d50d215163
|
@ -36,6 +36,7 @@ import org.hibernate.Session;
|
|||
import org.hibernate.Transaction;
|
||||
import org.hibernate.dialect.HSQLDialect;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -49,8 +50,8 @@ public class ABCProxyTest extends LegacyTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SkipForDialect( HSQLDialect.class )
|
||||
public void testDiscriminatorFiltering() throws Exception {
|
||||
if ( ( getDialect() instanceof HSQLDialect ) ) return;
|
||||
Session s = openSession();
|
||||
Transaction t = s.beginTransaction();
|
||||
s.createQuery("from C1 c1 left join c1.c2s c2").list();
|
||||
|
|
|
@ -28,17 +28,25 @@ import org.junit.Test;
|
|||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
|
||||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.relational.Table;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
//@FailureExpectedWithNewMetamodel
|
||||
public class NamingStrategyTest extends BaseCoreFunctionalTestCase {
|
||||
@Override
|
||||
public void configure(Configuration cfg) {
|
||||
|
@ -62,14 +70,58 @@ public class NamingStrategyTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
@Test
|
||||
public void testDatabaseColumnNames() {
|
||||
if ( isMetadataUsed() ) {
|
||||
EntityBinding entityBinding = metadata().getEntityBinding( Customers.class.getName() );
|
||||
assertNotNull( entityBinding );
|
||||
AttributeBinding attributeBinding = entityBinding.locateAttributeBinding( "specified_column" );
|
||||
assertNotNull( attributeBinding );
|
||||
assertTrue( SingularAttributeBinding.class.isInstance( attributeBinding ) );
|
||||
SingularAttributeBinding singularAttributeBinding = (SingularAttributeBinding) attributeBinding;
|
||||
assertEquals( 1, singularAttributeBinding.getRelationalValueBindings().size() );
|
||||
RelationalValueBinding valueBinding = singularAttributeBinding.getRelationalValueBindings().get( 0 );
|
||||
assertFalse( valueBinding.isDerived() );
|
||||
org.hibernate.metamodel.spi.relational.Column column = (org.hibernate.metamodel.spi.relational.Column) valueBinding
|
||||
.getValue();
|
||||
assertEquals( "CN_specified_column", column.getColumnName().getText() );
|
||||
|
||||
}
|
||||
else {
|
||||
PersistentClass classMapping = configuration().getClassMapping( Customers.class.getName() );
|
||||
Column stateColumn = (Column) classMapping.getProperty( "specified_column" ).getColumnIterator().next();
|
||||
assertEquals( "CN_specified_column", stateColumn.getName() );
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5848")
|
||||
public void testDatabaseTableNames() {
|
||||
if ( isMetadataUsed() ) {
|
||||
EntityBinding entityBinding = metadata().getEntityBinding( Item.class.getName() );
|
||||
assertNotNull( entityBinding );
|
||||
AttributeBinding attributeBinding = entityBinding.locateAttributeBinding( "specialPrice" );
|
||||
assertNotNull( attributeBinding );
|
||||
assertTrue( SingularAttributeBinding.class.isInstance( attributeBinding ) );
|
||||
SingularAttributeBinding singularAttributeBinding = (SingularAttributeBinding) attributeBinding;
|
||||
assertEquals( 1, singularAttributeBinding.getRelationalValueBindings().size() );
|
||||
RelationalValueBinding valueBinding = singularAttributeBinding.getRelationalValueBindings().get( 0 );
|
||||
assertFalse( valueBinding.isDerived() );
|
||||
org.hibernate.metamodel.spi.relational.Column column = (org.hibernate.metamodel.spi.relational.Column) valueBinding
|
||||
.getValue();
|
||||
Table table = (Table)column.getTable();
|
||||
|
||||
assertEquals( "TAB_ITEMS_SEC", table.getPhysicalName().getText() );
|
||||
|
||||
singularAttributeBinding = (SingularAttributeBinding)entityBinding.locateAttributeBinding( "price" );
|
||||
assertEquals( 1, singularAttributeBinding.getRelationalValueBindings().size() );
|
||||
valueBinding = singularAttributeBinding.getRelationalValueBindings().get( 0 );
|
||||
assertFalse( valueBinding.isDerived() );
|
||||
column = (org.hibernate.metamodel.spi.relational.Column) valueBinding
|
||||
.getValue();
|
||||
table = (Table)column.getTable();
|
||||
assertEquals( "TAB_ITEMS", table.getPhysicalName().getText());
|
||||
|
||||
}
|
||||
else {
|
||||
PersistentClass classMapping = configuration().getClassMapping( Item.class.getName() );
|
||||
Column secTabColumn = (Column) classMapping.getProperty( "specialPrice" ).getColumnIterator().next();
|
||||
assertEquals( "TAB_ITEMS_SEC", secTabColumn.getValue().getTable().getName() );
|
||||
|
@ -77,3 +129,4 @@ public class NamingStrategyTest extends BaseCoreFunctionalTestCase {
|
|||
assertEquals( "TAB_ITEMS", tabColumn.getValue().getTable().getName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue