本文整理汇总了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"));
}
示例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"));
}
示例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));
}
示例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());
}
示例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));
}
}
示例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"));
}
示例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());
}
示例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));
}
示例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);
}
示例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"));
}
示例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);
}
示例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
}
示例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()));
}
示例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));
}
示例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());
}