本文整理匯總了Java中org.junit.jupiter.api.Assertions.assertNull方法的典型用法代碼示例。如果您正苦於以下問題:Java Assertions.assertNull方法的具體用法?Java Assertions.assertNull怎麽用?Java Assertions.assertNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.junit.jupiter.api.Assertions
的用法示例。
在下文中一共展示了Assertions.assertNull方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testClassMethodInvoke
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testClassMethodInvoke() throws Exception {
Class<?> testClass = TestClassOne.class;
ClassWrapper<?> cw = Reflect.wrapClass(testClass);
Reflect.construct(cw);
/* Instance method */
String a = cw.invokeMethod("a", String.class);
Assertions.assertEquals("a", a);
/* Static method */
String b = cw.invokeMethod("b", String.class);
Assertions.assertEquals("b", b);
/* Void method */
Assertions.assertNull(cw.invokeMethod("c", Void.class));
Assertions.assertNull(cw.invokeMethod("c", void.class));
}
示例2: checkSupplier
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
private static <T> void checkSupplier(int readFailureCountTrigger, MockConnection connection, Address address, Supplier<T> supplier, Object ... values) throws Exception {
// verify that a read failure doesn't kill the consumer
// it logs (not verified) but returns null (as designed) and keeps working for the subsequent reads
connection.setReadException(readFailureCountTrigger, "This is a mock read exception");
int readCount = 0;
for (Object value : values) {
connection.setDataValue(address, value);
T readData = supplier.get();
// System.out.println("checkSupplier"+(readFailureCountTrigger > 0 ? "NEG" : "")+": value:"+value+" readData:"+readData);
if (readFailureCountTrigger <= 0)
Assertions.assertEquals(value, readData);
else {
if (++readCount != readFailureCountTrigger)
Assertions.assertEquals(value, readData);
else
Assertions.assertNull(readData);
}
}
}
示例3: testEventFired
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testEventFired() {
DummyObserver.MESSAGES.clear();
// Fire an event
weld.event().select(Foo.class).fire(new Foo());
Assertions.assertEquals(1, DummyObserver.MESSAGES.size());
Assertions.assertNull(DummyObserver.MESSAGES.get(0).getBar());
}
示例4: testClassFinding
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testClassFinding() throws Exception {
Class<?> testClass = TestClassOne.class;
String className = testClass.getName();
ClassWrapper<?> cw = Reflect.getClass(className).orElse(null);
Assertions.assertNotNull(cw, "Class wrapper shouldn't be null!");
Assertions.assertEquals(testClass, cw.getWrappedClass(), "Classes weren't equal!");
Assertions.assertNull(cw.getClassInstance(), "Class instance shouldn't be set!");
}
示例5: testClassConstructingWithInvalidArgs
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testClassConstructingWithInvalidArgs() throws Exception {
Class<TestClassTwo> testClass = TestClassTwo.class;
ClassWrapper<TestClassTwo> cw = Reflect.wrapClass(testClass);
NoSuchMethodException e = Assertions.assertThrows(NoSuchMethodException.class, ()->{
Reflect.construct(cw, of(1));
});
Assertions.assertNull(cw.getClassInstance(), "Class instance should be null!");
}
示例6: getExistingDriverTest
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
/**
* Tries to get the mock plc driver which is part of this testsuite.
*/
@Test
@Tag("fast")
void getExistingDriverTest() throws PlcException {
MockConnection mockConnection = (MockConnection) new PlcDriverManager().getConnection("mock://some-cool-url");
Assertions.assertNull(mockConnection.getAuthentication());
Assertions.assertTrue(mockConnection.isConnected());
Assertions.assertTrue(!mockConnection.isClosed());
}
示例7: getConditionOrNull
import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
@SuppressWarnings("deprecation")
void getConditionOrNull() {
Assertions.assertNull(filteringJooqImpl1.getConditionOrNull(emptyMap, "any", s -> DSL.trueCondition()));
Assertions.assertNull(filteringJooqImpl1.getConditionOrNull(notEmptyMap, "any", s -> DSL.trueCondition()));
Assertions.assertNotNull(filteringJooqImpl1.getConditionOrNull(notEmptyMap, "key1", s -> DSL.trueCondition()));
Assertions.assertNull(filteringJooqImpl1.getConditionOrNull(mapWithNullValues, "key1", s -> DSL.trueCondition()));
Assertions.assertNull(filteringJooqImpl1.getConditionOrNull(mapWithEmptyValues, "key1", s -> DSL.trueCondition()));
Assertions.assertNull(filteringJooqImpl1.getConditionOrNull(mapWithSpaceValues, "key1", s -> DSL.trueCondition()));
}