org.testng.annotations.Factory Java Examples

The following examples show how to use org.testng.annotations.Factory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReflectionUtils.java    From test-data-supplier with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private static Tuple2<Class<?>, String> getFactoryAnnotationMetaData(final ITestNGMethod testMethod) {
    var constructor = testMethod.getConstructorOrMethod().getConstructor();
    var method = testMethod.getConstructorOrMethod().getMethod();

    var factoryAnnotation = nonNull(method)
            ? ofNullable(method.getDeclaredAnnotation(Factory.class))
            : ofNullable(constructor.getDeclaredAnnotation(Factory.class));

    var dataProviderClass = factoryAnnotation
            .map(fa -> (Class) fa.dataProviderClass())
            .filter(cl -> cl != Object.class)
            .orElseGet(() -> testMethod.getConstructorOrMethod().getDeclaringClass());

    var dataProviderMethod = factoryAnnotation.map(Factory::dataProvider).orElse("");

    return Tuple.of(dataProviderClass, dataProviderMethod);
}
 
Example #2
Source File: ScriptTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a test factory for the set of .js source tests.
 *
 * @return a Object[] of test objects.
 * @throws Exception upon failure
 */
@SuppressWarnings("static-method")
@Factory
public Object[] suite() throws Exception {
    Locale.setDefault(new Locale(""));

    final List<ITest> tests = new ArrayList<>();
    final Set<String> orphans = new TreeSet<>();

    final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
        @Override
        public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
            return new ScriptRunnable(framework, testFile, engineOptions, testOptions,  scriptArguments);
        }

        @Override
        public void log(final String msg) {
            org.testng.Reporter.log(msg, true);
        }
    };

    TestFinder.findAllTests(tests, orphans, testFactory);

    if (System.getProperty(TEST_JS_INCLUDES) == null) {
        tests.add(new OrphanTestFinder(orphans));
    }

    return tests.toArray();
}
 
Example #3
Source File: ScriptTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a test factory for the set of .js source tests.
 *
 * @return a Object[] of test objects.
 * @throws Exception upon failure
 */
@SuppressWarnings("static-method")
@Factory
public Object[] suite() throws Exception {
    Locale.setDefault(new Locale(""));

    final List<ITest> tests = new ArrayList<>();
    final Set<String> orphans = new TreeSet<>();

    final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
        @Override
        public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
            return new ScriptRunnable(framework, testFile, engineOptions, testOptions,  scriptArguments);
        }

        @Override
        public void log(final String msg) {
            org.testng.Reporter.log(msg, true);
        }
    };

    TestFinder.findAllTests(tests, orphans, testFactory);

    if (System.getProperty(TEST_JS_INCLUDES) == null) {
        tests.add(new OrphanTestFinder(orphans));
    }

    return tests.toArray();
}
 
Example #4
Source File: ScriptTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a test factory for the set of .js source tests.
 *
 * @return a Object[] of test objects.
 * @throws Exception upon failure
 */
@SuppressWarnings("static-method")
@Factory
public Object[] suite() throws Exception {
    Locale.setDefault(new Locale(""));

    final List<ITest> tests = new ArrayList<>();
    final Set<String> orphans = new TreeSet<>();

    final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
        @Override
        public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
            return new ScriptRunnable(framework, testFile, engineOptions, testOptions,  scriptArguments);
        }

        @Override
        public void log(final String msg) {
            org.testng.Reporter.log(msg, true);
        }
    };

    TestFinder.findAllTests(tests, orphans, testFactory);

    if (System.getProperty(TEST_JS_INCLUDES) == null) {
        tests.add(new OrphanTestFinder(orphans));
    }

    return tests.toArray();
}
 
Example #5
Source File: HandlerPublisherVerificationTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Factory(dataProvider = "data")
public HandlerPublisherVerificationTest(int batchSize, int publishInitial, boolean scheduled) {
    super(new TestEnvironment(200));
    this.batchSize = batchSize;
    this.publishInitial = publishInitial;
    this.scheduled = scheduled;
}
 
