Java Code Examples for junit.framework.Assert.assertNull()

The following are Jave code examples for showing how to use assertNull() of the junit.framework.Assert class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: dubbox-hystrix   File: AbsentConfiguratorTest.java   View Source Code Vote up 6 votes
@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"));
}
 
Example 2
Project: EatDubbo   File: AbsentConfiguratorTest.java   View Source Code Vote up 6 votes
@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"));
}
 
Example 3
Project: GitHub   File: PresenterManagerTest.java   View Source Code Vote up 6 votes
@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));
}
 
Example 4
Project: aws-sdk-java-v2   File: BatchWriteRetryStrategyTest.java   View Source Code Vote up 6 votes
@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());
}
 
Example 5
Project: ExoPlayer-Offline   File: FakeExtractorOutput.java   View Source Code Vote up 6 votes
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));
  }
}
 
Example 6
Project: dubbocloud   File: OverrideConfiguratorTest.java   View Source Code Vote up 6 votes
@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"));
}
 
Example 7
Project: EatDubbo   File: FailbackClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test
public void testInvokeExceptoin() {
    resetInvokerToException();
    FailbackClusterInvoker<FailbackClusterInvokerTest> invoker = new FailbackClusterInvoker<FailbackClusterInvokerTest>(
                                                                                                                        dic);
    invoker.invoke(invocation);
    Assert.assertNull(RpcContext.getContext().getInvoker());
}
 
Example 8
Project: rate-limiting   File: HeaderFilterTest.java   View Source Code Vote up 5 votes
@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));
}
 
Example 9
Project: fuck_zookeeper   File: SessionTrackerTest.java   View Source Code Vote up 5 votes
/**
 * 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);
}
 
Example 10
Project: GitHub   File: PresenterManagerTest.java   View Source Code Vote up 5 votes
@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"));
}
 
Example 11
Project: redirector   File: ListServiceDAOTest.java   View Source Code Vote up 5 votes
@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);
}
 
Example 12
Project: dubbocloud   File: FailbackClusterInvokerTest.java   View Source Code Vote up 5 votes
@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
}
 
Example 13
Project: Mod-Tools   File: PatchTest.java   View Source Code Vote up 5 votes
/**
 * 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()));
}
 
Example 14
Project: fuck_zookeeper   File: ReadOnlyModeTest.java   View Source Code Vote up 5 votes
/**
 * 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));
}
 
Example 15
Project: litiengine   File: CustomPropertyProviderTests.java   View Source Code Vote up 5 votes
@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());
}
 
Example 16
Project: flume-release-1.7.0   File: TestFlumeEvent.java   View Source Code Vote up 5 votes
@Test
public void testSerialization() throws IOException {
  Map<String, String> headers = Maps.newHashMap();
  headers.put("key", "value");
  byte[] body = "flume".getBytes(Charsets.UTF_8);
  FlumeEvent in = new FlumeEvent(headers, body);
  FlumeEvent out = FlumeEvent.from(TestUtils.toDataInput(in));
  Assert.assertEquals(headers, out.getHeaders());
  Assert.assertTrue(Arrays.equals(body, out.getBody()));
  in.setHeaders(null);
  in.setBody(null);
  out = FlumeEvent.from(TestUtils.toDataInput(in));
  Assert.assertEquals(Maps.newHashMap(), out.getHeaders());
  Assert.assertNull(out.getBody());
}
 
Example 17
Project: li-android-sdk-core   File: LiPostClientResponseTest.java   View Source Code Vote up 4 votes
@Test
public void trahsformedResponseTest(){
    liBaseResponse = PowerMockito.mock(LiBaseResponse.class);
    liPostClientResponse = new LiPostClientResponse(liBaseResponse);
    Assert.assertNull(liPostClientResponse.getTransformedResponse());
}
 
Example 18
Project: shibboleth-idp-oidc-extension   File: BasicJWKCredentialTest.java   View Source Code Vote up 4 votes
@Test
public void testInitialState() {
    Assert.assertNull(jwk.getKid());
    Assert.assertNull(jwk.getAlgorithm());
}
 
Example 19
Project: incubator-netbeans   File: FXMLCompletionTestBase.java   View Source Code Vote up 4 votes
@SuppressWarnings("LeakingThisInConstructor")
public Lkp() {
    Assert.assertNull(DEFAULT);
    DEFAULT = this;
}
 
Example 20
Project: incubator-netbeans   File: UnitUtilities.java   View Source Code Vote up 4 votes
public UnitUtilities() {
    Assert.assertNull(DEFAULT_LOOKUP);
    DEFAULT_LOOKUP = this;
}