Search in sources :

Example 51 with SkipForDialect

use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.

the class CustomRunner method convertSkipToIgnore.

protected Ignore convertSkipToIgnore(FrameworkMethod frameworkMethod) {
    // @Skip
    Skip skip = Helper.locateAnnotation(Skip.class, frameworkMethod, getTestClass());
    if (skip != null) {
        if (isMatch(skip.condition())) {
            return buildIgnore(skip);
        }
    }
    // @SkipForDialects & @SkipForDialect
    for (SkipForDialect skipForDialectAnn : Helper.collectAnnotations(SkipForDialect.class, SkipForDialects.class, frameworkMethod, getTestClass())) {
        for (Class<? extends Dialect> dialectClass : skipForDialectAnn.value()) {
            if (skipForDialectAnn.strictMatching()) {
                if (dialectClass.equals(dialect.getClass())) {
                    return buildIgnore(skipForDialectAnn);
                }
            } else {
                if (dialectClass.isInstance(dialect)) {
                    return buildIgnore(skipForDialectAnn);
                }
            }
        }
    }
    // @RequiresDialects & @RequiresDialect
    final List<RequiresDialect> requiresDialects = Helper.collectAnnotations(RequiresDialect.class, RequiresDialects.class, frameworkMethod, getTestClass());
    if (!requiresDialects.isEmpty() && !isDialectMatchingRequired(requiresDialects)) {
        return buildIgnore(requiresDialects);
    }
    // @RequiresDialectFeature
    RequiresDialectFeature requiresDialectFeatureAnn = Helper.locateAnnotation(RequiresDialectFeature.class, frameworkMethod, getTestClass());
    if (requiresDialectFeatureAnn != null) {
        try {
            for (Class<? extends DialectCheck> checkClass : requiresDialectFeatureAnn.value()) {
                if (!checkClass.newInstance().isMatch(dialect)) {
                    return buildIgnore(requiresDialectFeatureAnn);
                }
            }
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException("Unable to instantiate DialectCheck", e);
        }
    }
    return null;
}
Also used : SkipForDialect(org.hibernate.testing.SkipForDialect) RequiresDialectFeature(org.hibernate.testing.RequiresDialectFeature) Skip(org.hibernate.testing.Skip) RequiresDialect(org.hibernate.testing.RequiresDialect) NoTestsRemainException(org.junit.runner.manipulation.NoTestsRemainException)

Example 52 with SkipForDialect

use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.

the class UnionSubclassTest method testQuerySubclassAttribute.

@Test
@SkipForDialect(value = TeradataDialect.class, jiraKey = "HHH-8190", comment = "SQL uses Teradata reserved word: title")
public void testQuerySubclassAttribute() {
    if (getDialect() instanceof HSQLDialect) {
        // TODO : why??
        return;
    }
    Session s = openSession();
    Transaction t = s.beginTransaction();
    Person p = new Person();
    p.setName("Emmanuel");
    p.setSex('M');
    s.persist(p);
    Employee q = new Employee();
    q.setName("Steve");
    q.setSex('M');
    q.setTitle("Mr");
    q.setSalary(new BigDecimal(1000));
    s.persist(q);
    List result = s.createQuery("from Person where salary > 100").list();
    assertEquals(result.size(), 1);
    assertSame(result.get(0), q);
    result = s.createQuery("from Person where salary > 100 or name like 'E%'").list();
    assertEquals(result.size(), 2);
    result = s.createCriteria(Person.class).add(Property.forName("salary").gt(new BigDecimal(100))).list();
    assertEquals(result.size(), 1);
    assertSame(result.get(0), q);
    result = s.createQuery("select salary from Person where salary > 100").list();
    assertEquals(result.size(), 1);
    assertEquals(((BigDecimal) result.get(0)).intValue(), 1000);
    s.delete(p);
    s.delete(q);
    t.commit();
    s.close();
}
Also used : HSQLDialect(org.hibernate.dialect.HSQLDialect) Transaction(org.hibernate.Transaction) List(java.util.List) BigDecimal(java.math.BigDecimal) Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test)

Example 53 with SkipForDialect

use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.

the class TypeOverrideTest method testRegisteredFunction.

