HHH-10904 - Fix tests failing when switching to MySQL

This commit is contained in:
Vlad Mihalcea 2016-06-29 16:29:26 +03:00
parent 5ef1da74c2
commit 0e6230faf0
7 changed files with 39 additions and 18 deletions

View File

@ -78,7 +78,7 @@ public class QueryWithLiteralsInSelectExpressionTest extends BaseEntityManagerFu
final EntityManager entityManager = getOrCreateEntityManager();
try {
final List<Object[]> elements = entityManager.createQuery(
"SELECT cast(null as boolean), false, e.name FROM MyEntity e",
"SELECT cast(null as char), false, e.name FROM MyEntity e",
Object[].class
).getResultList();
Assert.assertEquals( 1, elements.size() );

View File

@ -13,15 +13,17 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -29,6 +31,7 @@ import static org.junit.Assert.assertTrue;
* @author Piotr Krauzowicz <p.krauzowicz@visiona.pl>
* @author Gail Badner
*/
@SkipForDialect(value = MySQL5Dialect.class, comment = "BLOB/TEXT column 'id' used in key specification without a key length")
public class ByteArrayIdTest extends BaseCoreFunctionalTestCase {
@Override

View File

@ -19,6 +19,9 @@ import org.junit.Test;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -29,6 +32,7 @@ import static org.junit.Assert.assertTrue;
* @author Piotr Krauzowicz <p.krauzowicz@visiona.pl>
* @author Gail Badner
*/
@SkipForDialect(value = MySQL5Dialect.class, comment = "BLOB/TEXT column 'id' used in key specification without a key length")
public class PrimitiveByteArrayIdTest extends BaseCoreFunctionalTestCase {
@Override

View File

@ -6,15 +6,15 @@
*/
package org.hibernate.test.schemaupdate;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.EnumSet;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
@ -25,12 +25,13 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.hibernate.tool.schema.TargetType;
import org.hibernate.testing.Skip;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.hibernate.testing.TestForIssue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
@ -38,7 +39,7 @@ import static org.junit.Assert.assertThat;
* @author Andrea Boriero
*/
public class QuotedTableNameSchemaUpdateTest {
public class QuotedTableNameSchemaUpdateTest extends BaseUnitTestCase {
private File output;
private StandardServiceRegistry ssr;
@ -59,6 +60,7 @@ public class QuotedTableNameSchemaUpdateTest {
@Test
@TestForIssue(jiraKey = "HHH-10820")
@Skip(condition = Skip.OperatingSystem.Windows.class, message = "On Windows, MySQL is case insensitive!")
public void testSchemaUpdateWithQuotedTableName() throws Exception {
final MetadataSources metadataSources = new MetadataSources( ssr );
metadataSources.addAnnotatedClass( QuotedTable.class );

View File

@ -18,9 +18,11 @@ import org.hibernate.cfg.Environment;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.hibernate.tool.schema.TargetType;
import org.junit.Test;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
@ -29,7 +31,8 @@ import static org.junit.Assert.assertThat;
* @author Andrea Boriero
*/
@TestForIssue(jiraKey = "HHH-10373")
public class IdBagSequenceTest {
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
public class IdBagSequenceTest extends BaseUnitTestCase {
@Test
public void testIdBagSequenceGeneratorIsCreated() throws Exception {

View File

@ -23,8 +23,8 @@
</set>
<map name="tokens" sort="natural" table="search_tokens">
<key column="searchString"/>
<map-key column="key" type="string"/>
<element column="value" type="string"/>
<map-key column="`key`" type="string"/>
<element column="`value`" type="string"/>
</map>
</class>

View File

@ -45,10 +45,19 @@ public @interface Skip {
public boolean isMatch();
}
public static class AlwaysSkip implements Matcher {
class AlwaysSkip implements Matcher {
@Override
public boolean isMatch() {
return true;
}
}
interface OperatingSystem {
class Windows implements Matcher {
@Override
public boolean isMatch() {
return System.getProperty("os.name").toLowerCase().contains( "windows" );
}
}
}
}