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


Java Assertions.assertNull方法代碼示例

本文整理匯總了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));
}
 
開發者ID:mikroskeem,項目名稱:Shuriken,代碼行數:19,代碼來源:MethodReflectionTester.java

示例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);
    }
  }
}
 
開發者ID:apache,項目名稱:incubator-plc4x,代碼行數:20,代碼來源:PlcConnectionAdapterTest.java

示例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());
}
 
開發者ID:weld,項目名稱:weld-junit,代碼行數:9,代碼來源:FireEventTest.java

示例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!");
}
 
開發者ID:mikroskeem,項目名稱:Shuriken,代碼行數:11,代碼來源:ClassWrapperTester.java

示例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!");
}
 
開發者ID:mikroskeem,項目名稱:Shuriken,代碼行數:10,代碼來源:ClassWrapperTester.java

示例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());
}
 
開發者ID:apache,項目名稱:incubator-plc4x,代碼行數:12,代碼來源:PlcDriverManagerTest.java

示例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()));
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:11,代碼來源:FilteringJooqTest.java


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