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.btobits.automator.fix.ant.task.FixSequenceReset.java

@Override
protected void validate() throws Exception {
    Assert.assertTrue("Reference to FIX session is not specified", StringUtils.isNotBlank(refId));
    final Object obj = getProject().getReference(refId);
    Assert.assertNotNull("RefId[" + refId + "]. Failed to get FIX session.", obj);
    Assert.assertTrue("RefId[" + refId + "]. Unknown FIX session mode: " + obj.getClass().getSimpleName(),
            (obj instanceof FixSession));

    fixSession = (FixSession) obj;//from   w  w w .j  a v a2s.  c o  m
    Assert.assertTrue("Attribute 'newSeqNum' is required parameter and must be more than 0", newSeqNum > 0);
}

From source file:cz.fi.muni.pa165.dao.PlayerDaoImplTest.java

@Test
public void testDelete() {
    System.out.println("testDelete started");
    Player p1 = new Player();

    p1.setName("Ronaldo");
    p1.setPosition(Position.FORWARD);
    p1.setDateOfBirth(new Date(System.currentTimeMillis()));
    p1.setDressNumber(7);/*from  w w  w  . j a  v  a  2s.c o m*/
    p1.setCountry("Portugal");

    playerDao.create(p1);

    long id = p1.getId();
    Assert.assertNotNull("Player was not created!!", playerDao.findById(id));
    playerDao.delete(p1);
    Assert.assertNull("Player was not deleted", playerDao.findById(id));
}

From source file:org.deviceconnect.android.profile.restful.test.NormalDeviceOrientationProfileTestCase.java

/**
 * ondeviceorientation???./*w ww .j av a 2  s.c o  m*/
 * <pre>
 * ?HTTP
 * Method: PUT
 * Path: /deviceorientation/ondeviceorientation?deviceId=xxxx&sessionKey=xxxx
 * </pre>
 * <pre>
 * ??
 * result?0???????
 * ??????
 * </pre>
 */
public void testPutOnDeviceOrientation() {
    StringBuilder builder = new StringBuilder();
    builder.append(DCONNECT_MANAGER_URI);
    builder.append("/" + DeviceOrientationProfileConstants.PROFILE_NAME);
    builder.append("/" + DeviceOrientationProfileConstants.ATTRIBUTE_ON_DEVICE_ORIENTATION);
    builder.append("?");
    builder.append(DConnectProfileConstants.PARAM_DEVICE_ID + "=" + getDeviceId());
    builder.append("&");
    builder.append(DConnectProfileConstants.PARAM_SESSION_KEY + "=" + getClientId());
    builder.append("&");
    builder.append(AuthorizationProfileConstants.PARAM_ACCESS_TOKEN + "=" + getAccessToken());
    try {
        HttpUriRequest request = new HttpPut(builder.toString());
        JSONObject root = sendRequest(request);
        Assert.assertNotNull("root is null.", root);
        assertResultOK(root);

        JSONObject event = waitForEvent();
        JSONObject orientation = event.getJSONObject(DeviceOrientationProfileConstants.PARAM_ORIENTATION);
        Assert.assertNotNull(orientation);
        JSONObject a1 = orientation.getJSONObject(DeviceOrientationProfileConstants.PARAM_ACCELERATION);
        Assert.assertNotNull(a1);
        Assert.assertEquals(0.0, a1.getDouble(DeviceOrientationProfileConstants.PARAM_X));
        Assert.assertEquals(0.0, a1.getDouble(DeviceOrientationProfileConstants.PARAM_Y));
        Assert.assertEquals(0.0, a1.getDouble(DeviceOrientationProfileConstants.PARAM_Z));
        JSONObject a2 = orientation
                .getJSONObject(DeviceOrientationProfileConstants.PARAM_ACCELERATION_INCLUDING_GRAVITY);
        Assert.assertNotNull(a2);
        Assert.assertEquals(0.0, a2.getDouble(DeviceOrientationProfileConstants.PARAM_X));
        Assert.assertEquals(0.0, a2.getDouble(DeviceOrientationProfileConstants.PARAM_Y));
        Assert.assertEquals(0.0, a2.getDouble(DeviceOrientationProfileConstants.PARAM_Z));
        JSONObject r = orientation.getJSONObject(DeviceOrientationProfileConstants.PARAM_ROTATION_RATE);
        Assert.assertNotNull(r);
        Assert.assertEquals(0.0, r.getDouble(DeviceOrientationProfileConstants.PARAM_ALPHA));
        Assert.assertEquals(0.0, r.getDouble(DeviceOrientationProfileConstants.PARAM_BETA));
        Assert.assertEquals(0.0, r.getDouble(DeviceOrientationProfileConstants.PARAM_GAMMA));
        Assert.assertEquals(0.0, orientation.getDouble(DeviceOrientationProfileConstants.PARAM_INTERVAL));
    } catch (JSONException e) {
        fail("Exception in JSONObject." + e.getMessage());
    }
}