@Test
@SkipForDialect(value = SybaseASE15Dialect.class, jiraKey = "HHH-6426")
public void testRegisteredFunction() {
    Session s = openSession();
    s.getTransaction().begin();
    Entity e = new Entity("name ");
    s.save(e);
    s.getTransaction().commit();
    s.close();
    s = openSession();
    s.getTransaction().begin();
    e = (Entity) s.get(Entity.class, e.getId());
    assertFalse(e.getName().startsWith(StoredPrefixedStringType.PREFIX));
    assertEquals("name ", e.getName());
    s.getTransaction().commit();
    s.close();
    s = openSession();
    s.getTransaction().begin();
    s.delete(e);
    s.getTransaction().commit();
    s.close();
}
Also used : Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test)

Example 54 with SkipForDialect

use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.

the class IndexedCollectionTest method testMapKeyOnManyToManyOnId.

@Test
@SkipForDialect(value = TeradataDialect.class, jiraKey = "HHH-8190", comment = "uses Teradata reserved word - title")
public void testMapKeyOnManyToManyOnId() throws Exception {
    Session s;
    s = openSession();
    s.getTransaction().begin();
    News hibernate1 = new News();
    hibernate1.setTitle("#1 ORM solution in the Java world");
    hibernate1.setDetail("Well, that's no news ;-)");
    s.persist(hibernate1);
    PressReleaseAgency schwartz = new PressReleaseAgency();
    schwartz.setName("Schwartz");
    schwartz.getProvidedNews().put(hibernate1.getId(), hibernate1);
    s.persist(schwartz);
    s.flush();
    s.clear();
    schwartz = (PressReleaseAgency) s.get(PressReleaseAgency.class, schwartz.getId());
    assertEquals(1, schwartz.getProvidedNews().size());
    News news = schwartz.getProvidedNews().get(hibernate1.getId());
    assertNotNull(news);
    assertEquals(hibernate1.getTitle(), news.getTitle());
    s.delete(schwartz);
    s.delete(news);
    s.getTransaction().rollback();
    s.close();
}
Also used : Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test)

Example 55 with SkipForDialect

use of org.hibernate.testing.SkipForDialect in project hibernate-orm by hibernate.

the class GenericsTest method testManyToOneGenerics.

@SkipForDialect(value = AbstractHANADialect.class, comment = "known bug in HANA: rs.next() returns false for org.hibernate.id.enhanced.SequenceStructure$1.getNextValue() for this test")
@Test
public void testManyToOneGenerics() throws Exception {
    Paper white = new Paper();
    white.setName("WhiteA4");
    PaperType type = new PaperType();
    type.setName("A4");
    SomeGuy me = new SomeGuy();
    white.setType(type);
    white.setOwner(me);
    Price price = new Price();
    price.setAmount(new Double(1));
    price.setCurrency("Euro");
    white.setValue(price);
    Session s = openSession();
    Transaction tx = s.beginTransaction();
    s.persist(type);
    s.persist(price);
    s.persist(me);
    s.persist(white);
    tx.commit();
    //s.close();
    s = openSession();
    tx = s.beginTransaction();
    white = (Paper) s.get(Paper.class, white.getId());
    s.delete(white.getType());
    s.delete(white.getOwner());
    s.delete(white.getValue());
    s.delete(white);
    tx.commit();
//s.close();
}
Also used : Transaction(org.hibernate.Transaction) Session(org.hibernate.Session) SkipForDialect(org.hibernate.testing.SkipForDialect) Test(org.junit.Test)

Aggregations

SkipForDialect (org.hibernate.testing.SkipForDialect)87 Test (org.junit.Test)86 Session (org.hibernate.Session)66 Transaction (org.hibernate.Transaction)36 List (java.util.List)26 ArrayList (java.util.ArrayList)20 TestForIssue (org.hibernate.testing.TestForIssue)16 EntityManager (javax.persistence.EntityManager)15 Query (javax.persistence.Query)11 Item (org.hibernate.jpa.test.Item)10 Query (org.hibernate.Query)7 Parameter (javax.persistence.Parameter)6 BigDecimal (java.math.BigDecimal)5 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)4 SQLQuery (org.hibernate.SQLQuery)4 ScrollableResults (org.hibernate.ScrollableResults)4 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3 Date (java.util.Date)3 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)3