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


Java Assert.assertNull方法代码示例

本文整理汇总了Java中junit.framework.Assert.assertNull方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.assertNull方法的具体用法?Java Assert.assertNull怎么用?Java Assert.assertNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在junit.framework.Assert的用法示例。


在下文中一共展示了Assert.assertNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testOverride_Application

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testOverride_Application(){
    AbsentConfigurator configurator = new AbsentConfigurator(URL.valueOf("override://[email protected]/com.foo.BarService?timeout=200"));
    
    URL url = configurator.configure(URL.valueOf("dubbo://10.20.153.10:20880/com.foo.BarService?application=foo"));
    Assert.assertEquals("200", url.getParameter("timeout"));
    
    url = configurator.configure(URL.valueOf("dubbo://10.20.153.10:20880/com.foo.BarService?application=foo&timeout=1000"));
    Assert.assertEquals("1000", url.getParameter("timeout"));
    
    url = configurator.configure(URL.valueOf("dubbo://10.20.153.11:20880/com.foo.BarService?application=bar"));
    Assert.assertNull(url.getParameter("timeout"));
    
    url = configurator.configure(URL.valueOf("dubbo://10.20.153.11:20880/com.foo.BarService?application=bar&timeout=1000"));
    Assert.assertEquals("1000", url.getParameter("timeout"));
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:17,代码来源:AbsentConfiguratorTest.java

示例2: testOverride_Host

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testOverride_Host(){
    AbsentConfigurator configurator = new AbsentConfigurator(URL.valueOf("override://10.20.153.10/com.foo.BarService?timeout=200"));
    
    URL url = configurator.configure(URL.valueOf("dubbo://10.20.153.10:20880/com.foo.BarService?application=foo"));
    Assert.assertEquals("200", url.getParameter("timeout"));
    
    url = configurator.configure(URL.valueOf("dubbo://10.20.153.10:20880/com.foo.BarService?application=foo&timeout=1000"));
    Assert.assertEquals("1000", url.getParameter("timeout"));
    
    url = configurator.configure(URL.valueOf("dubbo://10.20.153.11:20880/com.foo.BarService?application=bar"));
    Assert.assertNull(url.getParameter("timeout"));
    
    url = configurator.configure(URL.valueOf("dubbo://10.20.153.11:20880/com.foo.BarService?application=bar&timeout=1000"));
    Assert.assertEquals("1000", url.getParameter("timeout"));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:17,代码来源:AbsentConfiguratorTest.java

示例3: putGetRemoveViewState

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void putGetRemoveViewState(){
  Activity activity = Mockito.mock(Activity.class);
  Application application = Mockito.mock(Application.class);
  Mockito.when(activity.getApplication()).thenReturn(application);

  Object viewState = new Object();

  String viewId ="123";
  Assert.assertNull(PresenterManager.getViewState(activity, viewId));

  PresenterManager.putViewState(activity, viewId, viewState);
  Assert.assertTrue(viewState == PresenterManager.getViewState(activity, viewId));

  PresenterManager.remove(activity, viewId);
  Assert.assertNull(PresenterManager.getPresenter(activity, viewId));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:PresenterManagerTest.java

示例4: testUnprocessedItemReturned_BatchWriteItemCallNotExceedMaxRetry

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testUnprocessedItemReturned_BatchWriteItemCallNotExceedMaxRetry() {
    when(ddbMock.batchWriteItem(any(BatchWriteItemRequest.class)))
        .thenReturn(BatchWriteItemResponse.builder().unprocessedItems(unprocessedItems).build());

    List<FailedBatch> failedBatches = mapper.batchSave(new Item("foo"));
    verify(ddbMock, times(MAX_RETRY + 1)).batchWriteItem(any(BatchWriteItemRequest.class));

    Assert.assertEquals(1, failedBatches.size());
    FailedBatch failedBatch = failedBatches.get(0);

    Assert.assertEquals(
            "Failed batch should contain the same UnprocessedItems returned in the BatchWriteItem response.",
            unprocessedItems,
            failedBatch.getUnprocessedItems());
    Assert.assertNull(
            "No exception should be set if the batch failed after max retry",
            failedBatch.getException());
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:20,代码来源:BatchWriteRetryStrategyTest.java

示例5: assertEquals

import junit.framework.Assert; //导入方法依赖的package包/类
public void assertEquals(FakeExtractorOutput expected) {
  Assert.assertEquals(expected.numberOfTracks, numberOfTracks);
  Assert.assertEquals(expected.tracksEnded, tracksEnded);
  if (expected.seekMap == null) {
    Assert.assertNull(seekMap);
  } else {
    // TODO: Bulk up this check if possible.
    Assert.assertNotNull(seekMap);
    Assert.assertEquals(expected.seekMap.getClass(), seekMap.getClass());
    Assert.assertEquals(expected.seekMap.isSeekable(), seekMap.isSeekable());
    Assert.assertEquals(expected.seekMap.getPosition(0), seekMap.getPosition(0));
  }
  for (int i = 0; i < numberOfTracks; i++) {
    Assert.assertEquals(expected.trackOutputs.keyAt(i), trackOutputs.keyAt(i));
    trackOutputs.valueAt(i).assertEquals(expected.trackOutputs.valueAt(i));
  }
}
 
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:18,代码来源:FakeExtractorOutput.java

示例6: testOverride_Application

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testOverride_Application(){
    OverrideConfigurator configurator = new OverrideConfigurator(URL.valueOf("override://[email protected]/com.foo.BarService?timeout=200"));
    
    URL url = configurator.configure(URL.valueOf("dubbo://10.20.153.10:20880/com.foo.BarService?application=foo"));
    Assert.assertEquals("200", url.getParameter("timeout"));
    
    url = configurator.configure(URL.valueOf("dubbo://10.20.153.10:20880/com.foo.BarService?application=foo&timeout=1000"));
    Assert.assertEquals("200", url.getParameter("timeout"));
    
    url = configurator.configure(URL.valueOf("dubbo://10.20.153.11:20880/com.foo.BarService?application=bar"));
    Assert.assertNull(url.getParameter("timeout"));
    
    url = configurator.configure(URL.valueOf("dubbo://10.20.153.11:20880/com.foo.BarService?application=bar&timeout=1000"));
    Assert.assertEquals("1000", url.getParameter("timeout"));
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:17,代码来源:OverrideConfiguratorTest.java

示例7: testInvokeExceptoin

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testInvokeExceptoin() {
    resetInvokerToException();
    FailbackClusterInvoker<FailbackClusterInvokerTest> invoker = new FailbackClusterInvoker<FailbackClusterInvokerTest>(
                                                                                                                        dic);
    invoker.invoke(invocation);
    Assert.assertNull(RpcContext.getContext().getInvoker());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:9,代码来源:FailbackClusterInvokerTest.java

示例8: headerNoExpression_HttpMethodDoesntMatch

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void headerNoExpression_HttpMethodDoesntMatch() throws Exception {
	HeaderFilterSettings settings = new HeaderFilterSettings();
	settings.setHeaderName("Cat");
	settings.setHttpMethods(httpMethods);

	HashSet<String> set = new HashSet<String>();
	set.add("hello");
	set.add("bye");

	final Enumeration<String> r = new Vector(set).elements();

	new Expectations() {
		{
			mockRequest.getMethod();
			result = "GET";

			mockRequest.getHeaders("Cat");
			result = r;
			maxTimes = 0;
		}
	};

	Filter filter = new HeaderFilter("f1", settings);

	Assert.assertNull(filter.filter(mockRequest));
}
 
开发者ID:akharchuk,项目名称:rate-limiting,代码行数:28,代码来源:HeaderFilterTest.java

示例9: testCloseSessionRequestAfterSessionExpiry

import junit.framework.Assert; //导入方法依赖的package包/类
/**
 * Verify the session closure request has reached PrepRequestProcessor soon
 * after session expiration by the session tracker
 */
@Test(timeout = 20000)
public void testCloseSessionRequestAfterSessionExpiry() throws Exception {
    ZooKeeperServer zks = setupSessionTracker();

    latch = new CountDownLatch(1);
    zks.sessionTracker.addSession(sessionId, sessionTimeout);
    SessionTrackerImpl sessionTrackerImpl = (SessionTrackerImpl) zks.sessionTracker;
    SessionImpl sessionImpl = sessionTrackerImpl.sessionsById
            .get(sessionId);
    Assert.assertNotNull("Sessionid:" + sessionId
            + " doesn't exists in sessiontracker", sessionImpl);

    // verify the session existence
    Object sessionOwner = new Object();
    sessionTrackerImpl.checkSession(sessionId, sessionOwner);

    // waiting for the session expiry
    latch.await(sessionTimeout * 2, TimeUnit.MILLISECONDS);

    // Simulating close session request: removeSession() will be executed
    // while OpCode.closeSession
    sessionTrackerImpl.removeSession(sessionId);
    SessionImpl actualSession = sessionTrackerImpl.sessionsById
            .get(sessionId);
    Assert.assertNull("Session:" + sessionId
            + " still exists after removal", actualSession);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:32,代码来源:SessionTrackerTest.java

示例10: getViewStateReturnsNull

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void getViewStateReturnsNull(){
  Activity activity = Mockito.mock(Activity.class);
  Application application = Mockito.mock(Application.class);
  Mockito.when(activity.getApplication()).thenReturn(application);

  Assert.assertNull(PresenterManager.getViewState(activity, "viewId123"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:PresenterManagerTest.java

示例11: testGetByIdCantDeserialize

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testGetByIdCantDeserialize() throws Exception {
    String id = "id";
    String service = "service";
    String resultSerialized = "testModel";
    setupCacheReturnOne(resultSerialized);
    setupDeserializeThrowsException();

    TestModel result = testee.getById(service, id);

    Assert.assertNull(result);
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:13,代码来源:ListServiceDAOTest.java

示例12: testRetryFailed

import junit.framework.Assert; //导入方法依赖的package包/类
@Test()
public void testRetryFailed() {

    resetInvokerToException();

    FailbackClusterInvoker<FailbackClusterInvokerTest> invoker = new FailbackClusterInvoker<FailbackClusterInvokerTest>(
                                                                                                                        dic);
    invoker.invoke(invocation);
    Assert.assertNull(RpcContext.getContext().getInvoker());
    invoker.retryFailed();// when retry the invoker which get from failed map already is not the mocked invoker,so
                          // it can be invoke successfully
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:13,代码来源:FailbackClusterInvokerTest.java

示例13: testFile

import junit.framework.Assert; //导入方法依赖的package包/类
/**
 * Test of getFile+setFile method, of class Patch.
 */
@Test
public void testFile() {
    System.out.println("file");
    Patch instance = new Patch();
    Original original = new Original();
    Assert.assertNull("original was pre-set?", instance.getFile());
    instance.setFile(original);
    Assert.assertTrue("original was not set or not retrieved", original.equals(instance.getFile()));
}
 
开发者ID:Idrinths-Stellaris-Mods,项目名称:Mod-Tools,代码行数:13,代码来源:PatchTest.java

示例14: testMultiTransaction

import junit.framework.Assert; //导入方法依赖的package包/类
/**
 * Test write operations using multi request.
 */
@Test(timeout = 90000)
public void testMultiTransaction() throws Exception {
    CountdownWatcher watcher = new CountdownWatcher();
    ZooKeeper zk = new ZooKeeper(qu.getConnString(), CONNECTION_TIMEOUT,
            watcher, true);
    watcher.waitForConnected(CONNECTION_TIMEOUT); // ensure zk got connected

    final String data = "Data to be read in RO mode";
    final String node1 = "/tnode1";
    final String node2 = "/tnode2";
    zk.create(node1, data.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);

    watcher.reset();
    qu.shutdown(2);
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    Assert.assertEquals("Should be in r-o mode", States.CONNECTEDREADONLY,
            zk.getState());

    // read operation during r/o mode
    String remoteData = new String(zk.getData(node1, false, null));
    Assert.assertEquals("Failed to read data in r-o mode", data, remoteData);

    try {
        Transaction transaction = zk.transaction();
        transaction.setData(node1, "no way".getBytes(), -1);
        transaction.create(node2, data.getBytes(),
                ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        transaction.commit();
        Assert.fail("Write operation using multi-transaction"
                + " api has succeeded during RO mode");
    } catch (NotReadOnlyException e) {
        // ok
    }

    Assert.assertNull("Should have created the znode:" + node2,
            zk.exists(node2, false));
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:42,代码来源:ReadOnlyModeTest.java

示例15: testSetCustomProperty

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testSetCustomProperty() {
  CustomPropertyProvider propProvider = new CustomPropertyProvider();
  propProvider.setCustomProperty("test", "testvalue");

  Assert.assertEquals("testvalue", propProvider.getCustomProperty("test"));
  Assert.assertNull(propProvider.getCustomProperty("test2"));
  Assert.assertEquals(1, propProvider.getAllCustomProperties().size());

  propProvider.setCustomProperty("test", "testvalue2");

  Assert.assertEquals("testvalue2", propProvider.getCustomProperty("test"));

  ArrayList<Property> props = new ArrayList<>();
  props.add(new Property("test2", "testvalue3"));
  props.add(new Property("test3", "testvalue4"));

  propProvider.setCustomProperties(props);

  Assert.assertEquals(2, propProvider.getAllCustomProperties().size());
  Assert.assertEquals("testvalue3", propProvider.getCustomProperty("test2"));
  Assert.assertEquals("testvalue4", propProvider.getCustomProperty("test3"));

  propProvider.setCustomProperties(null);
  Assert.assertNotNull(propProvider.getAllCustomProperties());
  Assert.assertEquals(0, propProvider.getAllCustomProperties().size());
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:28,代码来源:CustomPropertyProviderTests.java


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