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:eu.delving.sip.TestCoordinateConversion.java

private String functionCall(String param, boolean utmOut) {
    Binding binding = new Binding();
    binding.setVariable("param", param);
    binding.setVariable("utmOut", utmOut);
    functionScript.setBinding(binding);//w  ww . j  a v  a2s .  c o m
    Object result = functionScript.run();
    Assert.assertNotNull("No result for: " + param, result);
    Assert.assertFalse("Empty result for: " + param, result.toString().isEmpty());
    return result.toString();
}

From source file:org.thingsplode.server.repositories.RepositoryTest.java

@Test
@Transactional//from w ww .  j av a 2s  .  co m
public void test2Events() throws UnknownHostException {
    String deviceID = "test_device_1";
    String serialNumber = "12345";
    deviceRepo.save(TestFactory.createDevice(deviceID, serialNumber, "1"));
    Device d = deviceRepo.findByIdentification(deviceID);
    Assert.assertTrue("The serial number should match", serialNumber.equalsIgnoreCase(d.getSerialNumber()));
    Assert.assertTrue("The version should be 1", "1".equalsIgnoreCase(d.getModel().getVersion()));
    d.getModel().setVersion("2");
    deviceRepo.save(d);
    d = deviceRepo.findByIdentification(deviceID);
    Assert.assertTrue("The version should be 2", "2".equalsIgnoreCase(d.getModel().getVersion()));
    Assert.assertNotNull("The device id shall not be null at this stage", d.getId());
    for (int i = 1; i <= 100; i++) {
        Event devt = Event
                .create("some-special-event", "some-special-event-class", Event.EventType.STATE_UPDATE,
                        Event.Severity.INFO, Calendar.getInstance())
                .putComponent(d).putReceiveDate(Calendar.getInstance())
                .addIndication("peak", Value.Type.NUMBER, Integer.toString(i));
        Event cevt = Event
                .create("a component event", "comp event class", Event.EventType.STATE_UPDATE,
                        Event.Severity.ERROR, Calendar.getInstance())
                .putComponent((Component) d.getComponents().toArray()[0]).putReceiveDate(Calendar.getInstance())
                .addIndication("peak", Value.Type.TEXT, "componnent indication");
        eventRepo.save(devt);
        eventRepo.save(cevt);
    }

    int evtCount = (int) eventRepo.count();
    Assert.assertTrue("There should be 200 device events in the database at this stage, but there were: "
            + evtCount + ".", evtCount == 200);
    Page<Event> deviceEvtPage = eventRepo.findByComponent(d, new PageRequest(0, 300));
    int deviceEvtCount = deviceEvtPage.getContent().size();
    Assert.assertTrue("there should be 100 device events instead of [" + deviceEvtCount + "]",
            deviceEvtCount == 100);
    eventRepo.deleteAll();
    deviceRepo.delete(d);
    deviceAssertions(0);
}

From source file:com.btobits.automator.fix.ant.task.FixSendTask.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  va 2 s. c om*/
    //        senderCompId = fixSession.getSenderCompId();
    //        targetCompId = fixSession.getTargetCompId();
    //        fixVersion = fixSession.getFixVersion();
    conn = fixSession.getConnectivity();
    Assert.assertNotNull("RefId[" + refId + "]. getConnectivity() return NULL", conn);

    Assert.assertNotNull("'fillHeaderTrailer' is null. " + "Valid value list: full||onlyReq||none.",
            fillHeaderTrailer);
    if (StringUtils.isNotBlank(fileWithRawMessages)) {
        Assert.assertTrue(
                "RefId[" + refId + "]. File with FIX messages is not found: [" + fileWithRawMessages + "]",
                new File(fileWithRawMessages).exists());
        fileMode = true;
    } else {
        Assert.assertTrue("RefId[" + refId + "]. FIX messages pool(task child tags) is empty.",
                !messages.isEmpty());
        fileMode = false;
    }
}

From source file:it.cnr.icar.eric.client.xml.registry.infomodel.RegistryPackageTest.java

/** Test addition of Member Services to RegistryPackage */
public void testAddRegistryObjects() throws Exception {

    // -- Get the Registry Package
    RegistryPackage pkg = (RegistryPackage) getBQM().getRegistryObject(pkgId,
            LifeCycleManager.REGISTRY_PACKAGE);
    Assert.assertNotNull("Could not retrieve test package submitted in testSubmit", pkg);

    // -- Get the Service
    Service service = (Service) getBQM().getRegistryObject(serviceId);
    Assert.assertNotNull("Could not retrieve canonical XML Cataloging Service", service);

    // -- Add service to Registry Package and save
    ArrayList<Service> members = new ArrayList<Service>();
    members.add(service);//from w  w  w .  j  a v a 2 s.  c o m

    pkg.addRegistryObjects(members);

    // -- Save the Object
    ArrayList<RegistryPackage> objectsToSave = new ArrayList<RegistryPackage>();
    objectsToSave.add(pkg);

    BulkResponse resp = getLCM().saveObjects(objectsToSave);

    JAXRUtility.checkBulkResponse(resp);

}

From source file:org.apache.synapse.transport.passthru.config.BaseConfigurationTest.java

