HHH-11473 - Fix MySQLStorageEngineTest

This commit is contained in:
Andrea Boriero 2017-02-23 19:23:58 +00:00
parent 7c90905d73
commit bc3032785e
1 changed files with 10 additions and 3 deletions

View File

@ -12,7 +12,10 @@ import org.hibernate.dialect.MySQL57Dialect;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test; import org.junit.Test;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea
@ -21,19 +24,23 @@ public class MySQLStorageEngineTest extends BaseUnitTestCase {
@Test @Test
public void testDefaultStorage() { public void testDefaultStorage() {
assertEquals(" engine=InnoDB", new MySQL57Dialect().getTableTypeString()); assertEquals( " engine=InnoDB", new MySQL57Dialect().getTableTypeString() );
} }
@Test @Test
public void testOverrideStorage() { public void testOverrideStorage() {
String previousValue = System.setProperty( AvailableSettings.STORAGE_ENGINE, "myisam" ); String previousValue = System.setProperty( AvailableSettings.STORAGE_ENGINE, "myisam" );
try{ try {
assertEquals(" engine=MyISAM", new MySQL57Dialect().getTableTypeString()); assertEquals( " engine=MyISAM", new MySQL57Dialect().getTableTypeString() );
} }
finally { finally {
if ( previousValue != null ) { if ( previousValue != null ) {
System.setProperty( AvailableSettings.STORAGE_ENGINE, previousValue ); System.setProperty( AvailableSettings.STORAGE_ENGINE, previousValue );
} }
else {
System.clearProperty( AvailableSettings.STORAGE_ENGINE );
assertThat( System.getProperty( AvailableSettings.STORAGE_ENGINE ), is( nullValue() ) );
}
} }
} }
} }