From 47443bcf57cb4e66dbc02cd6c7e31459a0b4003c Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Wed, 3 Apr 2013 10:29:12 -0400 Subject: [PATCH] HHH-8127 Corrected failing test --- .../embeddables/EmbeddableIntegratorTest.java | 71 +++++++++---------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java index aa6bf65622..0fbe4f23ca 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java @@ -53,28 +53,25 @@ public class EmbeddableIntegratorTest extends BaseUnitTestCase { /** * Throws a mapping exception because DollarValue is not mapped */ - @Test(expected=GenericJDBCException.class) + @Test(expected = GenericJDBCException.class) public void testWithoutIntegrator() { - - ServiceRegistry reg = new StandardServiceRegistryBuilder(new BootstrapServiceRegistryImpl()) - .build(); - - SessionFactory sf = new Configuration() - .addAnnotatedClass( Investor.class ) - .buildSessionFactory(reg); - + ServiceRegistry reg = new StandardServiceRegistryBuilder( new BootstrapServiceRegistryImpl() ).build(); + + SessionFactory sf = new Configuration().addAnnotatedClass( Investor.class ) + .setProperty( "hibernate.hbm2ddl.auto", "create-drop" ).buildSessionFactory( reg ); + Session sess = sf.openSession(); Investor myInv = getInvestor(); - myInv.setId(1L); - - sess.save(myInv); + myInv.setId( 1L ); + + sess.save( myInv ); sess.flush(); sess.clear(); - - Investor inv = (Investor) sess.get(Investor.class, 1L); - assertEquals(new BigDecimal("100"), inv.getInvestments().get(0).getAmount().getAmount()); - + + Investor inv = (Investor) sess.get( Investor.class, 1L ); + assertEquals( new BigDecimal( "100" ), inv.getInvestments().get( 0 ).getAmount().getAmount() ); + sess.close(); sf.close(); StandardServiceRegistryBuilder.destroy( reg ); @@ -82,42 +79,38 @@ public class EmbeddableIntegratorTest extends BaseUnitTestCase { @Test public void testWithIntegrator() { - StandardServiceRegistry reg = new StandardServiceRegistryBuilder( - new BootstrapServiceRegistryBuilder().with( new InvestorIntegrator() ).build() - ).build(); - - SessionFactory sf = new Configuration() - .addAnnotatedClass( Investor.class ) + StandardServiceRegistry reg = new StandardServiceRegistryBuilder( new BootstrapServiceRegistryBuilder().with( + new InvestorIntegrator() ).build() ).build(); + + SessionFactory sf = new Configuration().addAnnotatedClass( Investor.class ) + .setProperty( "hibernate.hbm2ddl.auto", "create-drop" ).buildSessionFactory( reg ); - .setProperty("hibernate.hbm2ddl.auto", "create-drop") - .buildSessionFactory(reg); - Session sess = sf.openSession(); Investor myInv = getInvestor(); - myInv.setId(2L); - - sess.save(myInv); + myInv.setId( 2L ); + + sess.save( myInv ); sess.flush(); sess.clear(); - - Investor inv = (Investor) sess.get(Investor.class, 2L); - assertEquals(new BigDecimal("100"), inv.getInvestments().get(0).getAmount().getAmount()); - + + Investor inv = (Investor) sess.get( Investor.class, 2L ); + assertEquals( new BigDecimal( "100" ), inv.getInvestments().get( 0 ).getAmount().getAmount() ); + sess.close(); sf.close(); StandardServiceRegistryBuilder.destroy( reg ); } - + private Investor getInvestor() { Investor i = new Investor(); List investments = new ArrayList(); Investment i1 = new Investment(); - i1.setAmount(new DollarValue(new BigDecimal("100"))); - i1.setDate(new MyDate(new Date())); - i1.setDescription("Test Investment"); - investments.add(i1); - i.setInvestments(investments); - + i1.setAmount( new DollarValue( new BigDecimal( "100" ) ) ); + i1.setDate( new MyDate( new Date() ) ); + i1.setDescription( "Test Investment" ); + investments.add( i1 ); + i.setInvestments( investments ); + return i; } }