本文整理汇总了Java中org.unitils.util.AnnotationUtils类的典型用法代码示例。如果您正苦于以下问题:Java AnnotationUtils类的具体用法?Java AnnotationUtils怎么用?Java AnnotationUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnnotationUtils类属于org.unitils.util包,在下文中一共展示了AnnotationUtils类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDatabaseName
import org.unitils.util.AnnotationUtils; //导入依赖的package包/类
/**
* @see org.unitils.orm.common.OrmModule#getDatabaseName(java.lang.Object, java.lang.reflect.Method)
*/
@Override
protected void getDatabaseName(Object testObject, Method testMethod) {
JpaEntityManagerFactory dataSource = AnnotationUtils.getMethodOrClassLevelAnnotation(JpaEntityManagerFactory.class, testMethod, testObject.getClass());
if (dataSource != null) {
wrappers.add(getDatabaseModule().getWrapper(dataSource.databaseName()));
}
Set<JpaEntityManagerFactory> lstDataSources = AnnotationUtils.getFieldLevelAnnotations(testObject.getClass(), JpaEntityManagerFactory.class);
if (!lstDataSources.isEmpty()) {
for (JpaEntityManagerFactory testDataSource : lstDataSources) {
wrappers.add(getDatabaseModule().getWrapper(testDataSource.databaseName()));
}
}
}
示例2: getDatabaseName
import org.unitils.util.AnnotationUtils; //导入依赖的package包/类
/**
* @see org.unitils.orm.common.OrmModule#getDatabaseName(java.lang.Object, java.lang.reflect.Method)
*/
@Override
protected void getDatabaseName(Object testObject, Method testMethod) {
//List<String> dataSources = new ArrayList<String>();
HibernateSessionFactory dataSource = AnnotationUtils.getMethodOrClassLevelAnnotation(HibernateSessionFactory.class, testMethod, testObject.getClass());
if (dataSource != null) {
wrappers.add(getDatabaseModule().getWrapper(dataSource.databaseName()));
//dataSources.add(dataSource.databaseName());
}
Set<HibernateSessionFactory> lstDataSources = AnnotationUtils.getFieldLevelAnnotations(testObject.getClass(), HibernateSessionFactory.class);
if (!lstDataSources.isEmpty()) {
for (HibernateSessionFactory testDataSource : lstDataSources) {
//ataSources.add(testDataSource.databaseName());
wrappers.add(getDatabaseModule().getWrapper(testDataSource.databaseName()));
}
}
//return dataSources;
}
示例3: getCustomConfigMethod
import org.unitils.util.AnnotationUtils; //导入依赖的package包/类
/**
* @param testClass The test class, not null
* @return The test class's custom configuration method, if any
*/
protected Method getCustomConfigMethod(Class<?> testClass) {
Set<Method> annotatedMethods = AnnotationUtils.getMethodsAnnotatedWith(testClass, JpaEntityManagerFactory.class);
for (Method annotatedMethod : annotatedMethods) {
if (isCustomConfigMethod(annotatedMethod)) {
return annotatedMethod;
}
}
return null;
}
示例4: createAndInjectDummiesIntoTest
import org.unitils.util.AnnotationUtils; //导入依赖的package包/类
/**
* checks for the {@link Dummy} annotation on the testObject. If so it is created by the DummyObjectUtil. The two aproaches possible are
* stuffed or normal depending on the value in the {@link Dummy} annotation.
*
* @param testObject The tested object not null
*/
protected void createAndInjectDummiesIntoTest(Object testObject) {
Set<Field> fields = AnnotationUtils.getFieldsAnnotatedWith(testObject.getClass(), Dummy.class);
for (Field field : fields) {
Object dummy = createDummy(field.getType());
setFieldValue(testObject, field, dummy);
}
}
示例5: injectIntoAnnotatedFields
import org.unitils.util.AnnotationUtils; //导入依赖的package包/类
public static void injectIntoAnnotatedFields(Object objectToInject, Object target, Class<? extends Annotation> annotation) {
Set<Field> annotatedFields = AnnotationUtils.getFieldsAnnotatedWith(target.getClass(), annotation);
for (Field annotatedField : annotatedFields) {
setFieldValue(target, annotatedField, objectToInject);
}
}