@Test
public void testBuildHttpParams() throws Exception {
    HttpParams httpParams = baseConfiguration.buildHttpParams();
    Assert.assertNotNull("HTTP Parameters hasn't been initialized.", httpParams);
    String originServer = (String) httpParams.getParameter(HttpProtocolParams.ORIGIN_SERVER);
    Assert.assertEquals("Origin Server isn't correct.", "WSO2-PassThrough-HTTP", originServer);
}

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

@Test
public void testGetFormList_forUserStudy1() throws Exception {
    User user = userService.findUserByUsername("user");

    // user has study permissions for study1, so can see all forms even though they have only 1 form permission
    List<String> forms = formDownloadService.getFormsDefaultVersionXml(user, 1, null);
    Assert.assertNotNull("There are forms for user user", forms);
    Assert.assertEquals("There are two forms under study 1", 2, forms.size());
    Assert.assertTrue("xform is correct", forms.get(0).contains("<xf:instance id=\"patientreg\">"));
}

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

/**
 * ??.//from  w  w w  .jav  a 2s .  c o  m
 * <pre>
 * ?HTTP
 * Method: GET
 * Path: /file/receive?deviceid=xxxx&mediaid=xxxxx
 * </pre>
 * <pre>
 * ??
 * result?0???????
 * </pre>
 */
public void testGetReceive() {
    testSend();
    final String name = "test.png";
    URIBuilder builder = TestURIBuilder.createURIBuilder();
    builder.setProfile(FileProfileConstants.PROFILE_NAME);
    builder.setAttribute(FileProfileConstants.ATTRIBUTE_RECEIVE);
    builder.addParameter(DConnectProfileConstants.PARAM_DEVICE_ID, getDeviceId());
    builder.addParameter(FileProfileConstants.PARAM_PATH, name);
    builder.addParameter(DConnectMessage.EXTRA_ACCESS_TOKEN, getAccessToken());
    try {
        HttpUriRequest request = new HttpGet(builder.toString());
        JSONObject root = sendRequest(request);
        assertResultOK(root);

        String uri = root.getString(FileProfileConstants.PARAM_URI);
        Assert.assertNotNull("uri is null.", uri);
        uri += "&" + AuthorizationProfileConstants.PARAM_ACCESS_TOKEN + "=" + getAccessToken();
        byte[] data = getBytesFromHttp(uri);
        byte[] orig = getBytesFromAssets(name);
        Assert.assertNotNull("data is invalid.", data);
        Assert.assertEquals("data is invalid", orig.length, data.length);
    } catch (JSONException e) {
        fail("Exception in JSONObject." + e.getMessage());
    }
}

From source file:org.esco.portlet.changeetab.service.impl.CachingEtablissementServiceTest.java

@Test
public void testRetrieveSeveralExistingEtabs() throws Exception {
    final Collection<String> uais = new ArrayList<String>();
    uais.add(CachingEtablissementServiceTest.UAI_3);
    uais.add(CachingEtablissementServiceTest.UAI_1);

    final Map<String, Etablissement> etabs = this.service.retrieveEtablissementsByCodes(uais);

    Assert.assertNotNull("Should return an empty collection !", etabs);
    Assert.assertEquals("Should return only one etab !", 2, etabs.size());
    Assert.assertTrue("Bad etab in returned list !",
            etabs.containsValue(CachingEtablissementServiceTest.ETAB_1));
    Assert.assertTrue("Bad etab in returned list !",
            etabs.containsValue(CachingEtablissementServiceTest.ETAB_3));
}

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

/**
 * type0(?)?????.//from   w  w w .j  a  v  a  2s  .com
 * 
 * <pre>
 * ?HTTP
 * Method: POST
 * Path: /notification/notify?deviceid=xxxx&type=0&body=xxxx
 * </pre>
 * 
 * <pre>
 * ??
 * result?0???????
 * notificationid?1???????
 * </pre>
 */
public void testPostNotifyType001() {
    final int type = 0;
    StringBuilder builder = new StringBuilder();
    builder.append(DCONNECT_MANAGER_URI);
    builder.append("/" + NotificationProfileConstants.PROFILE_NAME);
    builder.append("/" + NotificationProfileConstants.ATTRIBUTE_NOTIFY);
    builder.append("?");
    builder.append(DConnectProfileConstants.PARAM_DEVICE_ID + "=" + getDeviceId());
    builder.append("&");
    builder.append(NotificationProfileConstants.PARAM_TYPE + "=" + type);
    builder.append("&");
    builder.append(NotificationProfileConstants.PARAM_BODY + "=test-message");
    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));
        Assert.assertEquals("notificationid is not equals.",
                TestNotificationProfileConstants.NOTIFICATION_ID[type],
                root.getString(NotificationProfileConstants.PARAM_NOTIFICATION_ID));
    } catch (JSONException e) {
        fail("Exception in JSONObject." + e.getMessage());
    }
}

From source file:de.hybris.platform.basecommerce.util.BaseCommerceBaseTest.java

protected OrderModel getOrderForCode(final String orderCode) {
    final DefaultGenericDao defaultGenericDao = new DefaultGenericDao(OrderModel._TYPECODE);
    defaultGenericDao.setFlexibleSearchService(flexibleSearchService);
    final List<OrderModel> orders = defaultGenericDao
            .find(Collections.singletonMap(OrderModel.CODE, orderCode));
    Assert.assertFalse(orders.isEmpty());
    final OrderModel orderModel = orders.get(0);
    Assert.assertNotNull("Order should have been loaded from database", orderModel);
    return orderModel;
}