當前位置: 首頁>>代碼示例>>Java>>正文


Java Factory類代碼示例

本文整理匯總了Java中org.testng.annotations.Factory的典型用法代碼示例。如果您正苦於以下問題:Java Factory類的具體用法?Java Factory怎麽用?Java Factory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Factory類屬於org.testng.annotations包,在下文中一共展示了Factory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getFactoryAnnotationMetaData

import org.testng.annotations.Factory; //導入依賴的package包/類
private Tuple2<Class<?>, String> getFactoryAnnotationMetaData() {
    val constructor = testMethod.getConstructorOrMethod().getConstructor();
    val method = testMethod.getConstructorOrMethod().getMethod();

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

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

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

    return Tuple.of(dataProviderClass, dataProviderMethod);
}
 
開發者ID:sskorol,項目名稱:test-data-supplier,代碼行數:18,代碼來源:DataSupplierMetaData.java

示例2: getTestsFromFile

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
public Object[] getTestsFromFile(ITestContext context) {

	if (null != context) {
		includeGroups = Arrays.asList(context.getIncludedGroups());
		excludeGroups = Arrays.asList(context.getExcludedGroups());
	}

	String sanariosloc = MetaDataScanner.getParameter(context, "scenario.file.loc");
	if (StringUtil.isNotBlank(sanariosloc)) {
		ConfigurationManager.getBundle().setProperty("scenario.file.loc", sanariosloc);
	}

	System.out.printf("include groups %s\n exclude groups: %s Scanarios location: %s \n", includeGroups,
			excludeGroups, sanariosloc);
	logger.info("scenario.file.loc"
			+ ConfigurationManager.getBundle().getStringArray("scenario.file.loc", "./scenarios"));
	for (String fileName : ConfigurationManager.getBundle().getStringArray("scenario.file.loc", "./scenarios")) {
		process(fileName);
	}

	logger.info("total test found: " + scenarios.size());
	return scenarios.toArray(new Object[scenarios.size()]);

}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:26,代碼來源:ScenarioFactory.java

示例3: createTestCases

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
public Object[] createTestCases()
{
    LOGGER.debug("Loading file based test cases");
    try {
        Optional<Path> productTestsPath = getConventionsTestsPath(TESTCASES_PATH_PART);
        if (!productTestsPath.isPresent()) {
            LOGGER.info("No convention tests cases");
            return NO_TEST_CASES;
        }

        factories = setupFactories();
        return createTestsForRootPath(productTestsPath.get());
    }
    catch (Exception e) {
        LOGGER.error("Could not create file test", e);
        throw new RuntimeException("Could not create test cases", e);
    }
}
 
開發者ID:prestodb,項目名稱:tempto,代碼行數:20,代碼來源:ConventionBasedTestFactory.java

示例4: tests

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
@Test
public Object[] tests() {
    return new Object[] {
            new BindingInstanceTest(),
            new BindingProvisionRequestTest(),
            new BindingProvisionResponseTest(),
            new HubCredentialsTest(),
            new HubLoginTest(),
            new HubProjectParametersTest(),
            new BindResourceTest(),
            new BindingInstanceServiceTest(),
            new PhoneHomeParametersTest(),
    };
}
 
開發者ID:blackducksoftware,項目名稱:hub-cf,代碼行數:16,代碼來源:ServiceBrokerTestFactory.java

示例5: suite

import org.testng.annotations.Factory; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:35,代碼來源:ScriptTest.java

示例6: runAllTests

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
public Object[] runAllTests() throws IOException, IllegalAccessException, InstantiationException {
    // Any new test file, add it to this list
    // TODO: Can use reflection to automatically add these
    List<Object> tests = new ArrayList<>();

    Set<ClassPath.ClassInfo> allClasses = new TreeSet<>(Comparator.comparing(ClassPath.ClassInfo::getName));

    ClassPath classpath = ClassPath.from(TestCollector.class.getClassLoader());
    allClasses.addAll(classpath.getTopLevelClasses("com.salesforce.dockerfileimageupdate.itest.tests"));
    for (ClassPath.ClassInfo classinfo : allClasses) {
        tests.add(classinfo.load().newInstance());
    }
    return tests.toArray();
}
 
開發者ID:salesforce,項目名稱:dockerfile-image-update,代碼行數:16,代碼來源:TestCollector.java

示例7: generateTestSuite

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
public Object[] generateTestSuite() {
    AbsTLApiTest.init();
    ArrayList<TLApiTest> list = new ArrayList<>();
    for (Class<? extends TLObject> clazz : constructorList) {
        list.add(new TLApiTest(clazz));
    }
    return list.toArray();
}
 
開發者ID:badoualy,項目名稱:kotlogram,代碼行數:10,代碼來源:TLApiTest.java

示例8: generateTestSuite

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
public Object[] generateTestSuite() throws IOException, DecoderException {
    ArrayList<TLApiDumpTest> list = new ArrayList<>();
    for (File file : DumpUtils.loadAll()) {
        list.add(new TLApiDumpTest(file));
    }
    return list.toArray();
}
 
開發者ID:badoualy,項目名稱:kotlogram,代碼行數:9,代碼來源:TLApiDumpTest.java

