Java Examples for org.testng.IObjectFactory
The following java examples will help you to understand the usage of org.testng.IObjectFactory. These source code samples are taken from different open source projects.
Example 1
| Project: TestNG-master File: ClassHelper.java View source code |
/**
* Create an instance for the given class.
*/
public static Object createInstance(Class<?> declaringClass, Map<Class<?>, IClass> classes, XmlTest xmlTest, IAnnotationFinder finder, ITestObjectFactory objectFactory) {
if (objectFactory instanceof IObjectFactory) {
return createInstance1(declaringClass, classes, xmlTest, finder, (IObjectFactory) objectFactory);
} else if (objectFactory instanceof IObjectFactory2) {
return createInstance2(declaringClass, (IObjectFactory2) objectFactory);
} else {
throw new AssertionError("Unknown object factory type:" + objectFactory);
}
}Example 2
| Project: powermock-master File: PowerMockTestCase.java View source code |
/**
* @return The PowerMock object factory.
*/
@ObjectFactory
public IObjectFactory create(ITestContext context) {
try {
final Class<?> powerMockObjectFactory = Class.forName("org.powermock.modules.testng.PowerMockObjectFactory");
return (IObjectFactory) powerMockObjectFactory.newInstance();
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Missing org.powermock.modules.testng.PowerMockObjectFactory in classpath.");
} catch (Exception e) {
throw new RuntimeException("PowerMock internal error", e);
}
}Example 3
| Project: Prendamigo-master File: TestNGContentHandler.java View source code |
/**
* Parse <suite>
*/
private void xmlSuite(boolean start, Attributes attributes) {
if (start) {
String name = attributes.getValue("name");
m_currentSuite = new XmlSuite();
m_currentSuite.setFileName(m_fileName);
m_currentSuite.setName(name);
m_currentSuiteParameters = Maps.newHashMap();
String verbose = attributes.getValue("verbose");
if (null != verbose) {
m_currentSuite.setVerbose(new Integer(verbose));
}
String jUnit = attributes.getValue("junit");
if (null != jUnit) {
m_currentSuite.setJUnit(Boolean.valueOf(jUnit).booleanValue());
}
String parallel = attributes.getValue("parallel");
if (null != parallel) {
if (XmlSuite.PARALLEL_METHODS.equals(parallel) || XmlSuite.PARALLEL_TESTS.equals(parallel) || XmlSuite.PARALLEL_NONE.equals(parallel) || XmlSuite.PARALLEL_CLASSES.equals(parallel) || "true".equals(parallel) || "false".equals(parallel)) {
m_currentSuite.setParallel(parallel);
} else {
Utils.log("Parser", 1, "[WARN] Unknown value of attribute 'parallel' at suite level: '" + parallel + "'.");
}
}
String configFailurePolicy = attributes.getValue("configfailurepolicy");
if (null != configFailurePolicy) {
if (XmlSuite.SKIP.equals(configFailurePolicy) || XmlSuite.CONTINUE.equals(configFailurePolicy)) {
m_currentSuite.setConfigFailurePolicy(configFailurePolicy);
}
}
String skip = attributes.getValue("skipfailedinvocationcounts");
if (skip != null) {
m_currentSuite.setSkipFailedInvocationCounts(Boolean.valueOf(skip));
}
String threadCount = attributes.getValue("thread-count");
if (null != threadCount) {
m_currentSuite.setThreadCount(Integer.parseInt(threadCount));
}
String dataProviderThreadCount = attributes.getValue("data-provider-thread-count");
if (null != dataProviderThreadCount) {
m_currentSuite.setDataProviderThreadCount(Integer.parseInt(dataProviderThreadCount));
}
String annotations = attributes.getValue("annotations");
if (null != annotations) {
m_currentSuite.setAnnotations(annotations);
} else if (VersionInfo.IS_JDK14) {
m_currentSuite.setAnnotations(XmlSuite.JAVADOC_ANNOTATION_TYPE);
}
String timeOut = attributes.getValue("time-out");
if (null != timeOut) {
m_currentSuite.setTimeOut(timeOut);
}
String objectFactory = attributes.getValue("object-factory");
if (null != objectFactory) {
try {
m_currentSuite.setObjectFactory((IObjectFactory) Class.forName(objectFactory).newInstance());
} catch (Exception e) {
Utils.log("Parser", 1, "[ERROR] Unable to create custom object factory '" + objectFactory + "' :" + e);
}
}
} else {
m_currentSuite.setParameters(m_currentSuiteParameters);
m_suites.add(m_currentSuite);
m_currentSuiteParameters = null;
}
}Example 4
| Project: activejpa-master File: ActiveJpaTestNGSpringContextTests.java View source code |
@ObjectFactory
public IObjectFactory getObjectFactory(ITestContext context) throws Exception {
return new DomainClassObjectFactory(Arrays.asList("org.testng.", "org.xml"));
}Example 5
| Project: mockito-cookbook-master File: BadlyDesignedNewPersonGeneratorPowerMockTestNgTest.java View source code |
@ObjectFactory
public IObjectFactory getObjectFactory() {
return new PowerMockObjectFactory();
}Example 6
| Project: eugene-master File: AIDsTest.java View source code |
@ObjectFactory
public IObjectFactory getObjectFactory() {
return new PowerMockObjectFactory();
}Example 7
| Project: minnal-master File: BaseJPAResourceTest.java View source code |
/**
* Note: Kind of hack to ensure that ActiveJPAAgent instruments all the models before they are loaded.
*
* @param context
* @return
* @throws Exception
*/
@ObjectFactory
public IObjectFactory getObjectFactory(ITestContext context) throws Exception {
ActiveJpaAgentLoader.instance().loadAgent();
return new ObjectFactoryImpl();
}Example 8
| Project: shifu-master File: PigExecutorTest.java View source code |
@ObjectFactory
public IObjectFactory setObjectFactor() {
return new PowerMockObjectFactory();
}Example 9
| Project: rhq-master File: RhqDownloadsScriptSourceProviderTest.java View source code |
@ObjectFactory
public IObjectFactory getObjectFactory() {
return new PowerMockObjectFactory();
}Example 10
| Project: PayPal-Java-SDK-master File: ValidateCertTest.java View source code |
@ObjectFactory
public IObjectFactory getObjectFactory() {
return new org.powermock.modules.testng.PowerMockObjectFactory();
}Example 11
| Project: sqoop-on-spark-master File: TestKiteExecutor.java View source code |
@ObjectFactory
public IObjectFactory getObjectFactory() {
return new org.powermock.modules.testng.PowerMockObjectFactory();
}Example 12
| Project: Illarion-Java-master File: TranslateTaskTest.java View source code |
@ObjectFactory
public IObjectFactory getObjectFactory() {
return new PowerMockObjectFactory();
}Example 13
| Project: lens-master File: TestRewriting.java View source code |
/**
* We need a special {@link IObjectFactory}.
*
* @return {@link PowerMockObjectFactory}.
*/
@ObjectFactory
public IObjectFactory getObjectFactory() {
return new PowerMockObjectFactory();
}