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:org.intalio.tempo.test.SpringTestSupport.java

protected Source getSourceFromClassPath(String fileOnClassPath) {
    InputStream stream = getClass().getResourceAsStream(fileOnClassPath);
    Assert.assertNotNull("Could not find file: " + fileOnClassPath + " on the classpath", stream);

    Source content = new StreamSource(stream);
    return content;
}

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

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

    p1.setName("Ronaldo");
    p1.setPosition(Position.FORWARD);
    p1.setDateOfBirth(new Date(System.currentTimeMillis()));
    p1.setDressNumber(7);//w w  w  .  jav a2  s .  c  o m
    p1.setCountry("Portugal");

    playerDao.create(p1);

    System.out.println(playerDao.findById(p1.getId()));
    Assert.assertNotNull("Player was not created!!", playerDao.findById(p1.getId()));
}

From source file:com.arhs.spring.boot.autoconfigure.UnitTestBase.java

/**
 * Asserts that the bean exists in the current context.
 *
 * @param bean The name of bean.//  w w  w .java  2 s . com
 */
protected void assertBeanExists(Class<?> bean) {
    Assert.assertNotNull("The bean does not exist in the context.", context.containsBean(bean.getName()));
}

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

@Override
protected void runTestInstructions() throws Exception {
    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 IControl));
    ((IControl) obj).start();//w w  w. j  av a  2 s .  c o  m
}

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

@Test
public void deleteFormData_shouldDeleteFormDataWithGivenId() throws Exception {
    final int formDataId = 1;

    Assert.assertNotNull("form data does not exist", studyManagerService.getFormData(formDataId));
    studyManagerService.deleteFormData(formDataId);
    Assert.assertNull("formData still exists", studyManagerService.getFormData(formDataId));
}

From source file:com.redblackit.web.controller.AdminControllerTest.java

/**
 * Helper method to run tests using about
 *///from   ww  w. j  ava 2s .c o m
private void doTestAbout() {
    ExtendedModelMap model = new ExtendedModelMap();

    adminController.about(model);

    Object versionInfoObj = model.get("versionInfo");
    Assert.assertNotNull("versionInfo model attribute", versionInfoObj);
    Assert.assertTrue("versionInfo is of type CompositeVersionInfo:" + versionInfoObj.getClass(),
            versionInfoObj instanceof CompositeVersionInfo);

    CompositeVersionInfo returnedVersionInfo = (CompositeVersionInfo) versionInfoObj;
    Assert.assertEquals("returned versionInfo", getExpectedCompositeVersionInfo(), returnedVersionInfo);
}

From source file:org.deviceconnect.android.manager.test.JSONConversionTest.java

/**
 * dConnectManager?BundleJSON????????????.
 * //  w  w  w  . jav a 2 s. com
 * @throws JSONException ???????
 */
