Example usage for junit.framework Assert assertNotNull

List of usage examples for junit.framework Assert assertNotNull

Introduction

In this page you can find the example usage for junit.framework Assert assertNotNull.

Prototype

static public void assertNotNull(String message, Object object) 

Source Link

Document

Asserts that an object isn't null.

Usage

From source file:com.workday.autoparse.json.demo.JsonTestUtils.java

static void assertJSONObjectsEqual(String message, JSONObject expected, Object actual) {
    if (expected == null) {
        Assert.assertNull(message + " is null", actual);
        return;/*  w ww  .j  a  v  a  2 s  . c o  m*/
    }

    Assert.assertNotNull(message + " not null", actual);
    Assert.assertTrue(message + " expected JSONObject but found " + actual.getClass().getCanonicalName(),
            actual instanceof JSONObject);

    JSONObject actualJsonObject = (JSONObject) actual;
    Assert.assertEquals(message + ": size", expected.length(), actualJsonObject.length());

    @SuppressWarnings("unchecked")
    Iterator<String> keys = expected.keys();
    while (keys.hasNext()) {
        String key = keys.next();
        Assert.assertEquals(message + ": " + key, expected.opt(key), actualJsonObject.opt(key));
    }
}

From source file:com.googlecode.flickrandroid.oauth.test.OAuthTest.java

@Test
public void testOAuthInterfaceTestLogin() throws FlickrException, IOException, JSONException {
    Assert.assertNotNull("Login failed", f.getOAuthInterface().testLogin()); //$NON-NLS-1$
    Assert.assertNotNull(f.getPhotosInterface().getAllContexts("5772049100")); //$NON-NLS-1$
}

From source file:ca.simplegames.micro.RoutingTest.java

@Test
public void testMicroIsLoaded() throws Exception {
    Assert.assertNotNull("This suite requires to have a Micro environment loaded.", micro);
}

From source file:org.intalio.tempo.test.SpringTestSupport.java

protected Object getBean(String name) {
    Object answer = null;//from w w w . j a  v a 2s .c  om
    if (_context != null) {
        answer = _context.getBean(name);
    }
    Assert.assertNotNull("Could not find object in Spring for key: " + name, answer);
    return answer;
}

From source file:org.obiba.onyx.core.domain.participant.ParticipantAttributeReaderTest.java

@Test
public void testGroupExistsForEveryAttribute() {
    for (ParticipantAttribute participantAttribute : participantAttributes) {
        Assert.assertNotNull("Group is null.", participantAttribute.getGroup());
    }//from   www . java  2 s  . co m
}

From source file:com.ktds.ldap.populator.AttributeCheckContextMapper.java

public DirContextAdapter mapFromContext(Object ctx) {
    DirContextAdapter adapter = (DirContextAdapter) ctx;
    Assert.assertEquals("Values and attributes need to have the same length ", expectedAttributes.length,
            expectedValues.length);//from  w w w .ja  va 2s. c o  m
    for (int i = 0; i < expectedAttributes.length; i++) {
        String attributeValue = adapter.getStringAttribute(expectedAttributes[i]);
        Assert.assertNotNull("Attribute " + expectedAttributes[i] + " was not present", attributeValue);
        Assert.assertEquals(expectedValues[i], attributeValue);
    }

    for (String absentAttribute : absentAttributes) {
        Assert.assertNull(adapter.getStringAttribute(absentAttribute));
    }

    return adapter;
}

From source file:com.ktds.ldap.populator.AttributeCheckAttributesMapper.java

public Object mapFromAttributes(Attributes attributes) throws NamingException {
    Assert.assertEquals("Values and attributes need to have the same length ", expectedAttributes.length,
            expectedValues.length);/*from  w w  w  .j  ava2  s.  com*/
    for (int i = 0; i < expectedAttributes.length; i++) {
        Attribute attribute = attributes.get(expectedAttributes[i]);
        Assert.assertNotNull("Attribute " + expectedAttributes[i] + " was not present", attribute);
        Assert.assertEquals(expectedValues[i], attribute.get());
    }

    for (String absentAttribute : absentAttributes) {
        Assert.assertNull(attributes.get(absentAttribute));
    }

    return null;
}

From source file:com.btobits.automator.fix.ant.task.SMTPStopTask.java

@Override
protected void runTestInstructions() throws Exception {
    final Object obj = getProject().getReference(refId);
    Assert.assertNotNull("RefId[" + refId + "]. Failed to get SMTP acceptor.", obj);
    Assert.assertTrue("RefId[" + refId + "]. Unknown SMTP acceptor type: " + obj.getClass().getSimpleName(),
            (obj instanceof IControl));
    ((IControl) obj).stop();/*from  www. j  av  a  2 s.c o m*/
}

From source file:com.btobits.automator.fix.ant.task.SMTPStartTask.java

@Override
protected void runTestInstructions() throws Exception {
    final Object obj = getProject().getReference(refId);
    Assert.assertNotNull("RefId[" + refId + "]. Failed to get SMTP acceptor.", obj);
    Assert.assertTrue("RefId[" + refId + "]. Unknown SMTP acceptor mode: " + obj.getClass().getSimpleName(),
            (obj instanceof IControl));
    ((IControl) obj).start();//from w w  w  .  j  av a  2s .c o m
}

From source file:org.openxdata.server.service.impl.FormDataServiceTest.java

@Test
public void getSetting_shouldNotReturnNullIfFormDataFoundWithGivenId() throws Exception {
    Assert.assertNotNull("formData with id=1 doesn't exist", studyManagerService.getFormData(1));
}