示例9: contractTests

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
public Object[] contractTests() {
    setup();

    ProviderImpl provider = new ProviderImpl();
    return new Object[] {
        new StagingAreaContract(provider),
        new RemoteStagingAreaContract(provider, instanceProvider)
    };
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:11,代碼來源:ITS3StagingArea.java

示例10: contractTests

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
public Object[] contractTests() {
    return new Object[] {
        new StagingAreaContract(
            (identifier, runtimeContext, executionTrace) -> new MapStagingArea(runtimeContext, executionTrace)
        )
    };
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:9,代碼來源:MapStagingAreaTest.java

示例11: contracts

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
public Object[] contracts() {
    return new Object[] {
        new MutableLocatableContract(MutableAnnotationTypeDeclaration.class),
        new XmlRootElementContract(MutableAnnotationTypeDeclaration.fromClass(MemoryRequirements.class))
    };
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:8,代碼來源:MutableAnnotationTypeDeclarationTest.java

示例12: contracts

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
public Object[] contracts() {
    List<Object> contractsList = new ArrayList<>();
    contractsList.addAll(Arrays.asList(MutableLocatableContract.contractsFor(MutableCompositeModule.class,
        MutableInputModule.class, MutableLoopModule.class, MutableProxyModule.class)));
    contractsList.add(new XmlRootElementContract(
        new MutableInputModule()
            .setRaw(
                new MutableSerializationRoot()
                    .setDeclaration("test.FooSerialization")
                    .setEntries(Arrays.<MutableSerializationNode<?>>asList(
                        new MutableSerializationRoot()
                            .setKey(SimpleName.identifier("a"))
                            .setDeclaration("test.BarSerialization")
                            .setEntries(Collections.<MutableSerializationNode<?>>singletonList(
                                new MutableSerializedString()
                                    .setString("Hello")
                            )),
                        new MutableByteSequence()
                            .setKey(SimpleName.identifier("c"))
                            .setArray("World".getBytes()),
                        new MutableSerializationRoot()
                            .setKey(Index.index(4))
                            .setDeclaration("test.BazSerialization")
                            .setEntries(Collections.<MutableSerializationNode<?>>singletonList(
                                new MutableSerializationRoot()
                                    .setKey(SimpleName.identifier("e"))
                                    .setEntries(Collections.<MutableSerializationNode<?>>singletonList(
                                        new MutableByteSequence()
                                            .setKey(SimpleName.identifier("f"))
                                            .setArray("!".getBytes())
                                    ))
                            ))
                    ))
            )
    ));
    return contractsList.toArray();
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:39,代碼來源:MutableModuleTest.java

示例13: contracts

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
public Object[] contracts() {
    List<Object> contractsList = new ArrayList<>();
    contractsList.addAll(Arrays.asList(MutableLocatableContract.contractsFor(MutableExecutable.class)));
    contractsList.add(new XmlRootElementContract(
        new MutableExecutable()
            .setModule(
                new MutableCompositeModule()
                    .setModules(Arrays.<MutableModule<?>>asList(
                        new MutableInputModule()
                            .setSimpleName("zero")
                            .setOutPortType(new MutableDeclaredType().setDeclaration(Integer.class.getName()))
                            .setRaw(
                                new MutableSerializationRoot()
                                    .setDeclaration(IntegerMarshaler.class.getName())
                                    .setEntries(Collections.<MutableSerializationNode<?>>singletonList(
                                        new MutableSerializedString().setString("0")
                                    ))
                            ),
                        new MutableProxyModule()
                            .setSimpleName("sum")
                            .setDeclaration("test.Sum")
                    ))
                    .setConnections(Collections.<MutableConnection<?>>singletonList(
                        new MutableSiblingConnection()
                            .setFromModule("zero").setFromPort(BareInputModule.OUT_PORT_NAME)
                            .setToModule("sum").setToPort("num1")
                    ))
            )
            .setBundleIdentifiers(Collections.singletonList(
                URI.create("x-maven:xyz.cloudkeeper.examples.bundles:simple:ckbundle.zip:1.0.0-SNAPSHOT")
            ))
    ));
    return contractsList.toArray();
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:36,代碼來源:MutableExecutableTest.java

示例14: getByteSequence

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
public Object[] byteSequences() {
    return new Object[] {
        new ByteSequenceContract("arrayBacked", new ByteSequenceProvider() {
            @Override
            public ByteSequence getByteSequence(byte[] content) {
                return ByteSequences.arrayBacked(content);
            }
        })
    };
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:12,代碼來源:ByteSequencesTest.java

示例15: contractTests

import org.testng.annotations.Factory; //導入依賴的package包/類
@Factory
public Object[] contractTests() throws IOException {
    setup();
    assert tempDir != null && executorService != null;

    ModuleConnectorProvider moduleConnectorProvider = new PrefetchingModuleConnectorProvider(tempDir);
    return new Object[] {
        new ModuleConnectorProviderContract(
            moduleConnectorProvider,
            (identifier, runtimeContext, executionTrace) -> new MapStagingArea(runtimeContext, executionTrace),
            WAIT_DURATION_MILLIS
        )
    };
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:15,代碼來源:PrefetchingModuleConnectorProviderTest.java


注:本文中的org.testng.annotations.Factory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。