public void testConversion() throws JSONException {
    StringBuilder builder = new StringBuilder();
    builder.append(DCONNECT_MANAGER_URI);
    builder.append("/json_test");
    builder.append("?");
    builder.append(DConnectMessage.EXTRA_DEVICE_ID + "=" + getDeviceId());
    builder.append("&");
    builder.append(DConnectMessage.EXTRA_ACCESS_TOKEN + "=" + getAccessToken());
    HttpUriRequest request = new HttpGet(builder.toString());
    JSONObject response = sendRequest(request);
    assertResultOK(response);
    JSONObject root = response.getJSONObject("extra");
    Assert.assertNotNull("root is null.", root);
    Assert.assertFalse(root.has(IntentDConnectMessage.EXTRA_REQUEST_CODE));
    Assert.assertEquals("http://localhost:8080", root.getString("uri"));
    Assert.assertEquals(0, root.getInt("byte"));
    Assert.assertEquals('0', root.getInt("char"));
    Assert.assertEquals(0, root.getInt("int"));
    Assert.assertEquals(0L, root.getLong("long"));
    Assert.assertEquals(0.0, root.getDouble("float"), TEST_FLOATING_VALUE);
    Assert.assertEquals(0.0, root.getDouble("double"), TEST_FLOATING_VALUE);
    Assert.assertEquals(false, root.getBoolean("boolean"));
    Assert.assertEquals(0, root.getInt(Byte.class.getName()));
    Assert.assertEquals('0', root.getInt(Character.class.getName()));
    Assert.assertEquals(0, root.getInt(Integer.class.getName()));
    Assert.assertEquals(0L, root.getLong(Long.class.getName()));
    Assert.assertEquals(0.0, root.getDouble(Float.class.getName()), TEST_FLOATING_VALUE);
    Assert.assertEquals(0.0, root.getDouble(Double.class.getName()), TEST_FLOATING_VALUE);
    Assert.assertEquals(false, root.getBoolean(Boolean.class.getName()));
    Assert.assertEquals(String.class.getName(), root.getString(String.class.getName()));
    Assert.assertEquals(1, root.getJSONArray(int[].class.getName()).length());
    Assert.assertEquals(0, root.getJSONArray(int[].class.getName()).get(0));
    Assert.assertEquals(1, root.getJSONArray(long[].class.getName()).length());
    Assert.assertEquals(0L, root.getJSONArray(long[].class.getName()).getLong(0));
    Assert.assertEquals(1, root.getJSONArray(float[].class.getName()).length());
    Assert.assertEquals(0.0, root.getJSONArray(float[].class.getName()).getDouble(0), TEST_FLOATING_VALUE);
    Assert.assertEquals(1, root.getJSONArray(double[].class.getName()).length());
    Assert.assertEquals(0.0, root.getJSONArray(double[].class.getName()).getDouble(0), TEST_FLOATING_VALUE);
    Assert.assertEquals(1, root.getJSONArray(boolean[].class.getName()).length());
    Assert.assertEquals(false, root.getJSONArray(boolean[].class.getName()).get(0));
    Assert.assertEquals(1, root.getJSONArray(Integer[].class.getName()).length());
    Assert.assertEquals(0, root.getJSONArray(Integer[].class.getName()).get(0));
    Assert.assertEquals(1, root.getJSONArray(Long[].class.getName()).length());
    Assert.assertEquals(0L, root.getJSONArray(Long[].class.getName()).getLong(0));
    Assert.assertEquals(1, root.getJSONArray(Float[].class.getName()).length());
    Assert.assertEquals(0.0, root.getJSONArray(Float[].class.getName()).getDouble(0), TEST_FLOATING_VALUE);
    Assert.assertEquals(1, root.getJSONArray(Double[].class.getName()).length());
    Assert.assertEquals(0.0, root.getJSONArray(Double[].class.getName()).getDouble(0), TEST_FLOATING_VALUE);
    Assert.assertEquals(1, root.getJSONArray(Boolean[].class.getName()).length());
    Assert.assertEquals(false, root.getJSONArray(Boolean[].class.getName()).get(0));
    Assert.assertEquals(1, root.getJSONArray(String[].class.getName()).length());
    Assert.assertEquals("String", root.getJSONArray(String[].class.getName()).get(0));
    Assert.assertNotNull(root.getJSONObject(Bundle.class.getName()));
    Assert.assertEquals(1, root.getJSONArray(Bundle[].class.getName()).length());
    Assert.assertNotNull(root.getJSONArray(Bundle[].class.getName()).get(0));
    Assert.assertEquals(1, root.getJSONArray("ArrayList<Integer>").length());
    Assert.assertEquals(0, root.getJSONArray("ArrayList<Integer>").get(0));
}

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

@Override
protected void validate() {
    Assert.assertTrue("Reference to FixDisconnectExpect is not specified", StringUtils.isNotBlank(refId));
    final Object obj = getProject().getReference(refId);
    Assert.assertNotNull("RefId[" + refId + "]. Failed to get FixDisconnectExpect instance.", obj);
    Assert.assertTrue("RefId[" + refId + "]. Referred object is not FixDisconnectExpect instance: "
            + obj.getClass().getSimpleName(), (obj instanceof FixDisconnectExpect));
    expectInstance = (FixDisconnectExpect) obj;
}

From source file:de.hybris.platform.integration.cis.avs.populators.CisAddressVerificationResultPopulator.java

@Override
public void populate(final AvsResult source, final AddressVerificationResultData target)
        throws ConversionException {
    Assert.assertNotNull("No CIS AVS result supplied", source);

    // add decision
    target.setDecision(AddressVerificationDecision.lookup(source.getDecision().toString().toLowerCase()));

    // add suggested addresses
    if (getShowSuggestedAddressesStrategy().shouldAddressSuggestionsBeShown()) {
        final List<AddressModel> addresses = getCisAvsReverseAddressesConverter()
                .convert(source.getSuggestedAddresses());
        target.setSuggestedAddresses(addresses);
    }//ww w.j  a v a  2s  . c  o m

    final List<AddressFieldErrorData> errorList = getCisAvsFieldErrorConverter()
            .convert(source.getFieldErrors());

    if (target.getDecision().equals(AddressVerificationDecision.REJECT)
            && CollectionUtils.isEmpty(source.getFieldErrors())
            && CollectionUtils.isEmpty(source.getSuggestedAddresses())) {
        target.setDecision(AddressVerificationDecision.UNKNOWN);
        final List<AddressFieldErrorData> tempList = new ArrayList<AddressFieldErrorData>();
        final AddressFieldErrorData data = new AddressFieldErrorData();
        data.setFieldType(AddressFieldType.UNKNOWN);
        tempList.add(data);
        target.setFieldErrors(tempList);
    } else {
        target.setFieldErrors(errorList);
    }
}

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

@Override
protected void runTestInstructions() throws Exception {
    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 IControl));
    ((IControl) obj).stop(sendLogout);/*from w ww  .j  a  va 2 s . c  o m*/
}