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(Object object) 

Source Link

Document

Asserts that an object isn't null.

Usage

From source file:ejportal.webapp.action.InstitutionActionTest.java

/**
 * Test remove.// ww  w  . j  a va  2s. co  m
 * 
 * @throws Exception
 *             the exception
 */
public void testRemove() throws Exception {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    ServletActionContext.setRequest(request);
    this.action.setDelete("");
    final Institution institution = new Institution();
    institution.setId(2L);
    // action.setInstitution(institution);
    this.action.setId(2L);
    Assert.assertEquals("success", this.action.delete());
    Assert.assertNotNull(request.getSession().getAttribute("messages"));
}

From source file:org.ualerts.fixed.web.controller.fixture.ManualEnrollmentControllerTest.java

/**
 * Validate the data returned during a completely clean submission
 *//*from   w w  w. java 2 s  . c o  m*/
@Test
public void validateGoodSubmission() throws Exception {
    final HttpServletRequest request = context.mock(HttpServletRequest.class);
    final HttpServletResponse resp = context.mock(HttpServletResponse.class);
    final FixtureModel fixture = new FixtureModel();
    final FixtureModel returningFixture = new FixtureModel();
    final BindingResult result = context.mock(BindingResult.class);

    fixture.setId(1L);
    returningFixture.setId(2L);

    context.checking(new Expectations() {
        {
            oneOf(result).hasErrors();
            will(returnValue(false));
            oneOf(fixtureService).createFixture(fixture);
            will(returnValue(returningFixture));
        }
    });

    Map<String, Object> response = controller.handleFormSubmission(request, resp, fixture, result);

    context.assertIsSatisfied();
    Assert.assertNotNull(response);
    Assert.assertTrue((Boolean) response.get("success"));
    Assert.assertNotNull(response.get("fixture"));
    Assert.assertEquals(FixtureModel.class, response.get("fixture").getClass());
    Assert.assertEquals(returningFixture, response.get("fixture"));
}

From source file:com.kurento.kmf.media.HttpPostEndpointTest.java

/**
 * Test for {@link MediaSessionStartedEvent}
 * // w ww  .  j  a  va 2 s  .  c  o  m
 * @throws InterruptedException
 */
@Test
public void testEventMediaSessionStarted() throws InterruptedException {
    final PlayerEndpoint player = pipeline.newPlayerEndpoint(URL_SMALL).build();
    HttpPostEndpoint httpEP = pipeline.newHttpPostEndpoint().build();
    player.connect(httpEP);

    final BlockingQueue<EndOfStreamEvent> eosEvents = new ArrayBlockingQueue<EndOfStreamEvent>(1);
    player.addEndOfStreamListener(new MediaEventListener<EndOfStreamEvent>() {

        @Override
        public void onEvent(EndOfStreamEvent event) {
            eosEvents.add(event);
        }
    });

    httpEP.addMediaSessionStartedListener(new MediaEventListener<MediaSessionStartedEvent>() {

        @Override
        public void onEvent(MediaSessionStartedEvent event) {
            player.play();
        }
    });

    DefaultHttpClient httpclient = new DefaultHttpClient();
    try {
        // This should trigger MediaSessionStartedEvent
        httpclient.execute(new HttpGet(httpEP.getUrl()));
    } catch (ClientProtocolException e) {
        throw new KurentoMediaFrameworkException();
    } catch (IOException e) {
        throw new KurentoMediaFrameworkException();
    }

    Assert.assertNotNull(eosEvents.poll(7, SECONDS));

    httpEP.release();
    player.release();
}

From source file:org.openmrs.module.atomfeed.AtomFeedUtilTest.java

/**
 * @see AtomFeedUtil#getUpdatedValue(OpenmrsObject)
 *//*from  w ww .  j  av a  2s  . co  m*/
@Test
public void getUpdatedValue_shouldNeverReturnNullEvenIfBothDateChangedAndDateCreatedAreNull() throws Exception {
    Patient patient = new Patient();
    Assert.assertNotNull(AtomFeedUtil.getUpdatedValue(patient));
}

From source file:alpha.portal.webapp.filter.LocaleFilterTest.java

/**
 * Test set invalid locale./*from w w  w . j  av  a 2s. c  o m*/
 * 
 * @throws Exception
 *             the exception
 */
