Search in sources :

Example 1 with MethodParameterScanner

use of org.reflections.scanners.MethodParameterScanner in project Smack by igniterealtime.

the class SmackIntegrationTestFramework method run.

public synchronized TestRunResult run() throws KeyManagementException, NoSuchAlgorithmException, SmackException, IOException, XMPPException, InterruptedException {
    testRunResult = new TestRunResult();
    LOGGER.info("SmackIntegrationTestFramework [" + testRunResult.testRunId + ']' + ": Starting");
    if (config.debug) {
        // JUL Debugger will not print any information until configured to print log messages of
        // level FINE
        // TODO configure JUL for log?
        SmackConfiguration.addDisabledSmackClass("org.jivesoftware.smack.debugger.JulDebugger");
        SmackConfiguration.DEBUG = true;
    }
    if (config.replyTimeout > 0) {
        SmackConfiguration.setDefaultReplyTimeout(config.replyTimeout);
    }
    if (config.securityMode != SecurityMode.required) {
        AccountManager.sensitiveOperationOverInsecureConnectionDefault(true);
    }
    // TODO print effective configuration
    String[] testPackages;
    if (config.testPackages == null) {
        testPackages = new String[] { "org.jivesoftware.smackx", "org.jivesoftware.smack" };
    } else {
        testPackages = config.testPackages.toArray(new String[config.testPackages.size()]);
    }
    Reflections reflections = new Reflections(testPackages, new SubTypesScanner(), new TypeAnnotationsScanner(), new MethodAnnotationsScanner(), new MethodParameterScanner());
    Set<Class<? extends AbstractSmackIntegrationTest>> inttestClasses = reflections.getSubTypesOf(AbstractSmackIntegrationTest.class);
    Set<Class<? extends AbstractSmackLowLevelIntegrationTest>> lowLevelInttestClasses = reflections.getSubTypesOf(AbstractSmackLowLevelIntegrationTest.class);
    Set<Class<? extends AbstractSmackIntTest>> classes = new HashSet<>(inttestClasses.size() + lowLevelInttestClasses.size());
    classes.addAll(inttestClasses);
    classes.addAll(lowLevelInttestClasses);
    if (classes.isEmpty()) {
        throw new IllegalStateException("No test classes found");
    }
    LOGGER.info("SmackIntegrationTestFramework [" + testRunResult.testRunId + "]: Finished scanning for tests, preparing environment");
    environment = prepareEnvironment();
    try {
        runTests(classes);
    } finally {
        // Ensure that the accounts are deleted and disconnected before we continue
        disconnectAndMaybeDelete(environment.conOne);
        disconnectAndMaybeDelete(environment.conTwo);
        disconnectAndMaybeDelete(environment.conThree);
    }
    return testRunResult;
}
Also used : MethodParameterScanner(org.reflections.scanners.MethodParameterScanner) MethodAnnotationsScanner(org.reflections.scanners.MethodAnnotationsScanner) SubTypesScanner(org.reflections.scanners.SubTypesScanner) TypeAnnotationsScanner(org.reflections.scanners.TypeAnnotationsScanner) BeforeClass(org.junit.BeforeClass) AfterClass(org.junit.AfterClass) Reflections(org.reflections.Reflections) HashSet(java.util.HashSet)

Example 2 with MethodParameterScanner

use of org.reflections.scanners.MethodParameterScanner in project disconf by knightliao.

the class ReflectionScanStatic method getReflection.

/**
     * 通过扫描,获取反射对象
     */
private Reflections getReflection(List<String> packNameList) {
    //
    // filter
    //
    FilterBuilder filterBuilder = new FilterBuilder().includePackage(Constants.DISCONF_PACK_NAME);
    for (String packName : packNameList) {
        filterBuilder = filterBuilder.includePackage(packName);
    }
    Predicate<String> filter = filterBuilder;
    //
    // urls
    //
    Collection<URL> urlTotals = new ArrayList<URL>();
    for (String packName : packNameList) {
        Set<URL> urls = ClasspathHelper.forPackage(packName);
        urlTotals.addAll(urls);
    }
    //
    Reflections reflections = new Reflections(new ConfigurationBuilder().filterInputsBy(filter).setScanners(new SubTypesScanner().filterResultsBy(filter), new TypeAnnotationsScanner().filterResultsBy(filter), new FieldAnnotationsScanner().filterResultsBy(filter), new MethodAnnotationsScanner().filterResultsBy(filter), new MethodParameterScanner()).setUrls(urlTotals));
    return reflections;
}
Also used : ConfigurationBuilder(org.reflections.util.ConfigurationBuilder) ArrayList(java.util.ArrayList) URL(java.net.URL) MethodParameterScanner(org.reflections.scanners.MethodParameterScanner) FieldAnnotationsScanner(org.reflections.scanners.FieldAnnotationsScanner) MethodAnnotationsScanner(org.reflections.scanners.MethodAnnotationsScanner) FilterBuilder(org.reflections.util.FilterBuilder) SubTypesScanner(org.reflections.scanners.SubTypesScanner) TypeAnnotationsScanner(org.reflections.scanners.TypeAnnotationsScanner) Reflections(org.reflections.Reflections)

Example 3 with MethodParameterScanner

use of org.reflections.scanners.MethodParameterScanner in project ocvn by devgateway.

the class ReflectionsConfiguration method reflections.

@Bean
public Reflections reflections() {
    logger.debug("Starting reflections scanners...");
    Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.devgateway.ocds.persistence.mongo")).setScanners(new SubTypesScanner(), new FieldAnnotationsScanner(), new MethodParameterScanner()));
    logger.debug("Configured reflections bean.");
    return reflections;
}
Also used : MethodParameterScanner(org.reflections.scanners.MethodParameterScanner) ConfigurationBuilder(org.reflections.util.ConfigurationBuilder) FieldAnnotationsScanner(org.reflections.scanners.FieldAnnotationsScanner) SubTypesScanner(org.reflections.scanners.SubTypesScanner) Reflections(org.reflections.Reflections) Bean(org.springframework.context.annotation.Bean)

Aggregations

Reflections (org.reflections.Reflections)3 MethodParameterScanner (org.reflections.scanners.MethodParameterScanner)3 SubTypesScanner (org.reflections.scanners.SubTypesScanner)3 FieldAnnotationsScanner (org.reflections.scanners.FieldAnnotationsScanner)2 MethodAnnotationsScanner (org.reflections.scanners.MethodAnnotationsScanner)2 TypeAnnotationsScanner (org.reflections.scanners.TypeAnnotationsScanner)2 ConfigurationBuilder (org.reflections.util.ConfigurationBuilder)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 AfterClass (org.junit.AfterClass)1 BeforeClass (org.junit.BeforeClass)1 FilterBuilder (org.reflections.util.FilterBuilder)1 Bean (org.springframework.context.annotation.Bean)1