本文整理汇总了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);
}
示例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]);
}
示例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;
}
示例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);
}
示例5: isClassAnnotatedWithPowerMockAnnotation
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; //导入依赖的package包/类
private boolean isClassAnnotatedWithPowerMockAnnotation(Class<?> testClass) {
return testClass.isAnnotationPresent(PrepareForTest.class) || testClass.isAnnotationPresent(SuppressStaticInitializationFor.class);
}
示例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));
}