From source file:org.deviceconnect.android.profile.restful.test.NormalPhoneProfileTestCase.java

/**
 * ??.//ww  w.  ja v  a 2s . c  om
 * <pre>
 * ?HTTP
 * Method: POST
 * Path: /phone/call?deviceid=xxxx&mediaid=yyyy
 * </pre>
 * <pre>
 * ??
 * result?0???????
 * </pre>
 */
public void testPostCall() {
    StringBuilder builder = new StringBuilder();
    builder.append(DCONNECT_MANAGER_URI);
    builder.append("/" + PhoneProfileConstants.PROFILE_NAME);
    builder.append("/" + PhoneProfileConstants.ATTRIBUTE_CALL);
    builder.append("?");
    builder.append(DConnectProfileConstants.PARAM_DEVICE_ID + "=" + getDeviceId());
    builder.append("&");
    builder.append(PhoneProfileConstants.PARAM_PHONE_NUMBER + "=" + TestPhoneProfileConstants.PHONE_NUMBER);
    builder.append("&");
    builder.append(AuthorizationProfileConstants.PARAM_ACCESS_TOKEN + "=" + getAccessToken());
    try {
        HttpUriRequest request = new HttpPost(builder.toString());
        JSONObject root = sendRequest(request);
        Assert.assertNotNull("root is null.", root);
        Assert.assertEquals(DConnectMessage.RESULT_OK, root.getInt(DConnectMessage.EXTRA_RESULT));
    } catch (JSONException e) {
        fail("Exception in JSONObject." + e.getMessage());
    }
}

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

@Test
public void saveFormData() throws Exception {
    FormData fd = new FormData(1, "data", "description", new Date(), new User(1, "guyzb"));
    studyManagerService.saveFormData(fd);
    Assert.assertNotNull("Id has been set", fd.getId());
}

From source file:org.openspaces.eviction.test.LRUSingleOrderTest.java

@Test
public void readKeepsAnObjectTest() throws Exception {
    logger.info("write an object");
    gigaSpace.write(new SilverMedal(0));

    logger.info("fill the space with more than cache size object and red the original in the middle");
    for (int i = 1; i <= cacheSize + 10; i++) {
        if (i == (cacheSize / 2))
            gigaSpace.read(new SilverMedal(0));
        else//from   ww  w . j a va 2s.  c  o m
            gigaSpace.write(new SilverMedal(i));
    }
    Assert.assertEquals("amount of objects in space is larger than cache size", gigaSpace.count(new Object()),
            cacheSize);

    logger.info("assert the original object is still in cache");
    Assert.assertNotNull("silver medal 0 is not in space", gigaSpace.read(new SilverMedal(0)));
    logger.info("Test Passed");
}

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

@Override
protected void validate() {
    Assert.assertTrue("Reference to FIX session is not specified", StringUtils.isNotBlank(refId));
    final Object obj = getProject().getReference(refId);
    Assert.assertNotNull("RefId[" + refId + "]. Failed to get FIX session.", obj);
    Assert.assertTrue("RefId[" + refId + "]. Unknown FIX session mode: " + obj.getClass().getSimpleName(),
            (obj instanceof FixSession));

    fixSession = (FixSession) obj;//from  w ww  .  j  a  va 2s. co m
    conn = fixSession.getConnectivity();
    Assert.assertNotNull("RefId[" + refId + "]. getConnectivity() return NULL", conn);
}

