mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
Add test exclusions
This commit is contained in:
parent
d03cd3c72d
commit
f84a2a6b8e
@ -554,12 +554,16 @@ public abstract class AbstractJPATest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@NoEclipseLink({DERBY, HSQLDB})
|
||||
@NoHibernate({DERBY, POSTGRESQL})
|
||||
public void Date_YearWeek() {
|
||||
int value = query().from(cat).select(cat.birthdate.yearWeek()).fetchFirst();
|
||||
assertTrue(value == 200006 || value == 200005);
|
||||
}
|
||||
|
||||
@Test
|
||||
@NoEclipseLink({DERBY, HSQLDB})
|
||||
@NoHibernate({DERBY, POSTGRESQL})
|
||||
public void Date_Week() {
|
||||
int value = query().from(cat).select(cat.birthdate.week()).fetchFirst();
|
||||
assertTrue(value == 6 || value == 5);
|
||||
|
||||
@ -6,6 +6,8 @@ import org.junit.rules.MethodRule;
|
||||
import org.junit.runners.model.FrameworkMethod;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.querydsl.core.Target;
|
||||
import com.querydsl.core.testutil.EmptyStatement;
|
||||
|
||||
/**
|
||||
@ -16,29 +18,33 @@ public class JPAProviderRule implements MethodRule {
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, FrameworkMethod method, Object target) {
|
||||
boolean noEclipseLink = hasAnnotation(method, NoEclipseLink.class);
|
||||
boolean noOpenJPA = hasAnnotation(method, NoOpenJPA.class);
|
||||
boolean noBatooJPA = hasAnnotation(method, NoBatooJPA.class);
|
||||
boolean noHibernate = hasAnnotation(method, NoHibernate.class);
|
||||
NoEclipseLink noEclipseLink = getAnnotation(method, NoEclipseLink.class);
|
||||
NoOpenJPA noOpenJPA = getAnnotation(method, NoOpenJPA.class);
|
||||
NoBatooJPA noBatooJPA = getAnnotation(method, NoBatooJPA.class);
|
||||
NoHibernate noHibernate = getAnnotation(method, NoHibernate.class);
|
||||
String mode = Mode.mode.get();
|
||||
if (mode == null) {
|
||||
return base;
|
||||
} else if (noEclipseLink && mode.contains("-eclipselink")) {
|
||||
} else if (noEclipseLink != null && applies(noEclipseLink.value()) && mode.contains("-eclipselink")) {
|
||||
return EmptyStatement.DEFAULT;
|
||||
} else if (noOpenJPA && mode.contains("-openjpa")) {
|
||||
} else if (noOpenJPA != null && applies(noOpenJPA.value()) && mode.contains("-openjpa")) {
|
||||
return EmptyStatement.DEFAULT;
|
||||
} else if (noBatooJPA && mode.contains("-batoo")) {
|
||||
} else if (noBatooJPA != null && applies(noBatooJPA.value()) && mode.contains("-batoo")) {
|
||||
return EmptyStatement.DEFAULT;
|
||||
} else if (noHibernate && !mode.contains("-")) {
|
||||
} else if (noHibernate != null && applies(noHibernate.value()) && !mode.contains("-")) {
|
||||
return EmptyStatement.DEFAULT;
|
||||
} else {
|
||||
return base;
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends Annotation> boolean hasAnnotation(FrameworkMethod method, Class<T> clazz) {
|
||||
return method.getMethod().isAnnotationPresent(clazz)
|
||||
|| method.getMethod().getDeclaringClass().isAnnotationPresent(clazz);
|
||||
private boolean applies(Target[] targets) {
|
||||
return targets.length == 0 || ImmutableSet.copyOf(targets).contains(Mode.target.get());
|
||||
}
|
||||
|
||||
private <T extends Annotation> T getAnnotation(FrameworkMethod method, Class<T> clazz) {
|
||||
T rv = method.getMethod().getAnnotation(clazz);
|
||||
return rv != null ? rv : method.getMethod().getDeclaringClass().getAnnotation(clazz);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,4 +7,5 @@ import java.lang.annotation.*;
|
||||
@Inherited
|
||||
public @interface NoBatooJPA {
|
||||
|
||||
com.querydsl.core.Target[] value() default {};
|
||||
}
|
||||
|
||||
@ -7,4 +7,5 @@ import java.lang.annotation.*;
|
||||
@Inherited
|
||||
public @interface NoEclipseLink {
|
||||
|
||||
com.querydsl.core.Target[] value() default {};
|
||||
}
|
||||
|
||||
@ -7,4 +7,5 @@ import java.lang.annotation.*;
|
||||
@Inherited
|
||||
public @interface NoHibernate {
|
||||
|
||||
com.querydsl.core.Target[] value() default {};
|
||||
}
|
||||
|
||||
@ -7,4 +7,5 @@ import java.lang.annotation.*;
|
||||
@Inherited
|
||||
public @interface NoOpenJPA {
|
||||
|
||||
com.querydsl.core.Target[] value() default {};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user