当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationUtils类代码示例

本文整理汇总了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()));
        }
    } 
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:19,代码来源:JpaModule.java

示例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;
    
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:24,代码来源:HibernateModule.java

示例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;
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:14,代码来源:AnnotationConfigLoader.java

示例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);
    }
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:14,代码来源:MockModule.java

示例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);
    }
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:7,代码来源:InjectionUtils.java


注:本文中的org.unitils.util.AnnotationUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。