Example #6
Source File: ScriptTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a test factory for the set of .js source tests.
 *
 * @return a Object[] of test objects.
 * @throws Exception upon failure
 */
@SuppressWarnings("static-method")
@Factory
public Object[] suite() throws Exception {
    Locale.setDefault(new Locale(""));

    final List<ITest> tests = new ArrayList<>();
    final Set<String> orphans = new TreeSet<>();

    final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
        @Override
        public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
            return new ScriptRunnable(framework, testFile, engineOptions, testOptions,  scriptArguments);
        }

        @Override
        public void log(final String msg) {
            org.testng.Reporter.log(msg, true);
        }
    };

    TestFinder.findAllTests(tests, orphans, testFactory);

    if (System.getProperty(TEST_JS_INCLUDES) == null) {
        tests.add(new OrphanTestFinder(orphans));
    }

    return tests.toArray();
}
 
Example #7
Source File: OrderbyDocumentQueryTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirect")
public OrderbyDocumentQueryTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #8
Source File: TriggerCrudTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirect")
public TriggerCrudTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #9
Source File: InternalFactoryTests.java    From test-data-supplier with Apache License 2.0 4 votes vote down vote up
@Factory(dataProvider = "getConstructorData", dataProviderClass = InternalFactoryTests.class)
public InternalFactoryTests(final int index) {
    // not implemented
}
 
Example #10
Source File: ExternalFactorySourceTests.java    From test-data-supplier with Apache License 2.0 4 votes vote down vote up
@Factory(dataProvider = "sourceData", dataProviderClass = ExternalFactorySourceTests.class)
public Object[] createTestClassInstance(final String data) {
    return new Object[]{new ExternalFactoryTestTarget(data)};
}
 
Example #11
Source File: StoredProcedureCrudTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirect")
public StoredProcedureCrudTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #12
Source File: TokenResolverTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuilders")
public TokenResolverTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #13
Source File: ReadFeedUdfsTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirect")
public ReadFeedUdfsTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #14
Source File: VeryLargeDocumentQueryTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "simpleClientBuildersWithDirect")
public VeryLargeDocumentQueryTest(Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #15
Source File: StoredProcedureUpsertReplaceTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirect")
public StoredProcedureUpsertReplaceTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #16
Source File: ReadFeedDocumentsTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirect")
public ReadFeedDocumentsTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #17
Source File: SinglePartitionDocumentQueryTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirect")
public SinglePartitionDocumentQueryTest(Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #18
Source File: AggregateQueryTests.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirect")
public AggregateQueryTests(Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #19
Source File: SessionTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirectSession")
public SessionTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
    this.subscriberValidationTimeout = TIMEOUT;
}
 
Example #20
Source File: UserCrudTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuilders")
public UserCrudTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #21
Source File: QueryValidationTests.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirectSession")
public QueryValidationTests(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
    random = new Random();
}
 
Example #22
Source File: ReadFeedCollectionsTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuilders")
public ReadFeedCollectionsTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #23
Source File: UserQueryTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuilders")
public UserQueryTest(Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #24
Source File: ReadFeedStoredProceduresTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirect")
public ReadFeedStoredProceduresTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #25
Source File: CollectionCrudTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirect")
public CollectionCrudTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
    this.subscriberValidationTimeout = TIMEOUT;
}
 
Example #26
Source File: CollectionQueryTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuilders")
public CollectionQueryTest(Builder clientBuilder) {
    super(clientBuilder);
    this.subscriberValidationTimeout = TIMEOUT;
}
 
Example #27
Source File: ReadFeedOffersTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuilders")
public ReadFeedOffersTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #28
Source File: PermissionQueryTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuilders")
public PermissionQueryTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #29
Source File: DocumentClientResourceLeakTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "simpleClientBuildersWithDirect")
public DocumentClientResourceLeakTest(Builder clientBuilder) {
    super(clientBuilder);
}
 
Example #30
Source File: SinglePartitionReadFeedDocumentsTest.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
@Factory(dataProvider = "clientBuildersWithDirect")
public SinglePartitionReadFeedDocumentsTest(AsyncDocumentClient.Builder clientBuilder) {
    super(clientBuilder);
}