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


Java SuppressStaticInitializationFor类代码示例

本文整理汇总了Java中org.powermock.core.classloader.annotations.SuppressStaticInitializationFor的典型用法代码示例。如果您正苦于以下问题:Java SuppressStaticInitializationFor类的具体用法?Java SuppressStaticInitializationFor怎么用?Java SuppressStaticInitializationFor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SuppressStaticInitializationFor类属于org.powermock.core.classloader.annotations包,在下文中一共展示了SuppressStaticInitializationFor类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testConvertDocumentToByteArray

import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; //导入依赖的package包/类
/**
 * Test convert document to byte array.
 * 
 * @throws Exception
 *             If something unexpected goes wrong.
 */
@Test
@PrepareForTest
@SuppressStaticInitializationFor
public void testConvertDocumentToByteArray() throws Exception {
	// Create a fake document.
	Document document = DocumentHelper.createDocument();
	Element root = document.addElement("ListExecutionContexts");
	root.addAttribute("id", "2");
	replayAll();
	// Perform the test
	final byte[] array = tested.convertDocumentToByteArray(document);
	verifyAll();
	assertNotNull(array);
	assertEquals(70, array.length);
}
 
开发者ID:powermock,项目名称:powermock-examples-maven,代码行数:22,代码来源:AbstractXMLRequestCreatorBaseTest.java

示例2: getClassesToModify

import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String[] getClassesToModify(AnnotatedElement element) {
	List<String> all = new LinkedList<String>();

	final SuppressStaticInitializationFor suppressAnnotation = element.getAnnotation(SuppressStaticInitializationFor.class);

	if (suppressAnnotation == null) {
		return null;
	} else {
		final String[] value = suppressAnnotation.value();
		for (String classToSuppress : value) {
			if (!"".equals(classToSuppress)) {
				all.add(classToSuppress);
				MockRepository.addSuppressStaticInitializer(classToSuppress);
			}
		}
	}

	return all.toArray(new String[0]);
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:24,代码来源:StaticConstructorSuppressExtractorImpl.java

示例3: anyMethodInClassHasPowerMockAnnotation

import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; //导入依赖的package包/类
private boolean anyMethodInClassHasPowerMockAnnotation(Class<?> testClass) {
    final Method[] methods = testClass.getMethods();
    for (Method method : methods) {
        if(method.isAnnotationPresent(PrepareForTest.class) || method.isAnnotationPresent(SuppressStaticInitializationFor.class)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:10,代码来源:PowerMockObjectFactory.java

示例4: testMockingWithChunking

import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; //导入依赖的package包/类
@SuppressStaticInitializationFor("samples.staticinitializer.SimpleStaticInitializerExample")
@Test
public void testMockingWithChunking() throws Exception {
	final String argument = "hello";
	assertNull(tested.getString());
	assertNull(tested.getConcatenatedString(argument));

	verify(tested).getConcatenatedString(argument);
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:10,代码来源:ChunkingAndStaticInitializerRemovalTest.java

示例5: isClassAnnotatedWithPowerMockAnnotation

import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; //导入依赖的package包/类
private boolean isClassAnnotatedWithPowerMockAnnotation(Class<?> testClass) {
    return testClass.isAnnotationPresent(PrepareForTest.class) || testClass.isAnnotationPresent(SuppressStaticInitializationFor.class);
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:4,代码来源:PowerMockObjectFactory.java

示例6: assertNativeCodeInvocationWorks

import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; //导入依赖的package包/类
@Test
@SuppressStaticInitializationFor("samples.staticinitializer.EvilStaticInitializerExample")
public void assertNativeCodeInvocationWorks() throws Exception {
	EvilStaticInitializerExample tested = new EvilStaticInitializerExample();
	assertThat(tested.doSomeNativeStuffUsingTheLoadedSystemLibrary(), instanceOf(String.class));
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:7,代码来源:EvilStaticInitializerExampleTest.java


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