public void testSetInvalidLocale() throws Exception {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("locale", "foo");

    final MockHttpServletResponse response = new MockHttpServletResponse();
    request.setSession(new MockHttpSession(null));

    this.filter.doFilter(request, response, new MockFilterChain());

    // a locale will get set regardless - there's no such thing as an
    // invalid one
    Assert.assertNotNull(request.getSession().getAttribute(Constants.PREFERRED_LOCALE_KEY));
}

From source file:org.netxilia.spi.impl.formula.TestFindAndFilter.java

@Test
public void testFilterValueNotFound() throws NetxiliaResourceException, NetxiliaBusinessException {
    ISheet sheet = SheetUtils.sheetWithCell("A1", 200, "A2", "200", "A3", 200.0);
    List<Integer> rows = operations.filter(sheet, new Formula("=A1=300")).getNonBlocking();
    Assert.assertNotNull(rows);
    Assert.assertEquals(rows.size(), 0);

}

From source file:ejportal.webapp.action.ExemplarActionTest.java

/**
 * Test remove.//from   w w  w .  j a va 2  s. co  m
 * 
 * @throws Exception
 *             the exception
 */
public void testRemove() throws Exception {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    ServletActionContext.setRequest(request);
    this.action.setDelete("");
    final Exemplar exemplar = new Exemplar();
    exemplar.setExemplarId(2L);
    // action.setExemplar(exemplar);
    this.action.setExemplarId(2L);
    Assert.assertEquals("success", this.action.delete());
    Assert.assertNotNull(request.getSession().getAttribute("messages"));
}

From source file:com.currencyfair.minfraud.MinFraudImplTest.java

@Test
public void testNonCloseableHttpResponseIsSupported() throws Exception {
    StringEntity responseEntity = new StringEntity(VALID_RESPONSE, ContentType.TEXT_PLAIN);
    HttpMethodFactory methodFactory = expectCreateHttpPost();
    HttpResponse httpResponse = EasyMock.createMock(HttpResponse.class);
    expectHttpResponse(httpResponse, 200, responseEntity);
    HttpClient client = expectHttpInvocation(httpResponse);
    EasyMock.replay(httpResponse);//  w w w  . j  a va 2 s  .  c o  m
    minFraudImpl.setHttpClient(client);
    minFraudImpl.setMethodFactory(methodFactory);
    minFraudImpl.setEndpoint(ENDPOINT);
    RiskScoreResponse response = minFraudImpl.calculateRisk(newRiskScoreRequest());
    Assert.assertNotNull(response);
    Assert.assertEquals(new BigDecimal("23.2"), response.getRiskScore());
    Assert.assertTrue(response.getGeoIpDetails().isCountryMatch());
    Assert.assertFalse(response.getGeoIpDetails().isHighRiskCountry());
    Assert.assertEquals("IE", response.getGeoIpDetails().getIpCountryCode());
    Assert.assertEquals(Integer.valueOf(48), response.getGeoIpDetails().getDistance());
    EasyMock.verify(httpResponse);
}

From source file:ejportal.webapp.action.InteresseActionTest.java

/**
 * Test remove./*w ww .j  a  v a2s  .  c o m*/
 * 
 * @throws Exception
 *             the exception
 */
public void testRemove() throws Exception {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    ServletActionContext.setRequest(request);
    this.action.setDelete("");
    final Interesse interesse = new Interesse();
    interesse.setInteresseId(2L);
    // action.setInteresse(interesse);
    this.action.setInteresseId(2L);
    Assert.assertEquals("success", this.action.delete());
    Assert.assertNotNull(request.getSession().getAttribute("messages"));
}

From source file:org.atemsource.atem.impl.hibernate.HibernateMetaDataRepositoryTest.java

@Test
public void testListAssociation() {
    final EntityType<EntityB> entityType = entityTypeRepository.getEntityType(EntityB.class);
    final ListAssociationAttribute<EntityA> attribute = (ListAssociationAttribute<EntityA>) entityType
            .getAttribute("listProperty");
    Assert.assertNotNull(attribute);
    EntityB entity = entityType.createEntity();
    EntityType<EntityA> targetType = (EntityType<EntityA>) attribute.getTargetType();
    EntityA associatedEntity = targetType.createEntity();
    attribute.setValue(entity, new ArrayList<EntityA>());
    attribute.addElement(entity, associatedEntity);
    Object associatedEntity2 = attribute.getValue(entity).get(0);
    Assert.assertEquals(associatedEntity, associatedEntity2);
}