From source file:de.hybris.platform.integration.cis.payment.commands.DefaultCisSubscriptionAuthorizationCommandTest.java

@Before
public void setUp() throws Exception {
    createCoreData();//from  www .  j  av a  2  s  .co m
    createDefaultCatalog();
    importCsv("/ondemandcommon/test/testAcceleratorData.csv", "UTF-8");
    final BaseSiteModel site = baseSiteService.getBaseSiteForUID("testSite");
    Assert.assertNotNull("no baseSite with uid 'testSite", site);
    site.setChannel(SiteChannel.B2C);
    baseSiteService.setCurrentBaseSite(site, false);
}

From source file:org.deviceconnect.android.profile.restful.test.NormalConnectProfileTestCase.java

/**
 * WiFi(ON/OFF)??.//  w ww  . jav a2 s.  c  o m
 * <pre>
 * ?HTTP
 * Method: GET
 * Path: /connect/wifi?deviceid=xxxx
 * </pre>
 * <pre>
 * ??
 * result?0???????
 * power?true???????
 * </pre>
 */
public void testGetWifi() {
    StringBuilder builder = new StringBuilder();
    builder.append(DCONNECT_MANAGER_URI);
    builder.append("/" + ConnectProfileConstants.PROFILE_NAME);
    builder.append("/" + ConnectProfileConstants.ATTRIBUTE_WIFI);
    builder.append("?");
    builder.append(DConnectProfileConstants.PARAM_DEVICE_ID + "=" + getDeviceId());
    builder.append("&");
    builder.append(AuthorizationProfileConstants.PARAM_ACCESS_TOKEN + "=" + getAccessToken());
    try {
        HttpUriRequest request = new HttpGet(builder.toString());
        JSONObject root = sendRequest(request);
        Assert.assertNotNull("root is null.", root);
        Assert.assertEquals(DConnectMessage.RESULT_OK, root.getInt(DConnectMessage.EXTRA_RESULT));
        Assert.assertEquals("power is not equals.", true,
                root.getBoolean(ConnectProfileConstants.PARAM_ENABLE));
    } catch (JSONException e) {
        fail("Exception in JSONObject." + e.getMessage());
    }
}

From source file:org.deviceconnect.android.profile.restful.test.NormalFileDescriptorProfileTestCase.java

/**
 * ??.//from   w w w .  j av a2s  .com
 * <pre>
 * ?HTTP
 * Method: GET
 * Path: /file_descriptor/open?deviceid=xxxx&mediaid=xxxx&flag=xxxx&mode=xxxx
 * </pre>
 * <pre>
 * ??
 * result?0???????
 * mediaid?"test.txt"???????
 * </pre>
 */
public void testOpen() {
    StringBuilder builder = new StringBuilder();
    builder.append(DCONNECT_MANAGER_URI);
    builder.append("/" + FileDescriptorProfileConstants.PROFILE_NAME);
    builder.append("/" + FileDescriptorProfileConstants.ATTRIBUTE_OPEN);
    builder.append("?");
    builder.append(DConnectProfileConstants.PARAM_DEVICE_ID + "=" + getDeviceId());
    builder.append("&");
    builder.append(FileDescriptorProfileConstants.PARAM_PATH + "=test.txt");
    builder.append("&");
    builder.append(FileDescriptorProfileConstants.PARAM_FLAG + "=r");
    builder.append("&");
    builder.append(AuthorizationProfileConstants.PARAM_ACCESS_TOKEN + "=" + getAccessToken());
    try {
        HttpUriRequest request = new HttpGet(builder.toString());
        JSONObject root = sendRequest(request);
        Assert.assertNotNull("root is null.", root);
        Assert.assertEquals(DConnectMessage.RESULT_OK, root.getInt(DConnectMessage.EXTRA_RESULT));
    } catch (JSONException e) {
        fail("Exception in JSONObject." + e.getMessage());
    }
}